diff --git a/gnu.emacs.daemon.plist b/gnu.emacs.daemon.plist deleted file mode 100644 index 767070d..0000000 --- a/gnu.emacs.daemon.plist +++ /dev/null @@ -1,21 +0,0 @@ - - - - - KeepAlive - - Label - gnu.emacs.daemon - ProgramArguments - - /Applications/Emacs.app/Contents/MacOS/Emacs - --daemon - - RunAtLoad - - UserName - salar - - - diff --git a/home.nix b/home.nix index 0e6d0f6..816f245 100644 --- a/home.nix +++ b/home.nix @@ -4,22 +4,16 @@ # Let Home Manager install and manage itself. programs.home-manager.enable = true; - home.username = "salar"; - home.homeDirectory = "/Users/salar"; + imports = (import ./programs); - # This value determines the Home Manager release that your - # configuration is compatible with. This helps avoid breakage - # when a new Home Manager release introduces backwards - # incompatible changes. - # - # You can update Home Manager without changing this value. See - # the Home Manager release notes for a list of state version - # changes in each release. - home.stateVersion = "21.05"; - - home.sessionVariables = { - EDITOR = "nvim"; - VISUAL = "$EDITOR"; + home = { + username = "salar"; + homeDirectory = "/Users/salar"; + stateVersion = "21.05"; + sessionVariables = { + EDITOR = "nvim"; + VISUAL = "$EDITOR"; + }; }; programs.bat = { @@ -43,52 +37,6 @@ gitProtocol = "ssh"; }; - programs.git = { - enable = true; - userEmail = "code@softinio.com"; - userName = "Salar Rahmanian"; - ignores = [ - "*~" - ".DS_Store" - "*.bloop" - "*.metals" - "*.metals.sbt" - "*metals.sbt" - "*.direnv" - "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide - "*hie.yaml" # ghcide files - "*.mill-version" # used by metals - "*.idea" - "*.vscode" - "*.python-version" - ]; - extraConfig = { - core = { - editor = "nvim"; - }; - github.user = "softinio"; - merge.tool = "intellij"; - mergetool = { - cmd = "idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""; - trustExitCode = true; - prompt = false; - }; - diff.tool = "intellij"; - difftool = { - cmd = "idea diff \"$LOCAL\" \"$REMOTE\""; - prompt = false; - }; - url = { - "git@github.com:" = { - insteadOf = "https://github.com/"; - }; - }; - pull = { - rebase = true; - }; - }; - }; - programs.htop = { enable = true; sortDescending = true; @@ -106,319 +54,6 @@ }; }; - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - withNodeJs = true; - plugins = with pkgs.vimPlugins; [ - ack-vim - auto-pairs - coc-nvim - coc-java - coc-json - coc-metals - coc-python - coc-tabnine - fzf-vim - git-messenger-vim - lightline-vim - nerdtree - nerdtree-git-plugin - rainbow - seoul256-vim - split-term-vim - vim-fugitive - vim-gitgutter - vim-polyglot - ]; - extraConfig = '' - set directory=$HOME/.vim/swapfiles/swap// - set undodir=~/.vim/swapfiles/undo// - set backupdir=~/.vim/swapfiles/backup// - " Make those folders automatically if they don't already exist. - if !isdirectory(expand(&undodir)) - call mkdir(expand(&undodir), "p") - endif - if !isdirectory(expand(&backupdir)) - call mkdir(expand(&backupdir), "p") - endif - if !isdirectory(expand(&directory)) - call mkdir(expand(&directory), "p") - endif - set t_Co=256 - set encoding=utf-8 - syntax on - set expandtab - set hidden - set showmatch - set colorcolumn=120 - set cursorcolumn - set cursorline - set cmdheight=2 - set smarttab - set linebreak - set hlsearch - set ignorecase - set incsearch - set guifont=SF\ Mono:h12 - set termguicolors - let g:clipboard = { - \ 'name': 'pbcopy', - \ 'copy': { - \ '+': 'pbcopy', - \ '*': 'pbcopy', - \ }, - \ 'paste': { - \ '+': 'pbpaste', - \ '*': 'pbpaste', - \ }, - \ 'cache_enabled': 0, - \ } - set clipboard=unnamed - let $NVIM_TUI_ENABLE_TRUE_COLOR=1 - let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 - let g:seoul256_background = 233 - let g:seoul256_srgb = 1 - colorscheme seoul256 - set background=dark - set number - let g:netrw_banner=0 " disable annoying banner - let g:netrw_browse_split=4 " open in prior window - let g:netrw_altv=1 " open splits to the right - let g:netrw_liststyle=3 " tree view - let g:netrw_list_hide=netrw_gitignore#Hide() - let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' - let g:netrw_list_hide= '.*\.pyc$' - au BufRead,BufNewFile *.sbt set filetype=scala - if executable("rg") - set grepprg=rg\ --vimgrep\ --no-heading - set grepformat=%f:%l:%c:%m,%f:%l:%m - endif - let g:ackprg='rg --vimgrep --no-heading' - set grepprg=rg\ --vimgrep - let g:rg_command = 'rg --vimgrep -S' - let mapleader = "\" - map! jj - " FZF - set rtp+=/Users/salar/.nix-profile/bin/fzf - imap (fzf-complete-line) - map b :Buffers - map f :Files - map g :GFiles - map y :Tags - autocmd! FileType fzf tnoremap q - nnoremap :FZF - - let g:rainbow_active = 1 - let g:rainbow_conf = { - \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], - \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], - \ 'operators': '_,_', - \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], - \ 'separately': { - \ '*': {}, - \ 'tex': { - \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], - \ }, - \ 'lisp': { - \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], - \ }, - \ 'vim': { - \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], - \ }, - \ 'html': { - \ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=## fold'], - \ }, - \ 'css': 0, - \ } - \} - let g:lightline = { - \ 'colorscheme': 'seoul256', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ], - \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] - \ }, - \ 'component_function': { - \ 'gitbranch': 'FugitiveHead' - \ }, - \ } - - " Nerdtree Configuration - let NERDTreeIgnore=['\.pyc$', '\~$', 'target'] "ignore files in NERDTree - let NERDTreeRespectWildIgnore=1 - let NERDTreeQuitOnOpen=1 - map m :NERDTreeToggle - " jump back to nerdtree - map n :NERDTree - " reveal in side bar - map e :NERDTreeFind - let NERDTreeShowHidden=1 - "nerdtree-git-plugin - let g:NERDTreeGitStatusIndicatorMapCustom= { - \ "Modified" : "✹", - \ "Staged" : "✚", - \ "Untracked" : "✭", - \ "Renamed" : "➜", - \ "Unmerged" : "═", - \ "Deleted" : "✖", - \ "Dirty" : "✗", - \ "Clean" : "✔︎", - \ "Unknown" : "?" - \ } - - " Switch to previous buffer mapped to tab - function SwitchBuffer() - b# - endfunction - - nmap :call SwitchBuffer() - - " split-term - let g:split_term_default_shell = "fish" - let g:split_term_vertical = 1 - - " START Configuration for coc.nvim - " -------------------------------- - " Better display for messages - set cmdheight=2 - - " You will have bad experience for diagnostic messages when it's default 4000. - set updatetime=300 - - " don't give |ins-completion-menu| messages. - set shortmess+=c - - " always show signcolumns - set signcolumn=yes - - " Use tab for trigger completion with characters ahead and navigate. - " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. - inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() - inoremap pumvisible() ? "\" : "\" - - function! s:check_back_space() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' - endfunction - - " Use to trigger completion. - inoremap coc#refresh() - - " Use to confirm completion, `u` means break undo chain at current position. - " Coc only does snippet and additional edit on confirm. - inoremap pumvisible() ? "\" : "\u\" - " Or use `complete_info` if your vim support it, like: - " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" - - " Use `[g` and `]g` to navigate diagnostics - nmap [g (coc-diagnostic-prev) - nmap ]g (coc-diagnostic-next) - - " Remap keys for gotos - nmap gd (coc-definition) - nmap gy (coc-type-definition) - nmap gi (coc-implementation) - nmap gr (coc-references) - - " Use K to show documentation in preview window - nnoremap K :call show_documentation() - - function! s:show_documentation() - if (index(['vim','help'], &filetype) >= 0) - execute 'h '.expand('') - else - call CocAction('doHover') - endif - endfunction - - " Highlight symbol under cursor on CursorHold - autocmd CursorHold * silent call CocActionAsync('highlight') - - " Remap for rename current word - nmap rn (coc-rename) - - " Remap for format selected region - xmap l (coc-format-selected) - nmap l (coc-format-selected) - - augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s). - autocmd FileType typescript,json,scala setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') - augroup end - - " Remap for do codeAction of selected region, ex: `aap` for current paragraph - xmap a (coc-codeaction-selected) - nmap a (coc-codeaction-selected) - - " Remap for do codeAction of current line - nmap ac (coc-codeaction) - " Fix autofix problem of current line - nmap qf (coc-fix-current) - - " Create mappings for function text object, requires document symbols feature of languageserver. - xmap if (coc-funcobj-i) - xmap af (coc-funcobj-a) - omap if (coc-funcobj-i) - omap af (coc-funcobj-a) - - " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python - nmap (coc-range-select) - xmap (coc-range-select) - - " Use `:Format` to format current buffer - command! -nargs=0 Format :call CocAction('format') - - " Use `:Fold` to fold current buffer - command! -nargs=? Fold :call CocAction('fold', ) - - " use `:OR` for organize import of current buffer - command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') - - " Using CocList - " Show all diagnostics - nnoremap a :CocList diagnostics - " Manage extensions - nnoremap e :CocList extensions - " Show commands - nnoremap c :CocList commands - " Find symbol of current document - nnoremap o :CocList outline - " Search workspace symbols - nnoremap s :CocList -I symbols - " Do default action for next item. - nnoremap j :CocNext - " Do default action for previous item. - nnoremap k :CocPrev - " Resume latest coc list - nnoremap p :CocListResume - - " Notify coc.nvim that has been pressed. - " Currently used for the formatOnType feature. - inoremap pumvisible() ? coc#_select_confirm() - \: "\u\\=coc#on_enter()\" - - " Toggle panel with Tree Views - nnoremap t :CocCommand metals.tvp - " Toggle Tree View 'metalsBuild' - nnoremap tb :CocCommand metals.tvp metalsBuild - " Toggle Tree View 'metalsCompile' - nnoremap tc :CocCommand metals.tvp metalsCompile - " Reveal current current class (trait or object) in Tree View 'metalsBuild' - nnoremap tf :CocCommand metals.revealInTreeView metalsBuild - - nmap ws (coc-metals-expand-decoration) - - ''; - }; - programs.fish = { enable = true; diff --git a/programs/default.nix b/programs/default.nix new file mode 100644 index 0000000..e087349 --- /dev/null +++ b/programs/default.nix @@ -0,0 +1,4 @@ +[ + ./git + ./neovim +] diff --git a/programs/git/default.nix b/programs/git/default.nix new file mode 100644 index 0000000..4b10a8f --- /dev/null +++ b/programs/git/default.nix @@ -0,0 +1,52 @@ +{ config, pkgs, ... }: + +let + gitConfig = { + core = { + editor = "nvim"; + pager = "diff-so-fancy | less --tabs=4 -RFX"; + }; + merge.tool = "intellij"; + mergetool = { + cmd = "idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""; + trustExitCode = true; + prompt = false; + }; + diff.tool = "intellij"; + difftool = { + cmd = "idea diff \"$LOCAL\" \"$REMOTE\""; + prompt = false; + }; + url = { + "git@github.com:" = { + insteadOf = "https://github.com/"; + }; + }; + pull = { + rebase = true; + }; + }; +in +{ + programs.git = { + enable = true; + userEmail = "code@softinio.com"; + userName = "Salar Rahmanian"; + ignores = [ + "*~" + ".DS_Store" + "*.bloop" + "*.metals" + "*.metals.sbt" + "*metals.sbt" + "*.direnv" + "*.envrc" # there is lorri, nix-direnv & simple direnv; let people decide + "*hie.yaml" # ghcide files + "*.mill-version" # used by metals + "*.idea" + "*.vscode" + "*.python-version" + ]; + extraConfig = gitConfig; + }; +} diff --git a/programs/neovim/coc-settings.nix b/programs/neovim/coc-settings.nix new file mode 100644 index 0000000..358d3cf --- /dev/null +++ b/programs/neovim/coc-settings.nix @@ -0,0 +1,8 @@ +{ + "languageserver" = { + "nix" = { + "command" = "rnix-lsp"; + "filetypes" = [ "nix" ]; + }; + }; +} diff --git a/programs/neovim/coc.vim b/programs/neovim/coc.vim new file mode 100644 index 0000000..1428def --- /dev/null +++ b/programs/neovim/coc.vim @@ -0,0 +1,138 @@ +" START Configuration for coc.nvim +" -------------------------------- +" Better display for messages +set cmdheight=2 + +" You will have bad experience for diagnostic messages when it's default 4000. +set updatetime=300 + +" don't give |ins-completion-menu| messages. +set shortmess+=c + +" always show signcolumns +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate. +" Use command ':verbose imap ' to make sure tab is not mapped by other plugin. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current position. +" Coc only does snippet and additional edit on confirm. +inoremap pumvisible() ? "\" : "\u\" +" Or use `complete_info` if your vim support it, like: +" inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" + +" Use `[g` and `]g` to navigate diagnostics +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" Remap keys for gotos +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" Highlight symbol under cursor on CursorHold +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Remap for rename current word +nmap rn (coc-rename) + +" Remap for format selected region +xmap l (coc-format-selected) +nmap l (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json,scala setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Remap for do codeAction of selected region, ex: `aap` for current paragraph +xmap a (coc-codeaction-selected) +nmap a (coc-codeaction-selected) + +" Remap for do codeAction of current line +nmap ac (coc-codeaction) +" Fix autofix problem of current line +nmap qf (coc-fix-current) + +" Create mappings for function text object, requires document symbols feature of languageserver. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Use for select selections ranges, needs server support, like: coc-tsserver, coc-python +nmap (coc-range-select) +xmap (coc-range-select) + +" Use `:Format` to format current buffer +command! -nargs=0 Format :call CocAction('format') + +" Use `:Fold` to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" use `:OR` for organize import of current buffer +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Using CocList +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item. +nnoremap j :CocNext +" Do default action for previous item. +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume + +" Notify coc.nvim that has been pressed. +" Currently used for the formatOnType feature. +inoremap pumvisible() ? coc#_select_confirm() + \: "\u\\=coc#on_enter()\" + +" Toggle panel with Tree Views +nnoremap t :CocCommand metals.tvp +" Toggle Tree View 'metalsBuild' +nnoremap tb :CocCommand metals.tvp metalsBuild +" Toggle Tree View 'metalsCompile' +nnoremap tc :CocCommand metals.tvp metalsCompile +" Reveal current current class (trait or object) in Tree View 'metalsBuild' +nnoremap tf :CocCommand metals.revealInTreeView metalsBuild + +nmap ws (coc-metals-expand-decoration) + + diff --git a/programs/neovim/config.vim b/programs/neovim/config.vim new file mode 100644 index 0000000..6cbbb64 --- /dev/null +++ b/programs/neovim/config.vim @@ -0,0 +1,154 @@ +set directory=$HOME/.vim/swapfiles/swap// +set undodir=~/.vim/swapfiles/undo// +set backupdir=~/.vim/swapfiles/backup// +" Make those folders automatically if they don't already exist. +if !isdirectory(expand(&undodir)) + call mkdir(expand(&undodir), "p") +endif +if !isdirectory(expand(&backupdir)) + call mkdir(expand(&backupdir), "p") +endif +if !isdirectory(expand(&directory)) + call mkdir(expand(&directory), "p") +endif +set t_Co=256 +set encoding=utf-8 +syntax on +set expandtab +set hidden +set showmatch +set colorcolumn=120 +set cursorcolumn +set cursorline +set cmdheight=2 +set smarttab +set linebreak +set hlsearch +set ignorecase +set incsearch +set guifont=SF\ Mono:h12 +set termguicolors +let g:clipboard = { + \ 'name': 'pbcopy', + \ 'copy': { + \ '+': 'pbcopy', + \ '*': 'pbcopy', + \ }, + \ 'paste': { + \ '+': 'pbpaste', + \ '*': 'pbpaste', + \ }, + \ 'cache_enabled': 0, + \ } +set clipboard=unnamed +let $NVIM_TUI_ENABLE_TRUE_COLOR=1 +let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 +let g:seoul256_background = 233 +let g:seoul256_srgb = 1 +colorscheme seoul256 +set background=dark +set number +let g:netrw_banner=0 " disable annoying banner +let g:netrw_browse_split=4 " open in prior window +let g:netrw_altv=1 " open splits to the right +let g:netrw_liststyle=3 " tree view +let g:netrw_list_hide=netrw_gitignore#Hide() +let g:netrw_list_hide.=',\(^\|\s\s\)\zs\.\S\+' +let g:netrw_list_hide= '.*\.pyc$' +au BufRead,BufNewFile *.sbt set filetype=scala +if executable("rg") + set grepprg=rg\ --vimgrep\ --no-heading + set grepformat=%f:%l:%c:%m,%f:%l:%m +endif +let g:ackprg='rg --vimgrep --no-heading' +set grepprg=rg\ --vimgrep +let g:rg_command = 'rg --vimgrep -S' +let mapleader = "\" +map! jj +" FZF +set rtp+=/Users/salar/.nix-profile/bin/fzf +imap (fzf-complete-line) +map b :Buffers +map f :Files +map g :GFiles +map y :Tags +autocmd! FileType fzf tnoremap q +nnoremap :FZF + +let g:rainbow_active = 1 +let g:rainbow_conf = { + \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], + \ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'], + \ 'operators': '_,_', + \ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'], + \ 'separately': { + \ '*': {}, + \ 'tex': { + \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'], + \ }, + \ 'lisp': { + \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'], + \ }, + \ 'vim': { + \ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'], + \ }, + \ 'html': { + \ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=## fold'], + \ }, + \ 'css': 0, + \ } + \} + let g:lightline = { + \ 'colorscheme': 'seoul256', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'gitbranch': 'FugitiveHead' + \ }, + \ } + +" Nerdtree Configuration +let NERDTreeIgnore=['\.pyc$', '\~$', 'target'] "ignore files in NERDTree +let NERDTreeRespectWildIgnore=1 +let NERDTreeQuitOnOpen=1 +map m :NERDTreeToggle +" jump back to nerdtree +map n :NERDTree +" reveal in side bar +map e :NERDTreeFind +let NERDTreeShowHidden=1 +"nerdtree-git-plugin +let g:NERDTreeGitStatusIndicatorMapCustom= { + \ "Modified" : "✹", + \ "Staged" : "✚", + \ "Untracked" : "✭", + \ "Renamed" : "➜", + \ "Unmerged" : "═", + \ "Deleted" : "✖", + \ "Dirty" : "✗", + \ "Clean" : "✔︎", + \ "Unknown" : "?" + \ } + +" Switch to previous buffer mapped to tab +function SwitchBuffer() + b# +endfunction + +nmap :call SwitchBuffer() + +" split-term +let g:split_term_default_shell = "fish" +let g:split_term_vertical = 1 + +" mkdx settings +let g:mkdx#settings = { 'highlight': { 'enable': 1 }, + \ 'enter': { 'shift': 1 }, + \ 'links': { 'external': { 'enable': 1 } }, + \ 'toc': { 'text': 'Table of Contents', 'update_on_write': 1 }, + \ 'fold': { 'enable': 1 } } +let g:polyglot_disabled = ['markdown'] + + diff --git a/programs/neovim/custom-plugins.nix b/programs/neovim/custom-plugins.nix new file mode 100644 index 0000000..e2001ff --- /dev/null +++ b/programs/neovim/custom-plugins.nix @@ -0,0 +1,12 @@ +{ buildVimPlugin }: + +{ + asyncrun-vim = buildVimPlugin { + name = "asyncrun-vim"; + src = builtins.fetchTarball { + name = "AsyncRun-Vim-v2.7.5"; + url = "https://github.com/skywind3000/asyncrun.vim/archive/2.7.5.tar.gz"; + sha256 = "02fiqf4rcrxbcgvj02mpd78wkxsrnbi54aciwh9fv5mnz5ka249m"; + }; + }; +} diff --git a/programs/neovim/default.nix b/programs/neovim/default.nix new file mode 100644 index 0000000..1369031 --- /dev/null +++ b/programs/neovim/default.nix @@ -0,0 +1,58 @@ +{ config, lib, pkgs, ... }: + +let + custom-plugins = pkgs.callPackage ./custom-plugins.nix { + inherit (pkgs.vimUtils) buildVimPlugin; + }; + + plugins = pkgs.vimPlugins // custom-plugins; + + overriddenPlugins = with pkgs; []; + + myVimPlugins = with plugins; [ + asyncrun-vim + ack-vim + coc-nvim + coc-java + coc-json + coc-metals + coc-pairs + coc-python + coc-tabnine + fzf-vim + git-messenger-vim + lightline-vim + nerdtree + nerdtree-git-plugin + rainbow + seoul256-vim + split-term-vim + vim-fugitive + vim-gitgutter + vim-polyglot + ] ++ overriddenPlugins; + + baseConfig = builtins.readFile ./config.vim; + cocConfig = builtins.readFile ./coc.vim; + cocSettings = builtins.toJSON (import ./coc-settings.nix); + vimConfig = baseConfig + cocConfig; + +in +{ + programs.neovim = { + enable = true; + extraConfig = vimConfig; + plugins = myVimPlugins; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + withNodeJs = true; # for coc.nvim + withPython = true; # for plugins + withPython3 = true; # for plugins + }; + + xdg.configFile = { + "nvim/coc-settings.json".text = cocSettings; + }; +} + diff --git a/run-emacsclient b/run-emacsclient deleted file mode 100755 index f3c1088..0000000 --- a/run-emacsclient +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -if [ -z "$EMACSCLIENT_OPTS" ]; then - EMACSCLIENT_OPTS="-nc" -fi - -if [ $# -eq 0 ]; then - COMMAND='/Users/salar/.nix-profile/bin/emacsclient '$EMACSCLIENT_OPTS' -e "(if (display-graphic-p) (x-focus-frame nil))"' -else - COMMAND='/Users/salar/.nix-profile/bin/emacsclient '$EMACSCLIENT_OPTS' "$@"' -fi - -if [ -z "$(shopt | grep login_shell)" ]; then - echo "$COMMAND" | exec bash --login -s "$@" -else - eval "exec $COMMAND" -fi - diff --git a/run-emacsclient-cli b/run-emacsclient-cli deleted file mode 100755 index 75c8fd3..0000000 --- a/run-emacsclient-cli +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -export EMACSCLIENT_OPTS='-t' -exec run-emacsclient "$@" -