diff options
author | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2024-04-11 20:47:04 +0200 |
---|---|---|
committer | jakob.stendahl <jakob.stendahl@infomedia.dk> | 2024-04-11 20:47:04 +0200 |
commit | d7c322109e9aa051b4c094a60a44e814211a9a3e (patch) | |
tree | 8c80aadb297f2bcfc140cc403860fbc9e0f53fc5 | |
parent | 1ca10664fbac7050271c99e19772e6582e2bfb93 (diff) | |
download | dotfiles-d7c322109e9aa051b4c094a60a44e814211a9a3e.tar.gz dotfiles-d7c322109e9aa051b4c094a60a44e814211a9a3e.zip |
Remove cmp
-rwxr-xr-x | Common/nvim/init.lua | 3 | ||||
-rwxr-xr-x | Common/nvim/lua/basic.lua | 4 | ||||
-rwxr-xr-x | Common/nvim/lua/helper_functions.lua | 11 | ||||
-rw-r--r-- | Common/nvim/lua/lsp-conf.lua | 104 | ||||
-rwxr-xr-x | Common/nvim/lua/plugins.lua | 11 |
5 files changed, 42 insertions, 91 deletions
diff --git a/Common/nvim/init.lua b/Common/nvim/init.lua index 4b99e7b..e947f23 100755 --- a/Common/nvim/init.lua +++ b/Common/nvim/init.lua @@ -1,6 +1,3 @@ --- Use a mapleader -vim.g.mapleader = "," - -- To debug -- vim.opt.verbosefile = ~/nvim.log -- vim.opt.verbose = 15 diff --git a/Common/nvim/lua/basic.lua b/Common/nvim/lua/basic.lua index 0d8b3f9..275deed 100755 --- a/Common/nvim/lua/basic.lua +++ b/Common/nvim/lua/basic.lua @@ -10,10 +10,6 @@ vim.opt.nu = false -- Autoread when file is changed outside vim vim.opt.autoread = true --- Use a mapleader ---vim.opt.mapleader = "," -vim.g.mapleader = "," - -- Convenient sudo saving of file vim.api.nvim_create_user_command( 'W', 'w !sudo tee % > /dev/null', diff --git a/Common/nvim/lua/helper_functions.lua b/Common/nvim/lua/helper_functions.lua index 6c12495..05150c0 100755 --- a/Common/nvim/lua/helper_functions.lua +++ b/Common/nvim/lua/helper_functions.lua @@ -173,3 +173,14 @@ end vim.cmd [[ command! InvertNumberUnderCursor lua invertNumberUnderCursor() ]] + +-- helpful highlight when yanking text +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd('TextYankPost', { + desc = 'Highlight when yanking (copying) text', + group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) + diff --git a/Common/nvim/lua/lsp-conf.lua b/Common/nvim/lua/lsp-conf.lua index b80706d..fde33b3 100644 --- a/Common/nvim/lua/lsp-conf.lua +++ b/Common/nvim/lua/lsp-conf.lua @@ -50,85 +50,43 @@ vim.diagnostic.config({ }, }) +vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} +vim.opt.shortmess = vim.opt.shortmess + { c = true} +vim.api.nvim_set_option('updatetime', 300) vim.cmd([[ set signcolumn=yes ]]) -- autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) -map("n", "<leader>d", ":lua vim.diagnostic.open_float(nil, {})<CR>", silentnoremap) - - -vim.opt.completeopt = {'menuone', 'noselect', 'noinsert'} -vim.opt.shortmess = vim.opt.shortmess + { c = true} -vim.api.nvim_set_option('updatetime', 300) --- Completion Plugin Setup -local cmp = require'cmp' +vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist) -local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api - .nvim_buf_get_lines(0, line - 1, line, true)[1] - :sub(col, col) - :match("%s") - == nil -end +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by <c-x><c-o> + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' -cmp.setup({ - -- Enable LSP snippets - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) - end, - }, - mapping = { - ['<C-p>'] = cmp.mapping.select_prev_item(), - ["<C-M-n>"] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - ['<C-e>'] = cmp.mapping.close(), - ['<CR>'] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Insert, - select = true, - }) - }, - -- Installed sources: - sources = { - { name = 'path' }, -- file paths - { name = 'nvim_lsp', keyword_length = 3 }, -- from language server - { name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized - { name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.* - { name = 'buffer', keyword_length = 2 }, -- source current buffer - { name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip - { name = 'calc'}, -- source for math calculation - }, - window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), - }, - completion = { - autocomplete = false, - completeopt = "menu,menuone,preview", - }, - formatting = { - fields = {'menu', 'abbr', 'kind'}, - format = function(entry, item) - local menu_icon ={ - nvim_lsp = 'λ', - vsnip = '⋗', - buffer = 'Ω', - path = '🖫', - } - item.menu = menu_icon[entry.source.name] - return item - end, - }, + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', '<space>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', '<space>f', function() + vim.lsp.buf.format { async = true } + end, opts) + end }) diff --git a/Common/nvim/lua/plugins.lua b/Common/nvim/lua/plugins.lua index 825da80..7610540 100755 --- a/Common/nvim/lua/plugins.lua +++ b/Common/nvim/lua/plugins.lua @@ -95,17 +95,6 @@ return require('packer').startup(function(use) use 'simrat39/rust-tools.nvim' --use 'mfussenegger/nvim-jdtls' - -- Completion framework: - use 'hrsh7th/nvim-cmp' - -- LSP completion source: - use 'hrsh7th/cmp-nvim-lsp' - -- Useful completion sources: - use 'hrsh7th/cmp-nvim-lua' - use 'hrsh7th/cmp-nvim-lsp-signature-help' - use 'hrsh7th/cmp-vsnip' - use 'hrsh7th/cmp-path' - use 'hrsh7th/vim-vsnip' - -- VimWiki stuff use { 'vimwiki/vimwiki', |