From dfb6c70ddebb8365afd5bd92f6993aa826bdcd8c Mon Sep 17 00:00:00 2001 From: Ali Shahid Date: Thu, 14 Jul 2022 13:06:29 +0545 Subject: [PATCH] [plugin configs] huge update --- lua/plugins/commits.lua | 49 ++--- lua/plugins/goto-preview.lua | 9 +- lua/plugins/neovim-session-manager.lua | 2 +- lua/plugins/null-ls_nvim.lua | 2 +- lua/plugins/nvim-bufferline_lua.lua | 2 +- lua/plugins/nvim-cmp.lua | 8 +- lua/plugins/nvim-lsp-installer.lua | 134 ++++---------- lua/plugins/nvim-lspconfig.lua | 236 ++++++++++++++++++------- lua/plugins/nvim-surround.lua | 87 +++++++++ lua/plugins/nvim-tree_lua.lua | 1 + lua/plugins/nvim-ts-autotag.lua | 3 +- lua/plugins/penvim.lua | 2 +- lua/plugins/telescope_nvim.lua | 4 +- lua/plugins/trouble_nvim.lua | 2 +- 14 files changed, 333 insertions(+), 208 deletions(-) create mode 100644 lua/plugins/nvim-surround.lua diff --git a/lua/plugins/commits.lua b/lua/plugins/commits.lua index bf9c0b1..68c4e55 100644 --- a/lua/plugins/commits.lua +++ b/lua/plugins/commits.lua @@ -1,14 +1,14 @@ -- Generated by: https://github.com/pullape/LCommit --- on 2022-07-02_17:17:46 +-- on 2022-07-14_13:03:37 return { - packer_nvim = 'd268d2e083ca0abd95a57dfbcc5d5637a615e219', + packer_nvim = 'e4c2afb37d31e99b399425e102c58b091fbc16be', filetype_nvim = 'b522628a45a17d58fc0073ffd64f9dc9530a8027', Abstract_cs = '04ac9f79651a39deda73987ee43e3e14a5868056', - nvim_lsp_installer = 'c13ea61d85e2170af35c06b47bcba143cf2f244b', - nvim_lspconfig = '057ca6b7f5312f323eb7212f9282ed723560bc3f', + nvim_lsp_installer = 'd6d564b21167161d85f41c2033ccc19a97b39a39', + nvim_lspconfig = '22bf8c4a549367893fdf7a6194aa87c5265fb9ca', lspkind_nvim = '57e5b5dfbe991151b07d272a06e365a77cc3d0e7', - nvim_treesitter = '78931d8bf15468d8f11f0c7910d470e88493b36b', + nvim_treesitter = 'b46cb0389d92abffa516be487e7ea0610e8ce35b', playground = 'ce7e4b757598f1c785ed0fd94fc65959acd7d39c', nvim_cmp = '9897465a7663997b7b42372164ffc3635321a2fe', cmp_nvim_lsp = 'affe808a5c56b71630f17aa7c38e15c59fd648a8', @@ -17,40 +17,41 @@ return { cmp_luasnip = 'a9de941bcbda508d0a45d28ae366bb3f08db2e36', cmp_nvim_lsp_signature_help = '007dd2740d9b70f2688db01a39d6d25b7169cd57', cmp_nvim_lua = 'd276254e7198ab7d00f117e88e223b4bd8c02d21', - LuaSnip = 'a12441e0598e93e67235eba67c8e6fbffc896f06', - friendly_snippets = '688691050074f39e6ec987321738494e08ba562e', - null_ls_nvim = 'a2b7bf89663c78d58a5494efbb791819a24bb025', - nvim_autopairs = '4a95b3982be7397cd8e1370d1a09503f9b002dbf', - telescope_nvim = '7df95f9b208ba7228a25e7f75fb4cc02d6604cce', + LuaSnip = '7d78278c2a935b8cd1b6b43065223e14490f3133', + friendly_snippets = '0e516c9d9892d6bf268492136971d315dd704d16', + null_ls_nvim = 'c9348b47918bee72b541580adf31e963c9028f82', + nvim_autopairs = '972a7977e759733dd6721af7bcda7a67e40c010e', + telescope_nvim = 'b79cd6c88b3d96b0f49cb7d240807cd59b610cd8', popup_nvim = 'b7404d35d5d3548a82149238289fa71f7f6de4ac', - plenary_nvim = '968a4b9afec0c633bc369662e78f8c5db0eba249', + plenary_nvim = '986ad71ae930c7d96e812734540511b4ca838aa2', telescope_fzf_native_nvim = '6a33ecefa9b3d9ade654f9a7a6396a00c3758ca6', - telescope_file_browser_nvim = '61a5521853ac739ae3d0d395f52c1178108e0114', + telescope_file_browser_nvim = 'd17f47bb563f4e761b7db120357d2f1b7630186f', telescope_media_files_nvim = '513e4ee385edd72bf0b35a217b7e39f84b6fe93c', telescope_ui_select_nvim = '62ea5e58c7bbe191297b983a9e7e89420f581369', nvim_ts_context_commentstring = '88343753dbe81c227a1c1fd2c8d764afb8d36269', vim_floaterm = 'e3f2d94d722603f8b65088ea1d7e0329951985bd', - nvim_web_devicons = '8d2c5337f0a2d0a17de8e751876eeb192b32310e', + nvim_web_devicons = '2d02a56189e2bde11edd4712fea16f08a6656944', vim_maximizer = '2e54952fe91e140a2e69f35f22131219fcd9c5f1', - Comment_nvim = '4086630ce2aaf76b2652516ee3169f0b558f6be1', + Comment_nvim = '7c49fb2ac01a9f03410100c8e78f647bbea857e8', nvim_colorizer_lua = '36c610a9717cc9ec426a07c8e6bf3b3abcb139d6', indent_blankline_nvim = '4a58fe6e9854ccfe6c6b0f59abb7cb8301e23025', - gitsigns_nvim = '4883988cf8b623f63cc8c7d3f11b18b7e81f06ff', + gitsigns_nvim = 'bb6c3bf6f584e73945a0913bb3adf77b60d6f6a2', trouble_nvim = 'da61737d860ddc12f78e638152834487eabf0ee5', - nvim_bufferline_lua = '68839d62785edfb4ff7a7b3c1e9f4b64d55749e8', + nvim_bufferline_lua = 'd7b775a35be9c80ed591d3335b35ec84e5c5d81e', scope_nvim = '2db6d31de8e3a98d2b41c0f0d1f5dc299ee76875', - nvim_tree_lua = 'cbbc799e6c5784fba9b6a842000caaebf07fa122', - feline_nvim = '1ea42671c523a080a01c62c40c2c8e7fc0139a8f', - alpha_nvim = 'ef27a59e5b4d7b1c2fe1950da3fe5b1c5f3b4c94', - penvim = '877d37cddddc7d3a8c534295cdbef9f082d1776f', + nvim_tree_lua = '0f96e32326a842798b6b8e638a91464521e4ef71', + feline_nvim = '2962c8c4a67f41ef35c58aa367ff2afb7a9691d3', + alpha_nvim = '417e756951cb0395f080f2c0eda84c8aadcbb80e', + penvim = '308f9af41d62dc20a416f1929b68297a70e86944', goto_preview = '99407d8e63305a5c68627cee156ca3991a75fd19', neovim_session_manager = '9652b392805dfd497877342e54c5a71be7907daf', renamer_nvim = '4a4707992a79f481f4882bab9b3823ac6455c942', - editorconfig_nvim = 'b96a75a470e5c26caf4e57c594e85ee5d0dc7bf1', - hop_nvim = '86e03769392f824ed8ed08de5b6afe6acc7fbdb3', - flutter_tools_nvim = '6b13345dd7ffe3b0a08536b8fadfa288af137616', + editorconfig_nvim = '918279fe8a432aea7555fae4aac52c705d7f3c2e', + hop_nvim = '6bcaeb7c0ea30afe137db11fcf681c373a7171bf', + flutter_tools_nvim = '8b0d82f1aa6d09cad74489d35d9fecfdc7fa45ec', awesome_flutter_snippets = 'a4f6448e457f492231f742ec51b077d8dd6f1831', dart_vim_plugin = '81e50e80329e5eac2c115f45585b1838a614d07a', nvim_ts_autotag = '044a05c4c51051326900a53ba98fddacd15fea22', - impatient_nvim = '969f2c5c90457612c09cf2a13fee1adaa986d350', + impatient_nvim = '2aa872de40dbbebe8e2d3a0b8c5651b81fe8b235', + nvim_surround = '325ed0328f6b37d274cc25bea6dd36f42569a26a', } diff --git a/lua/plugins/goto-preview.lua b/lua/plugins/goto-preview.lua index 04fa3c6..a62337a 100644 --- a/lua/plugins/goto-preview.lua +++ b/lua/plugins/goto-preview.lua @@ -62,11 +62,12 @@ require('goto-preview').setup { -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- local options = { noremap=true } -vim.api.nvim_set_keymap("n", "pd", "lua require('goto-preview').goto_preview_definition()", options) -vim.api.nvim_set_keymap("n", "pi", "lua require('goto-preview').goto_preview_implementation()", options) +vim.api.nvim_set_keymap("n", "gpd", "lua require('goto-preview').goto_preview_definition()", options) +vim.api.nvim_set_keymap("n", "gpi", "lua require('goto-preview').goto_preview_implementation()", options) -- Only set if telescope is installed -vim.api.nvim_set_keymap("n", "pr", "lua require('goto-preview').goto_preview_references()", options) -vim.api.nvim_set_keymap("n", "P", "lua require('goto-preview').close_all_win()", options) +vim.api.nvim_set_keymap("n", "gpr", "lua require('goto-preview').goto_preview_references()", options) + +vim.api.nvim_set_keymap("n", "gP", "lua require('goto-preview').close_all_win()", options) -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━❰ end Mappings ❱━━━━━━━━━━━━━━━━ -- diff --git a/lua/plugins/neovim-session-manager.lua b/lua/plugins/neovim-session-manager.lua index ab52fe5..31eafeb 100644 --- a/lua/plugins/neovim-session-manager.lua +++ b/lua/plugins/neovim-session-manager.lua @@ -19,7 +19,7 @@ local session_imported, session = pcall(require, 'session_manager') if not session_imported then return end session.setup({ - sessions_dir = vim.fn.expand('~/.cache/nvim/sessions'), -- The directory where the session files will be saved. + sessions_dir = vim.fn.stdpath('data').."/.cache/sessions", -- The directory where the session files will be saved. path_replacer = '__', -- The character to which the path separator will be replaced for session files. colon_replacer = '++', -- The character to which the colon symbol will be replaced for session files. autoload_mode = require('session_manager.config').AutoloadMode.Disabled, -- Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession diff --git a/lua/plugins/null-ls_nvim.lua b/lua/plugins/null-ls_nvim.lua index 32c2f49..be71418 100644 --- a/lua/plugins/null-ls_nvim.lua +++ b/lua/plugins/null-ls_nvim.lua @@ -179,7 +179,7 @@ vim.api.nvim_create_autocmd("FileType", { -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- local keymap = vim.api.nvim_set_keymap -keymap('n', 'gf', ':lua vim.lsp.buf.formatting_sync()', {noremap = true, silent = true}) +keymap('n', 'gf', ':lua vim.lsp.buf.format{ async=true }', {noremap = true, silent = true}) -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━❰ end Mappings ❱━━━━━━━━━━━━━━━━ -- diff --git a/lua/plugins/nvim-bufferline_lua.lua b/lua/plugins/nvim-bufferline_lua.lua index 067e23a..a4b87b2 100644 --- a/lua/plugins/nvim-bufferline_lua.lua +++ b/lua/plugins/nvim-bufferline_lua.lua @@ -162,7 +162,7 @@ keymap('n', ',', ':BufferLineMovePrev', options) -- nnoremap :BufferClose -- Magic buffer-picking mode -keymap('n', '', ':BufferLinePick', options) +keymap('n', '<\\>', ':BufferLinePick', options) -- go to buffer number keymap('n', '1', ':BufferLineGoToBuffer 1', options) diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua index e3c6e26..b00daf8 100644 --- a/lua/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -20,6 +20,9 @@ vim.o.completeopt = 'menuone,noselect' local cmp_imported_ok, cmp = pcall(require, 'cmp') if not cmp_imported_ok then return end +local luasnip_imported_ok, luasnip = pcall(require, 'luasnip') +if not luasnip_imported_ok then return end + -- for completion window width local ELLIPSIS_CHAR = '…' local MAX_LABEL_WIDTH = 35 @@ -44,7 +47,7 @@ cmp.setup({ }, snippet = { - expand = function(args) require('luasnip').lsp_expand(args.body) end, + expand = function(args) luasnip.lsp_expand(args.body) end, }, formatting = { @@ -116,9 +119,6 @@ cmp.setup({ -- :match("%s") == nil -- end -local luasnip_imported_ok, luasnip = pcall(require, 'luasnip') -if not luasnip_imported_ok then return end - cmp.setup({ mapping = { [''] = cmp.mapping.complete({}), diff --git a/lua/plugins/nvim-lsp-installer.lua b/lua/plugins/nvim-lsp-installer.lua index c4f2cf8..61d7d27 100644 --- a/lua/plugins/nvim-lsp-installer.lua +++ b/lua/plugins/nvim-lsp-installer.lua @@ -14,24 +14,22 @@ -- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -local lspinstaller_imported, lspinstaller = pcall(require, 'nvim-lsp-installer') -if not lspinstaller_imported then return end +local M = {} +M.setup = { -lspinstaller.setup{ + -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer", "sumneko_lua" } + -- This setting has no relation with the `automatic_installation` setting. + -- ensure_installed = {"sumneko_lua"}, - -- A list of servers to automatically install if they're not already installed. Example: { "rust_analyzer", "sumneko_lua" } - -- This setting has no relation with the `automatic_installation` setting. - -- ensure_installed = {"sumneko_lua"}, - - -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed. - -- This setting has no relation with the `ensure_installed` setting. - -- Can either be: - -- - false: Servers are not automatically installed. - -- - true: All servers set up via lspconfig are automatically installed. - -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed. - -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } } - automatic_installation = false, + -- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed. + -- This setting has no relation with the `ensure_installed` setting. + -- Can either be: + -- - false: Servers are not automatically installed. + -- - true: All servers set up via lspconfig are automatically installed. + -- - { exclude: string[] }: All servers set up via lspconfig, except the ones provided in the list, are automatically installed. + -- Example: automatic_installation = { exclude = { "rust_analyzer", "solargraph" } } + automatic_installation = false, ui = { -- Whether to automatically check for outdated servers when opening the UI window. @@ -43,22 +41,22 @@ lspinstaller.setup{ server_pending = "➜", server_uninstalled = "✗", }, - keymaps = { - -- Keymap to expand a server in the UI - toggle_server_expand = "", - -- Keymap to install the server under the current cursor position - install_server = "i", - -- Keymap to reinstall/update the server under the current cursor position - update_server = "u", - -- Keymap to check for new version for the server under the current cursor position - check_server_version = "c", - -- Keymap to update all installed servers - update_all_servers = "U", - -- Keymap to check which installed servers are outdated - check_outdated_servers = "C", - -- Keymap to uninstall a server - uninstall_server = "X", - }, + keymaps = { + -- Keymap to expand a server in the UI + toggle_server_expand = "", + -- Keymap to install the server under the current cursor position + install_server = "i", + -- Keymap to reinstall/update the server under the current cursor position + update_server = "u", + -- Keymap to check for new version for the server under the current cursor position + check_server_version = "c", + -- Keymap to update all installed servers + update_all_servers = "U", + -- Keymap to check which installed servers are outdated + check_outdated_servers = "C", + -- Keymap to uninstall a server + uninstall_server = "X", + }, }, -- The directory in which to install all servers. @@ -73,79 +71,7 @@ lspinstaller.setup{ max_concurrent_installers = 4, } - --- ───────────────────────────────────────────────── -- --- setup LSPs manually --- ───────────────────────────────────────────────── -- -local installed_servers = lspinstaller.get_installed_servers() --- don't setup servers if atleast one server is installed, or it will throw an error -if #installed_servers == 0 then return end - --- always call require("lspconfig") after require("nvim-lsp-installer").setup {}, this is the way -local lspconfig_imported, lspconfig = pcall(require, 'lspconfig') -if not lspconfig_imported then return end - -local capabilities = vim.lsp.protocol.make_client_capabilities() --- import lsp configs/options which are managed in seprate file, nvim-lspconfig.lua -local lsp_options = require("plugins.nvim-lspconfig").options - - -for _, server in ipairs(installed_servers) do - - -- for lua - if server.name == "sumneko_lua" then - lsp_options.settings = { - Lua = { - diagnostics = { - -- Get the language server to recognize the 'vim', 'use' global - globals = {'vim', 'use', 'require'}, - }, - workspace = { - -- Make the server aware of Neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - }, - -- Do not send telemetry data containing a randomized but unique identifier - telemetry = {enable = false}, - }, - } - end - - -- for clangd (c/c++) - -- [https://github.com/jose-elias-alvarez/null-ls.nvim/issues/428] - if server.name == "clangd" then - capabilities.offsetEncoding = { "utf-16" } - lsp_options.capabilities = capabilities - end - - -- for html - if server.name == "html" then - lsp_options.filetypes = {"html", "htmldjango"} - end - - -- for css / scss / sass - if server.name == "cssls" then - - --[==[ - Neovim does not currently include built-in snippets. - `vscode-css-language-server` only provides completions when snippet support is enabled. - To enable completion, install a snippet plugin and add the following override to your - language client capabilities during setup. Enable (broadcasting) snippet capability for completion - https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/cssls.lua - --]==] - capabilities.textDocument.completion.completionItem.snippetSupport = true - lsp_options.capabilities = capabilities - end - - lspconfig[server.name].setup(lsp_options) -end - --- for Flutter and Dart --- don't put this on loop to set it because dart LSP installed and maintained by akinsho/flutter-tools.nvim -lspconfig["dartls"].setup(lsp_options) --- ───────────────────────────────────────────────── -- --- end LSP setup --- ───────────────────────────────────────────────── -- - +return M -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ -- diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index c97a248..4e6ac1a 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -9,7 +9,18 @@ -local M = {} + +-- ───────────────────────────────────────────────── -- +local lspconfig_imported, lspconfig = pcall(require, 'lspconfig') +if not lspconfig_imported then return end + +local imported_lspinstaller, lspinstaller = pcall(require, 'nvim-lsp-installer') +if not imported_lspinstaller then return end + +local lsp = vim.lsp +local handlers = lsp.handlers +-- ───────────────────────────────────────────────── -- + -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━━━❰ Mappings ❱━━━━━━━━━━━━━━━━━━ -- @@ -39,24 +50,29 @@ local on_attach = function(client, bufnr) -- See `:help vim.lsp.*` for documentation on any of the below functions -- ───────────────────────────────────────────────── -- - buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', options) - buf_set_keymap('n', 'n', 'lua vim.diagnostic.goto_next()', options) - buf_set_keymap('n', 'b', 'lua vim.diagnostic.goto_prev()', options) - - buf_set_keymap('n', 'd', 'lua vim.lsp.buf.definition()', options) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.declaration()', options) - buf_set_keymap('n', 't', 'lua vim.lsp.buf.type_definition()', options) - buf_set_keymap('n', 'i', 'lua vim.lsp.buf.implementation()', options) - buf_set_keymap('n', 's', 'lua vim.lsp.buf.signature_help()', options) - buf_set_keymap('n', 'h', 'lua vim.lsp.buf.hover()', options) - buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', options) - -- using 'filipdutescu/renamer.nvim' for renaming + buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', options) + buf_set_keymap('n', 'q', 'lua vim.diagnostic.set_loclist({})', options) + buf_set_keymap('n', 'n', 'lua vim.diagnostic.goto_next()', options) + buf_set_keymap('n', 'b', 'lua vim.diagnostic.goto_prev()', options) + + buf_set_keymap('n', 'd', 'lua vim.lsp.buf.definition()', options) + buf_set_keymap('n', 'D', 'lua vim.lsp.buf.declaration()', options) + buf_set_keymap('n', 't', 'lua vim.lsp.buf.type_definition()', options) + buf_set_keymap('n', 'i', 'lua vim.lsp.buf.implementation()', options) + buf_set_keymap('n', 's', 'lua vim.lsp.buf.signature_help()', options) + buf_set_keymap('n', 'h', 'lua vim.lsp.buf.hover()', options) + buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', options) + -- using 'filipdutescu/renamer.nvim' for rename -- buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'r', 'Telescope lsp_references', options) - buf_set_keymap("n", "f", 'lua vim.lsp.buf.formatting_sync()', options) + buf_set_keymap('n', 'r', 'Telescope lsp_references', options) + buf_set_keymap("n", "f", 'lua vim.lsp.buf.format{ async=true }', options) + + buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', options) + buf_set_keymap('x', 'a', 'lua vim.lsp.buf.range_code_action()', options) - buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', options) - buf_set_keymap('x', 'a', 'lua vim.lsp.buf.range_code_action()', options) + -- buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workleader_folder()', opts) + -- buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workleader_folder()', opts) + -- buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workleader_folders()))', opts) end -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- @@ -70,64 +86,156 @@ end -- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -local lsp = vim.lsp -local capabilities = lsp.protocol.make_client_capabilities() -local handlers = lsp.handlers +local function setup_lsp_config() -M.options = { - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - }, - capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities), -} + -- options for lsp diagnostic + -- ───────────────────────────────────────────────── -- + vim.diagnostic.config({ + float = { + border = "rounded", + focusable = true, + style = "minimal", + source = "always", + header = "", + prefix = "", + }, + }) + + handlers["textDocument/publishDiagnostics"] = lsp.with( + lsp.diagnostic.on_publish_diagnostics, + { + underline = true, + signs = true, + update_in_insert = true, + virtual_text = { + true, + spacing = 6, + -- severity_limit='Error' -- Only show virtual text on error + }, + } + ) + + handlers["textDocument/hover"] = lsp.with(handlers.hover, {border = "rounded"}) + handlers["textDocument/signatureHelp"] = lsp.with(handlers.signature_help, {border = "rounded"}) + + -- show diagnostic on float window(like auto complete) + -- vim.api.nvim_command [[ autocmd CursorHold *.lua,*.sh,*.bash,*.dart,*.py,*.cpp,*.c,js lua vim.lsp.diagnostic.show_line_diagnostics() ]] + + -- set LSP diagnostic symbols/signs + -- ─────────────────────────────────────────────────-- + vim.api.nvim_command [[ sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl= ]] + vim.api.nvim_command [[ sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl= ]] + vim.api.nvim_command [[ sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl= ]] + vim.api.nvim_command [[ sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl= ]] + + vim.api.nvim_command [[ hi DiagnosticUnderlineError cterm=underline gui=underline guisp=#840000 ]] + vim.api.nvim_command [[ hi DiagnosticUnderlineHint cterm=underline gui=underline guisp=#07454b ]] + vim.api.nvim_command [[ hi DiagnosticUnderlineWarn cterm=underline gui=underline guisp=#2f2905 ]] + vim.api.nvim_command [[ hi DiagnosticUnderlineInfo cterm=underline gui=underline guisp=#265478 ]] + + -- Auto-format files prior to saving them + -- vim.api.nvim_command[[autocmd BufWritePre lua vim.lsp.buf.formatting_sync(nil, 1000)]] + + --[[ + " to change colors, it's better to define in color scheme + " highlight LspDiagnosticsUnderlineError guifg=#EB4917 gui=undercurl + " highlight LspDiagnosticsUnderlineWarning guifg=#EBA217 gui=undercurl + " highlight LspDiagnosticsUnderlineInformation guifg=#17D6EB gui=undercurl + " highlight LspDiagnosticsUnderlineHint guifg=#17EB7A gui=undercurl + --]] +end --- options for lsp diagnostic -- ───────────────────────────────────────────────── -- -vim.diagnostic.config({ - float = { - border = "rounded", - focusable = true, - style = "minimal", - source = "always", - header = "", - prefix = "", - }, -}) - -handlers["textDocument/publishDiagnostics"] = lsp.with( - lsp.diagnostic.on_publish_diagnostics, - { - underline = true, - signs = true, - update_in_insert = true, - virtual_text = { - true, - spacing = 6, - -- severity_limit='Error' -- Only show virtual text on error +-- setup LSPs +-- ───────────────────────────────────────────────── -- +local function setup_lsp(on_attach) + + local installed_servers = lspinstaller.get_installed_servers() + local capabilities = lsp.protocol.make_client_capabilities() + local lsp_options = { + on_attach = on_attach, + flags = { + debounce_text_changes = 150, }, + capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities), } -) -handlers["textDocument/hover"] = lsp.with(handlers.hover, {border = "rounded"}) -handlers["textDocument/signatureHelp"] = lsp.with(handlers.signature_help, {border = "rounded"}) + -- for Flutter and Dart + -- don't put this on loop to set it because dart LSP installed and maintained by akinsho/flutter-tools.nvim + lspconfig["dartls"].setup(lsp_options) + + -- don't setup servers if atleast one server is installed, or it will throw an error + if #installed_servers == 0 then return end + + for _, server in ipairs(installed_servers) do + local server_options = {} + + -- for lua + if server.name == "sumneko_lua" then + server_options.settings = { + Lua = { + diagnostics = { + -- Get the language server to recognize the 'vim', 'use' global + globals = {'vim', 'use', 'require'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = {enable = false}, + }, + } + end + + -- for clangd (c/c++) + -- [https://github.com/jose-elias-alvarez/null-ls.nvim/issues/428] + if server.name == "clangd" then + capabilities.offsetEncoding = { "utf-16" } + server_options.capabilities = capabilities + end + + -- for html + if server.name == "html" then + server_options.filetypes = {"html", "htmldjango"} + end + + -- for css / scss / sass + if server.name == "cssls" then + + --[==[ + Neovim does not currently include built-in snippets. + `vscode-css-language-server` only provides completions when snippet support is enabled. + To enable completion, install a snippet plugin and add the following override to your + language client capabilities during setup. Enable (broadcasting) snippet capability for completion + https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/cssls.lua + --]==] + capabilities.textDocument.completion.completionItem.snippetSupport = true + server_options.capabilities = capabilities + end + + lspconfig[server.name].setup(vim.tbl_deep_extend('force', lsp_options, server_options)) + end +end + + +-- NOTE: always call require("lspconfig") after require("nvim-lsp-installer").setup {}, this is the way --- se LSP diagnostic symbols/signs --- ─────────────────────────────────────────────────-- -vim.api.nvim_command [[ sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl= ]] -vim.api.nvim_command [[ sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl= ]] -vim.api.nvim_command [[ sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl= ]] -vim.api.nvim_command [[ sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl= ]] +-- import nvim-lsp-installer configs +local imported_lspinstaller_config, lspinstaller_config = pcall(require, "plugins.nvim-lsp-installer") +if not imported_lspinstaller_config then return end + +lspinstaller.setup(lspinstaller_config.setup) -- setup lsp-installer +setup_lsp_config() -- setup lsp configs (mainly UI) +setup_lsp(on_attach) -- setup lsp (like pyright, ccls ...) + +-- ───────────────────────────────────────────────── -- +-- end LSP setup +-- ───────────────────────────────────────────────── -- -vim.api.nvim_command [[ hi DiagnosticUnderlineError cterm=underline gui=underline guisp=#840000 ]] -vim.api.nvim_command [[ hi DiagnosticUnderlineHint cterm=underline gui=underline guisp=#07454b ]] -vim.api.nvim_command [[ hi DiagnosticUnderlineWarn cterm=underline gui=underline guisp=#2f2905 ]] -vim.api.nvim_command [[ hi DiagnosticUnderlineInfo cterm=underline gui=underline guisp=#265478 ]] -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ -- -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- -return M - diff --git a/lua/plugins/nvim-surround.lua b/lua/plugins/nvim-surround.lua new file mode 100644 index 0000000..43e778c --- /dev/null +++ b/lua/plugins/nvim-surround.lua @@ -0,0 +1,87 @@ + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- +-- ───────────────────────────────────────────────── -- +-- Plugin: nvim-surround +-- Github: github.com/kylechui/nvim-surround +-- Description: Add/change/delete surrounding delimiter pairs with ease. +-- ───────────────────────────────────────────────── -- +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- + + + + + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- +-- ━━━━━━━━━━━━━━━━━━━❰ configs ❱━━━━━━━━━━━━━━━━━━━ -- +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- + +local imported_surround, surround = pcall(require, 'nvim-surround') +if not imported_surround then return end + + +surround.setup({ + keymaps = { -- vim-surround style keymaps + insert = "ys", + insert_line = "yss", + visual = "S", + delete = "ds", + change = "cs", + }, + delimiters = { + pairs = { + ["("] = { "( ", " )" }, + [")"] = { "(", ")" }, + ["{"] = { "{ ", " }" }, + ["}"] = { "{", "}" }, + ["<"] = { "< ", " >" }, + [">"] = { "<", ">" }, + ["["] = { "[ ", " ]" }, + ["]"] = { "[", "]" }, + -- Define pairs based on function evaluations! + ["i"] = function() + return { + require("nvim-surround.utils").get_input( + "Enter the left delimiter: " + ), + require("nvim-surround.utils").get_input( + "Enter the right delimiter: " + ) + } + end, + ["f"] = function() + return { + require("nvim-surround.utils").get_input( + "Enter the function name: " + ) .. "(", + ")" + } + end, + }, + separators = { + ["'"] = { "'", "'" }, + ['"'] = { '"', '"' }, + ["`"] = { "`", "`" }, + }, + HTML = { + ["t"] = "type", -- Change just the tag type + ["T"] = "whole", -- Change the whole tag contents + }, + aliases = { + ["a"] = ">", -- Single character aliases apply everywhere + ["b"] = ")", + ["B"] = "}", + ["r"] = "]", + -- Table aliases only apply for changes/deletions + ["q"] = { '"', "'", "`" }, -- Any quote character + ["s"] = { ")", "]", "}", ">", "'", '"', "`" }, -- Any surrounding delimiter + }, + }, + highlight_motion = { -- Highlight before inserting/changing surrounds + duration = 0, + } +}) + +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- +-- ━━━━━━━━━━━━━━━━━❰ end configs ❱━━━━━━━━━━━━━━━━━ -- +-- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- + diff --git a/lua/plugins/nvim-tree_lua.lua b/lua/plugins/nvim-tree_lua.lua index af0dffb..c112ca5 100644 --- a/lua/plugins/nvim-tree_lua.lua +++ b/lua/plugins/nvim-tree_lua.lua @@ -54,6 +54,7 @@ require'nvim-tree'.setup { height = 30, hide_root_folder = false, side = 'left', + signcolumn = "no", -- auto_resize = true, -- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -- diff --git a/lua/plugins/nvim-ts-autotag.lua b/lua/plugins/nvim-ts-autotag.lua index ca68907..a8e856d 100644 --- a/lua/plugins/nvim-ts-autotag.lua +++ b/lua/plugins/nvim-ts-autotag.lua @@ -18,7 +18,8 @@ require('nvim-ts-autotag').setup({ autotag = { enable = true, - } + }, + filetypes = { 'html', 'javascript', 'javascriptreact', 'jsx', diff --git a/lua/plugins/penvim.lua b/lua/plugins/penvim.lua index 576bed5..a6b73dc 100644 --- a/lua/plugins/penvim.lua +++ b/lua/plugins/penvim.lua @@ -32,7 +32,7 @@ penvim.setup({ indentor = { enable = true, - indent_length = 4, + indent_length = 8, indent_type = "auto", -- auto|tab|space }, diff --git a/lua/plugins/telescope_nvim.lua b/lua/plugins/telescope_nvim.lua index 3139e49..66ee855 100644 --- a/lua/plugins/telescope_nvim.lua +++ b/lua/plugins/telescope_nvim.lua @@ -49,8 +49,8 @@ telescope.setup { file_ignore_patterns = { "__pycache__/", "__pycache__/*", - "build/", "env/", "gradle/", "node_modules/", "node_modules/*", - "smalljre_*/*", "target/", "vendor/*", + "build/", "gradle/", "node_modules/", "node_modules/*", + "smalljre_*/*", "target/", "vendor/*", ".dart_tool/", ".git/", ".github/", ".gradle/", ".idea/", ".vscode/", diff --git a/lua/plugins/trouble_nvim.lua b/lua/plugins/trouble_nvim.lua index 8e4229b..4e853c0 100644 --- a/lua/plugins/trouble_nvim.lua +++ b/lua/plugins/trouble_nvim.lua @@ -75,7 +75,7 @@ require("trouble").setup { local keymap = vim.api.nvim_set_keymap local opts = {silent = true, noremap = true} -keymap("n", "gt", "TroubleToggle", opts) +keymap("n", "t", "TroubleToggle", opts) --[===[ keymap("n", "xw", "Trouble lsp_workspace_diagnostics",