2022-09-25 18:01:06 +00:00
{
config ,
pkgs ,
. . .
} : {
home . packages = with pkgs ; [ fzf fd ] ;
programs . neovim = {
enable = true ;
withNodeJs = true ;
withPython3 = true ;
extraPython3Packages = ps : with ps ; [ black isort flake8 ipdb ] ;
#extraPackages = with pkgs; [];
plugins = with pkgs . vimPlugins ; [
# tree-sitter (code parser)
( nvim-treesitter . withPlugins ( _ : pkgs . tree-sitter . allGrammars ) )
2022-09-28 01:51:29 +00:00
# git integration
gitgutter
fugitive
rhubarb
# coc plugins
coc-json
coc-yaml
coc-pyright
2022-10-02 16:54:16 +00:00
coc-spell-checker
coc-rust-analyzer
2022-09-28 01:51:29 +00:00
# tmux integration
tmux-navigator
vim-obsession
vim-nix
2022-09-25 18:01:06 +00:00
# Eye candy
nvim-web-devicons
2022-09-28 01:51:29 +00:00
# base16-vim
nvim-base16
2022-09-28 01:51:29 +00:00
2022-09-25 18:01:06 +00:00
{
2022-09-28 01:51:29 +00:00
plugin = lualine-nvim ;
type = " l u a " ;
2022-09-25 18:01:06 +00:00
config = ''
2022-09-28 01:51:29 +00:00
require ( ' lualine' ) . setup {
options = {
icons_enabled = true ,
theme = ' auto' ,
component_separators = { left = ' ' , right = ' ' } ,
section_separators = { left = ' ' , right = ' ' } ,
disabled_filetypes = {
statusline = { } ,
winbar = { } ,
} ,
ignore_focus = { } ,
always_divide_middle = true ,
globalstatus = false ,
refresh = {
statusline = 1000 ,
tabline = 1000 ,
winbar = 1000 ,
}
} ,
sections = {
lualine_a = { ' mode' } ,
lualine_b = { ' branch' , ' diff' , ' diagnostics' } ,
lualine_c = { ' filename' } ,
lualine_x = { ' encoding' , ' fileformat' , ' filetype' } ,
lualine_y = { ' progress' } ,
lualine_z = { ' location' }
} ,
inactive_sections = {
lualine_a = { } ,
lualine_b = { } ,
lualine_c = { ' filename' } ,
lualine_x = { ' location' } ,
lualine_y = { } ,
lualine_z = { }
} ,
tabline = { } ,
winbar = { } ,
inactive_winbar = { } ,
extensions = { }
}
2022-09-25 18:01:06 +00:00
'' ;
}
2022-09-28 01:51:29 +00:00
# tmux integration
tmux-navigator
2022-10-02 16:54:16 +00:00
tmuxline-vim
2022-09-28 01:51:29 +00:00
vim-obsession
vim-nix
# Telescope (fuzzy finding)
telescope-nvim # Config for this in `extraConfig` since it depends on <leader> and I override that. (Generated config places plugin config above contents of extraConfig
2022-09-25 18:01:06 +00:00
{
plugin = telescope-file-browser-nvim ;
type = " l u a " ;
config = ''
vim . api . nvim_set_keymap (
" n " ,
" < s p a c e > f b " ,
" : T e l e s c o p e f i l e _ b r o w s e r < C R > " ,
{ noremap = true }
)
require ( " t e l e s c o p e " ) . load_extension ( " f i l e _ b r o w s e r " )
'' ;
}
{
plugin = telescope-coc-nvim ;
type = " l u a " ;
config = ''
require ( " t e l e s c o p e " ) . setup ( {
extensions = {
coc = {
prefer_locations = true ;
}
}
} )
require ( " t e l e s c o p e " ) . load_extension ( " c o c " )
vim . api . nvim_set_keymap (
" n " ,
" < l e a d e r > c o c " ,
" : T e l e s c o p e c o c < C R > " ,
{ noremap = true }
)
'' ;
}
] ;
coc = {
enable = true ;
settings = ''
{
coc . preferences . formatOnSaveFiletypes " : [
" * "
] ,
python . formatting . provider " : " black "
}
'' ;
2022-09-28 01:51:29 +00:00
# Copied the below from coc's README
pluginConfig =
''
" S o m e s e r v e r s h a v e i s s u e s w i t h b a c k u p f i l e s , s e e # 6 4 9 .
set nobackup
set nowritebackup
" H a v i n g l o n g e r u p d a t e t i m e ( d e f a u l t i s 4 0 0 0 m s = 4 s ) l e a d s t o n o t i c e a b l e
" d e l a y s a n d p o o r u s e r e x p e r i e n c e .
set updatetime = 300
" A l w a y s s h o w t h e s i g n c o l u m n , o t h e r w i s e i t w o u l d s h i f t t h e t e x t e a c h t i m e
" d i a g n o s t i c s a p p e a r / b e c o m e r e s o l v e d .
set signcolumn = yes
" U s e t a b f o r t r i g g e r c o m p l e t i o n w i t h c h a r a c t e r s a h e a d a n d n a v i g a t e .
" N O T E : T h e r e ' s a l w a y s c o m p l e t e i t e m s e l e c t e d b y d e f a u l t , y o u m a y w a n t t o e n a b l e
" n o s e l e c t b y ` " suggest . noselect " : t r u e ` i n y o u r c o n f i g u r a t i o n f i l e .
" N O T E : U s e c o m m a n d ' : v e r b o s e i m a p < t a b > ' t o m a k e s u r e t a b i s n o t m a p p e d b y
" o t h e r p l u g i n b e f o r e p u t t i n g t h i s i n t o y o u r c o n f i g .
inoremap <silent> <expr> <TAB>
\ coc #pum#visible() ? coc#pum#next(1) :
\ CheckBackspace ( ) ? " \< T a b > " :
\ coc #refresh()
inoremap <expr> <S-TAB> coc #pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" M a k e < C R > t o a c c e p t s e l e c t e d c o m p l e t i o n i t e m o r n o t i f y c o c . n v i m t o f o r m a t
" < C - g > u b r e a k s c u r r e n t u n d o , p l e a s e m a k e y o u r o w n c h o i c e .
inoremap <silent> <expr> <CR> coc #pum#visible() ? coc#pum#confirm()
\ : " \< C - g > u \< C R > \< c - r > = c o c # o n _ e n t e r ( ) \< C R > "
function ! CheckBackspace ( ) abort
let col = col ( ' . ' ) - 1
return ! col || getline ( ' . ' ) [ col - 1 ] = ~ # '\s'
endfunction
" U s e < c - s p a c e > t o t r i g g e r c o m p l e t i o n .
if has ( ' nvim' )
inoremap <silent> <expr> <c-space> coc #refresh()
else
inoremap <silent> <expr> < c- @ > coc #refresh()
endif
" U s e ` [ g ` a n d ` ] g ` t o n a v i g a t e d i a g n o s t i c s
" U s e ` : C o c D i a g n o s t i c s ` t o g e t a l l d i a g n o s t i c s o f c u r r e n t b u f f e r i n l o c a t i o n l i s t .
nmap <silent> [ g <Plug> ( coc-diagnostic-prev )
nmap <silent> ] g <Plug> ( coc-diagnostic-next )
" G o T o c o d e n a v i g a t i o n .
nmap <silent> gd <Plug> ( coc-definition )
nmap <silent> gy <Plug> ( coc-type-definition )
nmap <silent> gi <Plug> ( coc-implementation )
nmap <silent> gr <Plug> ( coc-references )
" U s e K t o s h o w d o c u m e n t a t i o n i n p r e v i e w w i n d o w .
nnoremap <silent> K : call ShowDocumentation ( ) <CR>
function ! ShowDocumentation ( )
if CocAction ( ' hasProvider' , ' hover' )
call CocActionAsync ( ' doHover' )
else
call feedkeys ( ' K' , ' in' )
endif
endfunction
" H i g h l i g h t t h e s y m b o l a n d i t s r e f e r e n c e s w h e n h o l d i n g t h e c u r s o r .
autocmd CursorHold * silent call CocActionAsync ( ' highlight' )
" S y m b o l r e n a m i n g .
nmap <leader> rn <Plug> ( coc-rename )
" F o r m a t t i n g s e l e c t e d c o d e .
xmap <leader> f <Plug> ( coc-format-selected )
nmap <leader> f <Plug> ( coc-format-selected )
augroup mygroup
autocmd !
" S e t u p f o r m a t e x p r s p e c i f i e d f i l e t y p e ( s ) .
autocmd FileType typescript , json setl formatexpr = CocAction ( ' formatSelected' )
" U p d a t e s i g n a t u r e h e l p o n j u m p p l a c e h o l d e r .
autocmd User CocJumpPlaceholder call CocActionAsync ( ' showSignatureHelp' )
augroup end
" A p p l y i n g c o d e A c t i o n t o t h e s e l e c t e d r e g i o n .
" E x a m p l e : ` < l e a d e r > a a p ` f o r c u r r e n t p a r a g r a p h
xmap <leader> a <Plug> ( coc-codeaction-selected )
nmap <leader> a <Plug> ( coc-codeaction-selected )
" R e m a p k e y s f o r a p p l y i n g c o d e A c t i o n t o t h e c u r r e n t b u f f e r .
nmap <leader> ac <Plug> ( coc-codeaction )
" A p p l y A u t o F i x t o p r o b l e m o n t h e c u r r e n t l i n e .
nmap <leader> qf <Plug> ( coc-fix-current )
" R u n t h e C o d e L e n s a c t i o n o n t h e c u r r e n t l i n e .
nmap <leader> cl <Plug> ( coc-codelens-action )
" M a p f u n c t i o n a n d c l a s s t e x t o b j e c t s
" N O T E : R e q u i r e s ' t e x t D o c u m e n t . d o c u m e n t S y m b o l ' s u p p o r t f r o m t h e l a n g u a g e s e r v e r .
xmap if <Plug> ( coc-funcobj-i )
omap if <Plug> ( coc-funcobj-i )
xmap af <Plug> ( coc-funcobj-a )
omap af <Plug> ( coc-funcobj-a )
xmap ic <Plug> ( coc-classobj-i )
omap ic <Plug> ( coc-classobj-i )
xmap ac <Plug> ( coc-classobj-a )
omap ac <Plug> ( coc-classobj-a )
" R e m a p < C - f > a n d < C - b > f o r s c r o l l f l o a t w i n d o w s / p o p u p s .
if has ( ' nvim-0 .4 . 0 ' ) || has ( ' patch-8 .2 . 0 7 5 0 ' )
nnoremap <silent> <nowait> <expr> <C-f> coc #float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
nnoremap <silent> <nowait> <expr> <C-b> coc #float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
inoremap <silent> <nowait> <expr> <C-f> coc #float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>"
inoremap <silent> <nowait> <expr> <C-b> coc #float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>"
vnoremap <silent> <nowait> <expr> <C-f> coc #float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
vnoremap <silent> <nowait> <expr> <C-b> coc #float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif
" U s e C T R L - S f o r s e l e c t i o n s r a n g e s .
" R e q u i r e s ' t e x t D o c u m e n t / s e l e c t i o n R a n g e ' s u p p o r t o f l a n g u a g e s e r v e r .
nmap <silent> <C-s> <Plug> ( coc-range-select )
xmap <silent> <C-s> <Plug> ( coc-range-select )
" A d d ` : F o r m a t ` c o m m a n d t o f o r m a t c u r r e n t b u f f e r .
command ! - nargs = 0 Format : call CocActionAsync ( ' format' )
" A d d ` : F o l d ` c o m m a n d t o f o l d c u r r e n t b u f f e r .
command ! - nargs = ? Fold : call CocAction ( ' fold' , <f-args> )
" A d d ` : O R ` c o m m a n d f o r o r g a n i z e i m p o r t s o f t h e c u r r e n t b u f f e r .
command ! - nargs = 0 OR : call CocActionAsync ( ' runCommand' , ' editor . action . organizeImport' )
" A d d ( N e o ) V i m ' s n a t i v e s t a t u s l i n e s u p p o r t .
" N O T E : P l e a s e s e e ` : h c o c - s t a t u s ` f o r i n t e g r a t i o n s w i t h e x t e r n a l p l u g i n s t h a t
" p r o v i d e c u s t o m s t a t u s l i n e : l i g h t l i n e . v i m , v i m - a i r l i n e .
set statusline ^ = % { coc #status()}%{get(b:,'coc_current_function',''
+ " ' ' "
+ '' ) }
2022-09-28 01:51:29 +00:00
" M a p p i n g s f o r C o C L i s t
" S h o w a l l d i a g n o s t i c s .
nnoremap <silent> <nowait> <space> a : <C-u> CocList diagnostics <cr>
" M a n a g e e x t e n s i o n s .
nnoremap <silent> <nowait> <space> e : <C-u> CocList extensions <cr>
" S h o w c o m m a n d s .
nnoremap <silent> <nowait> <space> c : <C-u> CocList commands <cr>
" F i n d s y m b o l o f c u r r e n t d o c u m e n t .
nnoremap <silent> <nowait> <space> o : <C-u> CocList outline <cr>
" S e a r c h w o r k s p a c e s y m b o l s .
nnoremap <silent> <nowait> <space> s : <C-u> CocList - I symbols <cr>
" D o d e f a u l t a c t i o n f o r n e x t i t e m .
nnoremap <silent> <nowait> <space> j : <C-u> CocNext <CR>
" D o d e f a u l t a c t i o n f o r p r e v i o u s i t e m .
nnoremap <silent> <nowait> <space> k : <C-u> CocPrev <CR>
" R e s u m e l a t e s t c o c l i s t .
nnoremap <silent> <nowait> <space> p : <C-u> CocListResume <CR>
''
# The below is custom and did not come from coc's README
+ ''
" G o T o c o d e n a v i g a t i o n .
nmap <silent> gd <Plug> ( coc-definition )
nmap <silent> gs : call CocAction ( ' jumpDefinition' , ' split' ) <CR>
nmap <silent> gv : call CocAction ( ' jumpDefinition' , ' vsplit' ) <CR>
nmap <silent> gn : call CocAction ( ' jumpDefinition' , ' tabe' ) <CR>
nmap <silent> gy <Plug> ( coc-type-definition )
nmap <silent> gi <Plug> ( coc-implementation )
nmap <silent> gr <Plug> ( coc-references )
2022-09-28 01:51:29 +00:00
'' ;
2022-09-25 18:01:06 +00:00
} ;
extraConfig = ''
2022-09-28 01:51:29 +00:00
set tabstop = 4
set shiftwidth = 4
set mouse = a
set expandtab
set number
set autoindent
syntax on
let mapleader = " ` "
2022-09-25 18:01:06 +00:00
2022-09-28 01:51:29 +00:00
" E y e C a n d y ( s e l e c t s t h e m e a n d s e t s u p t r a n s p a r e n c y )
colorscheme base16-darktooth
hi Normal guibg = none ctermbg = none
hi NormalNC guibg = NONE
hi LineNr guibg = none ctermbg = none
hi Folded guibg = none ctermbg = none
hi NonText guibg = none ctermbg = none
hi SpecialKey guibg = none ctermbg = none
hi VertSplit guibg = none ctermbg = none
hi SignColumn guibg = none ctermbg = none
hi EndOfBuffer guibg = none ctermbg = none
2022-09-28 01:51:29 +00:00
2022-10-02 16:54:16 +00:00
" T o g g l e l i n e h i g h l i g h t i n g b a s e d o n f o c u s
autocmd BufEnter * setlocal cursorline
autocmd BufLeave * setlocal nocursorline
2022-09-28 01:51:29 +00:00
" T o g g l e r e l a t i v e l i n e n u m b e r s
nmap <leader> num : set invrelativenumber <CR>
" B i n d i n g s f o r t e l e s c o p e - n v i m
nnoremap <leader> ff <cmd> lua require ( ' telescope . builtin' ) . find_files ( ) <cr>
nnoremap <leader> fg <cmd> lua require ( ' telescope . builtin' ) . live_grep ( ) <cr>
nnoremap <leader> fb <cmd> lua require ( ' telescope . builtin' ) . buffers ( ) <cr>
nnoremap <leader> fh <cmd> lua require ( ' telescope . builtin' ) . help_tags ( ) <cr>
2022-09-28 01:51:29 +00:00
" c o c
nnoremap <Leader> cmd : CocCommand <CR>
nnoremap <Leader> cfg : CocConfig <CR>
nnoremap <Leader> def : call CocAction ( ' jumpDefinition' ) <CR>
nnoremap <Leader> fmt : call CocActionAsync ( ' format' ) <CR>
2022-10-02 16:54:16 +00:00
vmap <leader> a <Plug> ( coc-codeaction-selected )
nmap <leader> a <Plug> ( coc-codeaction-selected )
2022-09-28 01:51:29 +00:00
" r h u b a r b
noremap <Leader> bro : GBrowse <CR>
" T a b c o m p l e t i o n
set wildmode = longest , list , full
set wildmenu
2022-09-25 18:01:06 +00:00
'' ;
} ;
}