mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Rename vimscript conf directory
This commit is contained in:
123
viml_conf/autocommands.vim
Normal file
123
viml_conf/autocommands.vim
Normal file
@@ -0,0 +1,123 @@
|
||||
" Do not use smart case in command line mode, extracted from https://vi.stackexchange.com/a/16511/15292.
|
||||
augroup dynamic_smartcase
|
||||
autocmd!
|
||||
autocmd CmdLineEnter : set nosmartcase
|
||||
autocmd CmdLineLeave : set smartcase
|
||||
augroup END
|
||||
|
||||
augroup term_settings
|
||||
autocmd!
|
||||
" Do not use number and relative number for terminal inside nvim
|
||||
autocmd TermOpen * setlocal norelativenumber nonumber
|
||||
" Go to insert mode by default to start typing command
|
||||
autocmd TermOpen * startinsert
|
||||
augroup END
|
||||
|
||||
" More accurate syntax highlighting? (see `:h syn-sync`)
|
||||
augroup accurate_syn_highlight
|
||||
autocmd!
|
||||
autocmd BufEnter * :syntax sync fromstart
|
||||
augroup END
|
||||
|
||||
" Return to last cursor position when opening a file
|
||||
augroup resume_cursor_position
|
||||
autocmd!
|
||||
autocmd BufReadPost * call s:resume_cursor_position()
|
||||
augroup END
|
||||
|
||||
" Only resume last cursor position when there is no go-to-line command (something like '+23').
|
||||
function s:resume_cursor_position() abort
|
||||
if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||
let l:args = v:argv " command line arguments
|
||||
for l:cur_arg in l:args
|
||||
" Check if a go-to-line command is given.
|
||||
let idx = match(l:cur_arg, '\v^\+(\d){1,}$')
|
||||
if idx != -1
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
|
||||
execute "normal! g`\"zvzz"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup numbertoggle
|
||||
autocmd!
|
||||
autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif
|
||||
autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
|
||||
augroup END
|
||||
|
||||
" Define or override some highlight groups
|
||||
augroup custom_highlight
|
||||
autocmd!
|
||||
autocmd ColorScheme * call s:custom_highlight()
|
||||
augroup END
|
||||
|
||||
function! s:custom_highlight() abort
|
||||
" For yank highlight
|
||||
highlight YankColor ctermfg=59 ctermbg=41 guifg=#34495E guibg=#2ECC71
|
||||
|
||||
" For cursor colors
|
||||
highlight Cursor cterm=bold gui=bold guibg=#00c918 guifg=black
|
||||
highlight Cursor2 guifg=red guibg=red
|
||||
|
||||
" For floating windows border highlight
|
||||
highlight FloatBorder guifg=LightGreen guibg=NONE
|
||||
|
||||
" highlight for matching parentheses
|
||||
highlight MatchParen cterm=bold,underline gui=bold,underline
|
||||
endfunction
|
||||
|
||||
augroup auto_close_win
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:quit_current_win()
|
||||
augroup END
|
||||
|
||||
" Quit Nvim if we have only one window, and its filetype match our pattern.
|
||||
function! s:quit_current_win() abort
|
||||
let l:quit_filetypes = ['qf', 'vista', 'NvimTree']
|
||||
|
||||
let l:should_quit = v:true
|
||||
|
||||
let l:tabwins = nvim_tabpage_list_wins(0)
|
||||
for w in l:tabwins
|
||||
let l:buf = nvim_win_get_buf(w)
|
||||
let l:bf = getbufvar(l:buf, '&filetype')
|
||||
|
||||
if index(l:quit_filetypes, l:bf) == -1
|
||||
let l:should_quit = v:false
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:should_quit
|
||||
qall
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup git_repo_check
|
||||
autocmd!
|
||||
autocmd VimEnter,DirChanged * call utils#Inside_git_repo()
|
||||
augroup END
|
||||
|
||||
" ref: https://vi.stackexchange.com/a/169/15292
|
||||
function! s:handle_large_file() abort
|
||||
let g:large_file = 10485760 " 10MB
|
||||
let f = expand("<afile>")
|
||||
|
||||
if getfsize(f) > g:large_file || getfsize(f) == -2
|
||||
set eventignore+=all
|
||||
" turning off relative number helps a lot
|
||||
set norelativenumber
|
||||
setlocal noswapfile bufhidden=unload buftype=nowrite undolevels=-1
|
||||
else
|
||||
set eventignore-=all relativenumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
augroup LargeFile
|
||||
autocmd!
|
||||
autocmd BufReadPre * call s:handle_large_file()
|
||||
augroup END
|
||||
|
||||
" Load auto-command defined in Lua
|
||||
lua require("custom-autocmd")
|
||||
178
viml_conf/options.vim
Normal file
178
viml_conf/options.vim
Normal file
@@ -0,0 +1,178 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
" change fillchars for folding, vertical split, end of buffer, and message separator
|
||||
set fillchars=fold:\ ,vert:\│,eob:\ ,msgsep:‾
|
||||
|
||||
" 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=500
|
||||
|
||||
set updatetime=500 " 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
|
||||
|
||||
" Ignore certain files and folders when globing
|
||||
set wildignore+=*.o,*.obj,*.dylib,*.bin,*.dll,*.exe
|
||||
set wildignore+=*/.git/*,*/.svn/*,*/__pycache__/*,*/build/**
|
||||
set wildignore+=*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.tiff,*.svg,*.ico
|
||||
set wildignore+=*.pyc,*.pkl
|
||||
set wildignore+=*.DS_Store
|
||||
set wildignore+=*.aux,*.bbl,*.blg,*.brf,*.fls,*.fdb_latexmk,*.synctex.gz,*.xdv
|
||||
set wildignorecase " ignore file and dir name cases in cmd-completion
|
||||
|
||||
" Set up backup directory
|
||||
let g:backupdir=expand(stdpath('data') . '/backup//')
|
||||
let &backupdir=g:backupdir
|
||||
|
||||
" Skip backup for patterns in option wildignore
|
||||
let &backupskip=&wildignore
|
||||
set backup " create backup for files
|
||||
set backupcopy=yes " copy the original file to backupdir and overwrite it
|
||||
|
||||
" General tab settings
|
||||
set tabstop=2 " number of visual spaces per TAB
|
||||
set softtabstop=2 " number of spaces in tab when editing
|
||||
set shiftwidth=2 " 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
|
||||
|
||||
" 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
|
||||
set mousescroll=ver:1,hor:0
|
||||
|
||||
" Disable showing current mode on command line since statusline plugins can show it.
|
||||
set noshowmode
|
||||
|
||||
set fileformats=unix,dos " Fileformats to use for new files
|
||||
|
||||
" 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=
|
||||
set titlestring=%{utils#Get_titlestr()}
|
||||
|
||||
" 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
|
||||
|
||||
" Do not show search match count on bottom right (seriously, I would strain my
|
||||
" neck looking at it). Using plugins like vim-anzu or nvim-hlslens is a better
|
||||
" choice, IMHO.
|
||||
set shortmess+=S
|
||||
|
||||
" Disable showing intro message (:intro)
|
||||
set shortmess+=I
|
||||
|
||||
" 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
|
||||
set pumblend=10 " pseudo transparency for completion menu
|
||||
|
||||
set winblend=0 " pseudo transparency for floating window
|
||||
|
||||
" 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+=9 " show 9 spell suggestions at most
|
||||
|
||||
" 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
|
||||
|
||||
set synmaxcol=250 " 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
|
||||
|
||||
" Enable true color support. Do not set this option if your terminal does not
|
||||
" support true colors! For a comprehensive list of terminals supporting true
|
||||
" colors, see https://github.com/termstandard/colors and https://gist.github.com/XVilka/8346728.
|
||||
set termguicolors
|
||||
|
||||
" 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
|
||||
|
||||
set signcolumn=yes:1
|
||||
|
||||
" Remove certain character from file name pattern matching
|
||||
set isfname-==
|
||||
set isfname-=,
|
||||
|
||||
" diff options
|
||||
set diffopt=
|
||||
set diffopt+=vertical " show diff in vertical position
|
||||
set diffopt+=filler " show filler for deleted lines
|
||||
set diffopt+=closeoff " turn off diff when one file window is closed
|
||||
set diffopt+=context:3 " context for diff
|
||||
set diffopt+=internal,indent-heuristic,algorithm:histogram
|
||||
set diffopt+=linematch:60
|
||||
|
||||
set nowrap " do no wrap
|
||||
set noruler
|
||||
409
viml_conf/plugins.vim
Normal file
409
viml_conf/plugins.vim
Normal file
@@ -0,0 +1,409 @@
|
||||
scriptencoding utf-8
|
||||
|
||||
" Plugin specification and lua stuff
|
||||
lua require('plugin_specs')
|
||||
|
||||
" Use short names for common plugin manager commands to simplify typing.
|
||||
" To use these shortcuts: first activate command line with `:`, then input the
|
||||
" short alias, e.g., `pi`, then press <space>, the alias will be expanded to
|
||||
" the full command automatically.
|
||||
call utils#Cabbrev('pi', 'Lazy install')
|
||||
call utils#Cabbrev('pud', 'Lazy update')
|
||||
call utils#Cabbrev('pc', 'Lazy clean')
|
||||
call utils#Cabbrev('ps', 'Lazy sync')
|
||||
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" configurations for vim script plugin "
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
"""""""""""""""""""""""""UltiSnips settings"""""""""""""""""""
|
||||
" Trigger configuration. Do not use <tab> if you use YouCompleteMe
|
||||
let g:UltiSnipsExpandTrigger='<c-j>'
|
||||
|
||||
" Do not look for SnipMate snippets
|
||||
let g:UltiSnipsEnableSnipMate = 0
|
||||
|
||||
" Shortcut to jump forward and backward in tabstop positions
|
||||
let g:UltiSnipsJumpForwardTrigger='<c-j>'
|
||||
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
|
||||
|
||||
" Configuration for custom snippets directory, see
|
||||
" https://jdhao.github.io/2019/04/17/neovim_snippet_s1/ for details.
|
||||
let g:UltiSnipsSnippetDirectories=['UltiSnips', 'my_snippets']
|
||||
|
||||
"""""""""""""""""""""""""" vlime settings """"""""""""""""""""""""""""""""
|
||||
command! -nargs=0 StartVlime call jobstart(printf("sbcl --load %s/vlime/lisp/start-vlime.lisp", g:package_home))
|
||||
|
||||
"""""""""""""""""""""""""""""LeaderF settings"""""""""""""""""""""
|
||||
" Do not use cache file
|
||||
let g:Lf_UseCache = 0
|
||||
" Refresh each time we call leaderf
|
||||
let g:Lf_UseMemoryCache = 0
|
||||
|
||||
" Ignore certain files and directories when searching files
|
||||
let g:Lf_WildIgnore = {
|
||||
\ 'dir': ['.git', '__pycache__', '.DS_Store', '*_cache'],
|
||||
\ 'file': ['*.exe', '*.dll', '*.so', '*.o', '*.pyc', '*.jpg', '*.png',
|
||||
\ '*.gif', '*.svg', '*.ico', '*.db', '*.tgz', '*.tar.gz', '*.gz',
|
||||
\ '*.zip', '*.bin', '*.pptx', '*.xlsx', '*.docx', '*.pdf', '*.tmp',
|
||||
\ '*.wmv', '*.mkv', '*.mp4', '*.rmvb', '*.ttf', '*.ttc', '*.otf',
|
||||
\ '*.mp3', '*.aac']
|
||||
\}
|
||||
|
||||
" Do not show fancy icons for Linux server.
|
||||
if g:is_linux
|
||||
let g:Lf_ShowDevIcons = 0
|
||||
endif
|
||||
|
||||
" Only fuzzy-search files names
|
||||
let g:Lf_DefaultMode = 'FullPath'
|
||||
|
||||
" Popup window settings
|
||||
let w = float2nr(&columns * 0.8)
|
||||
if w > 140
|
||||
let g:Lf_PopupWidth = 140
|
||||
else
|
||||
let g:Lf_PopupWidth = w
|
||||
endif
|
||||
|
||||
let g:Lf_PopupPosition = [0, float2nr((&columns - g:Lf_PopupWidth)/2)]
|
||||
|
||||
" Do not use version control tool to list files under a directory since
|
||||
" submodules are not searched by default.
|
||||
let g:Lf_UseVersionControlTool = 0
|
||||
|
||||
" Use rg as the default search tool
|
||||
let g:Lf_DefaultExternalTool = "rg"
|
||||
|
||||
" show dot files
|
||||
let g:Lf_ShowHidden = 1
|
||||
|
||||
" Disable default mapping
|
||||
let g:Lf_ShortcutF = ''
|
||||
let g:Lf_ShortcutB = ''
|
||||
|
||||
" set up working directory for git repository
|
||||
let g:Lf_WorkingDirectoryMode = 'a'
|
||||
|
||||
" Search files in popup window
|
||||
nnoremap <silent> <leader>ff :<C-U>Leaderf file --popup<CR>
|
||||
|
||||
" Grep project files in popup window
|
||||
nnoremap <silent> <leader>fg :<C-U>Leaderf rg --no-messages --popup<CR>
|
||||
|
||||
" Search vim help files
|
||||
nnoremap <silent> <leader>fh :<C-U>Leaderf help --popup<CR>
|
||||
|
||||
" Search tags in current buffer
|
||||
nnoremap <silent> <leader>ft :<C-U>Leaderf bufTag --popup<CR>
|
||||
|
||||
" Switch buffers
|
||||
nnoremap <silent> <leader>fb :<C-U>Leaderf buffer --popup<CR>
|
||||
|
||||
" Search recent files
|
||||
nnoremap <silent> <leader>fr :<C-U>Leaderf mru --popup --absolute-path<CR>
|
||||
|
||||
let g:Lf_PopupColorscheme = 'gruvbox_material'
|
||||
|
||||
" Change keybinding in LeaderF prompt mode, use ctrl-n and ctrl-p to navigate
|
||||
" items.
|
||||
let g:Lf_CommandMap = {'<C-J>': ['<C-N>'], '<C-K>': ['<C-P>']}
|
||||
|
||||
" do not preview results, it will add the file to buffer list
|
||||
let g:Lf_PreviewResult = {
|
||||
\ 'File': 0,
|
||||
\ 'Buffer': 0,
|
||||
\ 'Mru': 0,
|
||||
\ 'Tag': 0,
|
||||
\ 'BufTag': 1,
|
||||
\ 'Function': 1,
|
||||
\ 'Line': 0,
|
||||
\ 'Colorscheme': 0,
|
||||
\ 'Rg': 0,
|
||||
\ 'Gtags': 0
|
||||
\}
|
||||
|
||||
""""""""""""""""""""""""""""open-browser.vim settings"""""""""""""""""""
|
||||
if g:is_win || g:is_mac
|
||||
" Disable netrw's gx mapping.
|
||||
let g:netrw_nogx = 1
|
||||
|
||||
" Use another mapping for the open URL method
|
||||
nmap ob <Plug>(openbrowser-smart-search)
|
||||
xmap ob <Plug>(openbrowser-smart-search)
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
|
||||
let g:vista#renderer#icons = {
|
||||
\ 'member': '',
|
||||
\ }
|
||||
|
||||
" Do not echo message on command line
|
||||
let g:vista_echo_cursor = 0
|
||||
" Stay in current window when vista window is opened
|
||||
let g:vista_stay_on_open = 0
|
||||
|
||||
nnoremap <silent> <Space>t :<C-U>Vista!!<CR>
|
||||
|
||||
""""""""""""""""""""""""vim-mundo settings"""""""""""""""""""""""
|
||||
let g:mundo_verbose_graph = 0
|
||||
let g:mundo_width = 80
|
||||
|
||||
nnoremap <silent> <Space>u :MundoToggle<CR>
|
||||
|
||||
""""""""""""""""""""""""""""better-escape.vim settings"""""""""""""""""""""""""
|
||||
let g:better_escape_interval = 200
|
||||
|
||||
""""""""""""""""""""""""""""vim-xkbswitch settings"""""""""""""""""""""""""
|
||||
let g:XkbSwitchEnabled = 1
|
||||
|
||||
"""""""""""""""""""""""""""""" neoformat settings """""""""""""""""""""""
|
||||
let g:neoformat_enabled_python = ['black', 'yapf']
|
||||
let g:neoformat_cpp_clangformat = {
|
||||
\ 'exe': 'clang-format',
|
||||
\ 'args': ['--style="{IndentWidth: 4}"']
|
||||
\ }
|
||||
let g:neoformat_c_clangformat = {
|
||||
\ 'exe': 'clang-format',
|
||||
\ 'args': ['--style="{IndentWidth: 4}"']
|
||||
\ }
|
||||
|
||||
let g:neoformat_enabled_cpp = ['clangformat']
|
||||
let g:neoformat_enabled_c = ['clangformat']
|
||||
|
||||
"""""""""""""""""""""""""vim-markdown settings"""""""""""""""""""
|
||||
" Disable header folding
|
||||
let g:vim_markdown_folding_disabled = 1
|
||||
|
||||
" Whether to use conceal feature in markdown
|
||||
let g:vim_markdown_conceal = 1
|
||||
|
||||
" Disable math tex conceal and syntax highlight
|
||||
let g:tex_conceal = ''
|
||||
let g:vim_markdown_math = 0
|
||||
|
||||
" Support front matter of various format
|
||||
let g:vim_markdown_frontmatter = 1 " for YAML format
|
||||
let g:vim_markdown_toml_frontmatter = 1 " for TOML format
|
||||
let g:vim_markdown_json_frontmatter = 1 " for JSON format
|
||||
|
||||
" Let the TOC window autofit so that it doesn't take too much space
|
||||
let g:vim_markdown_toc_autofit = 1
|
||||
|
||||
"""""""""""""""""""""""""markdown-preview settings"""""""""""""""""""
|
||||
" Only setting this for suitable platforms
|
||||
if g:is_win || g:is_mac
|
||||
" Do not close the preview tab when switching to other buffers
|
||||
let g:mkdp_auto_close = 0
|
||||
|
||||
" Shortcuts to start and stop markdown previewing
|
||||
nnoremap <silent> <M-m> :<C-U>MarkdownPreview<CR>
|
||||
nnoremap <silent> <M-S-m> :<C-U>MarkdownPreviewStop<CR>
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""vim-grammarous settings""""""""""""""""""""""""""""""
|
||||
if g:is_mac
|
||||
let g:grammarous#languagetool_cmd = 'languagetool'
|
||||
let g:grammarous#disabled_rules = {
|
||||
\ '*' : ['WHITESPACE_RULE', 'EN_QUOTES', 'ARROWS', 'SENTENCE_WHITESPACE',
|
||||
\ 'WORD_CONTAINS_UNDERSCORE', 'COMMA_PARENTHESIS_WHITESPACE',
|
||||
\ 'EN_UNPAIRED_BRACKETS', 'UPPERCASE_SENTENCE_START',
|
||||
\ 'ENGLISH_WORD_REPEAT_BEGINNING_RULE', 'DASH_RULE', 'PLUS_MINUS',
|
||||
\ 'PUNCTUATION_PARAGRAPH_END', 'MULTIPLICATION_SIGN', 'PRP_CHECKOUT',
|
||||
\ 'CAN_CHECKOUT', 'SOME_OF_THE', 'DOUBLE_PUNCTUATION', 'HELL',
|
||||
\ 'CURRENCY', 'POSSESSIVE_APOSTROPHE', 'ENGLISH_WORD_REPEAT_RULE',
|
||||
\ 'NON_STANDARD_WORD', 'AU', 'DATE_NEW_YEAR'],
|
||||
\ }
|
||||
|
||||
augroup grammarous_map
|
||||
autocmd!
|
||||
autocmd FileType markdown nmap <buffer> <leader>x <Plug>(grammarous-close-info-window)
|
||||
autocmd FileType markdown nmap <buffer> <c-n> <Plug>(grammarous-move-to-next-error)
|
||||
autocmd FileType markdown nmap <buffer> <c-p> <Plug>(grammarous-move-to-previous-error)
|
||||
augroup END
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""unicode.vim settings""""""""""""""""""""""""""""""
|
||||
nmap ga <Plug>(UnicodeGA)
|
||||
|
||||
""""""""""""""""""""""""""""vim-sandwich settings"""""""""""""""""""""""""""""
|
||||
" Map s to nop since s in used by vim-sandwich. Use cl instead of s.
|
||||
nmap s <Nop>
|
||||
omap s <Nop>
|
||||
|
||||
""""""""""""""""""""""""""""vimtex settings"""""""""""""""""""""""""""""
|
||||
if executable('latex')
|
||||
" Hacks for inverse search to work semi-automatically,
|
||||
" see https://jdhao.github.io/2021/02/20/inverse_search_setup_neovim_vimtex/.
|
||||
function! s:write_server_name() abort
|
||||
let nvim_server_file = (has('win32') ? $TEMP : '/tmp') . '/vimtexserver.txt'
|
||||
call writefile([v:servername], nvim_server_file)
|
||||
endfunction
|
||||
|
||||
augroup vimtex_common
|
||||
autocmd!
|
||||
autocmd FileType tex call s:write_server_name()
|
||||
autocmd FileType tex nmap <buffer> <F9> <plug>(vimtex-compile)
|
||||
augroup END
|
||||
|
||||
let g:vimtex_compiler_latexmk = {
|
||||
\ 'build_dir' : 'build',
|
||||
\ }
|
||||
|
||||
" TOC settings
|
||||
let g:vimtex_toc_config = {
|
||||
\ 'name' : 'TOC',
|
||||
\ 'layers' : ['content', 'todo', 'include'],
|
||||
\ 'resize' : 1,
|
||||
\ 'split_width' : 30,
|
||||
\ 'todo_sorted' : 0,
|
||||
\ 'show_help' : 1,
|
||||
\ 'show_numbers' : 1,
|
||||
\ 'mode' : 2,
|
||||
\ }
|
||||
|
||||
" Viewer settings for different platforms
|
||||
if g:is_win
|
||||
let g:vimtex_view_general_viewer = 'SumatraPDF'
|
||||
let g:vimtex_view_general_options = '-reuse-instance -forward-search @tex @line @pdf'
|
||||
endif
|
||||
|
||||
if g:is_mac
|
||||
" let g:vimtex_view_method = "skim"
|
||||
let g:vimtex_view_general_viewer = '/Applications/Skim.app/Contents/SharedSupport/displayline'
|
||||
let g:vimtex_view_general_options = '-r @line @pdf @tex'
|
||||
|
||||
augroup vimtex_mac
|
||||
autocmd!
|
||||
autocmd User VimtexEventCompileSuccess call UpdateSkim()
|
||||
augroup END
|
||||
|
||||
" The following code is adapted from https://gist.github.com/skulumani/7ea00478c63193a832a6d3f2e661a536.
|
||||
function! UpdateSkim() abort
|
||||
let l:out = b:vimtex.out()
|
||||
let l:src_file_path = expand('%:p')
|
||||
let l:cmd = [g:vimtex_view_general_viewer, '-r']
|
||||
|
||||
if !empty(system('pgrep Skim'))
|
||||
call extend(l:cmd, ['-g'])
|
||||
endif
|
||||
|
||||
call jobstart(l:cmd + [line('.'), l:out, l:src_file_path])
|
||||
endfunction
|
||||
endif
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""vim-matchup settings"""""""""""""""""""""""""""""
|
||||
" Improve performance
|
||||
let g:matchup_matchparen_deferred = 1
|
||||
let g:matchup_matchparen_timeout = 100
|
||||
let g:matchup_matchparen_insert_timeout = 30
|
||||
|
||||
" Enhanced matching with matchup plugin
|
||||
let g:matchup_override_vimtex = 1
|
||||
|
||||
" Whether to enable matching inside comment or string
|
||||
let g:matchup_delim_noskips = 0
|
||||
|
||||
" Show offscreen match pair in popup window
|
||||
let g:matchup_matchparen_offscreen = {'method': 'popup'}
|
||||
|
||||
"""""""""""""""""""""""""" asyncrun.vim settings """"""""""""""""""""""""""
|
||||
" Automatically open quickfix window of 6 line tall after asyncrun starts
|
||||
let g:asyncrun_open = 6
|
||||
if g:is_win
|
||||
" Command output encoding for Windows
|
||||
let g:asyncrun_encs = 'gbk'
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""""firenvim settings""""""""""""""""""""""""""""""
|
||||
if exists('g:started_by_firenvim') && g:started_by_firenvim
|
||||
if g:is_mac
|
||||
set guifont=Iosevka\ Nerd\ Font:h18
|
||||
else
|
||||
set guifont=Consolas
|
||||
endif
|
||||
|
||||
" general config for firenvim
|
||||
let g:firenvim_config = {
|
||||
\ 'globalSettings': {
|
||||
\ 'alt': 'all',
|
||||
\ },
|
||||
\ 'localSettings': {
|
||||
\ '.*': {
|
||||
\ 'cmdline': 'neovim',
|
||||
\ 'priority': 0,
|
||||
\ 'selector': 'textarea',
|
||||
\ 'takeover': 'never',
|
||||
\ },
|
||||
\ }
|
||||
\ }
|
||||
|
||||
function s:setup_firenvim() abort
|
||||
set signcolumn=no
|
||||
set noruler
|
||||
set noshowcmd
|
||||
set laststatus=0
|
||||
set showtabline=0
|
||||
endfunction
|
||||
|
||||
augroup firenvim
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:setup_firenvim()
|
||||
autocmd BufEnter sqlzoo*.txt set filetype=sql
|
||||
autocmd BufEnter github.com_*.txt set filetype=markdown
|
||||
autocmd BufEnter stackoverflow.com_*.txt set filetype=markdown
|
||||
augroup END
|
||||
endif
|
||||
|
||||
""""""""""""""""""""""""""""""nvim-gdb settings""""""""""""""""""""""""""""""
|
||||
nnoremap <leader>dp :<C-U>GdbStartPDB python -m pdb %<CR>
|
||||
|
||||
""""""""""""""""""""""""""""""wilder.nvim settings""""""""""""""""""""""""""""""
|
||||
call timer_start(250, { -> s:wilder_init() })
|
||||
|
||||
function! s:wilder_init() abort
|
||||
try
|
||||
call wilder#setup({
|
||||
\ 'modes': [':', '/', '?'],
|
||||
\ 'next_key': '<Tab>',
|
||||
\ 'previous_key': '<S-Tab>',
|
||||
\ 'accept_key': '<C-y>',
|
||||
\ 'reject_key': '<C-e>'
|
||||
\ })
|
||||
|
||||
call wilder#set_option('pipeline', [
|
||||
\ wilder#branch(
|
||||
\ wilder#cmdline_pipeline({
|
||||
\ 'language': 'python',
|
||||
\ 'fuzzy': 1,
|
||||
\ 'sorter': wilder#python_difflib_sorter(),
|
||||
\ 'debounce': 30,
|
||||
\ }),
|
||||
\ wilder#python_search_pipeline({
|
||||
\ 'pattern': wilder#python_fuzzy_pattern(),
|
||||
\ 'sorter': wilder#python_difflib_sorter(),
|
||||
\ 'engine': 're',
|
||||
\ 'debounce': 30,
|
||||
\ }),
|
||||
\ ),
|
||||
\ ])
|
||||
|
||||
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}])
|
||||
call wilder#set_option('renderer', wilder#popupmenu_renderer({
|
||||
\ 'highlighter': wilder#basic_highlighter(),
|
||||
\ 'max_height': 15,
|
||||
\ 'highlights': {
|
||||
\ 'accent': l:hl,
|
||||
\ },
|
||||
\ 'left': [' ', wilder#popupmenu_devicons(),],
|
||||
\ 'right': [' ', wilder#popupmenu_scrollbar(),],
|
||||
\ 'apply_incsearch_fix': 0,
|
||||
\ }))
|
||||
catch /^Vim\%((\a\+)\)\=:E117/
|
||||
echohl Error |echomsg "Wilder.nvim missing"| echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
""""""""""""""""""""""""""""""vim-auto-save settings""""""""""""""""""""""""""""""
|
||||
let g:auto_save = 1 " enable AutoSave on Vim startup
|
||||
Reference in New Issue
Block a user