Created
April 29, 2021 19:31
-
-
Save 3lpsy/7856ba42446995b29b38c7f864b943fb to your computer and use it in GitHub Desktop.
Vimrc
This file contains hidden or 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
" syntax highlighting | |
filetype plugin indent on | |
syntax on | |
" Be better | |
set nocompatible | |
" Fast shortcuts | |
let mapleader = " " " map leader to Space | |
" Sets | |
set path+=** | |
" Wildmenu | |
set wildmenu | |
set wildmode=list:longest | |
set wildignore=.hg,.svn,*~,*.png,*.jpg,*.gif,*.settings,Thumbs.db,*.min.js,*.swp,publish/*,intermediate/*,*.o,*.hi,Zend,vendor | |
" Load tags | |
set tags=./tags;,tags; | |
" soft tabs | |
" Use wide tabs | |
set shiftwidth=4 | |
set softtabstop=4 | |
set tabstop=4 | |
set noexpandtab | |
" Wrapping options | |
set formatoptions=tc " wrap text and comments using textwidth | |
set formatoptions+=r " continue comments when pressing ENTER in I mode | |
set formatoptions+=q " enable formatting of comments with gq | |
set formatoptions+=n " detect lists for formatting | |
set formatoptions+=b " auto-wrap in insert mode, and do not wrap old long lines | |
" Set partial search and result highlighting | |
set incsearch | |
set ignorecase | |
set smartcase | |
set gdefault | |
set nohlsearch | |
" Show hidden buffers | |
set hidden | |
" No noise | |
set noerrorbells | |
" Diable swap file backup | |
" set noswapfile | |
" set nobackup | |
" Start scrolling sooner | |
set scrolloff=8 | |
" Special column | |
set signcolumn=yes | |
" Wrapping bar | |
set colorcolumn=100 | |
" Enable Mouse | |
set mouse=a " Enable mouse usage (all modes) in terminals | |
" Show those damn hidden characters | |
" Verbose: set listchars=nbsp:¬,eol:¶,extends:»,precedes:«,trail:• | |
set listchars=nbsp:¬,extends:»,precedes:«,trail:• | |
" Better display of messages | |
set cmdheight=2 | |
" don't know what it does | |
set updatetime=300 | |
" Sane splits | |
set splitright | |
set splitbelow | |
" Permanent undo | |
set undodir=~/.vim/undodir | |
set undofile | |
" Line numbers | |
set number " Enable line numbers | |
set relativenumber " Enable relative line numbers | |
" File/Display Stuff | |
set enc=utf8 | |
" set fileencodings=utf-8 | |
set guifont="FuraCode Nerd Font" | |
set encoding=utf-8 | |
set background=dark | |
" Lightline: always display status line | |
set laststatus=2 | |
" do not show mode | |
set noshowmode | |
let g:netrw_banner=0 " disable annoying banner | |
let g:netrw_browse_split=4 " open in prior window | |
"let g:netrw_browse_split=0 " 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\+' | |
" Display | |
autocmd BufRead *.orig set readonly | |
autocmd BufRead *.pacnew set readonly | |
autocmd InsertLeave * set nopaste | |
" Lightline update | |
autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Transparency | |
"if (has("autocmd") && !has("gui_running")) | |
" augroup colorset | |
" autocmd! | |
" let s:white = { "gui": "#ABB2BF", "cterm": "145", "cterm16" : "7" } | |
" autocmd ColorScheme * call onedark#set_highlight("Normal", { "fg": s:white }) " `bg` will not be styled since there is no `bg` setting | |
" augroup END | |
"endif | |
let g:nord_bold_vertical_split_line = 1 | |
let g:nord_italic_comments = 1 | |
colorscheme nord | |
" Enables 24-bit RGB color in the | |
set termguicolors | |
"if (has("autocmd") && !has("gui_running")) | |
augroup colorset | |
autocmd! | |
hi Normal guibg=NONE ctermbg=NONE | |
hi LineNr guifg=#d8dee9 | |
augroup END | |
"endif | |
" Lightline Settings | |
" | |
let g:lightline = { | |
\ 'colorscheme': 'nord', | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], | |
\ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ] | |
\ }, | |
\ 'component_function': { | |
\ 'filename': 'LightlineFilename', | |
\ 'cocstatus': 'coc#status' | |
\ }, | |
\ } | |
function! LightlineFilename() | |
return expand('%:t') !=# '' ? @% : '[No Name]' | |
endfunction | |
" vim-rooter | |
let g:rooter_patterns = ['=src', 'Cargo.toml'] | |
let g:rooter_silent_chdir = 1 | |
"let g:rooter_manual_only = 0 | |
" Rust Settings | |
let g:rustfmt_autosave = 1 | |
let g:rustfmt_emit_files = 1 | |
let g:rustfmt_fail_silently = 0 | |
" Python Black Settings | |
" format on save | |
autocmd BufWritePre *.py execute ':Black' | |
" Bindings (Basic) | |
" Save in multiple modes | |
nnoremap <silent><c-s> :<c-u>update<cr> | |
vnoremap <silent><c-s> <c-c>:update<cr>gv | |
inoremap <silent><c-s> <c-o>:update<cr> | |
" FZF | |
let g:fzf_layout = { 'down': '~30%' } | |
let g:fzf_history_dir = "~/vim/fzf_history" | |
" Open Files/Buffers List | |
nnoremap <silent> <C-p> :Files<CR> | |
nnoremap <silent> <leader>b :Buffers<CR> | |
nnoremap <silent> <leader>t :Tags<CR> | |
nnoremap <silent> <leader>T :BTags<CR> | |
" Search with ripgrep | |
nnoremap <silent> <Leader>f :Rg<CR> | |
" Search with ripgrep via regex | |
function! RipgrepFzf(query, fullscreen) | |
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true' | |
let initial_command = printf(command_fmt, shellescape(a:query)) | |
let reload_command = printf(command_fmt, '{q}') | |
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} | |
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) | |
endfunction | |
command! -nargs=* -bang Rrg call RipgrepFzf(<q-args>, <bang>0) | |
nnoremap <silent> <Leader>F :Rrg<CR> | |
" Jump to start and end of line using home row | |
map H ^ | |
map L $ | |
" No arrow keys --- force yourself to use the home row | |
nnoremap <up> <nop> | |
nnoremap <down> <nop> | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> | |
" Left and right can switch buffers | |
nnoremap <left> :bp<CR> | |
nnoremap <right> :bn<CR> | |
" Move by line | |
nnoremap j gj | |
nnoremap k gk | |
" Use <c-.> to trigger completion. | |
inoremap <silent><expr> <c-.> coc#refresh() | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current | |
" position. Coc only does snippet and additional edit on confirm. | |
if exists('*complete_info') | |
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
else | |
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
endif | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> <leader>G <Plug>(coc-diagnostic-prev) | |
nmap <silent> <leader>g <Plug>(coc-diagnostic-next) | |
" GoTo code navigation. | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Symbol renaming. | |
nmap <leader>rn <Plug>(coc-rename) | |
" <leader><leader> toggles between buffers | |
nnoremap <leader><leader> <c-^> | |
" <leader>, shows/hides hidden characters | |
nnoremap <leader>, :set invlist<cr> | |
" <leader>q shows stats | |
nnoremap <leader>q g<c-g> | |
nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30 <bar> :wincmd x<CR> | |
" wayland clipboard | |
nnoremap <C-@> :call system("wl-copy", @")<CR> | |
" move between splits | |
nmap <silent> <A-Up> :wincmd k<CR> | |
nmap <silent> <A-Down> :wincmd j<CR> | |
nmap <silent> <A-Left> :wincmd h<CR> | |
nmap <silent> <A-Right> :wincmd l<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment