nvim quirks

This commit is contained in:
Rouven Seifert 2023-02-21 22:16:03 +01:00
parent ad8fa192f9
commit e9e167d26d
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
2 changed files with 26 additions and 13 deletions

View file

@ -1,7 +1,12 @@
{ config, pkgs, ... }: { config, pkgs, ... }:
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
# a few language servers
python310Packages.python-lsp-server python310Packages.python-lsp-server
python310Packages.python-lsp-black
python310Packages.black
python310Packages.pylint
rnix-lsp
]; ];
programs.neovim = { programs.neovim = {
enable = true; enable = true;
@ -16,10 +21,11 @@
vim-nix # this destroys my tab settings, ffs vim-nix # this destroys my tab settings, ffs
nvim-lspconfig nvim-lspconfig
nvim-cmp nvim-cmp
lsp-format-nvim
cmp-buffer cmp-buffer
cmp-nvim-lsp cmp-nvim-lsp
cmp-path cmp-path
]; ];
}; };
xdg.configFile."nvim/init.lua".source = ./nvim.lua; xdg.configFile."nvim/init.lua".source = ./init.lua;
} }

View file

@ -16,8 +16,7 @@ cmd('highlight ColorColumn ctermbg=darkgray')
local function map(mode, lhs, rhs, opts) local function map(mode, lhs, rhs, opts)
local options = { noremap=true } local options = { noremap=true }
if opts then if opts then options = vim.tbl_extend('force', options, opts)
options = vim.tbl_extend('force', options, opts)
end end
vim.keymap.set(mode, lhs, rhs, options) vim.keymap.set(mode, lhs, rhs, options)
end end
@ -74,6 +73,7 @@ g.dracula_colorterm = 0
cmd('colorscheme dracula') cmd('colorscheme dracula')
local lsp = require("lspconfig") local lsp = require("lspconfig")
local lsp_format = require("lsp-format")
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts) vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
@ -83,6 +83,7 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys -- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
lsp_format.on_attach(client)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
@ -108,9 +109,23 @@ end
lsp.pylsp.setup { 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") local cmp = require("cmp")
@ -120,15 +135,6 @@ cmp.setup {
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), ['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
['<CR>'] = cmp.mapping.confirm({ select = false }), ['<CR>'] = cmp.mapping.confirm({ select = false }),
['<Tab>'] = 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' }),
['<S-Tab>'] = cmp.mapping(function(fallback) ['<S-Tab>'] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
@ -151,3 +157,4 @@ cmp.setup {
}), }),
} }