LSP Code restructuring

This commit is contained in:
Snoweuph 2024-05-31 18:59:57 +02:00
parent 9885622e29
commit 1e89056dee
Signed by: Snoweuph
GPG key ID: A494330694B208EF
10 changed files with 228 additions and 216 deletions

View file

@ -4,5 +4,6 @@ return {
require("plugins.editor.editor_code_snippets"), require("plugins.editor.editor_code_snippets"),
require("plugins.editor.editor_debugging"), require("plugins.editor.editor_debugging"),
require("plugins.editor.editor_language_server"), require("plugins.editor.editor_language_server"),
require("plugins.editor.editor_markdown_preview") require("plugins.editor.editor_markdown_preview"),
} require("plugins.editor.editor_nvim_dev")
}

View file

@ -1,5 +1,76 @@
lua_lsp = require("plugins.editor.language_server.language_server_lua")
generic_lsp = require("plugins.editor.language_server.language_server_generic")
go_lsp = require("plugins.editor.language_server.language_server_go")
web_lsp = require("plugins.editor.language_server.language_server_web")
php_lsp = require("plugins.editor.language_server.language_server_php")
return { return {
require("plugins.editor.language_server.language_server"), {
require("plugins.editor.language_server.language_server_extra"), "williamboman/mason.nvim",
require("plugins.editor.language_server.language_server_nvim_configuration"), lazy = false,
} config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
lazy = false,
opts = {
auto_install = true,
},
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
table.unpack(lua_lsp.mason_requirements),
table.unpack(generic_lsp.mason_requirements),
table.unpack(go_lsp.mason_requirements),
table.unpack(web_lsp.mason_requirements),
table.unpack(php_lsp.mason_requirements)
},
})
end,
},
{
"neovim/nvim-lspconfig",
lazy = false,
config = function()
-- Setup --
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig")
lua_lsp.setup(lspconfig, capabilities)
generic_lsp.setup(lspconfig, capabilities)
go_lsp.setup(lspconfig, capabilities)
web_lsp.setup(lspconfig, capabilities)
php_lsp.setup(lspconfig, capabilities)
-- Keybinding --
vim.keymap.set("n", "<leader>cd", vim.lsp.buf.hover, { desc = "Show Code Definition" })
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, { desc = "Go to Definition" })
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, { desc = "Go to References" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Do Code Actions" })
end,
},
{
"nvimtools/none-ls.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- Setup --
local null_ls = require("null-ls")
null_ls.setup({
sources = {
table.unpack(lua_lsp.formatter(null_ls)),
table.unpack(generic_lsp.formatter(null_ls)),
table.unpack(go_lsp.formatter(null_ls)),
table.unpack(web_lsp.formatter(null_ls)),
table.unpack(php_lsp.formatter(null_ls)),
},
})
-- Keybinding --
vim.keymap.set("n", "<leader>fc", vim.lsp.buf.format, { desc = "Format Code" })
end,
}
}

View file

@ -1,170 +0,0 @@
return {
{
"williamboman/mason.nvim",
lazy = false,
config = function()
require("mason").setup()
end,
},
{
"williamboman/mason-lspconfig.nvim",
lazy = false,
opts = {
auto_install = true,
},
config = function()
require("mason-lspconfig").setup({
ensure_installed = {
"lua_ls",
"bashls",
"dotls",
"jsonls",
"sqlls",
"lemminx",
"yamlls",
"marksman",
"html",
"emmet_ls",
"cssls",
"tailwindcss",
"tsserver",
"stimulus_ls",
"svelte",
"volar",
"eslint",
"phpactor",
"gopls",
"rust_analyzer",
"jdtls",
"kotlin_language_server",
"pylsp",
},
})
end,
},
{
"neovim/nvim-lspconfig",
lazy = false,
config = function()
-- Setup --
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require("lspconfig")
-- Lua support --
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
}
}
}
})
-- Bash support --
lspconfig.bashls.setup({
capabilities = capabilities,
})
-- Dotenv support --
lspconfig.dotls.setup({
capabilities = capabilities,
})
-- JSON support --
lspconfig.jsonls.setup({
capabilities = capabilities,
})
-- SQL support --
lspconfig.sqlls.setup({
capabilities = capabilities,
})
-- XML support --
lspconfig.lemminx.setup({
capabilities = capabilities,
})
-- YAML support --
lspconfig.yamlls.setup({
capabilities = capabilities,
})
-- Markdown support --
lspconfig.marksman.setup({
capabilities = capabilities,
})
-- HTML support --
lspconfig.html.setup({
capabilities = capabilities,
})
-- Emmet support --
lspconfig.emmet_ls.setup({
capabilities = capabilities,
})
-- PHP support --
lspconfig.phpactor.setup({
capabilities = capabilities,
})
-- CSS & SCSS support --$response
lspconfig.cssls.setup({
capabilities = capabilities,
})
-- Tailwind support --
lspconfig.tailwindcss.setup({
capabilities = capabilities,
})
-- JavaScript & TypeScript support --
lspconfig.tsserver.setup({
capabilities = capabilities,
})
-- Stimulus support --
lspconfig.stimulus_ls.setup({
capabilities = capabilities,
})
-- Svelte support --
lspconfig.svelte.setup({
capabilities = capabilities,
})
-- Vue support --
lspconfig.volar.setup({
capabilities = capabilities,
})
-- Go support --
lspconfig.gopls.setup({
capabilities = capabilities,
})
-- Rust support --
lspconfig.rust_analyzer.setup({
capabilities = capabilities,
})
-- Java support --
lspconfig.jdtls.setup({
capabilities = capabilities,
})
-- Kotlin support --
lspconfig.kotlin_language_server.setup({
capabilities = capabilities,
})
-- Python support --
lspconfig.pylsp.setup({
capabilities = capabilities,
})
-- Eslint support --
lspconfig.eslint.setup({
capabilities = capabilities,
})
-- Keybinding --
vim.keymap.set("n", "<leader>cd", vim.lsp.buf.hover, { desc = "Show Code Definition" })
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, { desc = "Go to Definition" })
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, { desc = "Go to References" })
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Do Code Actions" })
end,
}
}

