forked from nico/dots
nvim: redo LSP setup to be simpler
now uses more of the built-in LSP functionality built into neovim. - LSP configurations from the official repo - downloads LSPs from nix using lazy-lsp - autocomplete using blink.cmp - show status using fidget.nvim
This commit is contained in:
parent
4b7bf6b3b5
commit
6a644b4318
3 changed files with 67 additions and 123 deletions
29
stow/.config/nvim/lua/nico/lazy/blink.lua
Normal file
29
stow/.config/nvim/lua/nico/lazy/blink.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
return {
|
||||
'saghen/blink.cmp',
|
||||
dependencies = { 'rafamadriz/friendly-snippets' },
|
||||
|
||||
-- use a release tag to download pre-built binaries
|
||||
version = '1.*',
|
||||
-- AND/OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust
|
||||
-- build = 'cargo build --release',
|
||||
-- If you use nix, you can build from source using latest nightly rust with:
|
||||
-- build = 'nix run .#build-plugin',
|
||||
|
||||
opts = {
|
||||
keymap = { preset = 'default' },
|
||||
|
||||
appearance = {
|
||||
nerd_font_variant = 'mono'
|
||||
},
|
||||
|
||||
-- (Default) Only show the documentation popup when manually triggered
|
||||
completion = { documentation = { auto_show = false } },
|
||||
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer' },
|
||||
},
|
||||
|
||||
fuzzy = { implementation = "prefer_rust_with_warning" }
|
||||
},
|
||||
opts_extend = { "sources.default" }
|
||||
}
|
||||
|
|
@ -1,102 +1,22 @@
|
|||
return {
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"j-hui/fidget.nvim",
|
||||
"dundalek/lazy-lsp.nvim",
|
||||
},
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"j-hui/fidget.nvim", -- lsp status
|
||||
"dundalek/lazy-lsp.nvim", -- load LSPs from nix
|
||||
},
|
||||
config = function()
|
||||
require("fidget").setup {}
|
||||
require("lazy-lsp").setup {}
|
||||
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
local cmp_lsp = require("cmp_nvim_lsp")
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
cmp_lsp.default_capabilities())
|
||||
|
||||
require("fidget").setup({})
|
||||
|
||||
require("lazy-lsp").setup {
|
||||
-- By default all available servers are set up. Exclude unwanted or misbehaving servers.
|
||||
excluded_servers = {
|
||||
"ccls", "zk", "bufls", "ruff_lsp"
|
||||
},
|
||||
-- Alternatively specify preferred servers for a filetype (others will be ignored).
|
||||
preferred_servers = {
|
||||
markdown = {},
|
||||
python = { "pyright" },
|
||||
nix = { "nil_ls" },
|
||||
rust = { "rust_analyzer" },
|
||||
go = { "gopls" },
|
||||
c = { "clangd" },
|
||||
},
|
||||
prefer_local = true, -- Prefer locally installed servers over nix-shell
|
||||
-- Default config passed to all servers to specify on_attach callback and other options.
|
||||
default_config = {
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
-- on_attach = on_attach,
|
||||
-- capabilities = capabilities,
|
||||
},
|
||||
-- Override config for specific servers that will passed down to lspconfig setup.
|
||||
-- Note that the default_config will be merged with this specific configuration so you don't need to specify everything twice.
|
||||
configs = {
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-k>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-j>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<A-Enter>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
['<C-x>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-z>'] = cmp.mapping.scroll_docs(4),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- update_in_insert = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
end
|
||||
vim.lsp.enable({
|
||||
'gopls', -- go
|
||||
'pyright', -- python
|
||||
'lua_ls', -- lua
|
||||
'rust-analyzer', -- rust
|
||||
'nil_ls', -- nix
|
||||
'bashls', -- bash
|
||||
'html', -- html
|
||||
'cssls', -- css
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue