mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-24 00:29:43 -04:00
93 lines
2.4 KiB
Nix
93 lines
2.4 KiB
Nix
{ pkgs, ... }:
|
|
|
|
with pkgs.vimPlugins;
|
|
[
|
|
{ plugin = lsp-zero-nvim;
|
|
config = ''
|
|
lua << EOF
|
|
local lsp = require('lsp-zero').preset({})
|
|
|
|
lsp.on_attach(function(client, bufnr)
|
|
lsp.default_keymaps({buffer = bufnr})
|
|
end)
|
|
|
|
lsp.setup_servers({
|
|
"tsserver",
|
|
"eslint",
|
|
"hls",
|
|
"pyright",
|
|
"nil_ls",
|
|
"cssls",
|
|
"html",
|
|
"jsonls",
|
|
"diagnosticls",
|
|
"lua_ls",
|
|
"marksman",
|
|
"purescriptls",
|
|
"tailwindcss",
|
|
"bashls",
|
|
})
|
|
|
|
lsp.setup()
|
|
EOF
|
|
'';
|
|
}
|
|
|
|
{ plugin = null-ls-nvim; }
|
|
{ plugin = nvim-lspconfig; }
|
|
{ plugin = cmp-nvim-lsp; }
|
|
|
|
{ plugin = nvim-cmp;
|
|
config = ''
|
|
lua << EOF
|
|
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
|
|
|
|
local luasnip = require("luasnip")
|
|
local cmp = require'cmp'
|
|
|
|
cmp.setup({
|
|
snippet = {
|
|
expand = function(args)
|
|
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
end,
|
|
},
|
|
|
|
window = {
|
|
completion = cmp.config.window.bordered(),
|
|
documentation = cmp.config.window.bordered(),
|
|
},
|
|
|
|
enabled = function()
|
|
-- disable completion in comments
|
|
local context = require("cmp.config.context")
|
|
-- keep command mode completion enabled when cursor is in a comment
|
|
if vim.api.nvim_get_mode().mode == "c" then
|
|
return true
|
|
else
|
|
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
|
|
end
|
|
end,
|
|
|
|
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 }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
|
}),
|
|
|
|
sources = cmp.config.sources({
|
|
{ name = 'nvim_lsp' },
|
|
{ name = 'luasnip' }, -- For luasnip users.
|
|
}, {
|
|
{ name = 'buffer' },
|
|
})
|
|
})
|
|
EOF
|
|
'';
|
|
}
|
|
]
|