From 412f51cd7ad4ce610ecaf13210b52709fb3e0232 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Thu, 25 Nov 2021 00:05:34 +0100 Subject: Move config to lua. Add laravel snippets --- lua/alpha/lsp.lua | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 lua/alpha/lsp.lua (limited to 'lua/alpha/lsp.lua') diff --git a/lua/alpha/lsp.lua b/lua/alpha/lsp.lua new file mode 100644 index 0000000..c164846 --- /dev/null +++ b/lua/alpha/lsp.lua @@ -0,0 +1,47 @@ +local function on_attach() + -- keymaps for lsp + vim.api.nvim_set_keymap('n', 'K', ':lua vim.lsp.buf.hover()', {noremap = true}) + vim.api.nvim_set_keymap('n', 'vd', ':lua vim.lsp.buf.definition()', {noremap = true}) + + + vim.api.nvim_set_keymap('n', 'vo', ':LspRestart', {noremap = true}) + + -- diagnostics to move between info and errors + vim.api.nvim_set_keymap('n', 'vn', ':lua vim.lsp.diagnostic.goto_next()', {noremap = true}) + vim.api.nvim_set_keymap('n', 'vp', ':lua vim.lsp.diagnostic.goto_prev()', {noremap = true}) + + vim.api.nvim_set_keymap('n', 'vp', ':lua vim.lsp.diagnostic.goto_prev()', {noremap = true}) + + vim.api.nvim_set_keymap('n', 'vca', ':lua vim.lsp.buf.code_action()', {noremap = true}) + vim.api.nvim_set_keymap('n', 'vf', ':lua vim.lsp.buf.formatting()', {noremap = true}) + + vim.api.nvim_set_keymap('n', 'vi', ':lua vim.lsp.buf.implementation()', {noremap = true}) + vim.api.nvim_set_keymap('n', 'vrn', ':lua vim.lsp.buf.rename()', {noremap = true}) + + -- not sure since when I need signature help cant access this, maybe move to normal, but already have + -- the new snippet for the floating + -- vim.api.nvim_set_keymap('n', 'vsh', ':lua vim.lsp.buf.signature_help()', {noremap = true}) + require "lsp_signature".on_attach() + + vim.cmd [[au Filetype php setl omnifunc=v:lua.vim.lsp.omnifunc]] + vim.cmd [[autocmd FileType go setlocal omnifunc=v:lua.vim.lsp.omnifunc]] + + vim.g.completion_matching_strategy_list = { 'exact', 'substring', 'fuzzy' } + +end + +local lsp_installer = require("nvim-lsp-installer") + +lsp_installer.on_server_ready(function(server) + local opts = {} + + -- (optional) Customize the options passed to the server + if server.name == "emmet_ls" then + opts.filetypes = {"html", "css", "blade"} + 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 ]] +end) -- cgit v1.2.3