Transition to nixvim

This commit is contained in:
Vili Sinervä 2024-11-29 02:41:01 +02:00
parent 1efded5340
commit f8e3204979
No known key found for this signature in database
GPG key ID: DF8FEAF54EFAC996

View file

@ -1,4 +1,12 @@
{ config, pkgs, ... }: { pkgs, ... }:
let
nixvim = import (
builtins.fetchGit {
url = "https://github.com/nix-community/nixvim";
ref = "nixos-24.05";
}
);
in
{ {
#################### Git configuration #################### #################### Git configuration ####################
programs.git = { programs.git = {
@ -22,123 +30,119 @@
#################### Packages #################### #################### Packages ####################
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
nodejs-slim
nixfmt-rfc-style nixfmt-rfc-style
nixd nixd
]; ];
#################### Neovim configuration #################### #################### Neovim configuration ####################
programs.neovim = { imports = [ nixvim.nixosModules.nixvim ];
programs.nixvim = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
vimAlias = true; vimAlias = true;
configure = { colorschemes.vscode.enable = true;
packages.myVimPackage = with pkgs.vimPlugins; {
start = [ globals.mapleader = " ";
nerdtree
nerdtree-git-plugin opts = {
vim-gitgutter colorcolumn = "100";
vim-fugitive cursorline = true;
vim-tmux-navigator number = true;
vim-sleuth showcmd = true;
coc-nvim signcolumn = "yes";
coc-pairs
coc-clangd scrolloff = 16;
coc-cmake shiftwidth = 3;
coc-docker tabstop = 3;
coc-json
coc-markdownlint
coc-pyright
coc-rust-analyzer
coc-sh
coc-toml
coc-tsserver
coc-yaml
];
}; };
customRC =
let keymaps = [
coc-config = "${pkgs.writeTextDir "coc-settings.json" ''
{ {
"workspace.ignoredFolders": [ key = "<C-h>";
"$HOME", action = "<cmd>TmuxNavigateLeft<cr>";
"$HOME/.cargo/**", options.silent = true;
"$HOME/.rustup/**"
],
rust-analyzer.inlayHints.bindingModeHints.enable: true,
rust-analyzer.inlayHints.closureReturnTypeHints.enable: "always",
rust-analyzer.inlayHints.discriminantHints.enable: "always",
rust-analyzer.inlayHints.expressionAdjustmentHints.enable: "always",
rust-analyzer.inlayHints.expressionAdjustmentHints.hideOutsideUnsafe: true,
rust-analyzer.inlayHints.lifetimeElisionHints.enable: "always",
rust-analyzer.inlayHints.lifetimeElisionHints.useParameterNames: true,
"languageserver": {
"nix": {
"command": "nixd",
"filetypes": ["nix"]
} }
{
key = "<C-j>";
action = "<cmd>TmuxNavigateDown<cr>";
options.silent = true;
} }
{
key = "<C-k>";
action = "<cmd>TmuxNavigateUp<cr>";
options.silent = true;
} }
''}"; {
in key = "<C-l>";
'' action = "<cmd>TmuxNavigateRight<cr>";
syntax on options.silent = true;
set foldmethod=syntax }
];
set number # TODO Autocomplete
set colorcolumn=100 # TODO Filebrowser
set signcolumn=yes # TODO Check desireable keybinds and commands for all plugins
let NERDTreeShowLineNumbers=1 plugins = {
gitsigns.enable = true;
lualine = {
enable = true;
iconsEnabled = false;
};
markdown-preview.enable = true;
nix.enable = true;
rainbow-delimiters.enable = true;
sleuth.enable = true;
tmux-navigator = {
enable = true;
settings.no_mappings = true;
};
treesitter = {
enable = true;
folding = true;
indent = true;
nixGrammars = true;
};
set background=dark # cmp-vsnip.enable = true;
friendly-snippets.enable = true;
nvim-autopairs.enable = true;
set showcmd lsp = {
set scrolloff=16 enable = true;
keymaps = {
diagnostic = {
"<leader>j" = "goto_next";
"<leader>k" = "goto_prev";
};
lspBuf = {
K = "hover";
gD = "references";
gd = "definition";
gi = "implementation";
gt = "type_definition";
};
};
servers = {
clangd.enable = true;
cmake.enable = true;
dockerls.enable = true;
docker-compose-language-service.enable = true;
eslint.enable = true;
html.enable = true;
jsonls.enable = true;
nixd.enable = true;
pylsp.enable = true;
rust-analyzer = {
enable = true;
installCargo = true;
installRustc = true;
};
yamlls.enable = true;
};
};
lsp-format.enable = true;
filetype plugin indent on
set autoindent
set shiftwidth=3
set tabstop=3
" Some servers have issues with backup files, see #649
set nobackup
set nowritebackup
" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable
" delays and poor user experience
set updatetime=300
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Navigate suggestion list with tab and shift-tab
inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"
" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree.
autocmd BufEnter * if winnr() == winnr('h') && bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 |
\ let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif
" Start NERDTree. If a file is specified, move the cursor to its window.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * NERDTree | if argc() > 0 || exists('s:std_in') | wincmd p | endif
let g:coc_config_home = "${coc-config}"
let g:tmux_navigator_no_mappings = 1
noremap <silent> <C-h> :<C-U>TmuxNavigateLeft<cr>
noremap <silent> <C-j> :<C-U>TmuxNavigateDown<cr>
noremap <silent> <C-k> :<C-U>TmuxNavigateUp<cr>
noremap <silent> <C-l> :<C-U>TmuxNavigateRight<cr>
augroup nixcmd
autocmd!
autocmd BufWritePre *.nix mkview
autocmd BufWritePre *.nix %!nixfmt
autocmd BufWritePost *.nix loadview
augroup END
'';
}; };
}; };
} }