update vim config
This commit is contained in:
parent
a2ab9b3db1
commit
9e1e6df979
|
@ -1,5 +1,6 @@
|
|||
{ config, pkgs, ... }:
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
defaultEditor = true;
|
||||
|
@ -22,9 +23,7 @@
|
|||
syntax on
|
||||
au FileType markdown set colorcolumn=73 textwidth=72
|
||||
au FileType gitcommit set colorcolumn=73
|
||||
|
||||
lua << EOF
|
||||
EOF
|
||||
highlight NormalFloat guibg=NONE
|
||||
'';
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
|
@ -52,24 +51,87 @@
|
|||
require("nvim-tree").setup({
|
||||
-- :help nvim-tree-setup
|
||||
})
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set('n', '<C-N>', require("nvim-tree.api").tree.toggle, opts)
|
||||
require("which-key").register({['<C-n>'] = {
|
||||
require("nvim-tree.api").tree.toggle, 'Toggle NvimTree'
|
||||
}}, {mode='n', noremap=true, silent=true})
|
||||
''; }
|
||||
vim-sleuth
|
||||
luasnip
|
||||
{ plugin = nvim-cmp;
|
||||
config = lua ''
|
||||
local cmp = require('cmp')
|
||||
local function border(hl_name)
|
||||
return {
|
||||
{ "╭", hl_name },
|
||||
{ "─", hl_name },
|
||||
{ "╮", hl_name },
|
||||
{ "│", hl_name },
|
||||
{ "╯", hl_name },
|
||||
{ "─", hl_name },
|
||||
{ "╰", hl_name },
|
||||
{ "│", hl_name },
|
||||
}
|
||||
end
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
view = {
|
||||
|
||||
},
|
||||
window = {
|
||||
completion = {
|
||||
border = border "CmpBorder",
|
||||
winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
|
||||
},
|
||||
documentation = {
|
||||
border = border "CmpDocBorder",
|
||||
},
|
||||
},
|
||||
formatting = {
|
||||
format = function(_, vim_item)
|
||||
local icons = require("lspkind")
|
||||
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<tab>'] = cmp.mapping.confirm { select = true },
|
||||
['<cr>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = false,
|
||||
},
|
||||
['<tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true), "")
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
['<S-tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require('luasnip').jumpable(-1) then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<Plug>luasnip-jump-prev', true, true, true), "")
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
|
@ -77,8 +139,35 @@
|
|||
}),
|
||||
}
|
||||
''; }
|
||||
lspkind-nvim
|
||||
cmp_luasnip
|
||||
cmp-nvim-lsp
|
||||
{ plugin = nvim-autopairs;
|
||||
config = lua ''
|
||||
require('nvim-autopairs').setup({
|
||||
disable_filetype = { "TelescopePrompt" , "vim" },
|
||||
})
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done()
|
||||
)
|
||||
''; }
|
||||
{ plugin = comment-nvim;
|
||||
config = lua ''
|
||||
require('Comment').setup()
|
||||
local opts = { noremap=true, silent=true }
|
||||
vim.keymap.set('n', '<space>/', require("Comment.api").toggle.linewise.current, opts)
|
||||
vim.keymap.set('v', '<space>/', "<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", opts)
|
||||
require("which-key").register({['<space>/'] = {
|
||||
require("Comment.api").toggle.linewise.current, 'Comment current line'
|
||||
}}, {mode='n', noremap=true, silent=true})
|
||||
require("which-key").register({['<space>/'] = {
|
||||
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>", 'Comment current line'
|
||||
}}, {mode='v', noremap=true, silent=true})
|
||||
|
||||
''; }
|
||||
{ plugin = nvim-lspconfig;
|
||||
config = lua ''
|
||||
-- Mappings.
|
||||
|
@ -88,6 +177,12 @@
|
|||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
require("which-key").register({
|
||||
['<space>e'] = { vim.diagnostic.open_float, 'Show diagnostics in a floating window.' },
|
||||
['[d'] = { vim.diagnostic.goto_prev, 'Move to the previous diagnostic in the current buffer.' },
|
||||
[']d'] = { vim.diagnostic.goto_next, 'Get the next diagnostic closest to the cursor position.' },
|
||||
['<space>q'] = { vim.diagnostic.setloclist, 'Add buffer diagnostics to the location list.' },
|
||||
}, {mode='n', noremap=true, silent=true})
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
|
@ -113,6 +208,25 @@
|
|||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
|
||||
require("which-key").register({
|
||||
['gD'] = { vim.lsp.buf.declaration, 'Jumps to the declaration of the symbol under the cursor.' },
|
||||
['gd'] = { vim.lsp.buf.definition, 'Jumps to the definition of the symbol under the cursor.' },
|
||||
['K'] = { vim.lsp.buf.hover, 'Displays hover information about the symbol under the cursor in a floating window.' },
|
||||
['gi'] = { vim.lsp.buf.implementation, 'Lists all the implementations for the symbol under the cursor in the quickfix window.' },
|
||||
['<C-h>'] = { vim.lsp.buf.signature_help, 'Displays signature information about the symbol under the cursor in a floating window.' },
|
||||
['<space>wa'] = { vim.lsp.buf.add_workspace_folder, 'Add a folder to the workspace folders.' },
|
||||
['<space>wr'] = { vim.lsp.buf.remove_workspace_folder, 'Remove a folder from the workspace folders.' },
|
||||
['<space>wl'] = { function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, 'List workspace folders.' },
|
||||
['<space>D'] = { vim.lsp.buf.type_definition, 'Jumps to the definition of the type of the symbol under the cursor.' },
|
||||
['<space>rn'] = { vim.lsp.buf.rename, 'Rename old_fname to new_fname' },
|
||||
['<space>ca'] = { vim.lsp.buf.code_action, 'Selects a code action available at the current cursor position.' },
|
||||
['gr'] = { vim.lsp.buf.references, 'Lists all the references to the symbol under the cursor in the quickfix window.' },
|
||||
['<space>f'] = { function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, 'Formats a buffer.' },
|
||||
}, {mode='n', noremap=true, silent=true, buffer=bufnr})
|
||||
end
|
||||
|
||||
local lsp_flags = {
|
||||
|
@ -191,8 +305,13 @@
|
|||
["rust-analyzer"] = {}
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
''; }
|
||||
{ plugin = which-key-nvim;
|
||||
config = lua ''
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 500
|
||||
require("which-key").setup { }
|
||||
''; }
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue