From 5b30253665ea60ff81ba5f858d0e4b2d4cab7f76 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Mon, 21 Feb 2022 08:50:09 +0100 Subject: move some files, add trouble and efm --- after/plugin/lsp.lua | 54 ------------------------------------- init.lua | 1 + lua/alpha/lsp.lua | 67 ++++++++++++++++++++++++++++++++++++++++++++++ lua/alpha/plugins.lua | 13 +++++++++ plugin/packer_compiled.lua | 12 ++++++++- 5 files changed, 92 insertions(+), 55 deletions(-) delete mode 100644 after/plugin/lsp.lua create mode 100644 lua/alpha/lsp.lua diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua deleted file mode 100644 index 53d9746..0000000 --- a/after/plugin/lsp.lua +++ /dev/null @@ -1,54 +0,0 @@ -local telescope_mapper = require "alpha.telescope.mappings" - -local filetype_attach = setmetatable({ - go = function(_) - vim.cmd [[ - augroup lsp_buf_format - au! BufWritePre - autocmd BufWritePre :lua vim.lsp.buf.formatting_sync() - augroup 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", "", vim.lsp.buf.definition, { buffer = 0 }) - vim.keymap.set("n", "vrn", vim.lsp.buf.rename, { buffer = 0 }) - vim.keymap.set("n", "vf", vim.lsp.buf.formatting, { buffer = 0 }) - vim.keymap.set("n", "vn", vim.lsp.diagnostic.goto_next, { buffer = 0 }) - vim.keymap.set("n", "vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 }) - - telescope_mapper("gr", "lsp_references", nil, true) - telescope_mapper("pv", "find_symbol", nil, true) - - vim.api.nvim_set_keymap('n', 'vo', ':LspRestart', {noremap = true}) - - 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) -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) diff --git a/init.lua b/init.lua index 49e9d30..cc24210 100644 --- a/init.lua +++ b/init.lua @@ -19,3 +19,4 @@ require "alpha.telescope.mappings" require "alpha.dap" require "alpha.refactor" +require "alpha.lsp" diff --git a/lua/alpha/lsp.lua b/lua/alpha/lsp.lua new file mode 100644 index 0000000..5133edf --- /dev/null +++ b/lua/alpha/lsp.lua @@ -0,0 +1,67 @@ +local telescope_mapper = require "alpha.telescope.mappings" + +local filetype_attach = setmetatable({ + go = function(_) + vim.cmd [[ + augroup lsp_buf_format + au! BufWritePre + autocmd BufWritePre :lua vim.lsp.buf.formatting_sync() + augroup 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", "", vim.lsp.buf.definition, { buffer = 0 }) + vim.keymap.set("n", "vrn", vim.lsp.buf.rename, { buffer = 0 }) + vim.keymap.set("n", "vf", vim.lsp.buf.formatting, { buffer = 0 }) + vim.keymap.set("n", "vn", vim.lsp.diagnostic.goto_next, { buffer = 0 }) + vim.keymap.set("n", "vp", vim.lsp.diagnostic.goto_prev, { buffer = 0 }) + + telescope_mapper("gr", "lsp_references", nil, true) + telescope_mapper("pv", "find_symbol", nil, true) + + vim.api.nvim_set_keymap('n', 'vo', ':LspRestart', {noremap = true}) + + 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) +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) + +require "lspconfig".efm.setup { + init_options = {documentFormatting = true}, + settings = { + rootMarkers = {".git/"}, + languages = { + blade = { + {formatCommand = "blade-formatter --stdin", formatStdin = true} + }, + json = {} + } + } +} diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua index ca08a4f..581b7ca 100644 --- a/lua/alpha/plugins.lua +++ b/lua/alpha/plugins.lua @@ -140,6 +140,19 @@ return require('packer').startup(function(use) } } + -- Lua + use { + "folke/trouble.nvim", + requires = "kyazdani42/nvim-web-devicons", + config = function() + require("trouble").setup { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } + end + } + use 'jwalton512/vim-blade' use 'dracula/vim' diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua index 91bbd56..f7a7e71 100644 --- a/plugin/packer_compiled.lua +++ b/plugin/packer_compiled.lua @@ -292,6 +292,12 @@ _G.packer_plugins = { path = "/home/alpha/.local/share/nvim/site/pack/packer/start/telescope.nvim", url = "https://github.com/nvim-telescope/telescope.nvim" }, + ["trouble.nvim"] = { + config = { "\27LJ\2\n9\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\ftrouble\frequire\0" }, + loaded = true, + path = "/home/alpha/.local/share/nvim/site/pack/packer/start/trouble.nvim", + url = "https://github.com/folke/trouble.nvim" + }, vim = { loaded = true, path = "/home/alpha/.local/share/nvim/site/pack/packer/start/vim", @@ -406,6 +412,10 @@ _G.packer_plugins = { } time([[Defining packer_plugins]], false) +-- Config for: trouble.nvim +time([[Config for trouble.nvim]], true) +try_loadstring("\27LJ\2\n9\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\ftrouble\frequire\0", "config", "trouble.nvim") +time([[Config for trouble.nvim]], false) -- Config for: git-worktree.nvim time([[Config for git-worktree.nvim]], true) try_loadstring("\27LJ\2\n>\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\17git-worktree\frequire\0", "config", "git-worktree.nvim") @@ -413,8 +423,8 @@ time([[Config for git-worktree.nvim]], false) -- Command lazy-loads time([[Defining lazy-load commands]], true) -pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Http lua require("packer.load")({'vim-http'}, { cmd = "Http", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file VimwikiIndex lua require("packer.load")({'vimwiki'}, { cmd = "VimwikiIndex", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) +pcall(vim.cmd, [[command -nargs=* -range -bang -complete=file Http lua require("packer.load")({'vim-http'}, { cmd = "Http", l1 = , l2 = , bang = , args = , mods = "" }, _G.packer_plugins)]]) time([[Defining lazy-load commands]], false) vim.cmd [[augroup packer_load_aucmds]] -- cgit v1.2.3