diff options
| author | jdhao <jdhao@hotmail.com> | 2020-10-31 01:13:09 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2020-10-31 01:13:09 +0800 |
| commit | d0827ae776a83cddb30a4e7dada8d9f491cde334 (patch) | |
| tree | 9c4c39037c9e1288ceaa87a49c604c3bc7e28e94 /core/options.vim | |
| parent | bbceffe9cf7d806503930b82b0ac987d0fd9c0bd (diff) | |
move custom settings to core/ directory
Diffstat (limited to 'core/options.vim')
| -rw-r--r-- | core/options.vim | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/core/options.vim b/core/options.vim new file mode 100644 index 0000000..9b8dda1 --- /dev/null +++ b/core/options.vim @@ -0,0 +1,167 @@ +scriptencoding utf-8 + +"{ Builtin options and settings +" change filechar for folding, vertical split, and message separator +set fillchars=fold:\ ,vert:\│,msgsep:‾ + +" Paste mode toggle, it seems that Neovim's bracketed paste mode +" does not work very well for nvim-qt, so we use good-old paste mode +set pastetoggle=<F12> + +" Split window below/right when creating horizontal/vertical windows +set splitbelow splitright + +" Time in milliseconds to wait for a mapped sequence to complete, +" see https://unix.stackexchange.com/q/36882/221410 for more info +set timeoutlen=1000 + +set updatetime=1000 " For CursorHold events + +" Clipboard settings, always use clipboard for all delete, yank, change, put +" operation, see https://stackoverflow.com/q/30691466/6064933 +if !empty(provider#clipboard#Executable()) + set clipboard+=unnamedplus +endif + +" Disable creating swapfiles, see https://stackoverflow.com/q/821902/6064933 +set noswapfile + +" Set up backup directory +let g:backupdir=expand(stdpath('data') . '/backup') +if !isdirectory(g:backupdir) + call mkdir(g:backupdir, 'p') +endif +let &backupdir=g:backupdir + +set backupcopy=yes " copy the original file to backupdir and overwrite it + +" General tab settings +set tabstop=4 " number of visual spaces per TAB +set softtabstop=4 " number of spaces in tab when editing +set shiftwidth=4 " number of spaces to use for autoindent +set expandtab " expand tab to spaces so that tabs are spaces + +" Set matching pairs of characters and highlight matching brackets +set matchpairs+=<:>,「:」,『:』,【:】,“:”,‘:’,《:》 + +set number relativenumber " Show line number and relative line number + +" Ignore case in general, but become case-sensitive when uppercase is present +set ignorecase smartcase + +" File and script encoding settings for vim +set fileencoding=utf-8 +set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1 + +" Break line at predefined characters +set linebreak +" Character to show before the lines that have been soft-wrapped +set showbreak=↪ + +" List all matches and complete till longest common string +set wildmode=list:longest +set wildignorecase " ignore file and dir name cases in cmd-completion + +set cursorline " Show current line where the cursor is + +" Minimum lines to keep above and below cursor when scrolling +set scrolloff=3 + +" Use mouse to select and resize windows, etc. +set mouse=nic " Enable mouse in several mode +set mousemodel=popup " Set the behaviour of mouse + +" Do not show mode on command line since vim-airline can show it +set noshowmode + +set fileformats=unix,dos " Fileformats to use for new files + +set inccommand=nosplit " Show the result of substitution in real time for preview + +" Ignore certain files and folders when globbing +set wildignore+=*.o,*.obj,*.bin,*.dll,*.exe +set wildignore+=*/.git/*,*/.svn/*,*/__pycache__/*,*/build/** +set wildignore+=*.pyc +set wildignore+=*.DS_Store +set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz + +" Ask for confirmation when handling unsaved or read-only files +set confirm + +set visualbell noerrorbells " Do not use visual and errorbells +set history=500 " The number of command and search history to keep + +" Use list mode and customized listchars +set list listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:+ + +" Auto-write the file based on some condition +set autowrite + +" Show hostname, full path of file and last-mod time on the window title. The +" meaning of the format str for strftime can be found in +" http://man7.org/linux/man-pages/man3/strftime.3.html. The function to get +" lastmod time is drawn from https://stackoverflow.com/q/8426736/6064933 +set title +set titlestring= +if g:is_linux + set titlestring+=%(%{hostname()}\ \ %) +endif +set titlestring+=%(%{expand('%:p:~')}\ \ %) +set titlestring+=%{strftime('%Y-%m-%d\ %H:%M',getftime(expand('%')))} + +" Persistent undo even after you close a file and re-open it +set undofile + +" Do not show "match xx of xx" and other messages during auto-completion +set shortmess+=c + +" Completion behaviour +" set completeopt+=noinsert " Auto select the first completion entry +set completeopt+=menuone " Show menu even if there is only one item +set completeopt-=preview " Disable the preview window + +set pumheight=10 " Maximum number of items to show in popup menu + +" Insert mode key word completion setting +set complete+=kspell complete-=w complete-=b complete-=u complete-=t + +set spelllang=en,cjk " Spell languages +set spellsuggest+=10 " The number of suggestions shown in the screen for z= + +" Align indent to next multiple value of shiftwidth. For its meaning, +" see http://vim.1045645.n5.nabble.com/shiftround-option-td5712100.html +set shiftround + +set virtualedit=block " Virtual edit is useful for visual block edit + +" Correctly break multi-byte characters such as CJK, +" see https://stackoverflow.com/q/32669814/6064933 +set formatoptions+=mM + +" Tilde (~) is an operator, thus must be followed by motions like `e` or `w`. +set tildeop + +" Do not add two spaces after a period when joining lines or formatting texts, +" see https://stackoverflow.com/q/4760428/6064933 +set nojoinspaces + +set synmaxcol=200 " Text after this column number is not highlighted +set nostartofline + +" External program to use for grep command +if executable('rg') + set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case + set grepformat=%f:%l:%c:%m +endif + +" Highlight groups for cursor color +augroup cursor_color + autocmd! + autocmd ColorScheme * highlight Cursor cterm=bold gui=bold guibg=cyan guifg=black + autocmd ColorScheme * highlight Cursor2 guifg=red guibg=red +augroup END + +" Set up cursor color and shape in various mode, ref: +" https://github.com/neovim/neovim/wiki/FAQ#how-to-change-cursor-color-in-the-terminal +set guicursor=n-v-c:block-Cursor/lCursor,i-ci-ve:ver25-Cursor2/lCursor2,r-cr:hor20,o:hor20 +"} |
