nvim configuraion

This commit is contained in:
Rouven Seifert 2023-02-21 17:59:05 +01:00
parent adc6afca11
commit ad8fa192f9
Signed by: rouven.seifert
GPG key ID: B95E8FE6B11C4D09
3 changed files with 174 additions and 95 deletions

View file

@ -24,11 +24,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1676892629,
"narHash": "sha256-rlvsqoSBO5dCwfnn7xvImYREidIPJaiFS3b54TZF4pU=",
"lastModified": 1676933022,
"narHash": "sha256-gLghsEHOy2W2ZmSwqNOyj2mSHe9SMpdcbqnoySlZnmY=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "72ce74d3eae78a6b31538ea7ebe0c1fcf4a10f7a",
"rev": "5e889b385c43a8a72ada5ebc4888bbebb129b438",
"type": "github"
},
"original": {
@ -47,11 +47,11 @@
"xdph": "xdph"
},
"locked": {
"lastModified": 1676902515,
"narHash": "sha256-tFvDUIWmsEdAWnbwCDCDwcPxcZNGQzPfRpx5tSL/yl0=",
"lastModified": 1676981621,
"narHash": "sha256-kRvteNQ8kkhtyJF4b+CHBDUkleZFxsIxtbCDn7gEK20=",
"owner": "hyprwm",
"repo": "Hyprland",
"rev": "474ada9267ccb98015991ee9d0d93fbb5da72034",
"rev": "a66ef50469c7a347d27a9afec83db1be70be1c84",
"type": "github"
},
"original": {
@ -122,11 +122,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1676721149,
"narHash": "sha256-mN2EpTGxxVNnFZLoLWRwh6f7UWhXy4qE+wO2CZyrXps=",
"lastModified": 1676885936,
"narHash": "sha256-ZRKb6zBfTvdCOXI7nGC1L9UWSU5ay2ltxg+f5UIzBOU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "5f4e07deb7c44f27d498f8df9c5f34750acf52d2",
"rev": "b69883faca9542d135fa6bab7928ff1b233c167f",
"type": "github"
},
"original": {
@ -185,11 +185,11 @@
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1676776227,
"narHash": "sha256-CSBeyGiDMYDw/nmafLfuu0ErVu7rzGoWIQwm2NkQQKY=",
"lastModified": 1676959847,
"narHash": "sha256-KZS6sIsMXiNyN7jW45MrEo95iEXj6nMLKvxgxO181no=",
"owner": "Mic92",
"repo": "sops-nix",
"rev": "1da7257baa1d6801c45d9d3dedae7ce79c0e6498",
"rev": "2c5828439d718a6cddd9a511997d9ac7626a4aff",
"type": "github"
},
"original": {

View file

@ -1,99 +1,25 @@
{ config, pkgs, ... }:
{
home.packages = with pkgs; [
python310Packages.python-lsp-server
];
programs.neovim = {
enable = true;
# defaultEditor = true; why the hell doesn't this work :(
vimAlias = true;
plugins = with pkgs.vimPlugins; [
nerdtree
nerdcommenter
fugitive-gitlab-vim
vim-repeat
vim-airline
fzf-vim
dracula-vim
vim-nix # this destroys my tab settings, ffs
nvim-lspconfig
nvim-cmp
cmp-buffer
cmp-nvim-lsp
cmp-path
];
extraConfig =
''
" basic commands bound to uppercase key
command Q q
command W w
command Wq wq
command WQ wq
set shiftwidth=4
set noexpandtab
set preserveindent
set number relativenumber
set tabstop=4
set smartcase
set colorcolumn=120
set nowrap
highlight ColorColumn ctermbg=darkgray
" beautify indents
:set list lcs=tab:\|\
nnoremap ; :
nnoremap : ;
vnoremap ; :
vnoremap : ;
" set space as leader
nnoremap <SPACE> <Nop>
let mapleader = " "
" air-line
let g:airline_powerline_fonts = 1
" NERDTree
nnoremap <leader>n :NERDTreeFocus<CR> :NERDTreeRefreshRoot<CR>
" NERDTree autostart"
autocmd VimEnter * NERDTree | wincmd p
" Close the tab if NERDTree is the only window remaining in it.
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
"remove ex-mode shortcut
nmap Q <Nop>
" trigger the fuzzy finder (fzf)
nnoremap <leader>f :Files<CR>
nnoremap <leader>g :GFiles<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>r :Rg<CR>
" keybinds for coc
nnoremap <leader>d :CocDiagnostics<CR>
" quickfixlist binds
nnoremap <C-j> :cnext<CR>
nnoremap <C-k> :cprev<CR>
" locallist binds
nnoremap <C-l> :lnext<CR>
nnoremap <C-h> :lprev<CR>
" split keybinds
nnoremap <leader>s :sp<CR>
nnoremap <leader>v :vs<CR>
nnoremap <leader>h <C-w>h
nnoremap <leader>j <C-w>j
nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
" coloring stuff
let g:dracula_colorterm = 0
colorscheme dracula
" better autocompletion menu colors
highlight Pmenu ctermbg=darkgray ctermfg=black
highlight PmenuSel ctermbg=gray ctermfg=black
'';
};
xdg.configFile."nvim/init.lua".source = ./nvim.lua;
}

View file

@ -0,0 +1,153 @@
local g = vim.g
local opt = vim.opt
local cmd = vim.cmd
local autocmd = vim.api.nvim_create_autocmd
--local map = vim.api.nvim_set_keymap opt.shiftwidth = 4
opt.expandtab = false
opt.preserveindent = true
opt.number = true
opt.relativenumber = true
opt.tabstop = 4
opt.smartcase = true
opt.colorcolumn = { '120' }
opt.wrap = false
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)
end
vim.keymap.set(mode, lhs, rhs, options)
end
map({'n', 'v'}, ';', ':')
map({'n', 'v'}, ':', ';')
-- set space as leader
map('n', '<SPACE>', '<Nop>')
g.mapleader = " "
--air-line
g.airline_powerline_fonts = 1
--NERDTree
map('n', '<leader>n :NERDTreeFocus<CR>', ':NERDTreeRefreshRoot<CR>')
--NERDTree autostart"
autocmd('VimEnter', {command = 'NERDTree | wincmd p'})
--Close the tab if NERDTree is the only window remaining in it.
autocmd("BufEnter", {
pattern = "*",
command = "if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif"
})
-- remove ex-mode shortcut
map('n', 'Q', '<Nop>')
--trigger the fuzzy finder (fzf)
map('n', '<leader>f', ":Files<CR>")
map('n', '<leader>g', ":GFiles<CR>")
map('n', '<leader>b', ":Buffers<CR>")
map('n', '<leader>r', ":Rg<CR>")
--quickfixlist binds
map('n', '<C-j>', ":cnext<CR>")
map('n', '<C-k>', ":cprev<CR>")
--locallist binds
map('n', '<C-l>', ":lnext<CR>")
map('n', '<C-h>', ":lprev<CR>")
--split keybinds
map('n', '<leader>s', ":sp<CR>")
map('n', '<leader>v', ":vs<CR>")
map('n', '<leader>h', "<C-w>h")
map('n', '<leader>j', "<C-w>j")
map('n', '<leader>k', "<C-w>k")
map('n', '<leader>l', "<C-w>l")
--coloring stuff
g.dracula_colorterm = 0
cmd('colorscheme dracula')
local lsp = require("lspconfig")
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_next, opts)
vim.keymap.set('n', '<leader>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)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<leader>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
lsp.pylsp.setup {
on_attach = on_attach
}
local cmp = require("cmp")
cmp.setup {
mapping = cmp.mapping.preset.insert({
['<C-d>'] = 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 }),
['<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)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { 'i', 's' }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'path' }
}, {
{
name = 'buffer',
option = {
keyword_pattern = [[\k\+]], -- allow unicode multibyte characters
},
}
}),
}