From a56478039ef5e585bc7d141fbe06a22d1d9d9ba4 Mon Sep 17 00:00:00 2001 From: Jidbo Date: Mon, 12 Sep 2022 20:04:17 +0200 Subject: [PATCH] enhance lsp experience --- nvim/init.lua | 2 ++ nvim/lua/autocompletion.lua | 20 ++++++++++++++------ nvim/lua/mappings.lua | 3 --- nvim/lua/null-ls-config.lua | 12 ++++++++++++ nvim/lua/pluginoptions.lua | 8 +++++++- nvim/lua/plugins.lua | 7 ++++++- nvim/lua/troubleconfig.lua | 23 +++++++++++++++++++++++ 7 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 nvim/lua/null-ls-config.lua create mode 100644 nvim/lua/troubleconfig.lua diff --git a/nvim/init.lua b/nvim/init.lua index dd8e7a5..c2f95cc 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -10,6 +10,8 @@ require('statusline') require('snippets') require('autocompletion') require('treesitterconfig') +require('troubleconfig') +require('null-ls-config') require('filemanager') require('notes') require('zenmode') diff --git a/nvim/lua/autocompletion.lua b/nvim/lua/autocompletion.lua index ade1dc5..b9e1f1f 100644 --- a/nvim/lua/autocompletion.lua +++ b/nvim/lua/autocompletion.lua @@ -53,13 +53,14 @@ local on_attach = function(client, bufnr) local opts = { noremap = true, silent = true } buf_set_keymap("n", "gd", "Telescope lsp_definitions", opts) - buf_set_keymap("n", "gh", "lua vim.lsp.buf.hover()", opts) buf_set_keymap("n", "gD", "Telescope lsp_implementations", opts) - buf_set_keymap("n", "gs", "lua vim.lsp.buf.signature_help()", opts) - buf_set_keymap("n", "gR", "lua vim.lsp.buf.rename()", opts) - buf_set_keymap("n", "gH", "Telescope lsp_code_actions", opts) - buf_set_keymap("n", "gr", "Telescope lsp_references", opts) - buf_set_keymap("n", "ge", "lua vim.diagnostic.open_float()", opts) + -- buf_set_keymap("n", "gr", "Telescope lsp_references", opts) + vim.keymap.set("n", "gf",vim.lsp.buf.formatting) + vim.keymap.set("n", "gh", vim.lsp.buf.hover) + vim.keymap.set("n", "ge", vim.diagnostic.open_float) + vim.keymap.set("n", "gs", vim.lsp.buf.signature_help) + vim.keymap.set("n", "gR", vim.lsp.buf.rename) + vim.keymap.set("n", "gH", vim.lsp.buf.code_action) end local lsp_installer = require 'nvim-lsp-installer' @@ -71,3 +72,10 @@ lsp_installer.on_server_ready(function(server) server:setup(opts) vim.cmd [[ do User LspAttachBuffers ]] end) + +require "lsp_signature".setup { + handler_opts = { + border = "rounded" + }, + toggle_key = "", +} diff --git a/nvim/lua/mappings.lua b/nvim/lua/mappings.lua index 9c74fe0..50df72b 100644 --- a/nvim/lua/mappings.lua +++ b/nvim/lua/mappings.lua @@ -24,9 +24,6 @@ vim.keymap.set('n', 'f', 'Telescope find_files') vim.keymap.set('n', 'l', 'Telescope live_grep') vim.keymap.set('n', ' gy', 'Telescope treesitter') --- neo formatter -vim.keymap.set('n', 'p', ':Neoformat') - -- spelling vim.keymap.set('n', ' se', ':set spell spelllang=en') vim.keymap.set('n', ' sd', ':set spell spelllang=de') diff --git a/nvim/lua/null-ls-config.lua b/nvim/lua/null-ls-config.lua new file mode 100644 index 0000000..7191cd9 --- /dev/null +++ b/nvim/lua/null-ls-config.lua @@ -0,0 +1,12 @@ +require("null-ls").setup({ + sources = { + -- FORMATTING + require("null-ls").builtins.formatting.stylua, + require("null-ls").builtins.formatting.eslint, + require("null-ls").builtins.formatting.prettierd, + -- DIAGNOSTICS + require("null-ls").builtins.diagnostics.eslint, + -- COMPLETIONS + require("null-ls").builtins.completion.spell, + }, +}) diff --git a/nvim/lua/pluginoptions.lua b/nvim/lua/pluginoptions.lua index 68a6ae4..7fd3db3 100644 --- a/nvim/lua/pluginoptions.lua +++ b/nvim/lua/pluginoptions.lua @@ -41,4 +41,10 @@ require('colorizer').setup() -- nvim surround -require("nvim-surround").setup() +require("nvim-surround").setup({ + surrounds = { + ["*"] = { + add = { "*", "*" }, + }, + } +}) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index c2e6131..1890230 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -70,17 +70,22 @@ Plug 'nvim-lualine/lualine.nvim' Plug 'neovim/nvim-lspconfig' Plug 'williamboman/nvim-lsp-installer' +Plug 'jose-elias-alvarez/null-ls.nvim' + Plug 'hrsh7th/cmp-nvim-lsp' Plug 'hrsh7th/cmp-buffer' Plug 'hrsh7th/cmp-path' Plug 'hrsh7th/cmp-cmdline' Plug 'hrsh7th/nvim-cmp' +Plug 'folke/trouble.nvim' +Plug 'ray-x/lsp_signature.nvim' + Plug 'L3MON4D3/LuaSnip' Plug 'saadparwaiz1/cmp_luasnip' -- Autoformatter -Plug 'sbdchd/neoformat' +-- Plug 'sbdchd/neoformat' -- treesitter Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'}) diff --git a/nvim/lua/troubleconfig.lua b/nvim/lua/troubleconfig.lua new file mode 100644 index 0000000..9d291b8 --- /dev/null +++ b/nvim/lua/troubleconfig.lua @@ -0,0 +1,23 @@ +require("trouble").setup { + + +} + +vim.keymap.set("n", "xx", "TroubleToggle", + {silent = true, noremap = true} +) +vim.keymap.set("n", "xw", "TroubleToggle workspace_diagnostics", + {silent = true, noremap = true} +) +vim.keymap.set("n", "xd", "TroubleToggle document_diagnostics", + {silent = true, noremap = true} +) +vim.keymap.set("n", "xl", "TroubleToggle loclist", + {silent = true, noremap = true} +) +vim.keymap.set("n", "xq", "TroubleToggle quickfix", + {silent = true, noremap = true} +) +vim.keymap.set("n", "gr", "TroubleToggle lsp_references", + {silent = true, noremap = true} +)