From e3c702a55db40b9c32b6e0c9aaeec4a8eeaeb8bb Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Fri, 4 Aug 2023 18:16:46 +0000 Subject: [PATCH] boop --- vim/.vim/lua/plugins/base.lua | 13 ++++++ vim/.vim/lua/plugins/cmp.lua | 70 +++++++++++----------------- vim/.vim/lua/plugins/lsp.lua | 15 ++---- vim/.vim/lua/plugins/lsp_lines.lua | 7 +-- vim/.vim/lua/plugins/nvim-notify.lua | 13 ------ vim/.vimrc | 3 +- 6 files changed, 48 insertions(+), 73 deletions(-) delete mode 100644 vim/.vim/lua/plugins/nvim-notify.lua diff --git a/vim/.vim/lua/plugins/base.lua b/vim/.vim/lua/plugins/base.lua index 5bdd1f5..458d606 100644 --- a/vim/.vim/lua/plugins/base.lua +++ b/vim/.vim/lua/plugins/base.lua @@ -1,6 +1,19 @@ local use_google = require("utils").use_google return { + -- { + -- "rcarriga/nvim-notify", + -- config = function() + -- local colors = require("catppuccin.palettes").get_palette() + -- require("notify").setup({ + -- background_colour = colors.base, + -- fps = 10, -- default 30 + -- stages = "slide", -- default fade_in_slide_out + -- timeout = 5000, -- default 5000 + -- }) + -- vim.notify = require("notify") + -- end, + -- }, -- Pretty symbols { "nvim-tree/nvim-web-devicons", diff --git a/vim/.vim/lua/plugins/cmp.lua b/vim/.vim/lua/plugins/cmp.lua index 3a0eeb8..235071e 100644 --- a/vim/.vim/lua/plugins/cmp.lua +++ b/vim/.vim/lua/plugins/cmp.lua @@ -8,10 +8,6 @@ local has_words_before = function() return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end -local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) -end - return { { "tzachar/cmp-tabnine", @@ -29,6 +25,7 @@ return { dependencies = { "f3fora/cmp-spell", "hrsh7th/cmp-buffer", + "amarakon/nvim-cmp-buffer-lines", "hrsh7th/cmp-calc", "onsails/lspkind.nvim", "hrsh7th/cmp-cmdline", @@ -37,41 +34,37 @@ return { "hrsh7th/cmp-nvim-lsp-document-symbol", "hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-path", + "FelipeLema/cmp-async-path", "lukas-reineke/cmp-under-comparator", "ray-x/cmp-treesitter", }, config = function() + vim.opt.shortmess:append("c") + vim.opt.completeopt = { "menu", "menuone", "noselect" } + local cmp = require("cmp") local conditionalSources = cmp.config.sources({ - { name = "nvim_lsp", priority = 100 }, - { name = "nvim_lsp_signature_help", priority = 6 }, - { name = "luasnip", priority = 7 }, + { name = "nvim_lsp", priority = 8 }, + { name = "treesitter", priority = 7 }, + { name = "nvim_lsp_signature_help" }, + { name = "luasnip" }, { name = "calc" }, { name = "crates" }, { name = "nvim_lua" }, { name = "emoji" }, - { name = "path" }, - { name = "treesitter" }, - { - name = "spell", - option = { - keep_all_entries = false, - enable_in_context = function() - return true - end, - }, - }, - { name = "buffer", max_item_count = 5, keyword_length = 5 }, + { name = "async_path" }, + { name = "spell" }, + { name = "buffer", option = { keyword_pattern = [[\k\+]] }, priority = 1 }, + -- { name = "buffer-lines" }, }) if use_google() then require("cmp_nvim_ciderlsp").setup() - table.insert(conditionalSources, { name = "analysislsp" }) - table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 80 }) + table.insert(conditionalSources, { name = "analysislsp", priority = 5 }) + table.insert(conditionalSources, { name = "nvim_ciderlsp", priority = 9 }) else - table.insert(conditionalSources, { name = "cmp_tabnine" }) + table.insert(conditionalSources, { name = "cmp_tabnine", priority = 9 }) end local lspkind = require("lspkind") @@ -81,8 +74,9 @@ return { cmp.setup.cmdline({ "/", "?" }, { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ - { name = "nvim_lsp_document_symbol" }, - { name = "buffer", max_item_count = 5 }, + { name = "nvim_lsp_document_symbol", priority = 3 }, + { name = "treesitter", priority = 2 }, + { name = "buffer", option = { keyword_pattern = [[\k\+]] }, priority = 1 }, }), }) @@ -90,8 +84,9 @@ return { cmp.setup.cmdline(":", { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ - { name = "path", priority = 9 }, - { name = "cmdline" }, + { name = "async_path", priority = 9 }, + { name = "treesitter", priority = 7 }, + { name = "cmdline", priority = 8 }, }), }) @@ -101,7 +96,6 @@ return { [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.close(), [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), - [""] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping.confirm({ select = true }), [""] = cmp.mapping(function(fallback) if cmp.visible() then @@ -136,11 +130,12 @@ return { end), }, + preselect = cmp.PreselectMode.None, sources = conditionalSources, sorting = { comparators = { - -- cmp.config.compare.priority, + cmp.config.compare.priority, cmp.config.compare.offset, cmp.config.compare.exact, cmp.config.compare.score, @@ -160,19 +155,8 @@ return { formatting = { format = lspkind.cmp_format({ - mode = "symbol_text", - before = function(entry, vim_item) - if entry.source.name == "nvim_ciderlsp" then - if entry.completion_item.is_multiline then - -- multi-line specific formatting here - vim_item.menu = "  " - else - vim_item.menu = "" - end - end - return vim_item - end, - maxwidth = 50, -- half max width + -- mode = "symbol_text", + -- maxwidth = 50, -- half max width menu = { nvim_ciderlsp = "", buffer = "", @@ -181,7 +165,7 @@ return { nvim_lua = "", luasnip = "[LuaSnip]", cmp_tabnine = "[TabNine]", - path = "[path]", + async_path = "[async_path]", tmux = "[TMUX]", }, }), diff --git a/vim/.vim/lua/plugins/lsp.lua b/vim/.vim/lua/plugins/lsp.lua index 7d99230..093b173 100644 --- a/vim/.vim/lua/plugins/lsp.lua +++ b/vim/.vim/lua/plugins/lsp.lua @@ -33,10 +33,6 @@ return { local lsp_status = require("lsp-status") lsp_status.register_progress() - -- Don't show the dumb matching stuff - vim.opt.shortmess:append("c") - vim.opt.completeopt = { "menu", "menuone", "noselect" } - vim.opt.spell = true vim.opt.spelllang = { "en_us" } vim.lsp.handlers["window/showMessage"] = function(_, result, ctx) @@ -73,10 +69,7 @@ return { "bzl", "typescript", }, - -- required for proto generated files jump - root_dir = function(fname) - return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$") - end, + root_dir = lspconfig.util.root_pattern("google3/*BUILD"), settings = {}, }, } @@ -104,9 +97,7 @@ return { "typescript", "javascript", }, - root_dir = function(fname) - return string.match(fname, "(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$") - end, + root_dir = lspconfig.util.root_pattern("google3/*BUILD"), settings = {}, }, } @@ -126,7 +117,7 @@ return { }, codeDescriptionSupport = true, dataSupport = true, - layeredDiagnostics = true, + -- layeredDiagnostics = true, } capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities) diff --git a/vim/.vim/lua/plugins/lsp_lines.lua b/vim/.vim/lua/plugins/lsp_lines.lua index a84cafb..d680259 100644 --- a/vim/.vim/lua/plugins/lsp_lines.lua +++ b/vim/.vim/lua/plugins/lsp_lines.lua @@ -4,14 +4,15 @@ return { lazy = false, config = function() vim.diagnostic.config({ - -- virtual_lines = { only_current_line = true }, - virtual_lines = true, + virtual_lines = { only_current_line = true }, + -- virtual_lines = true, - -- update_in_insert = true, + update_in_insert = true, virtual_text = false, }) require("lsp_lines").setup() + require("lsp_lines").toggle() end, keys = { { diff --git a/vim/.vim/lua/plugins/nvim-notify.lua b/vim/.vim/lua/plugins/nvim-notify.lua deleted file mode 100644 index 608e35f..0000000 --- a/vim/.vim/lua/plugins/nvim-notify.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - "rcarriga/nvim-notify", - config = function() - local colors = require("catppuccin.palettes").get_palette() - require("notify").setup({ - background_colour = colors.base, - fps = 10, -- default 30 - stages = "slide", -- default fade_in_slide_out - timeout = 5000, -- default 5000 - }) - vim.notify = require("notify") - end, -} diff --git a/vim/.vimrc b/vim/.vimrc index 073ffc6..f211038 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -72,10 +72,9 @@ set scrolloff=3 " Minumum lines to keep above and below cursor " \ }, " \ cache_enabled: 1, " \ } -set shortmess=A +set shortmess=A " disable swap set shortmess+=O set modifiable -set omnifunc= completeopt=menuone,noinsert,noselect set updatetime=100