home: Add neovim
This commit is contained in:
parent
c5e32b564b
commit
f934caa993
|
@ -37,6 +37,7 @@ in
|
|||
./modules/htop.nix
|
||||
./modules/misc.nix
|
||||
./modules/mpd.nix
|
||||
./modules/neovim.nix
|
||||
./modules/sway.nix
|
||||
./modules/xcompose.nix
|
||||
./modules/xdg.nix
|
||||
|
|
7
users/simon/files/nvim/UltiSnips/rust.snippets
Normal file
7
users/simon/files/nvim/UltiSnips/rust.snippets
Normal file
|
@ -0,0 +1,7 @@
|
|||
snippet disp "Display trait implentation"
|
||||
impl fmt::Display for ${1:Struct} {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "${2}", ${3})
|
||||
}
|
||||
}${0}
|
||||
endsnippet
|
19
users/simon/files/nvim/UltiSnips/tex.snippets
Normal file
19
users/simon/files/nvim/UltiSnips/tex.snippets
Normal file
|
@ -0,0 +1,19 @@
|
|||
extends tex
|
||||
|
||||
snippet s "Section" b
|
||||
\section{$1}
|
||||
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet ss "Subsection" b
|
||||
\subsection{$1}
|
||||
|
||||
|
||||
endsnippet
|
||||
|
||||
snippet sss "Subsubsection" b
|
||||
\subsubsection{$1}
|
||||
|
||||
|
||||
endsnippet
|
23
users/simon/files/nvim/UltiSnips/texmath.snippets
Normal file
23
users/simon/files/nvim/UltiSnips/texmath.snippets
Normal file
|
@ -0,0 +1,23 @@
|
|||
extends texmath
|
||||
|
||||
snippet qf "Quadratic formula (user is responsible for parentheses)" w
|
||||
\frac{-${2:b} \pm \sqrt{$2^2 - 4 \cdot ${1:a} \cdot ${3:c}}}{2 \cdot $1}$0
|
||||
endsnippet
|
||||
|
||||
snippet aligned "aligned environment (in math mode)" w
|
||||
\begin{aligned}
|
||||
$1 &= $0 \\\\
|
||||
\end{aligned}
|
||||
endsnippet
|
||||
|
||||
snippet si "Insert SI unit (only works with simple numbers)" w
|
||||
\SI{${1:amount}}{${2:unit}}
|
||||
endsnippet
|
||||
|
||||
snippet · "Insert multiplication sign" A
|
||||
\cdot $0
|
||||
endsnippet
|
||||
|
||||
snippet // "Fraction" iA
|
||||
\frac{$1}{$2}$0
|
||||
endsnippet
|
234
users/simon/modules/neovim.nix
Normal file
234
users/simon/modules/neovim.nix
Normal file
|
@ -0,0 +1,234 @@
|
|||
{ config, pkgs, ... }:
|
||||
let
|
||||
languageClientSettings = pkgs.writeText "LanguageClient.json" (builtins.toJSON {
|
||||
rust.clippy_preference = "on";
|
||||
});
|
||||
rainbow_csv = pkgs.vimUtils.buildVimPluginFrom2Nix rec {
|
||||
name = "rainbow_csv";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "mechatroner";
|
||||
repo = name;
|
||||
rev = "df89266d6c03479def77793fd7a0a651986865a5";
|
||||
sha256 = "0c9b1r49vw6r3yhm6g02janyxw6d9j6bkjmv8zpdav46avmk74fh";
|
||||
};
|
||||
};
|
||||
vim-openscad = pkgs.vimUtils.buildVimPluginFrom2Nix rec {
|
||||
name = "vim-openscad";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "sirtaj";
|
||||
repo = name;
|
||||
rev = "81db508b1888fdbea994d43ccef1acd86c8af3f7";
|
||||
sha256 = "1wcdfayjpb9h0lzwdi5nda4c0ch263fdr0379l9k1gf47bgq9cx2";
|
||||
};
|
||||
};
|
||||
Vim-Jinja2-Syntax = pkgs.vimUtils.buildVimPluginFrom2Nix rec {
|
||||
name = "Vim-Jinja2-Syntax";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "Glench";
|
||||
repo = name;
|
||||
rev = "5d2496eb5fd4415c7ce062ccbcd53a3f0de93aa3";
|
||||
sha256 = "1ss065b2psalli46bs3v13fhaplqydh13bg3jg3zr98wbdn70cws";
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
" Basic display
|
||||
set number
|
||||
set colorcolumn=80
|
||||
|
||||
" Persistent undo
|
||||
set undofile
|
||||
set undolevels=4096
|
||||
set undoreload=16384
|
||||
|
||||
" Search
|
||||
set ignorecase
|
||||
|
||||
" Hide search when enter is pressed
|
||||
nnoremap <silent> <CR> :nohlsearch<CR>
|
||||
|
||||
" Autoload settings from file
|
||||
set modeline
|
||||
|
||||
" Use system clipboard
|
||||
set clipboard=unnamedplus
|
||||
|
||||
" Support more file encodings
|
||||
set fileencodings=ucs-bom,utf-8,default,sjis,latin1
|
||||
|
||||
" Scroll before reaching top/bottom
|
||||
set scrolloff=5
|
||||
|
||||
" Conceal when line is not active
|
||||
set conceallevel=1
|
||||
|
||||
" Just hide buffer instead of unloading
|
||||
set hidden
|
||||
|
||||
" Remap leader key
|
||||
let mapleader = ","
|
||||
|
||||
" Jump to the last position
|
||||
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
|
||||
\| exe "normal! g`\"" | endif
|
||||
|
||||
set background=dark
|
||||
silent! colorscheme solarized
|
||||
|
||||
" Set unknown filetypes
|
||||
autocmd BufRead,BufNewFile *.vpy set filetype=python
|
||||
|
||||
" Filetype specific properties
|
||||
autocmd Filetype arduino setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype c setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype cpp setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype css setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype dockerfile setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype dot setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype gitcommit setlocal colorcolumn=72
|
||||
autocmd Filetype go setlocal ts=4 sw=4 sts=4
|
||||
autocmd Filetype haskell setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype html setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype jinja.html setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype javascript setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype jinja setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype json setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype lua setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype markdown setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype openscad setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype python setlocal ts=4 sw=4 sts=4 expandtab
|
||||
autocmd Filetype sass setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype scss setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype sh setlocal ts=4 sw=4 sts=4
|
||||
autocmd Filetype tex setlocal ts=1 sw=1 sts=1 expandtab
|
||||
autocmd Filetype toml setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype vim setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype vue setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype xml setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype yaml setlocal ts=2 sw=2 sts=2 expandtab
|
||||
autocmd Filetype zsh setlocal ts=4 sw=4 sts=4 expandtab
|
||||
'';
|
||||
plugins = (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = LanguageClient-neovim;
|
||||
config = ''
|
||||
let g:LanguageClient_serverCommands = {
|
||||
\ 'rust': ['rustup', 'run', 'stable', 'rls'],
|
||||
\ 'go': ['${pkgs.gopls}/bin/gopls'],
|
||||
\ 'python': ['${pkgs.python3Packages.python-language-server}/bin/pyls'],
|
||||
\ 'typescript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'],
|
||||
\ 'javascript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'],
|
||||
\ 'haskell': ['${pkgs.haskellPackages.haskell-language-server}/bin/haskell-language-server', '--lsp'],
|
||||
\ }
|
||||
|
||||
let g:LanguageClient_loggingFile = '${config.xdg.dataHome}/nvim/LanguageClient.log'
|
||||
let g:LanguageClient_settingsPath = '${languageClientSettings}'
|
||||
|
||||
function LC_maps()
|
||||
if has_key(g:LanguageClient_serverCommands, &filetype)
|
||||
nnoremap <buffer> <silent> <F5> :call LanguageClient_contextMenu()<CR>
|
||||
nnoremap <buffer> <silent> K :call LanguageClient#textDocument_hover()<CR>
|
||||
nnoremap <buffer> <silent> gd :call LanguageClient#textDocument_definition()<CR>
|
||||
nnoremap <buffer> <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
|
||||
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd FileType * call LC_maps()
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = deoplete-nvim;
|
||||
config = ''
|
||||
let g:deoplete#enable_at_startup = 1
|
||||
'';
|
||||
}
|
||||
editorconfig-vim
|
||||
fzf-vim
|
||||
{
|
||||
plugin = nerdtree;
|
||||
config = ''
|
||||
map <Leader>N :NERDTreeTabsToggle<CR>
|
||||
map <Leader>n :NERDTreeFocusToggle<CR>
|
||||
'';
|
||||
}
|
||||
nerdtree-git-plugin
|
||||
{
|
||||
plugin = rust-vim;
|
||||
config = ''
|
||||
let g:rustfmt_autosave_if_config_present = 1
|
||||
let g:rust_fold = 1
|
||||
map <Leader>rt :RustTest<CR>
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = tagbar;
|
||||
config = "nmap <F8> :TagbarToggle<CR>";
|
||||
}
|
||||
{
|
||||
plugin = ultisnips;
|
||||
config = ''
|
||||
let g:UltiSnipsExpandTrigger = '<tab>'
|
||||
let g:UltiSnipsJumpForwardTrigger = '<tab>'
|
||||
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
|
||||
'';
|
||||
}
|
||||
{
|
||||
plugin = vim-airline;
|
||||
config = ''
|
||||
let g:airline_powerline_fonts = 1
|
||||
let g:airline_solarized_bg='dark'
|
||||
let g:airline_theme='solarized'
|
||||
'';
|
||||
}
|
||||
vim-airline-themes
|
||||
vim-better-whitespace
|
||||
vim-colors-solarized
|
||||
vim-devicons
|
||||
vim-fugitive
|
||||
vim-nerdtree-tabs
|
||||
vim-nix
|
||||
vim-snippets
|
||||
vim-toml
|
||||
{
|
||||
plugin = vimtex;
|
||||
config = ''
|
||||
let g:tex_flavor='latex'
|
||||
let g:vimtex_view_method='zathura'
|
||||
let g:tex_conceal='abdmg'
|
||||
let g:vimtex_syntax_autoload_packages = [
|
||||
\'amsmath',
|
||||
\'luacode',
|
||||
\]
|
||||
" this disables some helful warnings that often have a reason why I ignore them
|
||||
let g:vimtex_quickfix_ignore_filters = [
|
||||
\'Underfull \\hbox (badness [0-9]*) in ',
|
||||
\'Overfull \\hbox ([0-9]*.[0-9]*pt too wide) in ',
|
||||
\'Overfull \\vbox ([0-9]*.[0-9]*pt too high) detected ',
|
||||
\'Package hyperref Warning: Token not allowed in a PDF string',
|
||||
\'Package typearea Warning: Bad type area settings!',
|
||||
\]
|
||||
" When using math environments vim does not know if if it currently is in one
|
||||
" or outside of one unless it parses the file from the start. Parsing the
|
||||
" file from the start each time fixes this but leads to a performance drop
|
||||
" (depending on the number of lines).
|
||||
" Also, somehow using FileType tex does not work, so this will enable slow
|
||||
" syntax highlighting everywhere once a *.tex file is opened.
|
||||
autocmd BufEnter *.tex syntax sync fromstart
|
||||
'';
|
||||
}
|
||||
]) ++ [
|
||||
Vim-Jinja2-Syntax
|
||||
rainbow_csv
|
||||
vim-openscad
|
||||
];
|
||||
# TODO: add psf/black
|
||||
};
|
||||
|
||||
xdg.configFile = {
|
||||
"nvim/UltiSnips".source = ../files/nvim/UltiSnips;
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue