From f61a044c86e842c44b5e0ef77c0f32fefa6507d9 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 20:00:01 +0100 Subject: [PATCH 1/7] Remove unused configuration files --- templates/nvim/init.lua.j2 | 2 -- templates/nvim/lua/auto-commands.lua.j2 | 6 ----- templates/nvim/lua/nvim-cmp.lua.j2 | 35 ------------------------- 3 files changed, 43 deletions(-) delete mode 100644 templates/nvim/lua/auto-commands.lua.j2 delete mode 100644 templates/nvim/lua/nvim-cmp.lua.j2 diff --git a/templates/nvim/init.lua.j2 b/templates/nvim/init.lua.j2 index c540171..0240adf 100644 --- a/templates/nvim/init.lua.j2 +++ b/templates/nvim/init.lua.j2 @@ -2,8 +2,6 @@ require('options') require('lsp') -require('nvim-cmp') -require('auto-commands') require('tree-sitter') require('lua-line') require('git-signs') diff --git a/templates/nvim/lua/auto-commands.lua.j2 b/templates/nvim/lua/auto-commands.lua.j2 deleted file mode 100644 index ee6b22c..0000000 --- a/templates/nvim/lua/auto-commands.lua.j2 +++ /dev/null @@ -1,6 +0,0 @@ --- {{ ansible_managed }} - -vim.api.nvim_create_autocmd('Filetype', { - pattern = 'TelescopeResults', - command = [[:setlocal nofoldenable]], -}) diff --git a/templates/nvim/lua/nvim-cmp.lua.j2 b/templates/nvim/lua/nvim-cmp.lua.j2 deleted file mode 100644 index b013475..0000000 --- a/templates/nvim/lua/nvim-cmp.lua.j2 +++ /dev/null @@ -1,35 +0,0 @@ --- {{ ansible_managed }} - -local cmp = require('cmp') - -cmp.setup { - mapping = { - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.close(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, - [''] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, - }, - sources = { - { name = 'nvim_lsp' }, - }, -} From 9183c29751283022c3eca5bd6204568a57eaa4f1 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 20:00:58 +0100 Subject: [PATCH 2/7] Remove old statubar setup & install python-lsp-server globablly --- templates/nvim/lua/options.lua.j2 | 6 +----- vars/archlinux.yml | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/nvim/lua/options.lua.j2 b/templates/nvim/lua/options.lua.j2 index f04251f..36bbe52 100644 --- a/templates/nvim/lua/options.lua.j2 +++ b/templates/nvim/lua/options.lua.j2 @@ -51,13 +51,9 @@ vim.o.cursorline = true -- theme related vim.o.termguicolors = true --- enable statusbar -vim.o.laststatus = 2 -vim.o.statusline = ' %F %m%r%w %= %{hostname()} %{strlen(&ft)?&ft:"none"} %{(&bomb?",BOM":"")} %{&ff} %l/%L %c %P' - -- use a dedicated file explorer vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 -- python interpreter -vim.g.python3_host_prog = './env/bin/python' +vim.g.python3_host_prog = '/usr/bin/python3' diff --git a/vars/archlinux.yml b/vars/archlinux.yml index c76329f..410a5de 100644 --- a/vars/archlinux.yml +++ b/vars/archlinux.yml @@ -6,6 +6,7 @@ packages: - git - vim - neovim + - python-pynvim - wl-clipboard - npm - docker @@ -90,6 +91,11 @@ language_servers: server_name: 'pyright', auto_setup: false } + - { + package: python-lsp-server, + server_name: 'pylsp', + auto_setup: false + } python_download_url: 'https://www.python.org/ftp/python' python_versions: From b663f3bb2034480995cfc82e61e5e1f24d574de1 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 20:03:34 +0100 Subject: [PATCH 3/7] Remove previously removed files --- tasks/neovim.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tasks/neovim.yml b/tasks/neovim.yml index 36d771a..3779c71 100644 --- a/tasks/neovim.yml +++ b/tasks/neovim.yml @@ -112,18 +112,10 @@ dest: '{{ xdg_config_dir }}/nvim/after/ftplugin/yaml.lua', } - { src: 'templates/nvim/init.lua.j2', dest: '{{ xdg_config_dir }}/nvim/init.lua' } - - { - src: 'templates/nvim/lua/auto-commands.lua.j2', - dest: '{{ xdg_config_dir }}/nvim/lua/auto-commands.lua', - } - { src: 'templates/nvim/lua/lsp.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/lsp.lua', } - - { - src: 'templates/nvim/lua/nvim-cmp.lua.j2', - dest: '{{ xdg_config_dir }}/nvim/lua/nvim-cmp.lua', - } - { src: 'templates/nvim/lua/options.lua.j2', dest: '{{ xdg_config_dir }}/nvim/lua/options.lua', From d300288799efb30cbaff5bb0067c1046b03128a5 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 21:18:05 +0100 Subject: [PATCH 4/7] Add nvim-cmp mappings --- templates/nvim/lua/lsp.lua.j2 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/templates/nvim/lua/lsp.lua.j2 b/templates/nvim/lua/lsp.lua.j2 index 37b3645..541535f 100644 --- a/templates/nvim/lua/lsp.lua.j2 +++ b/templates/nvim/lua/lsp.lua.j2 @@ -120,12 +120,23 @@ cmp.setup({ formatting = { format = function(entry, vim_item) - vim_item.menu = string.format('[%s]', entry.source.source.client.name) + if entry.source.name == 'nvim_lsp' then + vim_item.menu = entry.source.source.client.name + end + return vim_item end, }, mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() From f45918c93d88b5860ae5d048cd108337a1346522 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 21:30:49 +0100 Subject: [PATCH 5/7] Remove python-lsp-server setup --- templates/nvim/lua/lsp.lua.j2 | 16 ---------------- vars/archlinux.yml | 7 ------- 2 files changed, 23 deletions(-) diff --git a/templates/nvim/lua/lsp.lua.j2 b/templates/nvim/lua/lsp.lua.j2 index 541535f..679f983 100644 --- a/templates/nvim/lua/lsp.lua.j2 +++ b/templates/nvim/lua/lsp.lua.j2 @@ -68,22 +68,6 @@ nvim_lsp.ruff.setup({ }) -nvim_lsp.pylsp.setup({ - on_attach = on_attach, - capabilities = capabilities, - cmd = { 'pylsp', '--verbose' }, - settings = { - pylsp = { - plugins = { - ruff = { - enabled = false -- now through ruff lsp - } - } - } - }, - root_dir = python_root_dir -}) - nvim_lsp.pyright.setup({ settings = { pyright = { diff --git a/vars/archlinux.yml b/vars/archlinux.yml index 410a5de..56ae648 100644 --- a/vars/archlinux.yml +++ b/vars/archlinux.yml @@ -38,8 +38,6 @@ aur_build_dir: '/usr/local/src' python_build_dir: '/usr/local/src' python_install_dir: '/opt' -# Note that the "python-lsp-server" and "neovim" python -# packages should be installed to the corresponding virtualenv as well. language_servers: - { package: ansible-language-server, @@ -91,11 +89,6 @@ language_servers: server_name: 'pyright', auto_setup: false } - - { - package: python-lsp-server, - server_name: 'pylsp', - auto_setup: false - } python_download_url: 'https://www.python.org/ftp/python' python_versions: From a3353cc601c781eedce3cac318fcace6d062d448 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 21:31:15 +0100 Subject: [PATCH 6/7] Show diagnostics source --- templates/nvim/lua/lsp.lua.j2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/templates/nvim/lua/lsp.lua.j2 b/templates/nvim/lua/lsp.lua.j2 index 679f983..df5144e 100644 --- a/templates/nvim/lua/lsp.lua.j2 +++ b/templates/nvim/lua/lsp.lua.j2 @@ -147,3 +147,10 @@ cmp.setup({ end, }, }) + +vim.diagnostic.config({ + float = { + source = 'always', + border = border + }, +}) From 2bbf7655c93a348c9042adbacc30c4643c8c29d9 Mon Sep 17 00:00:00 2001 From: Sonny Bakker Date: Fri, 3 Jan 2025 21:40:38 +0100 Subject: [PATCH 7/7] Use fallback for displaying completion source --- templates/nvim/lua/lsp.lua.j2 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/nvim/lua/lsp.lua.j2 b/templates/nvim/lua/lsp.lua.j2 index df5144e..92fbca2 100644 --- a/templates/nvim/lua/lsp.lua.j2 +++ b/templates/nvim/lua/lsp.lua.j2 @@ -105,7 +105,9 @@ cmp.setup({ formatting = { format = function(entry, vim_item) if entry.source.name == 'nvim_lsp' then - vim_item.menu = entry.source.source.client.name + vim_item.menu = string.format('[%s]', entry.source.source.client.name) + else + vim_item.menu = string.format('[%s]', entry.source.name) end return vim_item