Fixed lsp
This commit is contained in:
@@ -6,4 +6,3 @@ return {
|
||||
name = "plenary"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,107 +1,116 @@
|
||||
return {
|
||||
{
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
branch = "v4.x",
|
||||
lazy = true,
|
||||
config = false,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"williamboman/mason.nvim",
|
||||
lazy = false,
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- Autocompletion
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
"hrsh7th/cmp-cmdline",
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
{ "L3MON4D3/LuaSnip" },
|
||||
},
|
||||
config = function()
|
||||
local cmp = require('cmp')
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
}),
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.snippet.expand(args.body)
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
"L3MON4D3/LuaSnip",
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
"j-hui/fidget.nvim",
|
||||
},
|
||||
|
||||
-- LSP
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
cmd = { 'LspInfo', 'LspInstall', 'LspStart' },
|
||||
event = { 'BufReadPre', 'BufNewFile' },
|
||||
dependencies = {
|
||||
{ "hrsh7th/cmp-nvim-lsp" },
|
||||
{ "williamboman/mason.nvim" },
|
||||
{ "williamboman/mason-lspconfig.nvim" },
|
||||
},
|
||||
config = function()
|
||||
local lsp_zero = require('lsp-zero')
|
||||
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())
|
||||
|
||||
-- lsp_attach is where you enable features that only work
|
||||
-- if there is a language server active in the file
|
||||
local lsp_attach = function(client, bufnr)
|
||||
local opts = { buffer = bufnr }
|
||||
require("fidget").setup({})
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = {
|
||||
"clangd",
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
},
|
||||
handlers = {
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end,
|
||||
|
||||
vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts)
|
||||
vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts)
|
||||
vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts)
|
||||
vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts)
|
||||
vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts)
|
||||
vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts)
|
||||
vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts)
|
||||
vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts)
|
||||
vim.keymap.set({ 'n', 'x' }, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts)
|
||||
vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts)
|
||||
end
|
||||
|
||||
lsp_zero.extend_lspconfig({
|
||||
sign_text = true,
|
||||
lsp_attach = lsp_attach,
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
})
|
||||
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup({})
|
||||
end,
|
||||
lua_ls = function()
|
||||
require('lspconfig').lua_ls.setup({
|
||||
zls = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
lspconfig.zls.setup({
|
||||
root_dir = lspconfig.util.root_pattern(".git", "build.zig", "zls.json"),
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = vim.split(package.path, ';'),
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand('$VIMRUNTIME/lua')] = true,
|
||||
[vim.fn.expand('$VIMRUNTIME/lua/vim/lsp')] = true,
|
||||
},
|
||||
},
|
||||
zls = {
|
||||
enable_inlay_hints = true,
|
||||
enable_snippets = true,
|
||||
warn_style = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
vim.g.zig_fmt_parse_errors = 0
|
||||
vim.g.zig_fmt_autosave = 0
|
||||
end,
|
||||
["lua_ls"] = function()
|
||||
local lspconfig = require("lspconfig")
|
||||
lspconfig.lua_ls.setup {
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = { version = "Lua 5.1" },
|
||||
diagnostics = {
|
||||
globals = { "bit", "vim", "it", "describe", "before_each", "after_each" },
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
||||
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-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' }, -- For luasnip users.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
end
|
||||
}
|
||||
})
|
||||
|
||||
local _border = 'rounded'
|
||||
|
||||
vim.diagnostic.config({
|
||||
-- update_in_insert = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = _border,
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover, { border = _border }
|
||||
)
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help, { border = _border }
|
||||
)
|
||||
require('lspconfig.ui.windows').default_options = { border = _border }
|
||||
end
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
build = function()
|
||||
require("nvim-treesitter.instal").update({ with_sync = true})()
|
||||
require("nvim-treesitter.install").update({ with_sync = true })()
|
||||
end,
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
@@ -32,7 +32,6 @@ return {
|
||||
},
|
||||
}
|
||||
|
||||
vim .treesitter.language.register("templ", "templ")
|
||||
vim.treesitter.language.register("templ", "templ")
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -5,4 +5,3 @@ return {
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndoTreeToggle)
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user