diff --git a/home.nix b/home.nix index a15c726..24a14ec 100644 --- a/home.nix +++ b/home.nix @@ -18,9 +18,8 @@ home.stateVersion = "20.09"; home.sessionVariables = { - EDITOR = "$HOME/bin/run-emacsclient-cli"; + EDITOR = "nvim"; VISUAL = "$EDITOR"; - ALTERNATE_EDITOR = "nvim"; }; programs.git = { @@ -111,16 +110,21 @@ viAlias = true; vimAlias = true; vimdiffAlias = true; + withNodeJs = true; plugins = with pkgs.vimPlugins; [ - fzf-vim - seoul256-vim - vim-polyglot - vim-gitgutter - rainbow ack-vim auto-pairs + coc-nvim + coc-json + coc-python + coc-tabnine + fzf-vim lightline-vim + rainbow + seoul256-vim vim-fugitive + vim-gitgutter + vim-polyglot ]; extraConfig = '' set t_Co=256 @@ -136,6 +140,9 @@ set cmdheight=2 set smarttab set linebreak + set hlsearch + set ignorecase + set incsearch set guifont=SF\ Mono:h12 set termguicolors let g:clipboard = { @@ -184,6 +191,7 @@ map y :Tags autocmd! FileType fzf tnoremap q nnoremap :FZF + let g:rainbow_active = 1 let g:rainbow_conf = { \ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'], @@ -217,6 +225,94 @@ \ 'gitbranch': 'FugitiveHead' \ }, \ } + + " START Configuration for coc.nvim + " -------------------------------- + set nobackup + set nowritebackup + + " 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) + ''; }; @@ -274,6 +370,8 @@ set -xg NIX_PATH $HOME/.nix-defexpr/channels $NIX_PATH set -xg FZF_DEFAULT_OPTS "--preview='bat {} --color=always'" \n + + set -xg TOOLCHAINS swift ''; promptInit = '' @@ -287,7 +385,7 @@ ping="prettyping"; ".." = "cd .."; pj="python -m json.tool"; - k="exa --long --header --git --all"; + l="exa --long --header --git --all"; g="git"; gl="git log"; gc="git commit -m"; @@ -310,6 +408,7 @@ tabninecfg="vc /Users/salar/Library/Preferences/TabNine/TabNine.toml"; sshfre1="ssh salar@fre1.softinio.net"; moshfre1="mosh salar@fre1.softinio.net"; + sshls1="ssh -i pem/LightsailDefaultKey-us-west-2.pem admin@52.42.3.248"; portsupdate="sudo port -v selfupdate"; emacsload="launchctl load -w ~/Library/LaunchAgents/gnu.emacs.daemon.plist"; emacsunload="launchctl unload ~/Library/LaunchAgents/gnu.emacs.daemon.plist"; @@ -392,5 +491,6 @@ pkgs.hyperfine pkgs.graphviz pkgs.metals + pkgs.neofetch ]; }