diff --git a/home/.config/nvim/lua/colors/nord.lua b/home/.config/nvim/lua/colors/nord.lua index ff67918..38ad5fc 100644 --- a/home/.config/nvim/lua/colors/nord.lua +++ b/home/.config/nvim/lua/colors/nord.lua @@ -278,10 +278,35 @@ local function highlight_lsp() hi('LspReferenceRead', c.fg, c.grey_bright, '', '') hi('LspReferenceWrite', c.fg, c.grey_bright, '', '') vim.api.nvim_command('hi! link LspCodeLens Comment') + + -- Theses are for neovim 0.6 + vim.api.nvim_command('hi! link DiagnosticVirtualTextWarn LspDiagnosticsVirtualTextWarning') + vim.api.nvim_command('hi! link DiagnosticUnderlineWarn LspDiagnosticsUnderlineWarning') + vim.api.nvim_command('hi! link DiagnosticFloatingWarn LspDiagnosticsFloatingWarning') + vim.api.nvim_command('hi! link DiagnosticSignWarn LspDiagnosticsSignWarning') + vim.api.nvim_command('hi! link DiagnosticVirtualTextError LspDiagnosticsVirtualTextError') + vim.api.nvim_command('hi! link DiagnosticUnderlineError LspDiagnosticsUnderlineError') + vim.api.nvim_command('hi! link DiagnosticFloatingError LspDiagnosticsFloatingError') + vim.api.nvim_command('hi! link DiagnosticSignError LspDiagnosticsSignError') + vim.api.nvim_command('hi! link DiagnosticVirtualTextInfo LspDiagnosticsVirtualTextInformation') + vim.api.nvim_command('hi! link DiagnosticUnderlineInfo LspDiagnosticsUnderlineInformation') + vim.api.nvim_command('hi! link DiagnosticFloatingInfo LspDiagnosticsFloatingInformation') + vim.api.nvim_command('hi! link DiagnosticSignInfo LspDiagnosticsSignInformation') + vim.api.nvim_command('hi! link DiagnosticVirtualTextHint LspDiagnosticsVirtualTextHint') + vim.api.nvim_command('hi! link DiagnosticUnderlineHint LspDiagnosticsUnderlineHint') + vim.api.nvim_command('hi! link DiagnosticFloatingHint LspDiagnosticsFloatingHint') + vim.api.nvim_command('hi! link DiagnosticSignHint LspDiagnosticsSignHint') end -- Specify groups for plugins local function highlight_plugins() + -- nvim-cmp (experimental custom menu) + hi('CmpItemAbbr', c.fg, '', '', '') + hi('CmpItemAbbrMatch', c.yellow, '', '', '') + hi('CmpItemAbbrMatchFuzzy', c.yellow, '', '', '') + hi('CmpItemKind', c.fg, '', '', '') + hi('CmpItemMenu', c.fg, '', '', '') + -- Gitsigns hi('GitSignsAddNr' , c.green , '', '', '') hi('GitSignsChangeNr', c.yellow, '', '', '') diff --git a/home/.config/nvim/lua/modules/completion.lua b/home/.config/nvim/lua/modules/completion.lua index 079409b..717d492 100644 --- a/home/.config/nvim/lua/modules/completion.lua +++ b/home/.config/nvim/lua/modules/completion.lua @@ -5,11 +5,12 @@ function M.cmp_conf() local luasnip = require('luasnip') local has_words_before = function() - local cursor = vim.api.nvim_win_get_cursor(0) - return not vim.api.nvim_get_current_line():sub(1, cursor[2]):match('^%s$') + 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 cmp.setup { + experimental = {custom_menu = true}, -- Use custom highlightng for the floating completion menu formatting = { format = function(entry, vim_item) local lspkind_icons = { @@ -72,33 +73,35 @@ function M.cmp_conf() -- Change choice nodes for luasnip [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-prev-choice', true, true, true), '', true) + luasnip.change_choice(-1) else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) if luasnip.choice_active() then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-next-choice', true, true, true), '', true) + luasnip.change_choice(1) else fallback() end end, {'i', 's'}), -- supertab-like mapping [''] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) - elseif has_words_before() and luasnip.expand_or_jumpable() then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-expand-or-jump', true, true, true), '', true) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() else fallback() end end, {'i', 's'}), [''] = cmp.mapping(function(fallback) - if vim.fn.pumvisible() == 1 then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('', true, true, true), 'n', true) + if cmp.visible() then + cmp.select_prev_item() elseif luasnip.jumpable(-1) then - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('luasnip-jump-prev', true, true, true), '', true) + luasnip.jump(-1) else fallback() end diff --git a/home/.config/nvim/scripts/install b/home/.config/nvim/scripts/install index bcd7131..361593a 100755 --- a/home/.config/nvim/scripts/install +++ b/home/.config/nvim/scripts/install @@ -1,7 +1,5 @@ #!/bin/sh -# TODO: consider forking 'kabouzeid/nvim-lspinstall' or 'anott03/nvim-lspinstall' -# instead of running scripts if [ "$#" -ne 1 ]; then echo "Usage:" printf " - %s server_name: install specified server\n" "$0"