Add many packages for neovim, and config for them
This commit is contained in:
parent
a052a2d508
commit
148899497b
|
@ -36,6 +36,130 @@ vim.keymap.set('n', '<leader>fb', tbuiltin.buffers, {})
|
||||||
vim.keymap.set('n', '<leader>fh', tbuiltin.help_tags, {})
|
vim.keymap.set('n', '<leader>fh', tbuiltin.help_tags, {})
|
||||||
vim.keymap.set('n', '<leader>fs', tbuiltin.spell_suggest, {})
|
vim.keymap.set('n', '<leader>fs', tbuiltin.spell_suggest, {})
|
||||||
|
|
||||||
|
-- Mason (tool manager) setup
|
||||||
|
-- we want rust-analyzer and codelldb
|
||||||
|
require("mason").setup({
|
||||||
|
ui = {
|
||||||
|
icons = {
|
||||||
|
package_installed = "✔️",
|
||||||
|
package_pending = "🔄",
|
||||||
|
package_uninstalled = "🌐"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
require("mason-lspconfig").setup()
|
||||||
|
|
||||||
|
-- General LSP settings
|
||||||
|
-- from https://rsdlt.github.io/posts/rust-nvim-ide-guide-walkthrough-development-debug/
|
||||||
|
local sign = function(opts)
|
||||||
|
vim.fn.sign_define(opts.name, {
|
||||||
|
texthl = opts.name,
|
||||||
|
text = opts.text,
|
||||||
|
numhl = ''
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
sign({name = 'DiagnosticSignError', text = '🛑'})
|
||||||
|
sign({name = 'DiagnosticSignWarn', text = '⚠️'})
|
||||||
|
sign({name = 'DiagnosticSignHint', text = '💭'})
|
||||||
|
sign({name = 'DiagnosticSignInfo', text = '🗒️'})
|
||||||
|
|
||||||
|
vim.diagnostic.config({
|
||||||
|
virtual_text = false,
|
||||||
|
signs = true,
|
||||||
|
update_in_insert = true,
|
||||||
|
underline = true,
|
||||||
|
severity_sort = false,
|
||||||
|
float = {
|
||||||
|
border = 'rounded',
|
||||||
|
source = 'always',
|
||||||
|
header = '',
|
||||||
|
prefix = '',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.cmd([[
|
||||||
|
set signcolumn=yes
|
||||||
|
autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false })
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Rust tools for Rust-specific LSP
|
||||||
|
local rt = require("rust-tools")
|
||||||
|
rt.setup({
|
||||||
|
server = {
|
||||||
|
on_attach = function(_, bufnr)
|
||||||
|
-- ctrl + space for hover actions
|
||||||
|
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||||
|
-- ,a for code actions
|
||||||
|
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- set up treesitter
|
||||||
|
require('nvim-treesitter.configs').setup {
|
||||||
|
auto_install = false,
|
||||||
|
ident = { enable = true },
|
||||||
|
rainbow = {
|
||||||
|
enable = true,
|
||||||
|
extended_mode = true,
|
||||||
|
max_file_lines = nil,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- completion setup
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
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-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
-- Add tab support
|
||||||
|
['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<Tab>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-S-f>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<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(),
|
||||||
|
},
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
-- set terminal title
|
-- set terminal title
|
||||||
function _G.current_tab()
|
function _G.current_tab()
|
||||||
local curr_buf = vim.fn.bufnr()
|
local curr_buf = vim.fn.bufnr()
|
||||||
|
|
10
vim.nix
10
vim.nix
|
@ -8,6 +8,16 @@
|
||||||
plugins = with pkgs.vimPlugins; [
|
plugins = with pkgs.vimPlugins; [
|
||||||
vim-nix
|
vim-nix
|
||||||
rust-vim
|
rust-vim
|
||||||
|
rust-tools-nvim
|
||||||
|
nvim-cmp
|
||||||
|
snippets-nvim
|
||||||
|
nvim-treesitter
|
||||||
|
nvim-treesitter-parsers.rust
|
||||||
|
nvim-treesitter-parsers.lua
|
||||||
|
nvim-treesitter-parsers.toml
|
||||||
|
mason-nvim
|
||||||
|
mason-tool-installer-nvim
|
||||||
|
mason-lspconfig-nvim
|
||||||
fzf-vim
|
fzf-vim
|
||||||
sleuth
|
sleuth
|
||||||
whitespace-nvim # ,t to trim whitespace
|
whitespace-nvim # ,t to trim whitespace
|
||||||
|
|
Loading…
Reference in New Issue