restrucutre and add search function
This commit is contained in:
parent
89056915d1
commit
0b64b275a8
129
vim/vimrc
129
vim/vimrc
@ -3,8 +3,9 @@
|
|||||||
" \ V /| | | | | | | | | (__
|
" \ V /| | | | | | | | | (__
|
||||||
" \_/ |_|_| |_| |_|_| \___|
|
" \_/ |_|_| |_| |_|_| \___|
|
||||||
|
|
||||||
"(((((((((((( general settings ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
set nocompatible
|
"general settings
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
"tab/indent
|
"tab/indent
|
||||||
set tabstop=4
|
set tabstop=4
|
||||||
@ -70,20 +71,37 @@ set directory=~/.vim/.swap//,/tmp//
|
|||||||
"leader key
|
"leader key
|
||||||
let mapleader=','
|
let mapleader=','
|
||||||
|
|
||||||
"(((((((((((( normal keybinds ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"normal mode keybinds
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"normal keybinds
|
||||||
nnoremap <silent><leader><space> :let @/ = ""<CR>
|
nnoremap <silent><leader><space> :let @/ = ""<CR>
|
||||||
nnoremap <leader>p :set invpaste<CR>
|
nnoremap <leader>p :set invpaste<CR>
|
||||||
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
|
nnoremap <silent><leader>lb :call ToggleLineBreak()<CR>
|
||||||
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
|
nnoremap <silent><leader>wr :call ToggleWrap()<CR>
|
||||||
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
|
nnoremap <silent><leader>cc :call ToggleColorColumn()<CR>
|
||||||
|
|
||||||
nnoremap <leader>ts "=strftime("%F %T%z")<CR>p
|
nnoremap <leader>ts "=strftime("%F %T%z")<CR>p
|
||||||
nnoremap =j :%!python -m json.tool<CR>
|
nnoremap =j :%!python -m json.tool<CR>
|
||||||
|
|
||||||
"(((((((((((( abbreviations ))))))))))))
|
"plugin keybinds
|
||||||
|
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
|
||||||
|
nnoremap <leader>at :ALEToggle<CR>
|
||||||
|
if !exists('##TextYankPost')
|
||||||
|
map y <Plug>(highlightedyank)
|
||||||
|
endif
|
||||||
|
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
"abbreviations
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
inoreabbrev <expr> #!! "#!/usr/bin/env"
|
inoreabbrev <expr> #!! "#!/usr/bin/env"
|
||||||
|
|
||||||
"(((((((((((( commands ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"custom commands
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"common typos and abbreviations
|
||||||
cnoremap w!! w !sudo tee % > /dev/null
|
cnoremap w!! w !sudo tee % > /dev/null
|
||||||
command! W w !sudo tee % > /dev/null
|
command! W w !sudo tee % > /dev/null
|
||||||
command! Trim %s/\s\+$//
|
command! Trim %s/\s\+$//
|
||||||
@ -91,20 +109,30 @@ command! Q q
|
|||||||
command! WQ wq
|
command! WQ wq
|
||||||
command! Q1 q!
|
command! Q1 q!
|
||||||
|
|
||||||
"(((((((((((( plugins ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"plugins (vim-plug)
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"ensure vim-plug is installed on VimEnter
|
||||||
if empty(glob('~/.vim/autoload/plug.vim'))
|
if empty(glob('~/.vim/autoload/plug.vim'))
|
||||||
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
|
||||||
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||||
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"filetype may interfere with plugins
|
"filetype *may* interfere with certain plugins
|
||||||
filetype off
|
filetype off
|
||||||
|
|
||||||
|
"entry function
|
||||||
call plug#begin('~/.vim/plugged')
|
call plug#begin('~/.vim/plugged')
|
||||||
|
|
||||||
"## vim plug ##
|
"## vim plug ##
|
||||||
Plug 'junegunn/vim-plug'
|
Plug 'junegunn/vim-plug'
|
||||||
|
|
||||||
|
"-------------
|
||||||
"== general ==
|
"== general ==
|
||||||
|
"-------------
|
||||||
|
|
||||||
"## quality of life ##
|
"## quality of life ##
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
Plug 'tpope/vim-commentary'
|
Plug 'tpope/vim-commentary'
|
||||||
@ -112,33 +140,39 @@ call plug#begin('~/.vim/plugged')
|
|||||||
Plug 'tpope/vim-rsi'
|
Plug 'tpope/vim-rsi'
|
||||||
Plug 'tpope/vim-eunuch'
|
Plug 'tpope/vim-eunuch'
|
||||||
Plug 'tpope/vim-repeat'
|
Plug 'tpope/vim-repeat'
|
||||||
|
Plug 'editorconfig/editorconfig-vim'
|
||||||
|
|
||||||
"## git ##
|
"## git ##
|
||||||
Plug 'tpope/vim-fugitive'
|
Plug 'tpope/vim-fugitive'
|
||||||
Plug 'airblade/vim-gitgutter'
|
Plug 'airblade/vim-gitgutter'
|
||||||
"## editorconfig ##
|
|
||||||
Plug 'editorconfig/editorconfig-vim'
|
"## visual ##
|
||||||
"## colors, highlights and indents ##
|
|
||||||
Plug 'machakann/vim-highlightedyank'
|
Plug 'machakann/vim-highlightedyank'
|
||||||
|
|
||||||
|
"-----------------------
|
||||||
"== language specific ==
|
"== language specific ==
|
||||||
|
"-----------------------
|
||||||
|
|
||||||
"javascript/css/html
|
"javascript/css/html
|
||||||
Plug 'pangloss/vim-javascript'
|
Plug 'pangloss/vim-javascript'
|
||||||
Plug 'mattn/emmet-vim'
|
Plug 'mattn/emmet-vim'
|
||||||
|
|
||||||
"go
|
"go
|
||||||
Plug 'fatih/vim-go'
|
Plug 'fatih/vim-go'
|
||||||
|
|
||||||
"## linting ##
|
"## linting ##
|
||||||
Plug 'w0rp/ale'
|
Plug 'w0rp/ale'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
"(((((((((((( plugin keybinds ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
nnoremap <silent><leader>e :call ToggleNetrw()<CR>
|
"plugin settings
|
||||||
nnoremap <leader>at :ALEToggle<CR>
|
"------------------------------------------------------------------------------
|
||||||
if !exists('##TextYankPost')
|
|
||||||
map y <Plug>(highlightedyank)
|
|
||||||
endif
|
|
||||||
|
|
||||||
"(((((((((((( plugin settings ))))))))))))
|
" this function gets called with the VimEnter autocommand to set plugin
|
||||||
|
" options
|
||||||
function! SetPluginSettings()
|
function! SetPluginSettings()
|
||||||
|
|
||||||
"netrw
|
"netrw
|
||||||
let g:netrw_banner = 0
|
let g:netrw_banner = 0
|
||||||
let g:netrw_winsize = 24
|
let g:netrw_winsize = 24
|
||||||
@ -146,6 +180,9 @@ function! SetPluginSettings()
|
|||||||
let g:netrw_preview = 1
|
let g:netrw_preview = 1
|
||||||
let g:netrw_alto = 0
|
let g:netrw_alto = 0
|
||||||
let g:netrw_usetab = 1
|
let g:netrw_usetab = 1
|
||||||
|
let g:netrw_browsex_viewer = "xdg-open"
|
||||||
|
let g:NetrwIsOpen = 0 "for toggle function
|
||||||
|
|
||||||
"git gutter
|
"git gutter
|
||||||
augroup git_gutter
|
augroup git_gutter
|
||||||
if exists(':GitGutter')
|
if exists(':GitGutter')
|
||||||
@ -154,6 +191,8 @@ function! SetPluginSettings()
|
|||||||
autocmd BufWritePost * GitGutter "update GitGutter after writing
|
autocmd BufWritePost * GitGutter "update GitGutter after writing
|
||||||
endif
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"ale
|
||||||
if exists(':ALEToggle')
|
if exists(':ALEToggle')
|
||||||
let g:ale_fixers = {
|
let g:ale_fixers = {
|
||||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||||
@ -162,9 +201,17 @@ function! SetPluginSettings()
|
|||||||
let g:ale_sign_error = '->'
|
let g:ale_sign_error = '->'
|
||||||
let g:ale_sign_warning = '--'
|
let g:ale_sign_warning = '--'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"(((((((((((( general use functions ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"general functions
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
"----------------
|
||||||
|
"toggle functions
|
||||||
|
"----------------
|
||||||
|
|
||||||
function! ToggleColorColumn()
|
function! ToggleColorColumn()
|
||||||
if &cc == ''
|
if &cc == ''
|
||||||
set cc=80
|
set cc=80
|
||||||
@ -193,10 +240,8 @@ function! ToggleWrap()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"make netrw toggleable
|
function! ToggleNetrw() "make netrw toggleable
|
||||||
"https://vi.stackexchange.com/questions/10988/toggle-explorer-window
|
"https://vi.stackexchange.com/questions/10988/toggle-explorer-window
|
||||||
let g:NetrwIsOpen=0
|
|
||||||
function! ToggleNetrw()
|
|
||||||
if g:NetrwIsOpen
|
if g:NetrwIsOpen
|
||||||
let i = bufnr("$")
|
let i = bufnr("$")
|
||||||
while (i >= 1)
|
while (i >= 1)
|
||||||
@ -212,12 +257,22 @@ function! ToggleNetrw()
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"(((((((((((( enable syntax/filetype ))))))))))))
|
"----------------
|
||||||
|
"search functions
|
||||||
|
"----------------
|
||||||
|
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
"syntax/filetype
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
syntax enable
|
syntax enable
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
runtime macros/matchit.vim
|
runtime macros/matchit.vim
|
||||||
|
|
||||||
"(((((((((((( gui settings ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"gui settings
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
if has("gui_running")
|
if has("gui_running")
|
||||||
set guioptions -=m
|
set guioptions -=m
|
||||||
set guioptions -=T
|
set guioptions -=T
|
||||||
@ -230,48 +285,68 @@ if has("gui_running")
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"(((((((((((( win32 settings ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"win32 settings
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
if has('win32')
|
if has('win32')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
"(((((((((((( auto commands ))))))))))))
|
"------------------------------------------------------------------------------
|
||||||
|
"auto commands
|
||||||
|
"------------------------------------------------------------------------------
|
||||||
|
|
||||||
if has("autocmd")
|
if has("autocmd")
|
||||||
|
|
||||||
|
"------------
|
||||||
"## global ##
|
"## global ##
|
||||||
|
"------------
|
||||||
|
|
||||||
|
"set plugin settings on VimEnter
|
||||||
augroup set_plugin_settings
|
augroup set_plugin_settings
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimEnter * call SetPluginSettings()
|
autocmd VimEnter * call SetPluginSettings()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"keep equal proportions when windows resized
|
||||||
augroup auto_resize_windows
|
augroup auto_resize_windows
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd VimResized * wincmd =
|
autocmd VimResized * wincmd =
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
"## save cursor position in a file ##
|
"save cursor position in a file
|
||||||
au BufReadPost * if line("'\"") > 1 && line("'\"")
|
au BufReadPost * if line("'\"") > 1 && line("'\"")
|
||||||
\ <= line("$") | exe "normal! g'\"" | endif
|
\ <= line("$") | exe "normal! g'\"" | endif
|
||||||
|
|
||||||
|
"--------------------------------
|
||||||
"## language/filetype specific ##
|
"## language/filetype specific ##
|
||||||
|
"--------------------------------
|
||||||
|
|
||||||
|
"shell
|
||||||
augroup filetype_shell
|
augroup filetype_shell
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
autocmd BufNewFile,BufRead *bash* set syntax=sh
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"python
|
||||||
augroup filetype_python
|
augroup filetype_python
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
autocmd FileType python xnoremap <leader>r <esc>:'<,'>:w !python3<CR>
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"go
|
||||||
augroup filetype_go
|
augroup filetype_go
|
||||||
autocmd!
|
autocmd!
|
||||||
set expandtab!
|
set expandtab!
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"html
|
||||||
augroup filetype_html
|
augroup filetype_html
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType html :syntax sync fromstart
|
autocmd FileType html :syntax sync fromstart
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
"where tabs should = 2 spaces
|
||||||
augroup half_tab
|
augroup half_tab
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd FileType html,javascript,css,json,yaml,yml,sh
|
autocmd FileType html,javascript,css,json,yaml,yml,sh
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user