From 2eca6c0d56478b2689046a8d418369bef942793b Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Fri, 15 Mar 2024 15:10:00 +0100 Subject: [PATCH] Update Plugin Config --- lua/lsp/installer.lua | 51 --------- lua/lsp/metals.lua | 53 --------- lua/lsp/typescript.lua | 13 --- lua/plugins/cmp.lua | 233 +++++++++++++++++++------------------- lua/plugins/init.lua | 11 +- lua/plugins/tabline.lua | 8 +- lua/plugins/telescope.lua | 1 - lua/plugins/ui.lua | 3 +- 8 files changed, 124 insertions(+), 249 deletions(-) delete mode 100644 lua/lsp/installer.lua delete mode 100644 lua/lsp/metals.lua delete mode 100644 lua/lsp/typescript.lua diff --git a/lua/lsp/installer.lua b/lua/lsp/installer.lua deleted file mode 100644 index f0fa06f..0000000 --- a/lua/lsp/installer.lua +++ /dev/null @@ -1,51 +0,0 @@ -local status1, mason = pcall(require, "mason") -local status2, mason_lspconfig = pcall(require, "mason-lspconfig") -if (not (status1 and status2)) then return end - -return function(on_attach) - mason.setup {} - mason_lspconfig.setup { - ensure_installed = { 'jdtls', 'lua_ls' } - } - - local no_autosetup = { - jdtls = true - } - - local extra_config = { - lua_ls = { - on_attach = on_attach, - settings = { - Lua = { - diagnostics = { globals = { 'vim' } }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { enable = false }, - }, - }, - }, - ["pylsp"] = { - on_attach = on_attach, - settings = { - pylsp = { - plugins = { - rope_autoimport = { enabled = true, }, - isort = { enabled = true, }, - } - } - } - } - } - - mason_lspconfig.setup_handlers { - function(server_name) - if (not no_autosetup[server_name]) then - require("lspconfig")[server_name].setup( - extra_config[server_name] or { on_attach = on_attach } - ) - end - end, - } -end diff --git a/lua/lsp/metals.lua b/lua/lsp/metals.lua deleted file mode 100644 index fe7416d..0000000 --- a/lua/lsp/metals.lua +++ /dev/null @@ -1,53 +0,0 @@ -local status, metals = pcall(require, "metals") -if (not status) then return function() end end - -return function(on_attach) - metals_config = metals.bare_config() - metals_config.init_options.statusBarProvider = "on" - metals_config.settings = { - showImplicitArguments = true, - superMethodLensesEnabled = true, - } - metals_config.on_attach = function(client, bufnr) - require("metals").setup_dap() - on_attach(client, bufnr) - end - metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() - -- Debug settings if you're using nvim-dap - local dap = require("dap") - dap.configurations.scala = { - { - type = "scala", - request = "launch", - name = "RunOrTest", - metals = { - runType = "runOrTestFile", - --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example - }, - }, - { - type = "scala", - request = "launch", - name = "Test Target", - metals = { - runType = "testTarget", - }, - }, - } - - - -- Autocmd that will actually be in charging of starting the whole thing - local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) - vim.api.nvim_create_autocmd("FileType", { - -- NOTE: You may or may not want java included here. You will need it if you - -- want basic Java support but it may also conflict if you are using - -- something like nvim-jdtls which also works on a java filetype autocmd. - pattern = { "scala", "sbt" }, - callback = function() - require("metals").initialize_or_attach(metals_config) - end, - group = nvim_metals_group, - }) - - return metals_config -end diff --git a/lua/lsp/typescript.lua b/lua/lsp/typescript.lua deleted file mode 100644 index 560a7fe..0000000 --- a/lua/lsp/typescript.lua +++ /dev/null @@ -1,13 +0,0 @@ -local status, nvim_lsp = pcall(require, "lspconfig") -if (not status) then return function() end end - -return function(on_attach) - local protocol = require('vim.lsp.protocol') - - -- TypeScript - nvim_lsp.tsserver.setup { - on_attach = on_attach, - filetypes = { "typescript", "typescriptreact", "typescript.tsx" }, - cmd = { "typescript-language-server", "--stdio" } - } -end diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 09f3cb3..cbab29a 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -1,120 +1,119 @@ return { - { - "hrsh7th/nvim-cmp", - -- load cmp on InsertEnter - event = "InsertEnter", - -- these dependencies will only be loaded when cmp loads - -- dependencies are always lazy-loaded unless specified otherwise - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-cmdline', - -- 'hrsh7th/cmp-vsnip', - -- 'hrsh7th/vim-vsnip', - -- 'hrsh7th/vim-vsnip-integ', - 'L3MON4D3/LuaSnip', - 'saadparwaiz1/cmp_luasnip', - 'onsails/lspkind.nvim', - { - 'zbirenbaum/copilot-cmp', - dependencies = { "hrsh7th/nvim-cmp", - { - 'zbirenbaum/copilot.lua', - opts = { - suggestion = { enabled = false }, - panel = { enabled = false }, - filetypes = { - mail = false, - text = false, - } - } - }, - }, - config = function() - require("copilot_cmp").setup() - end - }, - }, - config = function() - local cmp = require('cmp') - local lspkind = require('lspkind') - local luasnip = require('luasnip') - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end + { + "hrsh7th/nvim-cmp", + -- load cmp on InsertEnter + event = "InsertEnter", + -- these dependencies will only be loaded when cmp loads + -- dependencies are always lazy-loaded unless specified otherwise + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-cmdline', + -- 'hrsh7th/cmp-vsnip', + -- 'hrsh7th/vim-vsnip', + -- 'hrsh7th/vim-vsnip-integ', + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + 'onsails/lspkind.nvim', + { + 'zbirenbaum/copilot-cmp', + dependencies = { "hrsh7th/nvim-cmp", + { + 'zbirenbaum/copilot.lua', + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + filetypes = { + mail = false, + text = false, + } + } + }, + }, + config = function() + require("copilot_cmp").setup() + end + }, + }, + config = function() + local cmp = require('cmp') + local lspkind = require('lspkind') + local luasnip = require('luasnip') + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end - cmp.setup({ - snippet = { - expand = function(args) - --vim.fn["vsnip#anonymous"](args.body) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = "copilot" }, - }, { - { name = 'buffer' }, - --{ name = 'path' }, - }), - formatting = { - format = lspkind.cmp_format({ - mode = 'symbol_text', -- show only symbol annotations - maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - symbol_map = { Copilot = "" }, - }) - }, - }) - end, - }, + cmp.setup({ + snippet = { + expand = function(args) + --vim.fn["vsnip#anonymous"](args.body) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = { + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }, + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = "copilot" }, + }, { + { name = 'buffer', option = { keyword_pattern = [[\k\+]] } }, + --{ name = 'path' }, + }), + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 80, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '…', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) + symbol_map = { Copilot = "" }, + }) + }, + }) + end, + }, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index ecc3208..d5e96e4 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -2,7 +2,6 @@ return { "folke/which-key.nvim", 'pbrisbin/vim-mkdir', 'fladson/vim-kitty', - 'tpope/vim-repeat', 'tpope/vim-surround', 'tpope/vim-characterize', @@ -17,8 +16,6 @@ return { }, -- ii / ai 'michaeljsmith/vim-indent-object', - {'lewis6991/gitsigns.nvim', config=true}, - 'neovim/nvim-lspconfig', { 'nvim-telescope/telescope.nvim', @@ -34,15 +31,9 @@ return { 'folke/trouble.nvim', 'folke/lsp-colors.nvim', 'nvim-lua/popup.nvim', - 'junegunn/vim-easy-align', 'machakann/vim-highlightedyank', 'lambdalisue/suda.vim', - -- git - 'lambdalisue/gina.vim', - 'gregsexton/gitv', - 'gisphm/vim-gitignore', - 'sjl/splice.vim', 'jamessan/vim-gnupg', {'lervag/vimtex', @@ -62,5 +53,7 @@ return { 'Glench/Vim-Jinja2-Syntax', 'GEverding/vim-hocon', 'nfnty/vim-nftables', + 'nfnty/vim-nftables', + 'Everduin94/nvim-quick-switcher', } -- 'powerman/vim-plugin-AnsiEsc', diff --git a/lua/plugins/tabline.lua b/lua/plugins/tabline.lua index 0336192..e210668 100644 --- a/lua/plugins/tabline.lua +++ b/lua/plugins/tabline.lua @@ -13,7 +13,7 @@ return { tabline = { lualine_a = { 'branch' }, lualine_b = {}, - lualine_c = { { 'windows', show_filename_only = false, symbols = { modified = " ✏️]", alternate_file = " 🔃", folder = " 📁"} ,}}, + lualine_c = { { 'buffers', show_filename_only = false, symbols = { modified = " ✏️]", alternate_file = " 🔃", folder = " 📁"} ,}}, lualine_x = {}, lualine_y = {}, lualine_z = { @@ -35,16 +35,16 @@ return { } } }, sections = { - lualine_a = { filename }, + lualine_a = { 'filename' }, lualine_b = { 'diff', 'diagnostics' }, lualine_x = { "require'lsp-status'.status()" }, lualine_y = { 'filetype' }, - lualine_z = { 'searchcount', 'location' } + lualine_z = { 'searchcount', 'selectioncount', 'location' } }, inactive_sections = { lualine_a = {}, lualine_b = {}, - lualine_c = { filename }, + lualine_c = { 'filename' }, lualine_x = { 'location' }, lualine_y = {}, lualine_z = {} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 218dd96..a38dfba 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -50,6 +50,5 @@ return { local telescope = require('telescope') telescope.setup(opts) telescope.load_extension('fzf') - telescope.load_extension('ui-select') end, } diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index ba6fee3..7a228e2 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -1,8 +1,9 @@ return { { 'stevearc/dressing.nvim', + enabled = true, dependencies = { - 'nvim-telescope/telescope-ui-select.nvim', + --'nvim-telescope/telescope-ui-select.nvim', }, opts = { select = {