Created
January 20, 2022 20:24
-
-
Save SylEleuth/03a0106490fcc3d4019b7e14d0efb90a to your computer and use it in GitHub Desktop.
nvim config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set nocompatible | |
filetype plugin on | |
syntax on | |
call plug#begin() | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'honza/vim-snippets' | |
Plug 'neovim/nvim-lsp' " nvim-lsp | |
" Plug 'easymotion/vim-easymotion' | |
Plug 'phaazon/hop.nvim' | |
Plug 'mbbill/undotree' " Undo history visualizer (F5) | |
Plug 'tpope/vim-commentary' " Comment with 'gcc' | |
Plug 'tpope/vim-surround' " Surround words and phrases with parentheses, brackets, quotes, XML tags, and more | |
" Plug 'jiangmiao/auto-pairs' " Insert or delete brackets, parens, quotes in pair | |
Plug 'raimondi/delimitmate' " Insert or delete brackets, parens, quotes in pair | |
Plug 'lukas-reineke/indent-blankline.nvim' " Disply the indention levels with thin vertical lines and leading spaces | |
" Plug 'yamatsum/nvim-cursorline' " Highlight words and lines on the cursor for Neovim | |
Plug 'norcalli/nvim-colorizer.lua' " Color highlighter | |
Plug 'preservim/tagbar' " Displays tags in a window, ordered by scope | |
Plug 'famiu/bufdelete.nvim' " Deleting a buffer in Vim without closing the window | |
Plug 'moll/vim-bbye' " Delete buffers and close files in Vim without closing your windows | |
Plug 'godlygeek/tabular' " Vim script for text filtering and alignment | |
Plug 'luochen1990/rainbow' " Colored parentheses | |
Plug 'terryma/vim-multiple-cursors' " Multiple selection | |
Plug 'pbrisbin/vim-mkdir' " Automatically create any non-existent directories before writing the buffer | |
Plug 'RRethy/vim-illuminate' " Automatically highlighting other uses of the word under the cursor | |
Plug 'psliwka/vim-smoothie' | |
Plug 'lambdalisue/suda.vim' | |
Plug 'nacro90/numb.nvim' " Peek lines just when you intend | |
Plug 'sudormrfbin/cheatsheet.nvim' " A searchable cheatsheet for neovim from within the editor (requirements below) | |
Plug 'nvim-lua/popup.nvim' | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'nvim-telescope/telescope.nvim' | |
Plug 'nvim-treesitter/nvim-treesitter' | |
Plug 'AckslD/nvim-neoclip.lua' | |
Plug 'tami5/sqlite.lua' | |
Plug 'kdheepak/lazygit.nvim' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'kyazdani42/nvim-web-devicons' | |
Plug 'vim-airline/vim-airline' " Cool powerline bars | |
Plug 'vim-airline/vim-airline-themes' | |
" Plug 'NTBBloodbath/galaxyline.nvim' , {'branch': 'main'} | |
Plug 'vifm/vifm.vim' | |
Plug 'mhinz/vim-startify' " Starting screen | |
Plug 'Lenovsky/nuake' " A Quake-style terminal panel for Neovim and Vim | |
Plug 'voldikss/vim-floaterm' | |
Plug 'akinsho/toggleterm.nvim' | |
Plug 'nvie/vim-flake8' " Python linter | |
" Plug 'sheerun/vim-polyglot' | |
Plug 'vim-python/python-syntax' | |
Plug 'peterhoeg/vim-qml' | |
Plug 'kshenoy/vim-signature' " place, toggle and display marks | |
Plug 'tpope/vim-fugitive' " Git wrapper | |
Plug 'rbong/vim-flog' " Git branch viewer | |
Plug 'airblade/vim-gitgutter' " Shows git diff | |
Plug 'tveskag/nvim-blame-line' | |
Plug 'vimwiki/vimwiki' | |
Plug 'plasticboy/vim-markdown' | |
Plug 'pechorin/any-jump.vim' " Jump to any definition and references (leader-j) | |
" Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } } | |
Plug 'gruvbox-community/gruvbox' | |
" Plug 'sainnhe/gruvbox-material' | |
" Plug 'morhetz/gruvbox' | |
" Plug 'dracula/vim' | |
" Plug 'drewtempelmeyer/palenight.vim' " similar to dracula | |
call plug#end() | |
" ###### COLOR SCHEMES | |
if has ('termguicolors') | |
set termguicolors | |
endif | |
set t_Co=256 | |
" Grubox material settings | |
" let g:gruvbox_material_background = 'medium' | |
" set background = dark | |
" let g:gruvbox_contrast_dark = 'soft' | |
" let g:gruvbox_material_enable_italic = 1 | |
" let g:gruvbox_material_enable_bold = 1 | |
" let g:gruvbox_material_diagnostic_text_highlight = 1 | |
" let g:gruvbox_material_diagnostic_line_highlight = 1 | |
" let g:gruvbox_material_diagnostic_virtual_text = 'colored' | |
" let g:gruvbox_material_current_word = 'bold' | |
let g:gruvbox_italic = 1 | |
let g:gruvbox_bold = 1 | |
let g:gruvbox_italicize_comments = 1 | |
let g:gruvbox_italicize_strings = 1 | |
let g:gruvbox_contrast_dark = 'medium' | |
if &diff | |
colorscheme gruvbox | |
else | |
colorscheme gruvbox | |
endif | |
set cursorline | |
hi CursorLine ctermbg=236 ctermfg=0 guibg=#32302f | |
set cursorcolumn | |
set ignorecase " Search case insensitive: | |
set smartcase " .. but not when search pattern contains upper case characters | |
set mouse=a " Copy selected text with mouse to system clipboard | |
set updatetime=250 " If this many milliseconds nothing is typed the swap file will be written to disk | |
set lazyredraw " buffers screen updates instead of updating all the time | |
set linebreak " breaks lines by word rather than character | |
set timeoutlen=500 | |
let g:vim_json_conceal=0 | |
set clipboard+=unnamedplus | |
set hidden " Buffers | |
set nobackup | |
set nowritebackup | |
set updatetime=300 | |
set shortmess+=c | |
set signcolumn=auto | |
" Usable 'Tab' | |
set shiftwidth=4 | |
set tabstop=4 | |
set softtabstop=4 | |
set expandtab | |
set infercase | |
set linespace=8 | |
set showtabline=0 | |
set laststatus=2 | |
set encoding=UTF-8 | |
" set nofoldenable " disable folding | |
" Persistent undo | |
set undofile | |
set undodir=$HOME/Dropbox/vimundo | |
set undolevels=1000 | |
set undoreload=10000 | |
" COC config | |
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. | |
if exists('*complete_info') | |
inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" | |
else | |
imap pumvisible() ? "\" : "\u\" | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. | |
nmap [g (coc-diagnostic-prev) | |
nmap ]g (coc-diagnostic-next) | |
" GoTo code navigation. | |
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('') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor. | |
" autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Symbol renaming. | |
nmap rn (coc-rename) | |
" Formatting selected code. | |
xmap fs (coc-format-selected) | |
nmap fs (coc-format-selected) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder. | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" Applying codeAction to the selected region. | |
" Example: `aap` for current paragraph | |
xmap a (coc-codeaction-selected) | |
nmap a (coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap ac (coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap qf (coc-fix-current) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if (coc-funcobj-i) | |
omap if (coc-funcobj-i) | |
xmap af (coc-funcobj-a) | |
omap af (coc-funcobj-a) | |
xmap ic (coc-classobj-i) | |
omap ic (coc-classobj-i) | |
xmap ac (coc-classobj-a) | |
omap ac (coc-classobj-a) | |
" Use for selections ranges. | |
" NOTE: Requires 'textDocument/selectionRange' support from the language server. | |
" coc-tsserver, coc-python are the examples of servers that support it. | |
nmap (coc-range-select) | |
xmap (coc-range-select) | |
" Use CTRL-S for selections ranges. | |
" Requires 'textDocument/selectionRange' support of language server. | |
nmap (coc-range-select) | |
xmap (coc-range-select) | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', ) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') | |
" Use for trigger snippet expand. | |
imap (coc-snippets-expand) | |
" Use for select text for visual placeholder of snippet. | |
vmap (coc-snippets-select) | |
" Use for jump to next placeholder, it's default of coc.nvim | |
let g:coc_snippet_next = '' | |
" Use for jump to previous placeholder, it's default of coc.nvim | |
let g:coc_snippet_prev = '' | |
" Use for both expand and jump (make expand higher priority.) | |
imap (coc-snippets-expand-jump) | |
" Use x for convert visual selected code to snippet | |
xmap x (coc-convert-snippet) | |
let g:lsp_cxx_hl_use_text_props = 1 | |
" END of COC config | |
autocmd VimResized * wincmd = | |
" Overwrite illuminate background color | |
autocmd VimEnter * hi illuminatedWord guibg=#3c3836 | |
let g:Illuminate_highlightUnderCursor = 0 | |
augroup numbertoggle | |
autocmd! | |
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber | |
autocmd BufLeave,FocusLost,InsertEnter * set number norelativenumber | |
augroup END | |
" *** KEYMAPS *** | |
" nnoremap : | |
nnoremap ; : | |
nmap oo o | |
nmap Oo O | |
map j gj | |
map k gk | |
nnoremap h | |
nnoremap j | |
nnoremap k | |
nnoremap l | |
map :Vifm | |
nnoremap | |
" move between buffers | |
map :bnext | |
map :bprevious | |
nnoremap :Nuake | |
inoremap :Nuake | |
tnoremap :Nuake | |
nmap :TagbarToggle | |
vnoremap y "+y | |
vnoremap p "+p | |
" move lines up and down | |
nnoremap :m .+1== | |
nnoremap :m .-2== | |
inoremap :m .+1==gi | |
inoremap :m .-2==gi | |
vnoremap :m '>+1gv=gv | |
vnoremap :m '<-2gv=gv | |
" for the autocomplete suggest menu | |
inoremap pumvisible() ? "\" : "\" | |
inoremap pumvisible() ? "\" : "\" | |
" TAB in general mode will move to text buffer | |
nnoremap :bnext | |
" SHIFT-TAB will go back | |
nnoremap :bprevious | |
nmap ] $ | |
nmap [ 0 | |
nmap ' :Startify | |
" nmap e CocCommand explorer | |
nmap CocCommand explorer | |
nnoremap q :Bdelete | |
nnoremap :UndotreeToggle | |
vmap rr :Tabularize spaces | |
nmap r= :Tabularize /= | |
vmap r= :Tabularize /= | |
nmap r: :Tabularize /:\zs | |
vmap r: :Tabularize /:\zs | |
nmap r- :Tabularize /-\zs | |
vmap r- :Tabularize /-\zs | |
nnoremap h :History | |
nnoremap cc :ToggleBlameLine | |
" Show blame info below the statusline instead of using virtual text | |
" let g:blameLineUseVirtualText = 0 | |
" Configuration example | |
let g:floaterm_keymap_toggle = 't' | |
" let g:floaterm_keymap_new = '' | |
" let g:floaterm_keymap_prev = '' | |
" let g:floaterm_keymap_next = '' | |
nnoremap gg :LazyGit | |
" " EasyMotion | |
" " s{char}{char} to move to {char}{char} | |
" nmap s (easymotion-overwin-f2) | |
" " f{char} to move to {char} | |
" map f (easymotion-bd-f) | |
" nmap f (easymotion-overwin-f) | |
" " Move to line | |
" map l (easymotion-bd-jk) | |
" nmap l (easymotion-overwin-line) | |
" " Move to word | |
" map w (easymotion-bd-w) | |
" nmap w (easymotion-overwin-w) | |
" Find files using Telescope command-line sugar. | |
nnoremap e Telescope find_files | |
nnoremap er Telescope live_grep | |
nnoremap b Telescope buffers | |
nnoremap fh Telescope help_tags | |
" Open, reload config | |
nmap v :call EditConfig() | |
nmap V :so $MYVIMRC | |
" *** END OF KEYMAPS *** | |
" Open config file | |
function! EditConfig() | |
for config in ['$MYGVIMRC', '$MYVIMRC'] | |
if exists(config) | |
execute 'edit '.config | |
endif | |
endfor | |
endfunction | |
" Lazygit settings | |
let g:lazygit_floating_window_winblend = 0 " transparency of floating window | |
let g:lazygit_floating_window_scaling_factor = 0.9 " scaling factor for floating window | |
let g:lazygit_floating_window_corner_chars = ['', '', '', ''] " customize lazygit popup window corner characters | |
let g:lazygit_floating_window_use_plenary = 0 " use plenary.nvim to manage floating window if available | |
let g:lazygit_use_neovim_remote = 0 " fallback to 0 if neovim-remote is not installed | |
"highlight BadWhitespace ctermbg=red guibg=red | |
" au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/ | |
" easymotion | |
let g:EasyMotion_smartcase = 1 | |
let g:EasyMotion_verbose = 0 | |
let g:EasyMotion_do_shade = 0 | |
let g:EasyMotion_prompt = ' => ' | |
hi link EasyMotionTarget GruvboxPurple | |
hi link EasyMotionShade GruvboxPurple | |
hi link EasyMotionTarget2First GruvboxPurple | |
hi link EasyMotionTarget2Second GruvboxPurple | |
" Airline | |
let g:airline_theme = 'gruvbox' | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#formatter = 'unique_tail' | |
let g:airline_powerline_fonts = 1 | |
"let g:airline#extensions#tabline#fnamemod = ':p:.' | |
let g:airline#extensions#tabline#buffer_nr_show = 0 | |
let g:airline#extensions#whitespace#enabled = 0 | |
let g:airline#extensions#tabline#buffer_min_count = 1 | |
"let g:airline#extensions#tabline#fnamecollapse = 1 | |
" save folds and such when close file | |
augroup remember_folds | |
autocmd! | |
autocmd BufWinLeave *.* mkview | |
autocmd BufWinEnter *.* silent! loadview | |
augroup END | |
" Tagbar | |
let g:tagbar_width = max([40, winwidth(0) / 5]) | |
let g:tagbar_autofocus = 1 | |
let g:rainbow_active = 1 "Color brackets | |
" Startify settings | |
function! StartifyEntryFormat() | |
return 'WebDevIconsGetFileTypeSymbol(absolute_path) ." ". entry_path' | |
endfunction | |
let g:startify_files_number = 20 | |
let g:startify_session_autoload = 1 | |
let g:startify_session_delete_buffers = 1 | |
let g:startify_change_to_vcs_root = 1 | |
let g:startify_fortune_use_unicode = 1 | |
let g:startify_session_persistence = 1 | |
let g:startify_session_dir = '~/.config/nvim/session' | |
let g:startify_lists = [ | |
\ { 'type': 'files', 'header': [' Files'] }, | |
\ { 'type': 'dir', 'header': [' Current Directory '. getcwd()] }, | |
\ { 'type': 'sessions', 'header': [' Sessions'] }, | |
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, | |
\ ] | |
let g:startify_lists = [ | |
\ { 'type': 'files', 'header': [' MRU'] }, | |
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] }, | |
\ ] | |
let g:startify_bookmarks = [ | |
\ '~/.config/nvim/init.vim', | |
\ '~/.zshrc', | |
\ '~/.p10k.zsh', | |
\ '~/.config/kitty/kitty.conf' | |
\ ] | |
let g:startify_custom_header = 0 | |
" let g:startify_enable_special = 0 | |
" IndentLine settings | |
let g:indentLine_char = '│' | |
let g:indentLine_enabled = 1 | |
let g:indentLine_leadingSpaceChar = "." | |
let g:indentLine_leadingSpaceEnabled = 1 | |
" PYTHON settings | |
let g:python_host_prog = '/usr/bin/python' | |
let g:python3_host_prog = '/usr/bin/python3' | |
syntax on | |
let g:python_highlight_all = 1 | |
" let g:syntastic_python_checkers=['flake8'] | |
" Python indentations | |
au BufNewFile,BufRead *.py | |
\ set tabstop=4 | | |
\ set softtabstop=4 | | |
\ set shiftwidth=4 | | |
\ set textwidth=79 | | |
\ set wrapmargin=0 | | |
\ set formatoptions+=t | | |
\ set expandtab | | |
" \ set autoindent | | |
\ set fileformat=unix | | |
\ set foldmethod=indent | | |
\ set foldnestmax=10 | | |
\ set nofoldenable | | |
\ set foldlevel=2 | | |
let g:jedi#auto_initialization = 1 | |
let g:jedi#completions_enabled = 0 | |
let g:jedi#auto_vim_configuration = 0 | |
let g:jedi#smart_auto_mappings = 0 | |
let g:jedi#popup_on_dot = 0 | |
let g:jedi#completions_command = "" | |
let g:jedi#show_call_signatures = "1" | |
" VimWiki | |
autocmd FileType vimwiki set ft=markdown | |
let g:vimwiki_list = [{'path': '~/Dropbox/vimwiki/', | |
\ 'syntax': 'markdown', 'ext': '.md'}] | |
let g:vimwiki_global_ext = 0 | |
let g:vimwiki_folding = '' | |
let g:floaterm_height = 0.8 | |
let g:floaterm_width = 0.8 | |
let g:floaterm_title = 0 | |
let g:suda_smart_edit = 1 | |
" let g:vifm_exec = expand('$HOME/.config/vifm/vifmrun') | |
lua << EOF | |
local map = vim.api.nvim_set_keymap | |
require('colorizer').setup() | |
require('neoclip').setup({ | |
history = 1000, | |
enable_persistant_history = true, | |
db_path = vim.fn.stdpath("data") .. "/databases/neoclip.sqlite3", | |
filter = nil, | |
preview = true, | |
default_register = '"', | |
default_register_macros = 'q', | |
enable_macro_history = true, | |
content_spec_column = false, | |
on_paste = { | |
set_reg = false, | |
}, | |
on_replay = { | |
set_reg = false, | |
}, | |
}) | |
-- Line peeker | |
require('numb').setup{ | |
show_numbers = true, -- Enable 'number' for the window while peeking | |
show_cursorline = true, -- Enable 'cursorline' for the window while peeking | |
number_only = false, -- Peek only when the command is only a number instead of when it starts with a number | |
} | |
require('telescope').setup { | |
defaults = { | |
dynamic_preview_title = true, | |
} | |
} | |
map('n', 'c', 'lua require"telescope".extensions.neoclip.default()', {noremap=true}) | |
map('n', '', 'lua require"illuminate".next_reference{wrap=true}', {noremap=true}) | |
map('n', '', 'lua require"illuminate".next_reference{reverse=true,wrap=true}', {noremap=true}) | |
-- Hop motion | |
require('hop').setup() | |
map('n', 'f', "lua require'hop'.hint_char1()", {noremap=true}) | |
map('n', 's', "lua require'hop'.hint_char2()", {noremap=true}) | |
map('n', 'w', "lua require'hop'.hint_words()", {noremap=true}) | |
map('n', 'l', "lua require'hop'.hint_lines()", {noremap=true}) | |
vim.cmd('highlight HopNextKey guibg=none guifg=#fe8019') | |
vim.cmd('highlight HopNextKey1 guibg=none guifg=#fe8019') | |
vim.cmd('highlight HopNextKey2 guibg=none guifg=#fe8019') | |
vim.cmd('highlight HopUnmatched guibg=none guifg=#504945') | |
-- Indent blankline | |
require("indent_blankline").setup { | |
show_end_of_line = true, | |
space_char_blankline = " ", | |
show_current_context_start = true, | |
char_highlight_list = { | |
"IndentBlanklineIndent1", | |
"IndentBlanklineIndent2", | |
"IndentBlanklineIndent3", | |
"IndentBlanklineIndent4", | |
"IndentBlanklineIndent5", | |
"IndentBlanklineIndent6", | |
} | |
} | |
vim.opt.list = true | |
--vim.opt.listchars:append("space:⋅") | |
--vim.opt.listchars:append("eol:↴") | |
vim.opt.termguicolors = true | |
vim.cmd [[highlight IndentBlanklineIndent1 guifg=#D65D0E gui=nocombine]] | |
vim.cmd [[highlight IndentBlanklineIndent2 guifg=#FABD2F gui=nocombine]] | |
vim.cmd [[highlight IndentBlanklineIndent3 guifg=#8EC07C gui=nocombine]] | |
vim.cmd [[highlight IndentBlanklineIndent4 guifg=#83A598 gui=nocombine]] | |
vim.cmd [[highlight IndentBlanklineIndent5 guifg=#458588 gui=nocombine]] | |
vim.cmd [[highlight IndentBlanklineIndent6 guifg=#B16286 gui=nocombine]] | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment