Last active
December 7, 2022 01:04
-
-
Save abiriadev/c6435f1081109082a6533ffbce2d6387 to your computer and use it in GitHub Desktop.
my cute ~/.vimrc file >ㅂ<
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
""" basic settings | |
syntax on | |
set nocompatible " useless in nvim, but may stil needed yet | |
filetype plugin on | |
" set filetype indent on | |
set complete-=i " limit the files searched for auto-completes | |
set lazyredraw " don't redraw screen during macro and script execution. | |
set encoding=utf-8 | |
" add spell | |
set complete+=k | |
set spell | |
set spelllang=en_us | |
set spellfile+=~/.vim/spell/custom.add | |
" make backup before overwriting a file. | |
" set backup | |
" set wrap | |
set linebreak | |
set scrolloff=1 | |
set sidescrolloff=5 | |
set display+=lastline " always show last line | |
set laststatus=2 " always show status bar | |
set ruler " always show cursor position | |
set wildmenu | |
set title | |
" set foldmethod=indent | |
set backupdir=~/.cache/vim | |
set confirm | |
set dir=~/.cache/vim | |
set nrformats-=octal | |
" set visualbell | |
" display line numbers | |
set number | |
" ignore character case while searching | |
set ignorecase | |
" override the above option when there is at least one uppercase character. | |
set smartcase | |
" make search results interactive | |
set hlsearch | |
set incsearch | |
" prevent automatically inserting comment leader when type 'o' or 'O'. | |
" set formatoptions-=c,r,o | |
" do not display the current 'mode' at the bottom line. | |
" but I still love it. | |
" set noshowmode | |
" makes the indent width to 4-space | |
set tabstop=4 | |
set shiftround | |
set shiftwidth=4 | |
set expandtab " use spaces rather than tabs | |
set smarttab | |
" useful indent settings | |
set autoindent " default | |
set smartindent | |
" history buffer of vim. | |
" default is 20, but I need more spaces. | |
set history=2048 | |
" display horizontal line | |
set cursorline | |
" display vertical line. I don't like that yet. | |
" set cursorcolumn | |
" always enable mouse features | |
set mouse=a | |
" use system clipboard as a default register | |
set clipboard+=unnamedplus | |
""" vim-plug | |
" install vim-plug automatically if it was not installed. | |
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' | |
if empty(glob(data_dir . '/autoload/plug.vim')) | |
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' | |
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC | |
endif | |
" list of plugins | |
call plug#begin() | |
Plug 'neoclide/coc.nvim', { 'branch': 'release' } | |
Plug 'voldikss/vim-floaterm' | |
Plug 'tpope/vim-commentary' | |
Plug 'suy/vim-context-commentstring' | |
Plug 'tpope/vim-unimpaired' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-endwise' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-abolish' | |
Plug 'kana/vim-textobj-user' | |
Plug 'kana/vim-textobj-entire' | |
Plug 'mileszs/ack.vim' | |
Plug 'tpope/vim-fugitive' | |
" powerlines | |
" Plug 'vim-airline/vim-airline' | |
" Plug 'itchyny/lightline.vim' | |
Plug 'nvim-lualine/lualine.nvim' | |
" Plug 'nvim-lualine/lualine.nvim' | |
Plug 'kyazdani42/nvim-web-devicons' | |
Plug 'akinsho/bufferline.nvim', { 'tag': 'v2.*' } | |
Plug 'preservim/nerdtree' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
" Plug 'justinmk/vim-sneak' | |
Plug 'easymotion/vim-easymotion' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " if you have installed fzf by git, you can also use below line | |
" Plug '~/.fzf' " same as: set rtp+=~/.fzf | |
Plug 'junegunn/fzf.vim' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'SirVer/ultisnips' | |
Plug 'honza/vim-snippets' | |
Plug 'sheerun/vim-polyglot' | |
" Goyo | |
Plug 'junegunn/goyo.vim' | |
Plug 'junegunn/limelight.vim' | |
Plug 'lambdalisue/suda.vim' | |
" Scrolls | |
Plug 'dstein64/nvim-scrollview', { 'branch': 'main' } | |
" Plug 'vim-scripts/ZoomWin' | |
" Plug 'dhruvasagar/vim-zoom' | |
" LSP | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'hrsh7th/nvim-cmp' " Completion framework | |
Plug 'hrsh7th/cmp-nvim-lsp' | |
Plug 'hrsh7th/cmp-vsnip' | |
Plug 'hrsh7th/cmp-path' | |
Plug 'hrsh7th/cmp-buffer' | |
Plug 'simrat39/rust-tools.nvim' | |
Plug 'hrsh7th/vim-vsnip' " Snippet engine | |
Plug 'nvim-lua/popup.nvim' | |
Plug 'nvim-lua/plenary.nvim' | |
Plug 'nvim-telescope/telescope.nvim' | |
Plug 'mfussenegger/nvim-jdtls' | |
Plug 'ray-x/go.nvim' | |
Plug 'ray-x/guihua.lua' | |
Plug 'dstein64/vim-startuptime' | |
" Plug 'airblade/vim-gitgutter' | |
Plug 'lewis6991/gitsigns.nvim' | |
" themes | |
Plug 'morhetz/gruvbox' | |
Plug 'rakr/vim-one' | |
Plug 'nanotech/jellybeans.vim' | |
Plug 'drewtempelmeyer/palenight.vim' | |
Plug 'ayu-theme/ayu-vim' | |
Plug 'junegunn/seoul256.vim' | |
Plug 'arcticicestudio/nord-vim' | |
" local | |
Plug '~/lab/hello-vim-plugin/hello' | |
" @vp: marker | |
call plug#end() | |
let g:ctrlp_extensions = ['buffertag', 'tag', 'line', 'dir'] | |
let g:airline#extensions#tabline#enabled = 1 | |
lua << EOF | |
require('gitsigns').setup() | |
EOF | |
lua << EOF | |
require("bufferline").setup{} | |
EOF | |
lua << EOF | |
require('lualine').setup { | |
options = { | |
icons_enabled = true, | |
theme = 'auto', | |
component_separators = { left = '', right = ''}, | |
section_separators = { left = '', right = ''}, | |
disabled_filetypes = {}, | |
always_divide_middle = true, | |
globalstatus = false, | |
}, | |
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 = {}, | |
extensions = {} | |
} | |
EOF | |
" to make vim-airline look sharp | |
let g:airline_powerline_fonts = 1 | |
" let g:suda#prompt = 'Password: ' | |
" let g:suda_smart_edit = 1 | |
" fzf settings | |
function! s:build_quickfix_list(lines) | |
call setqflist(map(copy(a:lines), '{ "filename": v:val }')) | |
copen | |
cc | |
endfunction | |
let g:fzf_action = { | |
\ 'ctrl-q': function('s:build_quickfix_list'), | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-x': 'split', | |
\ 'ctrl-v': 'vsplit' } | |
" ultisnips settings | |
let g:UltiSnipsExpandTrigger="<tab>" | |
let g:UltiSnipsJumpForwardTrigger="<tab>" | |
let g:UltiSnipsJumpBackwardTrigger="<S-tab>" | |
""" themes | |
" to make my eyes peaceful | |
set background=dark | |
" truecolor support for theme | |
" Use 24-bit (true-color) mode in Vim/Neovim when outside tmux. | |
" If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support | |
" (see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.) | |
if (empty($TMUX)) | |
if (has("nvim")) | |
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > | |
let $NVIM_TUI_ENABLE_TRUE_COLOR=1 | |
endif | |
" For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > | |
" Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > | |
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
endif | |
" increase the font size for neovide or other GUIs. | |
set guifont=Jetbrains\ Mono:h11 " set font as 'Jetbrains Mono' with 11pt | |
" italic font settings: | |
let g:gruvbox_italic=1 " gruvbox | |
let g:onedark_terminal_italics=1 " one | |
let g:palenight_terminal_italics=1 " palenight | |
let g:jellybeans_use_term_italics=1 " jellybeans | |
"" etc settings for each themes: | |
" gruvbox | |
let g:gruvbox_italicize_strings=1 | |
let g:gruvbox_improved_warnings=1 | |
" let g:gruvbox_contrast_dark='hard' | |
" ayu | |
let ayucolor="dark" | |
" set editor theme (colorscheme) | |
colorscheme gruvbox " (gruvbox|one|palenight|jellybeans|ayu|seoul256|nord) | |
"" etc settings for each powerline plugins | |
" airline | |
" lightline | |
" lualine | |
" set airline theme to same as current colorscheme | |
" let g:airline_theme='one' | |
" let g:airline_theme='palenight' | |
" let g:airline_theme='palenight' | |
" lightline setting | |
" let g:lightline = { 'colorscheme': 'palenight' } | |
"" custom color setting | |
" moderate highlight color for terminal | |
highlight Search cterm=italic,underline ctermfg=214 ctermbg=NONE | |
" remove scary color inversing | |
highlight Visual cterm=NONE ctermbg=241 gui=NONE guibg=#665c54 | |
""" LSP | |
set completeopt=menuone,noinsert,noselect | |
set shortmess+=c | |
lua <<EOF | |
local nvim_lsp = require'lspconfig' | |
local opts = { | |
tools = { -- rust-tools options | |
autoSetHints = true, | |
hover_with_actions = true, | |
inlay_hints = { | |
show_parameter_hint = false, | |
parameter_hints_prefix = "", | |
other_hints_prefix = "", | |
} | |
}, | |
server = { | |
-- on_attach is a callback called when the language server attachs to the buffer | |
-- on_attach = on_attach, | |
settings = { | |
-- to enable rust-analyzer settings visit: | |
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc | |
["rust-analyzer"] = { | |
-- enable clippy on save | |
checkOnSave = { | |
command = "clippy" | |
}, | |
} | |
} | |
}, | |
}, | |
require('rust-tools').setup(opts) | |
EOF | |
" Setup Completion | |
" See https://github.com/hrsh7th/nvim-cmp#basic-configuration | |
lua <<EOF | |
local cmp = require'cmp' | |
cmp.setup({ | |
-- Enable LSP snippets | |
snippet = { | |
expand = function(args) | |
vim.fn["vsnip#anonymous"](args.body) | |
end, | |
}, | |
mapping = { | |
['<C-p>'] = cmp.mapping.select_prev_item(), | |
['<C-n>'] = cmp.mapping.select_next_item(), | |
-- Add tab support | |
['<S-Tab>'] = cmp.mapping.select_prev_item(), | |
['<Tab>'] = cmp.mapping.select_next_item(), | |
['<C-d>'] = cmp.mapping.scroll_docs(-4), | |
['<C-f>'] = cmp.mapping.scroll_docs(4), | |
['<C-Space>'] = cmp.mapping.complete(), | |
['<C-e>'] = cmp.mapping.close(), | |
['<CR>'] = cmp.mapping.confirm({ | |
behavior = cmp.ConfirmBehavior.Insert, | |
select = true, | |
}) | |
}, | |
-- Installed sources | |
sources = { | |
{ name = 'nvim_lsp' }, | |
{ name = 'vsnip' }, | |
{ name = 'path' }, | |
{ name = 'buffer' }, | |
}, | |
}) | |
EOF | |
""" maps | |
" remap 'next tab' to Ctrl+Tab | |
nnoremap <C-Tab> gt | |
" nnoremap <C-S-Tab> gT | |
" shortcut to disable 'hlsearch' temporarily | |
" usually, <C-l> is also a refreshing(redrawing) command. | |
" ! this behavior is now built-in feature | |
" nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l> | |
" it is more fast to type 'jk' instead of press Esc, | |
" another experimental mapping, which 'clears' the search register. | |
nnoremap <C-S-l> :HelloWorld<CR> | |
" another experimental mapping, which 'clears' the search register. | |
nnoremap <C-S-l> :HelloWorld<CR> | |
" which is very far from my left hand in my keyboard. | |
imap <silent>jk<Esc> | |
" auto formatting for {}<CR> | |
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
inoremap {<CR> {<CR>}<Esc>O | |
" auto-completion for each bracket | |
inoremap ( ()<Esc>i | |
inoremap " ""<Esc>i | |
inoremap < <><Esc>i | |
inoremap [ []<Esc>i | |
inoremap { {}<Esc>i | |
" add alternative shortcut for vim-commentary | |
nnoremap <C-/> <Plug>CommentaryLine | |
inoremap <C-/> <Esc><Plug>CommentaryLineA | |
xnoremap <C-/> <Plug>Commentary | |
nnoremap <C-`> :FloatermToggle<CR> | |
tnoremap <C-`> <C-\><C-n>:FloatermToggle<CR> | |
" useful mapping idea mentioned at :help visual-search | |
" original: | |
" vnoremap * y/<C-R>"<CR> | |
" vnoremap # y?<C-R>"<CR> | |
" better version, inspired from | |
" http://got-ravings.blogspot.com/2008/07/vim-pr0n-visual-search-mappings.html | |
xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>//<CR> | |
xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>??<CR> | |
" some useful alternative shortcut | |
xnoremap <C-f> :<C-u>call <SID>VSetSearch('/')<CR>//<CR> | |
function! s:VSetSearch(type) | |
let temp = @@ | |
norm! gvy | |
let @/ = '\V' . substitute(escape(@@, a:type.'\'), '\n', '\\n', 'g') | |
let @@ = temp | |
endfunction | |
" remap & to && | |
nnoremap & :&&<CR> | |
xnoremap & :&&<CR> | |
" alias for :Explore, which is too long to type. | |
cnoreabbrev E Explore | |
" shortcut for %:h<Tab> which expands to current directory path. | |
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%' | |
" make directory path automatically even it does not exist. | |
cnoremap ww !mkdir -p %:h \| write | |
" automatically correct typo, specifically 'W' to 'w'. | |
cnoreabbrev <expr> W getcmdtype() is# ':' && getcmdline() is# 'W' ? 'w' : 'W' | |
cnoreabbrev <expr> Q getcmdtype() is# ':' && getcmdline() is# 'Q' ? 'q' : 'Q' | |
" leave terminal buffer by <Esc> | |
tnoremap <Esc> <C-\><C-n> | |
""" autocmd | |
autocmd vimenter * ++nested HelloWorld | |
autocmd FileType * set formatoptions-=o | |
" autocmd BufWritePost * call system("ctags -R --exclude=.git") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment