diff --git a/users/rouven/modules/neovim/default.nix b/users/rouven/modules/neovim/default.nix index 83b954e..e660ba0 100644 --- a/users/rouven/modules/neovim/default.nix +++ b/users/rouven/modules/neovim/default.nix @@ -1,7 +1,12 @@ { config, pkgs, ... }: { home.packages = with pkgs; [ + # a few language servers python310Packages.python-lsp-server + python310Packages.python-lsp-black + python310Packages.black + python310Packages.pylint + rnix-lsp ]; programs.neovim = { enable = true; @@ -16,10 +21,11 @@ vim-nix # this destroys my tab settings, ffs nvim-lspconfig nvim-cmp + lsp-format-nvim cmp-buffer cmp-nvim-lsp cmp-path ]; }; - xdg.configFile."nvim/init.lua".source = ./nvim.lua; + xdg.configFile."nvim/init.lua".source = ./init.lua; } diff --git a/users/rouven/modules/neovim/nvim.lua b/users/rouven/modules/neovim/init.lua similarity index 92% rename from users/rouven/modules/neovim/nvim.lua rename to users/rouven/modules/neovim/init.lua index dc8ae37..9284d01 100644 --- a/users/rouven/modules/neovim/nvim.lua +++ b/users/rouven/modules/neovim/init.lua @@ -16,8 +16,7 @@ cmd('highlight ColorColumn ctermbg=darkgray') local function map(mode, lhs, rhs, opts) local options = { noremap=true } - if opts then - options = vim.tbl_extend('force', options, opts) + if opts then options = vim.tbl_extend('force', options, opts) end vim.keymap.set(mode, lhs, rhs, options) end @@ -74,6 +73,7 @@ g.dracula_colorterm = 0 cmd('colorscheme dracula') local lsp = require("lspconfig") +local lsp_format = require("lsp-format") vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) @@ -83,6 +83,7 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) -- Use an on_attach function to only map the following keys -- after the language server attaches to the current buffer local on_attach = function(client, bufnr) + lsp_format.on_attach(client) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') @@ -108,9 +109,23 @@ end lsp.pylsp.setup { - on_attach = on_attach + on_attach = on_attach, + settings = { + pylsp = { + plugins = { + pylint = { enable = true }, + black = { + enable = true, + line_legth=120, + }, + }, + }, + }, } +lsp.rnix.setup { + on_attach = on_attach +} local cmp = require("cmp") @@ -120,15 +135,6 @@ cmp.setup { [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), [''] = cmp.mapping.confirm({ select = false }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { 'i', 's' }), [''] = cmp.mapping(function(fallback) if cmp.visible() then @@ -151,3 +157,4 @@ cmp.setup { }), } +