View file

@ -1,40 +0,0 @@
return {
"nvimtools/none-ls.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
-- Setup --
local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- Prettier --
null_ls.builtins.formatting.prettier,
-- Php --
null_ls.builtins.diagnostics.phpstan,
null_ls.builtins.formatting.phpcsfixer.with({
prefer_local = "vendor/bin/php-cs-fixer",
args = { "fix", "--allow-risky=yes", "$FILENAME" }
}),
-- Twig --
null_ls.builtins.diagnostics.twigcs,
-- JavaScript & Typescript
--null_ls.builtins.formatting.eslint_d,
-- Lua --
null_ls.builtins.formatting.stylua,
-- Go --
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl
},
})
-- Keybinding --
vim.keymap.set("n", "<leader>fc", vim.lsp.buf.format, { desc = "Format Code" })
end,
}

View file

@ -0,0 +1,32 @@
local LSP = {}
LSP.mason_requirements = {
"bashls",
"jsonls",
"sqlls",
"lemminx",
"yamlls",
"marksman"
}
LSP.plugin_info = {
}
function LSP.setup(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.bashls.setup(config)
lspconfig.jsonls.setup(config)
lspconfig.sqlls.setup(config)
lspconfig.lemminx.setup(config)
lspconfig.yamlls.setup(config)
lspconfig.marksman.setup(config)
end
function LSP.formatter(null_ls)
return {
null_ls.builtins.formatting.prettier
}
end
return LSP

View file

@ -0,0 +1,23 @@
local LSP = {}
LSP.mason_requirements = {
"gopls"
}
LSP.plugin_info = {
}
function LSP.setup(lspconfig, capabilities)
lspconfig.gopls.setup({ capabilities = capabilities })
end
function LSP.formatter(null_ls)
return {
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.code_actions.gomodifytags,
null_ls.builtins.code_actions.impl
}
end
return LSP

View file

@ -0,0 +1,30 @@
local LSP = {}
LSP.mason_requirements = {
"lua_ls"
}
LSP.plugin_info = {
}
function LSP.setup(lspconfig, capabilities)
lspconfig.lua_ls.setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
}
}
}
})
end
function LSP.formatter(null_ls)
return {
null_ls.builtins.formatting.stylua
}
end
return LSP

View file

@ -0,0 +1,29 @@
local LSP = {}
LSP.mason_requirements = {
"phpactor",
"stimulus_ls"
}
LSP.plugin_info = {
}
function LSP.setup(lspconfig, capabilities)
local config = { capabilities = capabilities }
lspconfig.phpactor.setup(config)
lspconfig.stimulus_ls.setup(config)
end
function LSP.formatter(null_ls)
return {
null_ls.builtins.diagnostics.phpstan,
null_ls.builtins.formatting.phpcsfixer.with({
prefer_local = "vendor/bin/php-cs-fixer",
args = { "fix", "--allow-risky=yes", "$FILENAME" }
}),
null_ls.builtins.diagnostics.twigcs,
}
end
return LSP

View file

@ -0,0 +1,36 @@
local LSP = {}
LSP.mason_requirements = {
"html",
"emmet_ls",
"cssls",
"tailwindcss",
"tsserver",
"svelte",
"volar",
"eslint",
}
LSP.plugin_info = {
}
function LSP.setup(lspconfig)
local config = { capabilities = capabilities }
lspconfig.html.setup(config)
lspconfig.emmet_ls.setup(config)
lspconfig.cssls.setup(config)
lspconfig.tailwindcss.setup(config)
lspconfig.tsserver.setup(config)
lspconfig.svelte.setup(config)
lspconfig.volar.setup(config)
lspconfig.eslint.setup(config)
end
function LSP.formatter(null_ls)
return {
null_ls.builtins.formatting.eslint_d,
}
end
return LSP