diff --git a/README.md b/README.md index 015c7d3..4c7976d 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,18 @@ --- -Configuration files for windows applications +Configuration files for different applications (_in windows_) -- Nvim +[![Vim](https://img.shields.io/badge/VIM-%2311AB00.svg?&style=for-the-badge&logo=vim&logoColor=white)](https://www.vim.org/) +[![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)](https://neovim.io/) +[![Bash](https://img.shields.io/badge/Shell_Script-121011?style=for-the-badge&logo=gnu-bash&logoColor=white)](https://www.gnu.org/software/bash/) + +## Fonts + +_(Nerd Fonts Needed)_ + +My favourites + +- Operator Mono +- Fira Code +- Source Code Pro diff --git a/nvim/README.md b/nvim/README.md index fc4327b..f345fed 100644 --- a/nvim/README.md +++ b/nvim/README.md @@ -4,9 +4,26 @@ My setup for various applications. -## nvim ๐Ÿš€ +## nvim :rocket: -- with language support for cpp and python -- for coc - - `:CocCommand clangd.install ` (make sure clangd path is added to `:CocConfig`) - - `:CocInstall coc-clangd coc-css coc-emmet coc-eslint coc-html coc-java coc-jedi coc-json coc-lua coc-pairs coc-prettier coc-pyright coc-snippets coc-tsserver coc-vimlsp ` +### COC : Conquer of Completion + +- `:CocCommand clangd.install ` (make sure clangd path is added to `:CocConfig`) +- `:CocInstall coc-clangd coc-css coc-emmet coc-eslint coc-html coc-java coc-jedi coc-json coc-lua coc-pairs coc-prettier coc-pyright coc-snippets coc-tsserver coc-vimlsp ` +- quick tip : + you can move to floating window using `C-w` commands + +### Firenvim + +#### Installation + +- first follow installation instruction here : https://github.com/glacambre/firenvim +- to setup config jsons run + ```bash + $ nvim --headless "+call firenvim#install(0) | q" + #or inside neovim + :call firenvim#install(0) + ``` +- to allow only specific websites, follow here : https://github.com/glacambre/firenvim/issues/321 +- set shortcut inside chrome://extensions/shortcuts for firenvim on focus +- other troubleshootings : https://github.com/glacambre/firenvim/blob/master/TROUBLESHOOTING.md diff --git a/nvim/general/augroups.vim b/nvim/general/augroups.vim new file mode 100644 index 0000000..ad09b52 --- /dev/null +++ b/nvim/general/augroups.vim @@ -0,0 +1,59 @@ +""" +"Auto Commands +""" +" trim trailing whitespace ----- {{{ +"https://vi.stackexchange.com/a/456 +fun! TrimWhitespace() + let l:save = winsaveview() + keeppatterns %s/\s\+$//e + call winrestview(l:save) +endfun + +augroup TRIM_WHITESPACE + autocmd! + autocmd BufWritePre * if !&binary && &ft !=# 'mail' + \| call TrimWhitespace() + \| endif +augroup END +" }}} + +" persistent folding state --- {{{ +augroup REMEMBER_FOLDS + autocmd! + autocmd BufWinLeave *.* mkview + autocmd BufWinEnter *.* silent! loadview +augroup END +" --- }}} + +" Cursor management --- {{{ +"https://github.com/microsoft/terminal/issues/4335 +" +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +" +augroup CURSOR_MANAGEMENT + autocmd! + +" powershell requires different format for escape codes +" see : +" (i) https://docs.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption?view=powershell-5.1#example-6--use-vimodechangehandler-to-display-vi-mode-changes +" (ii) https://github.com/microsoft/terminal/issues/1604 +if has('win32') + "https://github.com/neovim/neovim/issues/4867#issuecomment-291249173" + autocmd VimEnter * silent !echo -ne "\e[2 q" + autocmd VimLeave * set guicursor=a:ver25 + +else + autocmd VimEnter * silent !echo -ne "\e[2 q" + autocmd VimLeave * silent !echo -ne "\e[6 q" +" autocmd VimLeave * let &t_me="\]50;CursorShape=1\x7" +" autocmd VimLeave * let &t_SI.="\[6 q" +endif +augroup END +" }} diff --git a/nvim/general/colorscheme_settings.vim b/nvim/general/colorscheme_settings.vim new file mode 100644 index 0000000..96ac0ca --- /dev/null +++ b/nvim/general/colorscheme_settings.vim @@ -0,0 +1,25 @@ +let g:colorscheme='default' +" gruvbox ----- {{{ +if (has("termguicolors")) + set termguicolors +endif +set background=dark +" colorscheme gruvbox +" au Colorscheme gruvbox :hi Keyword gui=italic cterm=italic +"https://github.com/sainnhe/gruvbox-material/blob/master/doc/gruvbox-material.txt +"soft,medium,hard +"let g:gruvbox_material_background = 'medium' +let g:gruvbox_material_transparent_background = 1 +let g:gruvbox_material_enable_bold = 1 +let g:gruvbox_material_enable_italic = 1 +"let g:gruvbox_material_statusline_style = 'original' +let g:gruvbox_material_diagnostic_virtual_text = 'colored' +let g:gruvbox_material_better_performance = 1 +"configuration must be dont before applying colorscheme +" +"if &filetype!='gitcommit' +colorscheme gruvbox-material +"endif + +" }}} + diff --git a/nvim/general/cursor.vim b/nvim/general/cursor.vim new file mode 100644 index 0000000..4640c59 --- /dev/null +++ b/nvim/general/cursor.vim @@ -0,0 +1,23 @@ +" also see augroups.vim +" cursor ----- {{{ +" Cursor in terminal +" https//vim.fandom.com/wiki/Configuring_the_cursor +" 1 or 0 -> blinking block +" 2 solid block +" 3 -> blinking underscore +" 4 solid underscore +" Recent versions of xterm (282 or above) also support +" 5 -> blinking vertical bar +" 6 -> solid vertical bar +if &term =~ '^xterm' + " normal mode || + " .= means shorthand for appending : see help .= + let &t_EI .= "\[1 q" + " replace mode _ + let &t_SR .= "\e[4 q" + " insert mode | + let &t_SI .= "\[6 q" +endif +" +" }}} + diff --git a/nvim/general/general.vim b/nvim/general/general.vim index d634802..259b54d 100644 --- a/nvim/general/general.vim +++ b/nvim/general/general.vim @@ -2,7 +2,15 @@ set mouse=a " CLIPBOARD ----- {{{ "vim clipboard and system clipboard same now -set clipboard^=unnamed +set clipboard^=unnamed + +"wrap backspace +set backspace=indent,eol,start +"https://stackoverflow.com/a/53872985/12988588 +"dont save character deleted using `x` +"send it to The blackhole-register +nnoremap x "_x + set autochdir " }}} @@ -19,7 +27,9 @@ set tabstop=4 set softtabstop=4 set shiftwidth=4 set number relativenumber -" Show white spaces https://gist.github.com/jdavid82/d40f40e6f124aad6223eba0ff0c7ad65#file-vimrc-L37-L39 +set scrolloff=8 +"set colorcolumn=80 +" Show white spaces https://gist.github.com/jdavid82/d40f40e6f124aad6223eba0ff0c7ad65#file-vimrc-L37-L39 "set listchars=tab:>ยท,trail:~,extends:>,precedes:<,space:ยท "set list " }}} @@ -27,8 +37,10 @@ set number relativenumber " SEARCHING ----- {{{ set nohlsearch +set incsearch "on by default" " clear last used search pattern:http://vimdoc.sourceforge.net/htmldoc/pattern.html#last-pattern -let @/="" +" +let @/="" " }}} " FOLDING ----- {{{ @@ -38,12 +50,7 @@ set foldmethod=marker " }}} " BUFFERS ----- {{{ -" remember foldings -augroup remember_folds - autocmd! - autocmd BufWinLeave *.* mkview - autocmd BufWinEnter *.* silent! loadview -augroup END +" remember foldings is nvim/general/augroups.vim " }}} " SPLITS ----- {{{ @@ -56,7 +63,7 @@ nnoremap "}}} -" wildmenu ----- {{{ + " Nice menu when typing `:find *.py` set wildmode=longest,list,full set wildmenu @@ -97,3 +104,4 @@ set shortmess+=c " if has('gui_running') " set guioptions-=e " endif + diff --git a/nvim/general/git.vim b/nvim/general/git.vim new file mode 100644 index 0000000..1f501ab --- /dev/null +++ b/nvim/general/git.vim @@ -0,0 +1,27 @@ +function Set_git_settings() + "colorscheme gruvbox + "below line is important : gruvbox-material doesn't work + let g:lightline.colorscheme='gruvbox' +endfunction + +if &diff + set nornu + "https://stackoverflow.com/questions/2019281/load-different-colorscheme-when-using-vimdiff + " highlight! DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + " highlight! DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + " highlight! DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red + " highlight! DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red + " Fix the difficult-to-read default setting for diff text highlighting. The + " bang (!) is required since we are overwriting the DiffText setting. The highlighting + " for \"Todo" also looks nice (yellow) if you don't like the \"MatchParen" colors. + highlight! link DiffText MatchParen + + :call Set_git_settings() +endif + + +augroup GITCOMMIT_SETTINGS + "https://vi.stackexchange.com/questions/4343/can-i-detect-whether-current-vim-instance-is-launched-by-git + autocmd! + autocmd FileType gitcommit silent :call Set_git_settings() +augroup END diff --git a/nvim/general/keybindings.vim b/nvim/general/keybindings.vim index b4d68f6..4091626 100644 --- a/nvim/general/keybindings.vim +++ b/nvim/general/keybindings.vim @@ -5,7 +5,7 @@ inoremap jk " yanking ----- {{{ "to match the behaviour of 'C' and 'D' -nnoremap Y y$ +nnoremap Y y$ "highlight the yanked area for an extened period augroup highlight_yank autocmd! @@ -22,7 +22,7 @@ nnoremap N Nzz " " breakpoints ----- {{{ "puts the next line at the end of current line : mz = create a mark called z , do J, `z = goto mark z -nnoremap J mzJ`z +nnoremap J mzJ`z "undo breakpoints inoremap . .u inoremap , ,u @@ -31,7 +31,7 @@ inoremap ? ?u " }}} " " moving lines with ALT key ----- {{{ -"https://vim.fandom.com/wiki/Moving_lines_up_or_down +"https://vim.fandom.com/wiki/Moving_lines_up_or_down nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi diff --git a/nvim/general/leader.vim b/nvim/general/leader.vim index e55ef7c..fb62310 100644 --- a/nvim/general/leader.vim +++ b/nvim/general/leader.vim @@ -6,11 +6,19 @@ nmap so :e $LOCALAPPDATA/nvim/init.vim nnoremap n :bnext nnoremap p :bprev nnoremap b :buffers + +" splits ----- {{{ nnoremap w w nnoremap h h nnoremap l l nnoremap j j nnoremap k k +" +nnoremap r= = +nnoremap = :exe "resize " . (winheight(0) * 3/2) +nnoremap - :exe "resize " . (winheight(0) * 2/3) +nnoremap 0 :exe "vertical resize " . (winwidth(0) * 3/2) +nnoremap 9 :exe "vertical resize " . (winwidth(0) * 2/3) +" }}} "nmap ws : - diff --git a/nvim/init.vim b/nvim/init.vim index 51b9beb..703c0da 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -1,16 +1,24 @@ let mapleader = "\" +source $LOCALAPPDATA/nvim/general/augroups.vim source $LOCALAPPDATA/nvim/plugs/plugins.vim +source $LOCALAPPDATA/nvim/general/colorscheme_settings.vim source $LOCALAPPDATA/nvim/plugs/coc.vim +source $LOCALAPPDATA/nvim/plugs/lightline_v1.vim +source $LOCALAPPDATA/nvim/plugs/telescope_plug.vim +source $LOCALAPPDATA/nvim/plugs/firenvim.vim source $LOCALAPPDATA/nvim/plugs/markdown.vim + +source $LOCALAPPDATA/nvim/general/cursor.vim source $LOCALAPPDATA/nvim/general/general.vim source $LOCALAPPDATA/nvim/general/leader.vim source $LOCALAPPDATA/nvim/general/keybindings.vim + source $LOCALAPPDATA/nvim/languages/languages.vim -"set path+=* + +source $LOCALAPPDATA/nvim/general/git.vim + +"set path+=** hi Normal ctermbg=none guibg=none -"wrap backspace -set backspace=indent,eol,start hi Comment gui=italic cterm=italic hi htmlArg gui=italic cterm=italic - diff --git a/nvim/plugs/coc.vim b/nvim/plugs/coc.vim index c04ab60..89c65e8 100644 --- a/nvim/plugs/coc.vim +++ b/nvim/plugs/coc.vim @@ -8,7 +8,7 @@ if has("nvim-0.5.0") || has("patch-8.1.1564") else set signcolumn=yes endif - + " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap ' to make sure tab is not mapped by " other plugin before putting this into your config. @@ -64,8 +64,9 @@ autocmd CursorHold * silent call CocActionAsync('highlight') nmap rn (coc-rename) " Formatting selected code. -xmap f (coc-format-selected) -nmap f (coc-format-selected) +" f starts in telescope settings +" xmap f (coc-format-selected) +" nmap f (coc-format-selected) augroup mygroup autocmd! @@ -81,9 +82,9 @@ xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. -nmap ac (coc-codeaction) +nmap ca (coc-codeaction) " Apply AutoFix to problem on the current line. -nmap qf (coc-fix-current) +nmap cf (coc-fix-current) " Use CTRL-S for selections ranges. " Requires 'textDocument/selectionRange' support of language server. @@ -102,6 +103,24 @@ command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organize " Add (Neo)Vim's native statusline support. " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline. -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} +"set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} "nnoremap q :call CocAction('diagnosticInfo') +" Using CocList +" Show all diagnostics +nnoremap cl :CocList diagnostics +" Manage extensions +nnoremap ce :CocList extensions +" Show commands +nnoremap cc :CocList commands +" Find symbol of current document +nnoremap co :CocList outline +" Search workspace symbols +nnoremap cs :CocList -I symbols +" Do default action for next item. +nnoremap cj :CocNext +" Do default action for previous item. +nnoremap ck :CocPrev +" Resume latest coc list +nnoremap cp :CocListResume +" diff --git a/nvim/plugs/firenvim.vim b/nvim/plugs/firenvim.vim new file mode 100644 index 0000000..bfa87bb --- /dev/null +++ b/nvim/plugs/firenvim.vim @@ -0,0 +1,32 @@ +"Firenvim +" +"if you want to make Firenvim ignore and in normal mode and in all modes to let your browser handle them, you should define ignoreKeys like this:ignoreKeys +if exists('g:started_by_firenvim') + set laststatus=0 + let g:firenvim_config = { + \ 'globalSettings': { + \ 'alt': 'all', + \ }, + \ 'localSettings': { + \ '.*': { + \ 'cmdline': 'neovim', + \ 'content': 'text', + \ 'priority': 0, + \ 'selector': 'textarea', + \ 'takeover': 'always', + \ }, + \ } + \ } + "https://github.com/glacambre/firenvim/issues/321 + " Setup a shortcut variable to the per site settings array + let fc = g:firenvim_config['localSettings'] + "let g:firenvim_config = { 'localSettings': s:fc } + + " Configure all sites + let fc['.*'] = { 'selector': 'textarea, div[role="textbox"]', 'priority': 0, 'takeover': 'never' } + let fc['https?://github.com/*'] = { 'selector': 'textarea', 'priority': 1,'takeover':'never' } + "let fc['.*'] = { 'selector': 'textarea' } + au BufEnter github.com_*.txt set filetype=markdown +else + set laststatus=2 +endif diff --git a/nvim/plugs/plugins.vim b/nvim/plugs/plugins.vim index b2436c8..3712bf6 100644 --- a/nvim/plugs/plugins.vim +++ b/nvim/plugs/plugins.vim @@ -1,28 +1,24 @@ " plugins ----- {{{ call plug#begin("$VIM/nvim/plugged") Plug 'morhetz/gruvbox' - +Plug 'sainnhe/gruvbox-material' Plug 'preservim/nerdtree' Plug 'tiagofumo/vim-nerdtree-syntax-highlight' Plug 'tpope/vim-fugitive' Plug 'ryanoasis/vim-devicons' - " Track the engine. Plug 'SirVer/ultisnips' " Snippets are separated from the engine. Add this if you want them: Plug 'honza/vim-snippets' - "Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } "Plug 'junegunn/fzf.vim' - +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' Plug 'neoclide/coc.nvim', {'branch': 'release'} "Plug 'w0rp/ale' Plug 'sheerun/vim-polyglot' - Plug 'itchyny/lightline.vim' - Plug 'preservim/nerdcommenter' - Plug 'tpope/vim-surround' "Plug 'mhinz/vim-startify' @@ -35,10 +31,12 @@ Plug 'tpope/vim-surround' " use pre build, add 'vim-plug' to the filetype list so vim-plug can update this plugin " see: https://github.com/iamcco/markdown-preview.nvim/issues/50 Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} -call plug#end() -" }}} +Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } + +call plug#end() +" }}} " UltiSnips ----- {{{ " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. @@ -48,19 +46,10 @@ let g:UltiSnipsExpandTrigger = '' "to aviod overlapping with coc mapping "let g:UltiSnipsJumpBackwardTrigger="" " }}} -" gruvbox ----- {{{ -if (has("termguicolors")) - set termguicolors -endif -set background=dark -colorscheme gruvbox -au Colorscheme gruvbox :hi Keyword gui=italic cterm=italic -" }}} - " NERDTree ----- {{{ -let g:NERDTreeShowHidden = 1 -let g:NERDTreeMinimalUI = 1 " hide helper -let g:NERDTreeIgnore = ['^node_modules$','\.git$', '\.idea$', '\.vscode$', '\.history$'] " ignore node_modules to increase load speed +let g:NERDTreeShowHidden = 1 +let g:NERDTreeMinimalUI = 0 " hide helper +let g:NERDTreeIgnore = ['^node_modules$','\.git$', '\.idea$', '\.vscode$', '\.history$'] " ignore node_modules to increase load speed let g:NERDTreeStatusline = '' " set to empty to use lightline " " Toggle "noremap :NERDTreeToggle @@ -73,9 +62,9 @@ autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isT " NERDTree Syntax Highlight " " Enables folder icon highlighting using exact match -let g:NERDTreeHighlightFolders = 1 +let g:NERDTreeHighlightFolders = 1 " " Highlights the folder name -let g:NERDTreeHighlightFoldersFullName = 1 +let g:NERDTreeHighlightFoldersFullName = 1 " " Color customization let s:brown = "905532" let s:aqua = "3AFFDB" @@ -96,21 +85,21 @@ let s:white = "FFFFFF" let s:rspec_red = 'FE405F' let s:git_orange = 'F54D27' " " This line is needed to avoid error -let g:NERDTreeExtensionHighlightColor = {} +let g:NERDTreeExtensionHighlightColor = {} " " Sets the color of css files to blue -let g:NERDTreeExtensionHighlightColor['css'] = s:blue +let g:NERDTreeExtensionHighlightColor['css'] = s:blue " " This line is needed to avoid error -let g:NERDTreeExactMatchHighlightColor = {} +let g:NERDTreeExactMatchHighlightColor = {} " " Sets the color for .gitignore files -let g:NERDTreeExactMatchHighlightColor['.gitignore'] = s:git_orange +let g:NERDTreeExactMatchHighlightColor['.gitignore'] = s:git_orange " " This line is needed to avoid error -let g:NERDTreePatternMatchHighlightColor = {} +let g:NERDTreePatternMatchHighlightColor = {} " " Sets the color for files ending with _spec.rb -let g:NERDTreePatternMatchHighlightColor['.*_spec\.rb$'] = s:rspec_red +let g:NERDTreePatternMatchHighlightColor['.*_spec\.rb$'] = s:rspec_red " " Sets the color for folders that did not match any rule -let g:WebDevIconsDefaultFolderSymbolColor = s:beige +let g:WebDevIconsDefaultFolderSymbolColor = s:beige " " Sets the color for files that did not match any rule -let g:WebDevIconsDefaultFileSymbolColor = s:blue +let g:WebDevIconsDefaultFileSymbolColor = s:blue " NERDTree Git Plugin let g:NERDTreeGitStatusIndicatorMapCustom = { @@ -128,7 +117,7 @@ let g:NERDTreeGitStatusIndicatorMapCustom = { " }}} " SUPPRESS WARNINGS ----- {{{ -"autocmd VimEnter * unlet g:NERDTreeUpdateOnCursorHold +"autocmd VimEnter * unlet g:NERDTreeUpdateOnCursorHold "autocmd VimEnter * unlet g:NERDTreeIndicatorMapCustom " }}} @@ -154,7 +143,7 @@ let g:NERDTrimTrailingWhitespace = 1 let g:NERDToggleCheckAllLines = 1 " " Add spaces after comment delimiters by default let g:NERDSpaceDelims = 1 -" " Map ++ to call NERD Commenter and use iTerm key bindings +" " Map ++ to call NERD Commenter and use iTerm key bindings " " to bind Ctmd+/ to ++ vmap NERDCommenterToggle nmap NERDCommenterToggle @@ -171,28 +160,6 @@ nmap NERDCommenterToggle " }}} -" lightline ----- {{{ -" Lightline -"let g:lightline = { - ""\ 'colorscheme': 'powerlineish', - ""\ 'active': { - ""\ 'left': [['mode', 'paste' ], ['readonly', 'filename', 'modified']], - ""\ 'right': [['lineinfo'], ['percent'], ['fileformat', 'fileencoding']] - \ } - \ } -let g:lightline = { - \ 'colorscheme': 'powerlineish', - \ 'active': { - \ 'left': [ [ 'mode', 'paste' ],['readonly', 'filename', 'modified']], - \ 'right' : [['cocstatus', 'currentfunction'],['lineinfo'], ['percent'],['filetype','fileformat','fileencoding']] - \ }, - \ 'component_function': { - \ 'cocstatus': 'coc#status', - \ 'currentfunction': 'CocCurrentFunction' - \ }, - \ } -" }}} -" " vim-startify ----- {{{ "let g:startify_custom_header += [ ""\'โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— ',