all repos — dotfiles @ ba9198071452e26eb6f620dcee69246a152059d2

my *nix dotfiles

nvim: use nvim-cmp
Anirudh Oppiliappan x@icyphox.sh
Thu, 26 May 2022 16:20:35 +0530
commit

ba9198071452e26eb6f620dcee69246a152059d2

parent

5f9bcaa2801fcb93bf5cbed574d6e6027c7f0c67

M config/nvim/_init.luaconfig/nvim/_init.lua

@@ -4,6 +4,7 @@ -- TODO: ref: https://github.com/neovim/neovim/pull/15436

-- require 'impatient' require 'settings' +require 'completion' require 'maps' require 'statusline.line' require 'treesitter'

@@ -15,3 +16,4 @@ require 'lsp.python'

require 'lsp.go' require 'lsp.lua' require 'lsp.json' +
M config/nvim/colors/plain.vimconfig/nvim/colors/plain.vim

@@ -95,6 +95,7 @@ call s:h("Comment", {"fg": s:comment, "cterm": "italic"})

call s:h("Function", {"fg": s:norm, "cterm": "bold"}) call s:h("FloatWin", {"fg": s:norm, "bg": s:black}) + hi! link Constant firstAccent hi! link Character Constant hi! link Number Constant

@@ -204,7 +205,7 @@ call s:h("CursorColumn", {"bg": s:bg_very_subtle})

call s:h("CursorLine", {"bg": s:cursor_line}) call s:h("ColorColumn", {"bg": s:bg_subtle}) -call s:h("MatchParen", {"bg": s:bg_very_subtle, "fg": s:norm}) +call s:h("MatchParen", {"bg": s:pink, "fg": s:norm}) hi link qfLineNr secondAccent hi link qfFileName firstAccent

@@ -367,3 +368,5 @@ hi link cssTagName Normal

" floatwin hi link NormalFloat FloatWin +hi link CmpItemKind firstAccent +hi link CmpItemAbbrMatch secondAccent
A config/nvim/lua/completion.lua

@@ -0,0 +1,77 @@

+local cmp = require 'cmp' +local luasnip = require 'luasnip' + +local has_words_before = function() + 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({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.abort(), + ['<CR>'] = cmp.mapping.confirm({ select = true }), + ["<Tab>"] = cmp.mapping(function(fallback) + 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" }), + + ["<S-Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer' }, + }) +}) + +cmp.setup.cmdline('/', { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = 'buffer' }, + { name = 'luasnip' } + } +}) + +cmp.setup.cmdline(':', { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = 'path' } + }, { + { name = 'cmdline' } + }) +}) + +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +require('lspconfig')['gopls'].setup { + capabilities = capabilities +} +
M config/nvim/lua/maps.luaconfig/nvim/lua/maps.lua

@@ -82,9 +82,9 @@ buf_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', options)

buf_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', options) buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', options) - if client.resolved_capabilities.document_formatting then + if client.server_capabilities.document_formatting then buf_set_keymap('n', 'ff', '<cmd>lua vim.lsp.buf.formatting()<CR>', options) - elseif client.resolved_capabilities.document_range_formatting then + elseif client.server_capabilities.document_range_formatting then buf_set_keymap('n', 'ff', '<cmd>lua vim.lsp.buf.range_formatting()<CR>', options) end end
M config/nvim/lua/settings.luaconfig/nvim/lua/settings.lua

@@ -26,6 +26,7 @@ o.tabstop = 4

o.shiftwidth = 4 o.softtabstop = 4 o.showmode = true +o.cursorline = true o.listchars='tab:│ ,nbsp:␣,trail:·,extends:>,precedes:<' o.hidden = true o.completeopt = { 'menuone', 'noselect', 'noinsert' }

@@ -98,27 +99,32 @@ end

end, }) --- coq.nvim -g.coq_settings = { - auto_start = 'shut-up', - xdg = true, - clients = { - snippets = { warn = {} } - }, - display = { - icons = { - mode = 'none' - }, - preview = { - border = 'rounded', - }, - }, -} - -- filetype.nvim g.do_filetype_lua = 1 g.did_load_filetypes = 0 +-- tabout.nvim +require('tabout').setup { + tabkey = '<Tab>', + backwards_tabkey = '<S-Tab>', + act_as_tab = true, + act_as_shift_tab = false, + default_tab = '<C-t>', + default_shift_tab = '<C-d>', + enable_backwards = true, + completion = true, + tabouts = { + {open = "'", close = "'"}, + {open = '"', close = '"'}, + {open = '`', close = '`'}, + {open = '(', close = ')'}, + {open = '[', close = ']'}, + {open = '{', close = '}'} + }, + ignore_beginning = true, + exclude = {} +} + -- disable built-in plugins local disabled_built_ins = { 'gzip',

@@ -129,6 +135,6 @@ 'zipPlugin',

'zip', } -for i = 1, 6 do +for i, _ in ipairs(disabled_built_ins) do g['loaded_' .. disabled_built_ins[i]] = 1 end
M nix/programs/neovim.nixnix/programs/neovim.nix

@@ -1,9 +1,21 @@

{ config , pkgs , self +, lib , ... }: +let + tabout = pkgs.vimUtils.buildVimPlugin { + name = "tabout.nvim"; + src = pkgs.fetchFromGitHub { + owner = "abecodes"; + repo = "tabout.nvim"; + rev = "be655cc7ce0f5d6d24eeaf8b36e82693fd2facca"; + sha256 = "sha256-wB9HIS0HW1DExgQ/is8/ejpH9FVYfH4UpS9HA6pgYK4="; + }; + }; +in { programs.neovim = { enable = true;

@@ -21,15 +33,26 @@ extraConfig = ''

runtime _init.lua ''; plugins = with pkgs.vimPlugins; [ - coq_nvim + nvim-cmp + cmp-buffer + cmp_luasnip + cmp-nvim-lsp + cmp-treesitter + cmp-path + + nvim-lspconfig (nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars)) + luasnip playground vim-surround targets-vim vim-gitgutter vim-rsi nvim-treesitter-textobjects + conflict-marker-vim + tabout + vim-jsonnet ]; }; }