aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-08 09:58:56 +0100
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2023-01-08 09:58:56 +0100
commitf7bcac5ee5db56081981bb946a66d3fc34807988 (patch)
tree2cfc8d60054508d5297cd392d6df1e540057bcc7
parentfb9196e7766f53115009c081f0b4308ca6c081b4 (diff)
downloadnvim-conf-f7bcac5ee5db56081981bb946a66d3fc34807988.tar.gz
nvim-conf-f7bcac5ee5db56081981bb946a66d3fc34807988.zip
feat: refactor lsp & cmp to lua folder from after
-rw-r--r--after/plugin/lsp.lua162
-rw-r--r--after/plugin/mason.lua62
-rw-r--r--after/plugin/null-ls.lua17
-rw-r--r--init.lua2
-rw-r--r--lua/alpha/completition/init.lua (renamed from after/plugin/cmp.lua)13
-rw-r--r--lua/alpha/lsp/attach.lua29
-rw-r--r--lua/alpha/lsp/init.lua12
-rw-r--r--lua/alpha/lsp/mason.lua12
-rw-r--r--lua/alpha/lsp/servers.lua11
-rw-r--r--lua/alpha/lsp/setups.lua65
-rw-r--r--lua/alpha/lsp/tools.lua4
-rw-r--r--lua/alpha/neovide.lua29
-rw-r--r--lua/alpha/plugins.lua21
-rw-r--r--lua/alpha/telescope/init.lua2
14 files changed, 159 insertions, 282 deletions
diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua
deleted file mode 100644
index e2f5652..0000000
--- a/after/plugin/lsp.lua
+++ /dev/null
@@ -1,162 +0,0 @@
-local telescope_mapper = require("alpha.telescope.mappings")
-local lspconfig = require("lspconfig")
-
-local lsp_formatting = function(bufnr, allowed_clientes)
- vim.lsp.buf.format({
- filter = function(client)
- for _, value in pairs(allowed_clientes) do
- if client.name == value then
- return true
- end
- end
-
- return false
- end,
- bufnr = bufnr,
- })
-end
-
--- if you want to set up formatting on save, you can use this as a callback
-local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
-
-local format_on_save = function(allowed_clients)
- return function(client, bufnr)
- if client.supports_method("textDocument/formatting") then
- vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
- vim.api.nvim_create_autocmd("BufWritePre", {
- group = augroup,
- buffer = bufnr,
- callback = function()
- lsp_formatting(bufnr, allowed_clients)
- end,
- })
- end
- end
-end
-
-local filetype_attach = setmetatable({
- go = format_on_save({ "gopls" }),
- -- php = format_on_save,
- -- lua = format_on_save,
-
- gdscript = function(_) end,
-}, {
- __index = function()
- return function() end
- end,
-})
-
--- Since I use null os this allows to have the format and actions
--- in all buffers not just configured servers
-vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {})
-
-vim.keymap.set("n", "<leader>vf", function()
- return vim.lsp.buf.format({ async = true })
-end, {})
-
-
-local function on_attach(client, bufnr)
- local filetype = vim.api.nvim_buf_get_option(0, "filetype")
- -- keymaps for lsp
- vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
- vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
- vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0 })
- vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true })
-
- telescope_mapper("gr", "lsp_references", nil, true)
- telescope_mapper("<leader>pv", "find_symbol", nil, true)
- telescope_mapper("<leader>pd", "lsp_document_symbols", nil, true)
- telescope_mapper("<c-]>", "lsp_definitions", nil, true)
-
- vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
-
- -- Attach any filetype specific options to the client
- filetype_attach[filetype](client, bufnr)
-end
-
--- Actual configs
-local lsp_flags = {
- debounce_text_changes = 150,
-}
-
--- Server configurations
-
-lspconfig["rust_analyzer"].setup({
- on_attach = on_attach,
- flags = lsp_flags,
- -- Server-specific settings...
- settings = {
- ["rust-analyzer"] = {},
- },
-})
-
-lspconfig.dockerls.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-lspconfig.phpactor.setup({
- on_attach = on_attach,
- flags = lsp_flags,
- filetypes = { "php", "cucumber" },
-})
-
-lspconfig.jsonls.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-lspconfig.html.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-local capabilities = vim.lsp.protocol.make_client_capabilities()
-capabilities.textDocument.completion.completionItem.snippetSupport = true
-
-lspconfig.emmet_ls.setup({
- on_attach = on_attach,
- flags = lsp_flags,
- capabilities = capabilities,
- filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" },
-})
-
-lspconfig.gopls.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-lspconfig.gdscript.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-lspconfig.tsserver.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-lspconfig.volar.setup({
- on_attach = on_attach,
- flags = lsp_flags,
-})
-
-lspconfig["sumneko_lua"].setup({
- on_attach = on_attach,
- flags = lsp_flags,
- settings = {
- Lua = {
- runtime = {
- version = "LuaJIT",
- },
- diagnostics = {
- globals = { "vim" },
- },
- workspace = {
- library = vim.api.nvim_get_runtime_file("", true),
- },
- telemetry = {
- enable = false,
- },
- },
- },
-})
diff --git a/after/plugin/mason.lua b/after/plugin/mason.lua
deleted file mode 100644
index f3655c2..0000000
--- a/after/plugin/mason.lua
+++ /dev/null
@@ -1,62 +0,0 @@
-local ok, mason = pcall(require, "mason")
-if not ok then
- return
-end
-
-local mason_lspconfig = require("mason-lspconfig")
-
-mason.setup({
- ui = {
- icons = {
- package_installed = "โœ“",
- package_pending = "โžœ",
- package_uninstalled = "โœ—",
- },
- },
-})
-
-mason_lspconfig.setup({
- automatic_installation = false,
-})
-
-require('mason-tool-installer').setup {
-
- -- a list of all tools you want to ensure are installed upon
- -- start; they should be the names Mason uses for each tool
- ensure_installed = {
- "blade-formatter",
- "dockerfile-language-server",
- "emmet-ls",
- "go-debug-adapter",
- "golangci-lint",
- "gopls",
- "html-lsp",
- "json-lsp",
- "lua-language-server",
- "php-debug-adapter",
- "rust-analyzer",
- "stylua",
- "typescript-language-server",
- "vue-language-server",
- "phpactor",
- "sql-formatter",
- },
-
- -- if set to true this will check each tool for updates. If updates
- -- are available the tool will be updated. This setting does not
- -- affect :MasonToolsUpdate or :MasonToolsInstall.
- -- Default: false
- auto_update = false,
-
- -- automatically install / update on startup. If set to false nothing
- -- will happen on startup. You can use :MasonToolsInstall or
- -- :MasonToolsUpdate to install tools and check for updates.
- -- Default: true
- run_on_start = true,
-
- -- set a delay (in ms) before the installation starts. This is only
- -- effective if run_on_start is set to true.
- -- e.g.: 5000 = 5 second delay, 10000 = 10 second delay, etc...
- -- Default: 0
- start_delay = 3000, -- 3 second delay
-}
diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua
index b3bc7d1..7bccec2 100644
--- a/after/plugin/null-ls.lua
+++ b/after/plugin/null-ls.lua
@@ -7,19 +7,26 @@ local composer = require("composer")
local php_actions = require("php-code-actions")
local laravel_actions = require("laravel.code-actions")
+
+-- format and code actions for non lsp buffers
+vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {})
+vim.keymap.set("n", "<leader>vf", function()
+ return vim.lsp.buf.format({ async = true })
+end, {})
+
local sources = {
- -- null_ls.builtins.code_actions.gitsigns,
- null_ls.builtins.formatting.stylua,
+ null_ls.builtins.code_actions.gitsigns,
+ -- null_ls.builtins.formatting.stylua,
-- null_ls.builtins.diagnostics.eslint,
-- null_ls.builtins.formatting.phpcsfixer,
- null_ls.builtins.diagnostics.golangci_lint,
+ -- null_ls.builtins.diagnostics.golangci_lint,
-- null_ls.builtins.diagnostics.codespell.with({
-- args = { "--ignore-words-list", "crate" },
-- }),
null_ls.builtins.formatting.jq,
- null_ls.builtins.code_actions.gitrebase,
+ -- null_ls.builtins.code_actions.gitrebase,
null_ls.builtins.code_actions.refactoring,
- null_ls.builtins.formatting.sql_formatter,
+ -- null_ls.builtins.formatting.sql_formatter,
php_actions.getter_setter,
php_actions.file_creator,
}
diff --git a/init.lua b/init.lua
index 67d7bca..5cb108c 100644
--- a/init.lua
+++ b/init.lua
@@ -8,7 +8,7 @@ require("alpha.globals")
require("alpha.disable_builtin")
require("alpha.telescope.setup")
require("alpha.telescope.mappings")
+require("alpha.lsp")
require("alpha.dap")
-require("alpha.neovide")
require("alpha.colors")
require("alpha.diagnostic")
diff --git a/after/plugin/cmp.lua b/lua/alpha/completition/init.lua
index 8e980d1..0537a48 100644
--- a/after/plugin/cmp.lua
+++ b/lua/alpha/completition/init.lua
@@ -1,8 +1,4 @@
-local ok, cmp = pcall(require, "cmp")
-if not ok then
- return
-end
-
+local cmp = require("cmp")
local lspkind = require("lspkind")
local luasnip = require("luasnip")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
@@ -131,10 +127,3 @@ cmp.setup.filetype({ "dap-repl", "dapui_watches" }, {
{ name = "buffer" },
}),
})
-
--- Setup lspconfig.
-local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
--- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
-require("lspconfig")["emmet_ls"].setup({
- capabilities = capabilities,
-})
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua
new file mode 100644
index 0000000..ce63e02
--- /dev/null
+++ b/lua/alpha/lsp/attach.lua
@@ -0,0 +1,29 @@
+local telescope_mapper = require("alpha.telescope.mappings")
+
+local filetype_attach = setmetatable({}, {
+ __index = function()
+ return function() end
+ end,
+})
+return function (client, bufnr)
+ local filetype = vim.api.nvim_buf_get_option(0, "filetype")
+ -- keymaps for lsp
+ vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
+ vim.keymap.set("i", "<c-h>", vim.lsp.buf.signature_help, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vo", ":LspRestart<cr>", { noremap = true })
+ vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {})
+ vim.keymap.set("n", "<leader>vf", function()
+ return vim.lsp.buf.format({ async = true })
+ end, {})
+
+ telescope_mapper("gr", "lsp_references", nil, true)
+ telescope_mapper("<leader>pv", "find_symbol", nil, true)
+ telescope_mapper("<leader>pd", "lsp_document_symbols", nil, true)
+ telescope_mapper("<c-]>", "lsp_definitions", nil, true)
+
+ vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
+
+ -- Attach any filetype specific options to the client
+ filetype_attach[filetype](client, bufnr)
+end
diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua
new file mode 100644
index 0000000..86b06a6
--- /dev/null
+++ b/lua/alpha/lsp/init.lua
@@ -0,0 +1,12 @@
+-- LSP configuration
+
+-- install servers and tools
+require('alpha.lsp.mason')
+local setups = require("alpha.lsp.setups")
+
+local lspconfig = require('lspconfig')
+require('mason-lspconfig').setup_handlers({
+ function (server_name)
+ lspconfig[server_name].setup(setups[server_name]())
+ end
+})
diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua
new file mode 100644
index 0000000..9dab32e
--- /dev/null
+++ b/lua/alpha/lsp/mason.lua
@@ -0,0 +1,12 @@
+local mason = require("mason")
+local mason_lspconfig = require("mason-lspconfig")
+
+mason.setup()
+
+mason_lspconfig.setup({
+ ensure_installed = require('alpha.lsp.servers'),
+})
+
+require('mason-tool-installer').setup({
+ ensure_installed = require('alpha.lsp.tools'),
+})
diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua
new file mode 100644
index 0000000..921a628
--- /dev/null
+++ b/lua/alpha/lsp/servers.lua
@@ -0,0 +1,11 @@
+return {
+ "phpactor",
+ "rust_analyzer",
+ "gopls",
+ "sumneko_lua",
+ "emmet_ls",
+ "jsonls",
+ "html",
+ "tsserver",
+ "volar",
+}
diff --git a/lua/alpha/lsp/setups.lua b/lua/alpha/lsp/setups.lua
new file mode 100644
index 0000000..646eec1
--- /dev/null
+++ b/lua/alpha/lsp/setups.lua
@@ -0,0 +1,65 @@
+local lsp_attach = require("alpha.lsp.attach")
+
+local lsp_flags = {
+ debounce_text_changes = 150,
+}
+
+return setmetatable({
+ rust_analyzer = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ settings = {
+ ["rust-analyzer"] = {},
+ },
+ }
+ end,
+ phpactor = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ filetypes = { "php", "cucumber" },
+ }
+ end,
+ emmet_ls = function()
+ local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
+
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ capabilities = capabilities,
+ filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" },
+ }
+ end,
+ sumneko_lua = function()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ settings = {
+ Lua = {
+ runtime = {
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ globals = { "vim" },
+ },
+ workspace = {
+ library = vim.api.nvim_get_runtime_file("", true),
+ },
+ telemetry = {
+ enable = false,
+ },
+ },
+ },
+ }
+ end,
+}, {
+ __index = function()
+ return function ()
+ return {
+ on_attach = lsp_attach,
+ flags = lsp_flags,
+ }
+ end
+ end,
+})
diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua
new file mode 100644
index 0000000..23ef226
--- /dev/null
+++ b/lua/alpha/lsp/tools.lua
@@ -0,0 +1,4 @@
+return {
+ "go-debug-adapter",
+ "php-debug-adapter",
+}
diff --git a/lua/alpha/neovide.lua b/lua/alpha/neovide.lua
deleted file mode 100644
index 1e419d3..0000000
--- a/lua/alpha/neovide.lua
+++ /dev/null
@@ -1,29 +0,0 @@
-local default_font = "VictorMono Nerd Font:b"
-local default_size = 14;
-
-vim.g.neovide_transparency = 0.9
-vim.g.neovide_hide_mouse_when_typing = true
-
-local function set_font(font, size)
- font = font or default_font
- size = size or default_size
-
- vim.o.guifont = string.format("%s:h%d", font, size)
-end
-
-set_font()
-
-local maps = {
- f0 = 14,
- f1 = 15,
- f2 = 16,
- f3 = 18,
- f4 = 20,
- f5 = 22,
-}
-
-for key, value in pairs(maps) do
- vim.keymap.set("n", "<leader>" .. key, function ()
- set_font(nil, value)
- end)
-end
diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua
index 0b83100..c0a4f82 100644
--- a/lua/alpha/plugins.lua
+++ b/lua/alpha/plugins.lua
@@ -18,8 +18,8 @@ return require("packer").startup(function(use)
home = first
end
- if vim.fn.isdirectory(vim.fn.expand("~/plugins/" .. plug_path)) == 1 then
- opts[1] = "~/plugins/" .. plug_path
+ if vim.fn.isdirectory(vim.fn.expand("~/code/plugins/" .. plug_path)) == 1 then
+ opts[1] = "~/code/plugins/" .. plug_path
else
opts[1] = string.format("%s/%s", home, plug_path)
end
@@ -30,6 +30,8 @@ return require("packer").startup(function(use)
use("wbthomason/packer.nvim")
use("lewis6991/impatient.nvim")
+ use("jwalton512/vim-blade")
+
use({
"ThePrimeagen/refactoring.nvim",
requires = {
@@ -85,25 +87,25 @@ return require("packer").startup(function(use)
"rcarriga/cmp-dap",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind-nvim",
+ "hrsh7th/cmp-nvim-lsp-signature-help",
{ "L3MON4D3/LuaSnip", tag = "v1.*" },
"windwp/nvim-autopairs",
},
})
- -- LSP
- use({
- "neovim/nvim-lspconfig",
- "hrsh7th/cmp-nvim-lsp-signature-help",
- "jose-elias-alvarez/null-ls.nvim",
- })
-
-- Installation of LSP/Debuggers/Other
use({
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
+ "neovim/nvim-lspconfig",
"WhoIsSethDaniel/mason-tool-installer.nvim",
})
+ -- Null ls
+ use({
+ "jose-elias-alvarez/null-ls.nvim",
+ })
+
use({
"nvim-telescope/telescope.nvim",
requires = {
@@ -206,7 +208,6 @@ return require("packer").startup(function(use)
use("junegunn/vim-easy-align")
- use("jwalton512/vim-blade")
use("jghauser/mkdir.nvim")
diff --git a/lua/alpha/telescope/init.lua b/lua/alpha/telescope/init.lua
index eaa5800..ccb1b9e 100644
--- a/lua/alpha/telescope/init.lua
+++ b/lua/alpha/telescope/init.lua
@@ -73,7 +73,7 @@ function M.projectionist()
end
function M.laravel_commands()
- return require("telescope").extensions.laravel.commands()
+ return require("telescope").extensions.laravel.laravel()
end
function M.api_specs()