chore: move plugins to an upper level

This commit is contained in:
Mariano Z. 2024-12-22 12:16:36 -03:00
parent 9569774c7b
commit 99bcb4ca97
Signed by: marianozunino
GPG key ID: 4C73BAD25156DACE
50 changed files with 69 additions and 69 deletions

View file

@ -0,0 +1,13 @@
return {
"olexsmir/gopher.nvim",
ft = "go",
config = function(_, opts)
require("gopher").setup(opts)
vim.keymap.set("n", "<leader>gmt", ":GoMod tidy<cr>", {
desc = "[Go] Tidy",
})
end,
build = function()
vim.cmd([[silent! GoInstallDeps]])
end,
}

View file

@ -0,0 +1,9 @@
return {
"folke/lazydev.nvim",
ft = "lua",
opts = {
library = {
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
},
},
}

View file

@ -0,0 +1,10 @@
return {
"yioneko/nvim-vtsls",
dependencies = {
"dmmulroy/ts-error-translator.nvim",
},
config = function()
require("ts-error-translator").setup()
end,
ft = { "typescript", "javascript", "jsx", "tsx", "json" },
}

139
lua/plugins/lsp/init.lua Normal file
View file

@ -0,0 +1,139 @@
local M = {
"neovim/nvim-lspconfig",
dependencies = {
"saghen/blink.cmp",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
require("plugins.lsp.extras.lazydev"),
require("plugins.lsp.extras.gopher"),
require("plugins.lsp.extras.typescript"),
},
}
local function setup_autocommands(client, bufnr)
if client.server_capabilities.documentHighlightProvider then
local group = vim.api.nvim_create_augroup("LSPDocumentHighlight", { clear = true })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
group = group,
buffer = bufnr,
callback = vim.lsp.buf.document_highlight,
})
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
group = group,
buffer = bufnr,
callback = vim.lsp.buf.clear_references,
})
end
end
local function setup_keymaps(bufnr)
local keymaps = {
{ "<C-h>", vim.lsp.buf.signature_help, "Signature Help" },
{ "<leader>cw", vim.lsp.buf.rename, "Rename" },
{ "<leader>r", vim.lsp.buf.rename, "Rename" },
{ "vd", vim.diagnostic.open_float, "Open Diagnostics" },
{ "<leader>lr", ":LspRestart<CR>", "Restart LSP" },
{ "<leader>li", ":LspInfo<CR>", "LSP Info" },
}
for _, map in ipairs(keymaps) do
nmap(map[1], map[2], {
buffer = bufnr,
desc = map[3],
})
end
end
local function on_attach(client, bufnr)
setup_autocommands(client, bufnr)
setup_keymaps(bufnr)
end
local BORDER = "rounded"
local handlers = {
["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = BORDER }),
["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = BORDER }),
}
function M.config()
require("mason").setup({
max_concurrent_installers = 4,
})
-- Ensure all tools are installed
local ensure_installed = {
-- LSP servers
"gopls",
"graphql-language-service-cli",
"html-lsp",
"htmx-lsp",
"json-lsp",
"lua-language-server",
"omnisharp",
"vtsls",
"yaml-language-server",
-- Formatters
"prettierd",
"shfmt",
"stylua",
"latexindent",
-- Additional tools
"eslint_d",
"templ",
}
local registry = require("mason-registry")
for _, tool in ipairs(ensure_installed) do
if not registry.is_installed(tool) then
vim.cmd("MasonInstall " .. tool)
end
end
require("mason-lspconfig").setup({
automatic_installation = true,
ensure_installed = {
"gopls",
"html",
"htmx",
"jsonls",
"lua_ls",
"omnisharp",
"yamlls",
"graphql",
},
handlers = {
function(server_name)
local capabilities = require("blink.cmp").get_lsp_capabilities()
-- Enable folding capabilities
capabilities.textDocument.foldingRange = {
dynamicRegistration = false,
lineFoldingOnly = true,
}
local base_opts = {
on_attach = on_attach,
capabilities = capabilities,
handlers = handlers,
flags = {
debounce_text_changes = 150,
},
}
-- Try to load server-specific configuration
local ok, server_opts = pcall(require, "plugins.lsp.servers." .. server_name)
if ok then
base_opts = vim.tbl_deep_extend("force", base_opts, server_opts)
end
-- Set up the LSP server
require("lspconfig")[server_name].setup(base_opts)
end,
},
})
end
return M

View file

@ -0,0 +1,15 @@
return {
settings = {
gopls = {
gofumpt = true, -- https://github.com/mvdan/gofumpt a stricter gofmt
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
},
},
},
flags = {
debounce_text_changes = 150, -- https://github.com/golang/tools/blob/master/gopls/doc/settings.md#change-detection
},
}

View file

@ -0,0 +1,3 @@
return {
filetypes = { "html", "templ" },
}

View file

@ -0,0 +1,3 @@
return {
filetypes = { "html", "templ" },
}

View file

@ -0,0 +1,16 @@
return {
settings = {
json = {
schemas = require("schemastore").json.schemas(),
},
},
setup = {
commands = {
Format = {
function()
vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line("$"), 0 })
end,
},
},
},
}

View file

@ -0,0 +1,21 @@
return {
settings = {
Lua = {
format = {
enable = false,
},
hint = {
enable = false,
arrayIndex = "Disable", -- "Enable" | "Auto" | "Disable"
await = true,
paramName = "Disable", -- "All" | "Literal" | "Disable"
paramType = true,
semicolon = "All", -- "All" | "SameLine" | "Disable"
setType = false,
},
telemetry = {
enable = false,
},
},
},
}

View file

@ -0,0 +1,7 @@
return {
settings = {
enable_roslyn_analyzers = true,
organize_imports_on_format = true,
enable_import_completion = true,
},
}

View file

@ -0,0 +1,21 @@
return {
settings = {
yaml = {
schemaStore = {
-- You must disable built-in schemaStore support if you want to use
-- this plugin and its advanced options like `ignore`.
enable = false,
-- Avoid TypeError: Cannot read properties of undefined (reading 'length')
url = "",
},
schemas = require("schemastore").yaml.schemas({
-- additional schemas (not in the catalog)
extra = {
url = "https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/argoproj.io/application_v1alpha1.json",
name = "Argo CD Application",
fileMatch = "argocd-application.yaml",
},
}),
},
},
}