aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/lsp.lua
diff options
context:
space:
mode:
authorAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
committerAriel D'Alessandro <dalessandro.ariel@gmail.com>2022-04-11 08:41:09 +0200
commit5f6142f224ac128d62c4cb5c7d4acf45db19e5c2 (patch)
tree3630b6d24bac761c3e0c2381112fb4ec63d83f2e /lua/alpha/lsp.lua
parent76c51d6b471250550afd0461b4ea4316a5b4f506 (diff)
downloadnvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.tar.gz
nvim-conf-5f6142f224ac128d62c4cb5c7d4acf45db19e5c2.zip
Apply stylelua and clean
Diffstat (limited to 'lua/alpha/lsp.lua')
-rw-r--r--lua/alpha/lsp.lua83
1 files changed, 40 insertions, 43 deletions
diff --git a/lua/alpha/lsp.lua b/lua/alpha/lsp.lua
index bd6b449..d0ac991 100644
--- a/lua/alpha/lsp.lua
+++ b/lua/alpha/lsp.lua
@@ -1,70 +1,67 @@
-local telescope_mapper = require "alpha.telescope.mappings"
+local telescope_mapper = require("alpha.telescope.mappings")
local filetype_attach = setmetatable({
- go = function(_)
- vim.cmd [[
+ go = function(_)
+ vim.cmd([[
augroup lsp_buf_format
au! BufWritePre <buffer>
autocmd BufWritePre <buffer> :lua vim.lsp.buf.formatting_sync()
augroup END
- ]]
- end,
+ ]])
+ end,
}, {
- __index = function()
- return function() end
- end,
+ __index = function()
+ return function() end
+ end,
})
local function on_attach(client)
- 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", "<c-]>", vim.lsp.buf.definition, { buffer = 0 })
- vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
- vim.keymap.set("n", "<leader>vf", vim.lsp.buf.formatting, { buffer = 0 })
- vim.keymap.set("n", "<leader>vn", vim.lsp.diagnostic.goto_next, { buffer = 0 })
- vim.keymap.set("n", "<leader>vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 })
+ 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", "<c-]>", vim.lsp.buf.definition, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vf", vim.lsp.buf.formatting, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vn", vim.lsp.diagnostic.goto_next, { buffer = 0 })
+ vim.keymap.set("n", "<leader>vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 })
- telescope_mapper("gr", "lsp_references", nil, true)
- telescope_mapper("<leader>pv", "find_symbol", nil, true)
+ telescope_mapper("gr", "lsp_references", nil, true)
+ telescope_mapper("<leader>pv", "find_symbol", nil, true)
- vim.api.nvim_set_keymap('n', '<leader>vo', ':LspRestart<cr>', {noremap = true})
+ vim.api.nvim_set_keymap("n", "<leader>vo", ":LspRestart<cr>", { noremap = true })
- require "lsp_signature".on_attach()
+ require("lsp_signature").on_attach()
- vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
- -- Attach any filetype specific options to the client
- filetype_attach[filetype](client)
+ vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc"
+ -- Attach any filetype specific options to the client
+ filetype_attach[filetype](client)
end
local lsp_installer = require("nvim-lsp-installer")
lsp_installer.on_server_ready(function(server)
- local opts = {}
+ local opts = {}
- -- (optional) Customize the options passed to the server
- if server.name == "emmet_ls" then
- opts.filetypes = {"html", "css", "blade", "typescriptreact"}
- end
+ -- (optional) Customize the options passed to the server
+ if server.name == "emmet_ls" then
+ opts.filetypes = { "html", "css", "blade", "typescriptreact" }
+ end
- opts.on_attach = on_attach
- -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
- server:setup(opts)
- vim.cmd [[ do User LspAttachBuffers ]]
+ opts.on_attach = on_attach
+ -- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
+ server:setup(opts)
+ vim.cmd([[ do User LspAttachBuffers ]])
end)
-
-vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
- vim.lsp.diagnostic.on_publish_diagnostics, {
- underline = true,
- update_in_insert = false,
- virtual_text = { spacing = 2, prefix = "●" },
- severity_sort = true,
- }
-)
+vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ underline = true,
+ update_in_insert = false,
+ virtual_text = { spacing = 2, prefix = "●" },
+ severity_sort = true,
+})
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
for type, icon in pairs(signs) do
- local hl = "DiagnosticSign" .. type
- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end