minimal lsp
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
require("romanzy.plugins.rose-pine")
|
||||
require("romanzy.plugins.nvim-treesitter")
|
||||
require("romanzy.plugins.lsp")
|
||||
|
||||
102
nvim/.config/nvim/lua/romanzy/plugins/lsp.lua
Normal file
102
nvim/.config/nvim/lua/romanzy/plugins/lsp.lua
Normal file
@@ -0,0 +1,102 @@
|
||||
vim.pack.add({
|
||||
{
|
||||
src = "https://github.com/mason-org/mason.nvim",
|
||||
name = "mason.nvim",
|
||||
},
|
||||
{
|
||||
src = "https://github.com/mason-org/mason-lspconfig.nvim",
|
||||
name = "mason-lspconfig.nvim",
|
||||
},
|
||||
{
|
||||
src = "https://github.com/neovim/nvim-lspconfig",
|
||||
name = "nvim-lspconfig",
|
||||
},
|
||||
})
|
||||
|
||||
local mason_lspconfig = require("mason-lspconfig")
|
||||
|
||||
vim.opt.completeopt = { "menu", "menuone", "noselect", "popup", "fuzzy" }
|
||||
|
||||
vim.diagnostic.config({
|
||||
severity_sort = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = false,
|
||||
float = {
|
||||
border = "rounded",
|
||||
source = "if_many",
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
|
||||
vim.lsp.completion.enable(true, client.id, ev.buf, {
|
||||
autotrigger = true,
|
||||
})
|
||||
|
||||
if client:supports_method("textDocument/inlayHint") then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = ev.buf })
|
||||
end
|
||||
|
||||
local opts = { buffer = ev.buf }
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
||||
vim.keymap.set("n", "grd", vim.lsp.buf.references, opts)
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts)
|
||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
local managed_servers = {
|
||||
"bashls",
|
||||
"clangd",
|
||||
"jsonls",
|
||||
"lua_ls",
|
||||
"marksman",
|
||||
"taplo",
|
||||
"ts_ls",
|
||||
"yamlls",
|
||||
}
|
||||
local servers = {
|
||||
bashls = {},
|
||||
clangd = {},
|
||||
jsonls = {},
|
||||
marksman = {},
|
||||
taplo = {},
|
||||
ts_ls = {},
|
||||
yamlls = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" },
|
||||
},
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
},
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for server_name, config in pairs(servers) do
|
||||
config.capabilities = vim.tbl_deep_extend("force", {}, capabilities, config.capabilities or {})
|
||||
vim.lsp.config(server_name, config)
|
||||
end
|
||||
|
||||
require("mason").setup()
|
||||
|
||||
mason_lspconfig.setup({
|
||||
automatic_enable = managed_servers,
|
||||
})
|
||||
@@ -1,5 +1,17 @@
|
||||
{
|
||||
"plugins": {
|
||||
"mason-lspconfig.nvim": {
|
||||
"rev": "21c5b3ebeaa0412e28096bb0701434c51c1fbf76",
|
||||
"src": "https://github.com/mason-org/mason-lspconfig.nvim"
|
||||
},
|
||||
"mason.nvim": {
|
||||
"rev": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d",
|
||||
"src": "https://github.com/mason-org/mason.nvim"
|
||||
},
|
||||
"nvim-lspconfig": {
|
||||
"rev": "bfcc0171a43f22afa61d927ffe9fcb6cb85dc99e",
|
||||
"src": "https://github.com/neovim/nvim-lspconfig"
|
||||
},
|
||||
"nvim-treesitter": {
|
||||
"rev": "4916d6592ede8c07973490d9322f187e07dfefac",
|
||||
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
|
||||
|
||||
Reference in New Issue
Block a user