2017-12-28 13:49:45 +00:00
|
|
|
" Important stuff {{{
|
2018-08-03 10:50:24 +00:00
|
|
|
scriptencoding utf-8 " Set utf-8 as default script encoding
|
2018-04-04 18:12:51 +00:00
|
|
|
let g:loaded_python_provider=1 " Disable python 2 interface
|
|
|
|
let g:python_host_skip_check=1 " Skip python 2 host check
|
2020-02-29 07:00:08 +00:00
|
|
|
let python_highlight_all=1 " full python syntax highlighting
|
2020-04-14 04:07:37 +00:00
|
|
|
let g:python3_host_prog = '/bin/python3'
|
2020-04-18 15:59:02 +00:00
|
|
|
let g:node_host_prog = '~/.local/share/npm/bin/neovim-node-host'
|
2020-04-14 04:07:37 +00:00
|
|
|
|
|
|
|
if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
|
2020-04-28 18:34:58 +00:00
|
|
|
silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
|
|
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
|
2020-04-14 04:07:37 +00:00
|
|
|
endif
|
2017-12-28 13:49:45 +00:00
|
|
|
" }}}
|
2018-01-22 05:32:55 +00:00
|
|
|
" Plugins {{{
|
2020-04-14 04:07:37 +00:00
|
|
|
call plug#begin(stdpath('data') . '/plugged')
|
2020-04-18 15:59:02 +00:00
|
|
|
Plug 'dense-analysis/ale'
|
2019-12-12 17:21:10 +00:00
|
|
|
Plug 'othree/yajs.vim', {'for': 'javascript'}
|
|
|
|
Plug 'othree/es.next.syntax.vim', {'for': 'javascript'}
|
2019-06-23 03:48:32 +00:00
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
2020-04-14 04:07:37 +00:00
|
|
|
Plug 'jpalardy/vim-slime', {'for': ['python', 'foxdot']}
|
2020-04-28 18:34:58 +00:00
|
|
|
Plug 'sheerun/vim-polyglot'
|
2019-05-30 15:00:26 +00:00
|
|
|
Plug 'tmsvg/pear-tree'
|
|
|
|
Plug 'tpope/vim-commentary'
|
2020-04-28 18:34:58 +00:00
|
|
|
Plug 'srcery-colors/srcery-vim'
|
2018-04-04 18:12:51 +00:00
|
|
|
call plug#end()
|
2017-12-28 13:49:45 +00:00
|
|
|
" }}}
|
2018-01-24 19:32:47 +00:00
|
|
|
" Options {{{
|
2018-04-04 18:12:51 +00:00
|
|
|
set binary
|
2019-12-14 10:34:45 +00:00
|
|
|
set path+=** " Full tab completion with subfolders and all
|
2019-12-20 21:08:06 +00:00
|
|
|
set inccommand=nosplit " Live preview of substitutes and other similar commands
|
|
|
|
set clipboard^=unnamedplus " system clipboard (requires +clipboard)
|
|
|
|
set fileencoding=utf-8 " The encoding written to file.
|
2019-05-30 15:00:26 +00:00
|
|
|
set shell=/bin/zsh " Setting shell to zsh
|
2019-12-20 21:08:06 +00:00
|
|
|
set number " Line numbers on
|
2019-12-12 17:21:10 +00:00
|
|
|
set noshowmode " Always hide mode
|
|
|
|
set showtabline=2 " Always Show tabline
|
2019-05-30 15:00:26 +00:00
|
|
|
set pumheight=12 " Completion window max size
|
|
|
|
set helpheight=12 " Minimum help window height
|
|
|
|
set noswapfile " New buffers will be loaded without creating a swapfile
|
2019-12-20 21:08:06 +00:00
|
|
|
set hidden " Enables to switch between unsaved buffers and keep undo history
|
2019-05-30 15:00:26 +00:00
|
|
|
set lazyredraw " Don't redraw while executing macros (better performance)
|
|
|
|
set showmatch " Show matching brackets when text indicator is over them
|
2019-06-23 03:48:32 +00:00
|
|
|
set matchpairs+=<:> " Add HTML brackets to pair matching
|
|
|
|
set matchtime=1 " Tenths of a second to show the matching paren
|
|
|
|
set cpoptions-=m " showmatch will wait 0.5s or until a char is typed
|
2019-05-30 15:00:26 +00:00
|
|
|
set nojoinspaces " No extra space when joining a line which ends with . ? !
|
|
|
|
set updatetime=300 " Update time used to create swap file or other things
|
|
|
|
set synmaxcol=200 " Don't try to syntax highlight minified files
|
|
|
|
set splitbelow " Splitting a window will put the new window below the current
|
|
|
|
set splitright " Splitting a window will put the new window right of the current
|
|
|
|
set notimeout " Time out on key codes but not mappings.
|
|
|
|
set ignorecase " Ignore case by default
|
|
|
|
set cursorline " Hightlight the screen line of the cursor
|
|
|
|
set visualbell " Use visual bell instead of beeping
|
2019-08-22 01:42:47 +00:00
|
|
|
set scrolloff=5 " Keep this many lines padding when scrolling
|
2019-12-20 21:08:06 +00:00
|
|
|
set shortmess+=aoOIWcs " Shorten messages and don't show intro
|
2019-05-30 15:00:26 +00:00
|
|
|
set foldnestmax=10 " Deepest fold is 10 levels
|
2019-12-20 21:08:06 +00:00
|
|
|
set foldmethod=marker " Markers are used to specify folds.
|
2019-12-03 14:50:43 +00:00
|
|
|
set foldclose=all " Folds closed by default
|
2019-12-20 21:08:06 +00:00
|
|
|
set foldlevelstart=10 " Don't auto open folds after this many levels
|
2019-12-03 14:50:43 +00:00
|
|
|
set selectmode=key " Shift + arrow keys for selecting text
|
2019-12-20 21:08:06 +00:00
|
|
|
set keymodel=startsel " This one complements the one above it
|
2019-12-03 14:50:43 +00:00
|
|
|
set signcolumn=yes " Gutter for diagnostics and git status
|
2019-12-20 21:08:06 +00:00
|
|
|
set tabstop=8 " Number of spaces a <Tab> equals
|
2019-12-12 17:21:10 +00:00
|
|
|
set shiftwidth=4 " Number of spaces to use in auto(indent)
|
|
|
|
set softtabstop=4 " While performing editing operations
|
|
|
|
set shiftround " Round indent to multiple of 'shiftwidth'
|
2019-12-14 10:34:45 +00:00
|
|
|
set breakindent " Keep indentation
|
2019-12-20 21:08:06 +00:00
|
|
|
set expandtab
|
2020-02-29 07:00:08 +00:00
|
|
|
set nosmarttab
|
2019-12-12 17:21:10 +00:00
|
|
|
set title
|
2019-05-05 15:19:30 +00:00
|
|
|
set redrawtime=500
|
2018-04-04 18:12:51 +00:00
|
|
|
set ttimeoutlen=10
|
|
|
|
set nowritebackup
|
2018-09-20 19:17:01 +00:00
|
|
|
set completeopt-=preview
|
2018-04-04 18:12:51 +00:00
|
|
|
set nostartofline
|
|
|
|
set modeline
|
|
|
|
set undofile
|
|
|
|
set undolevels=1000
|
|
|
|
set undoreload=10000
|
|
|
|
set undodir=$HOME/.config/nvim/undo
|
2019-12-20 21:08:06 +00:00
|
|
|
set formatoptions+=nl
|
2020-04-28 18:34:58 +00:00
|
|
|
set formatoptions-=crot
|
2019-05-30 15:00:26 +00:00
|
|
|
set pastetoggle=<F12>
|
2020-04-28 18:34:58 +00:00
|
|
|
set fillchars+=vert:\
|
2019-12-12 17:21:10 +00:00
|
|
|
set grepprg=rg\ --vimgrep\ --hidden\ --no-heading
|
|
|
|
set grepformat=%f:%l:%c:%m,%f:%l:%m
|
2020-04-28 18:34:58 +00:00
|
|
|
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2020-03-29 19:16:35 +00:00
|
|
|
set wildignore+=*.jpg,*.jpeg,*.bmp,*.gif,*.png,*.svg " image
|
2019-12-20 21:08:06 +00:00
|
|
|
set wildignore+=*.manifest " gb
|
|
|
|
set wildignore+=*.o,*.obj,*.exe,*.dll,*.so,*.out,*.class " compiler
|
|
|
|
set wildignore+=*.swp,*.swo,*.swn " vim
|
2020-03-29 19:16:35 +00:00
|
|
|
set wildignore+=*/.git,*/.hg,*/.svn,*/node_modules " vcs
|
2019-12-20 21:08:06 +00:00
|
|
|
|
2018-11-04 23:36:14 +00:00
|
|
|
if &diff
|
2019-12-20 21:08:06 +00:00
|
|
|
set textwidth=80
|
2020-01-23 14:25:42 +00:00
|
|
|
highlight! link DiffText MatchParen
|
2018-11-04 23:36:14 +00:00
|
|
|
endif
|
|
|
|
|
2018-08-31 04:12:16 +00:00
|
|
|
let mapleader="\<SPACE>"
|
2019-12-12 17:21:10 +00:00
|
|
|
let maplocalleader=','
|
2018-08-31 04:12:16 +00:00
|
|
|
let formatlistpat='^\s*\(\d\+[\]:.)}\t ]\|[*-][\t ]\)\s*'
|
2020-02-29 07:00:08 +00:00
|
|
|
let g:polyglot_disabled = ['javascript', 'python']
|
2020-04-28 18:34:58 +00:00
|
|
|
let g:vim_markdown_toc_autofit = 1
|
2019-12-12 17:21:10 +00:00
|
|
|
let g:markdown_fenced_languages = ['vim', 'help']
|
2020-04-14 04:07:37 +00:00
|
|
|
let g:vim_jsx_pretty_colorful_config = 1
|
|
|
|
let g:jsx_ext_required = 1
|
2018-08-28 16:13:36 +00:00
|
|
|
" }}}
|
2020-04-18 15:59:02 +00:00
|
|
|
" {{{ Ale
|
|
|
|
let g:ale_use_global_executables = 1
|
|
|
|
let g:ale_completion_enabled = 0
|
|
|
|
let g:ale_linters_explicit = 1
|
|
|
|
let g:ale_lint_delay = 0
|
|
|
|
let g:ale_lint_on_text_changed = 'normal'
|
|
|
|
let g:ale_lint_on_insert_leave = 1
|
|
|
|
let g:ale_fix_on_save = 1
|
|
|
|
let g:ale_close_preview_on_insert = 1
|
|
|
|
let g:ale_sign_highlight_linenrs = 1
|
|
|
|
let g:ale_sign_error = '✖'
|
|
|
|
let g:ale_sign_warning = '⚠'
|
|
|
|
let g:ale_sign_info = '●'
|
|
|
|
let g:ale_set_balloons = 1
|
|
|
|
let g:ale_virtualtext_cursor = 1
|
|
|
|
let g:ale_loclist_msg_format = '[%linter%] %s% (code)% [%severity%]'
|
|
|
|
let g:ale_set_highlights = 1
|
|
|
|
let g:ale_set_signs = 1
|
|
|
|
let g:ale_python_mypy_options = '--ignore-missing-imports'
|
|
|
|
let g:ale_python_pylint_options = '--disable=C'
|
|
|
|
let g:ale_python_flake8_options = '--ignore=E221'
|
|
|
|
let g:move_key_modifier = 'N'
|
|
|
|
|
|
|
|
let g:ale_linter_aliases = {
|
|
|
|
\ 'jsx': ['css', 'javascript'],
|
|
|
|
\ 'vue': ['vue', 'javascript'],
|
|
|
|
\}
|
|
|
|
let g:ale_linters = {
|
|
|
|
\ 'javascript': ['prettier_standard'],
|
2020-04-28 18:34:58 +00:00
|
|
|
\ 'jsx': ['prettier_standard'],
|
2020-04-18 15:59:02 +00:00
|
|
|
\ 'typescript': ['tsserver', 'eslint'],
|
2020-04-28 18:34:58 +00:00
|
|
|
\ 'json': ['prettier_standard'],
|
|
|
|
\ 'html': ['prettier_standard'],
|
|
|
|
\ 'css': ['stylelint'],
|
|
|
|
\ 'scss': ['stylelint'],
|
|
|
|
\ 'bash': ['shellcheck'],
|
|
|
|
\ 'sh': ['shellcheck'],
|
|
|
|
\ 'vim': ['vint'],
|
|
|
|
\ 'python': ['pyls', 'flake8', 'pylint']
|
2020-04-18 15:59:02 +00:00
|
|
|
\}
|
|
|
|
let g:ale_fixers = {
|
2020-04-28 18:34:58 +00:00
|
|
|
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
2020-04-18 15:59:02 +00:00
|
|
|
\ 'javascript': ['prettier_standard'],
|
2020-04-28 18:34:58 +00:00
|
|
|
\ 'jsx': ['prettier_standard'],
|
2020-04-18 15:59:02 +00:00
|
|
|
\ 'typescript': ['prettier_standard'],
|
2020-04-28 18:34:58 +00:00
|
|
|
\ 'json': ['prettier_standard'],
|
|
|
|
\ 'scss': ['stylelint'],
|
|
|
|
\ 'css': ['stylelint'],
|
|
|
|
\ 'html': ['prettier_standard'],
|
|
|
|
\ 'markdown': ['prettier_standard'],
|
|
|
|
\ 'python': ['autopep8', 'isort', 'yapf']
|
2020-04-18 15:59:02 +00:00
|
|
|
\}
|
|
|
|
let g:ale_pattern_options = {
|
|
|
|
\ '\.min\.js$': {'ale_linters': [], 'ale_fixers': []},
|
|
|
|
\ '\.min\.css$': {'ale_linters': [], 'ale_fixers': []},
|
|
|
|
\}
|
|
|
|
|
|
|
|
nmap <silent> <F7> <Plug>(ale_previous_wrap)
|
|
|
|
nmap <silent> <F8> <Plug>(ale_next_wrap)
|
|
|
|
" }}}
|
2019-05-30 15:00:26 +00:00
|
|
|
" CoC {{{
|
2020-04-28 18:34:58 +00:00
|
|
|
let g:coc_global_extensions = ['coc-lists', 'coc-highlight', 'coc-explorer', 'coc-snippets', 'coc-python', 'coc-tsserver', 'coc-emmet', 'coc-css', 'coc-html', 'coc-json']
|
2019-12-12 17:21:10 +00:00
|
|
|
|
2019-11-28 17:05:32 +00:00
|
|
|
" Lists
|
|
|
|
nnoremap <silent><F1> :<C-u>CocList -S --ignore-case helptags<CR>
|
2019-12-20 21:08:06 +00:00
|
|
|
nnoremap <silent><F2> :<C-u>CocList -S --ignore-case files<CR>
|
2019-11-28 17:05:32 +00:00
|
|
|
nnoremap <silent><F3> :<C-u>CocList --normal buffers<CR>
|
|
|
|
nnoremap <silent><F4> :<C-u>CocList windows<CR>
|
2020-04-28 18:34:58 +00:00
|
|
|
nnoremap <silent><F9> :<C-u>CocList snippets<CR>
|
2019-05-30 15:00:26 +00:00
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
" Explorer
|
|
|
|
nnoremap <silent><F5> :CocCommand explorer<CR>
|
|
|
|
|
|
|
|
" Config
|
|
|
|
nnoremap <silent><F6> :CocConfig<CR>
|
|
|
|
|
2019-10-12 02:38:12 +00:00
|
|
|
" <CR> to confirm completion
|
|
|
|
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<CR>"
|
2019-05-30 15:00:26 +00:00
|
|
|
|
2019-09-28 15:34:59 +00:00
|
|
|
inoremap <silent><expr> <TAB>
|
2020-04-28 18:34:58 +00:00
|
|
|
\ pumvisible() ? coc#_select_confirm() :
|
|
|
|
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
|
|
|
|
\ <SID>check_back_space() ? "\<TAB>" :
|
|
|
|
\ coc#refresh()
|
2019-09-28 15:34:59 +00:00
|
|
|
|
|
|
|
function! s:check_back_space() abort
|
2020-04-28 18:34:58 +00:00
|
|
|
let col = col('.') - 1
|
|
|
|
return !col || getline('.')[col - 1] =~# '\s'
|
2019-09-28 15:34:59 +00:00
|
|
|
endfunction
|
|
|
|
|
2020-04-28 18:34:58 +00:00
|
|
|
let g:coc_snippet_next = '<tab>'
|
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
" Use <c-space> to trigger completion.
|
|
|
|
inoremap <silent><expr> <c-space> coc#refresh()
|
|
|
|
|
|
|
|
" GoTo code navigation.
|
2020-04-28 18:34:58 +00:00
|
|
|
nnoremap <silent> gd <Plug>(coc-definition)
|
|
|
|
nnoremap <silent> gr <Plug>(coc-references)
|
2020-04-14 04:07:37 +00:00
|
|
|
|
|
|
|
" 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.
|
2020-04-28 18:34:58 +00:00
|
|
|
nnoremap <leader>rn <Plug>(coc-rename)
|
2018-08-31 04:12:16 +00:00
|
|
|
"}}}
|
2019-05-05 15:19:30 +00:00
|
|
|
" Colors {{{
|
2019-06-23 03:48:32 +00:00
|
|
|
set termguicolors
|
2020-04-28 18:34:58 +00:00
|
|
|
let g:srcery_transparent_background = 1
|
|
|
|
let g:srcery_italic = 1
|
|
|
|
let g:srcery_underline = 1
|
|
|
|
let g:srcery_undercurl = 1
|
|
|
|
let g:srcery_inverse_matches = 1
|
|
|
|
colorscheme srcery
|
2019-05-30 15:00:26 +00:00
|
|
|
|
|
|
|
function! MyHighlights() abort
|
|
|
|
highlight Trail ctermbg=red guibg=red
|
|
|
|
call matchadd('Trail', '\s\+$', 100)
|
2019-06-23 03:48:32 +00:00
|
|
|
highlight ColorColumn ctermbg=magenta
|
|
|
|
call matchadd('ColorColumn', '\%81v', 100)
|
2019-05-30 15:00:26 +00:00
|
|
|
endfunction
|
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
hi! VertSplit ctermbg=NONE ctermfg=NONE cterm=NONE guibg=NONE guifg=#080808 gui=NONE
|
2019-09-28 15:34:59 +00:00
|
|
|
hi! Folded ctermbg=NONE guibg=NONE
|
2020-04-28 18:34:58 +00:00
|
|
|
hi! TabLineFill ctermfg=NONE ctermbg=NONE cterm=NONE guibg=NONE guifg=#ef2f27 gui=NONE
|
2020-04-14 04:07:37 +00:00
|
|
|
hi! TablineSel ctermfg=234 ctermbg=NONE guibg=NONE guifg=#008bbd
|
|
|
|
hi! RedrawDebugClear guibg=#080808
|
|
|
|
hi! NvimInternalError guifg=#080808
|
|
|
|
hi! DiffAdded guifg=#333333
|
|
|
|
hi! PmenuSel guifg=#6699cc guibg=#111111
|
|
|
|
hi! PmenuThumb guifg=#333333
|
2019-05-30 15:00:26 +00:00
|
|
|
hi! link CocErrorSign WarningMsg
|
|
|
|
hi! link CocWarningSign Number
|
|
|
|
hi! link CocInfoSign Type
|
2020-04-19 04:42:47 +00:00
|
|
|
hi! CocUnderline gui=undercurl term=undercurl
|
|
|
|
hi! CocErrorHighlight ctermfg=red guifg=#c4384b gui=undercurl term=undercurl
|
|
|
|
hi! CocWarningHighlight ctermfg=yellow guifg=#c4ab39 gui=undercurl term=undercurl
|
2018-08-31 04:12:16 +00:00
|
|
|
" }}}
|
2019-08-22 01:42:47 +00:00
|
|
|
" Statusline {{{
|
2020-04-14 04:07:37 +00:00
|
|
|
highlight User1 ctermfg=251 ctermbg=NONE guibg=NONE guifg=#c6c6c6
|
|
|
|
highlight User2 ctermfg=234 ctermbg=NONE guibg=NONE guifg=#f74782
|
|
|
|
highlight User3 ctermfg=234 ctermbg=4 guibg=NONE guifg=#008bb4
|
|
|
|
highlight User4 ctermfg=234 ctermbg=251 guibg=NONE guifg=#c6c6c6
|
|
|
|
highlight User5 ctermfg=234 ctermbg=4 guibg=NONE guifg=#e64eff
|
|
|
|
highlight User6 ctermfg=234 ctermbg=9 guibg=NONE guifg=#fbad34
|
|
|
|
highlight User7 ctermfg=234 ctermbg=251 guibg=NONE guifg=#407e4a
|
2019-08-22 01:42:47 +00:00
|
|
|
|
2019-12-28 16:20:17 +00:00
|
|
|
let g:modes={
|
2019-08-22 01:42:47 +00:00
|
|
|
\ 'n' : ['%3*', 'NORMAL'],
|
2019-12-28 16:20:17 +00:00
|
|
|
\ 'no' : ['%3*', 'NORMAL·OPERATOR PENDING'],
|
2019-08-22 01:42:47 +00:00
|
|
|
\ 'v' : ['%5*', 'VISUAL'],
|
2019-12-28 16:20:17 +00:00
|
|
|
\ 'V' : ['%5*', 'V·LINE'],
|
2019-08-22 01:42:47 +00:00
|
|
|
\ '^V' : ['%5*', 'V·BLOCK'],
|
|
|
|
\ 's' : ['%7*', 'SELECT'],
|
|
|
|
\ 'S' : ['%7*', 'S·LINE'],
|
|
|
|
\ '^S' : ['%7*', 'S·BLOCK'],
|
2019-12-28 16:20:17 +00:00
|
|
|
\ 'i' : ['%4*', 'INSERT'],
|
|
|
|
\ 'R' : ['%2*', 'REPLACE'],
|
|
|
|
\ 'Rv' : ['%2*', 'V·REPLACE'],
|
|
|
|
\ 'c' : ['%6*', 'COMMAND'],
|
|
|
|
\ 'cv' : ['%6*', 'VIM EX'],
|
|
|
|
\ 'ce' : ['%6*', 'EX'],
|
|
|
|
\ 'r' : ['%1*', 'PROMPT'],
|
|
|
|
\ 'rm' : ['%1*', 'MORE'],
|
|
|
|
\ 'r?' : ['%1*', 'CONFIRM'],
|
|
|
|
\ '!' : ['%*1', 'SHELL'],
|
|
|
|
\ 't' : ['%*1', 'TERMINAL']
|
|
|
|
\}
|
2019-08-22 01:42:47 +00:00
|
|
|
|
|
|
|
function! LinterStatus() abort
|
2020-04-18 15:59:02 +00:00
|
|
|
let l:counts = ale#statusline#Count(bufnr(''))
|
|
|
|
let l:all_errors = l:counts.error + l:counts.style_error
|
|
|
|
let l:all_non_errors = l:counts.total - l:all_errors
|
|
|
|
return l:counts.total == 0 ? '' : printf(
|
|
|
|
\ ' ⚠ :%d ✖ :%d ',
|
|
|
|
\ l:all_non_errors,
|
|
|
|
\ l:all_errors
|
|
|
|
\)
|
2019-08-22 01:42:47 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! ModeColor() abort
|
2019-12-28 16:20:17 +00:00
|
|
|
return get(g:modes, mode(), '%*')[0]
|
2019-08-22 01:42:47 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! CurrentMode() abort
|
2019-12-28 16:20:17 +00:00
|
|
|
return ' ' . get(g:modes, mode(), '-')[1] . ' '
|
2019-08-22 01:42:47 +00:00
|
|
|
endfunction
|
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
function! LinePasteMode() abort
|
2019-08-22 01:42:47 +00:00
|
|
|
let paste_status = &paste
|
|
|
|
if paste_status == 1
|
2019-12-12 17:21:10 +00:00
|
|
|
return ' paste '
|
2019-08-22 01:42:47 +00:00
|
|
|
else
|
2019-12-12 17:21:10 +00:00
|
|
|
return ''
|
2019-08-22 01:42:47 +00:00
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! Statusline()
|
2019-12-12 17:21:10 +00:00
|
|
|
let b:status=''
|
2019-08-22 01:42:47 +00:00
|
|
|
let b:status.=ModeColor()
|
|
|
|
let b:status.=CurrentMode()
|
|
|
|
let b:status.=LinePasteMode()
|
2019-12-12 17:21:10 +00:00
|
|
|
let b:status.='%1* '
|
|
|
|
let b:status.='%= '
|
2020-04-18 15:59:02 +00:00
|
|
|
let b:status.=coc#status()
|
2020-02-29 07:00:08 +00:00
|
|
|
let b:status.=' %6*'
|
2019-08-22 01:42:47 +00:00
|
|
|
let b:status.=LinterStatus()
|
2019-12-12 17:21:10 +00:00
|
|
|
let b:status.='%3* %p%% %c '
|
2020-04-14 04:07:37 +00:00
|
|
|
let b:status.=''
|
2019-08-22 01:42:47 +00:00
|
|
|
return b:status
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
set statusline=%!Statusline()
|
|
|
|
" }}}
|
2019-12-12 17:21:10 +00:00
|
|
|
" Tabline {{{
|
|
|
|
function! Tabline()
|
|
|
|
let s = ''
|
|
|
|
for i in range(tabpagenr('$'))
|
|
|
|
let tab = i + 1
|
|
|
|
let winnr = tabpagewinnr(tab)
|
|
|
|
let buflist = tabpagebuflist(tab)
|
|
|
|
let bufnr = buflist[winnr - 1]
|
|
|
|
let bufname = bufname(bufnr)
|
|
|
|
let bufmodified = getbufvar(bufnr, '&mod')
|
|
|
|
|
|
|
|
let s .= '%' . tab . 'T'
|
|
|
|
let s .= (tab == tabpagenr() ? '%#TabLineSel#' : '%#TabLine#')
|
|
|
|
let s .= ' ' . tab .':'
|
2019-12-28 16:20:17 +00:00
|
|
|
let s .= (bufname !=? '' ? fnamemodify(bufname, ':t') . ' ' : '[No Name] ')
|
2019-12-12 17:21:10 +00:00
|
|
|
|
|
|
|
if bufmodified
|
2019-12-28 16:20:17 +00:00
|
|
|
let s .= ' + '
|
2019-12-12 17:21:10 +00:00
|
|
|
endif
|
|
|
|
endfor
|
|
|
|
|
|
|
|
let s .= '%#TabLineFill#'
|
|
|
|
if (exists('g:tablineclosebutton'))
|
|
|
|
let s .= '%=%999XX'
|
|
|
|
endif
|
|
|
|
return s
|
|
|
|
endfunction
|
|
|
|
set tabline=%!Tabline()
|
|
|
|
" }}}
|
2018-11-04 23:36:14 +00:00
|
|
|
" AutoCommands {{{
|
2019-12-12 17:21:10 +00:00
|
|
|
if !exists('autocommands_loaded') && has('autocmd')
|
2018-11-04 23:36:14 +00:00
|
|
|
let autocommands_loaded = 1
|
|
|
|
|
2020-04-15 22:08:22 +00:00
|
|
|
function! PopOutOfInsertMode() abort
|
2019-06-23 03:48:32 +00:00
|
|
|
if v:insertmode
|
|
|
|
call feedkeys("\<C-\>\<C-n>")
|
|
|
|
endif
|
|
|
|
endfunction
|
2018-11-04 23:36:14 +00:00
|
|
|
|
2020-04-15 22:08:22 +00:00
|
|
|
function! Relativize(v) abort
|
2019-08-22 01:42:47 +00:00
|
|
|
if &number
|
|
|
|
let &relativenumber = a:v
|
|
|
|
endif
|
|
|
|
endfunction
|
|
|
|
|
2020-04-15 22:08:22 +00:00
|
|
|
function! LocalStatusLine() abort
|
2019-12-12 17:21:10 +00:00
|
|
|
let b:status = '%#error#[HELP]%*'
|
2019-08-22 01:42:47 +00:00
|
|
|
return b:status
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
aug relativize
|
|
|
|
au BufWinEnter,FocusGained,InsertLeave,WinEnter * call Relativize(1)
|
|
|
|
au BufWinLeave,FocusLost,InsertEnter,WinLeave * call Relativize(0)
|
|
|
|
aug END
|
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
aug on_save
|
2019-08-22 01:42:47 +00:00
|
|
|
au BufWritePre * :%s/\s\+$//e
|
2020-03-29 19:16:35 +00:00
|
|
|
au BufWritePost *xresources !xrdb %
|
|
|
|
au BufWritePost *sxhkdrc !pkill -USR1 sxhkd
|
|
|
|
au QuitPre * if empty(&buftype) | lclose | endif
|
2019-06-23 03:48:32 +00:00
|
|
|
aug END
|
2019-05-30 15:00:26 +00:00
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
aug term_stuff
|
2020-04-28 18:34:58 +00:00
|
|
|
au TermOpen * setlocal nonumber norelativenumber laststatus=0
|
|
|
|
au TermOpen * setlocal signcolumn=no noruler nocursorline
|
|
|
|
aug END
|
2019-06-23 03:48:32 +00:00
|
|
|
|
|
|
|
aug miscs
|
2019-08-22 01:42:47 +00:00
|
|
|
au CursorHold * silent call CocActionAsync('highlight')
|
2019-12-12 17:21:10 +00:00
|
|
|
au CursorHold * call CocActionAsync('doHover')
|
2019-10-12 02:38:12 +00:00
|
|
|
au User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
2019-12-12 17:21:10 +00:00
|
|
|
au ColorScheme * call MyHighlights()
|
2020-04-14 04:07:37 +00:00
|
|
|
aug END
|
2019-01-08 13:01:43 +00:00
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
aug inserts
|
2020-04-15 22:08:22 +00:00
|
|
|
au InsertEnter * norm zz
|
2020-04-28 18:34:58 +00:00
|
|
|
au InsertEnter * setlocal nocursorline
|
|
|
|
au InsertLeave * setlocal cursorline nopaste
|
2019-06-23 03:48:32 +00:00
|
|
|
au InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
|
|
|
|
au FocusLost,TabLeave * call PopOutOfInsertMode()
|
2019-05-05 15:19:30 +00:00
|
|
|
aug END
|
|
|
|
|
2018-11-04 23:36:14 +00:00
|
|
|
aug skeletons
|
2019-06-23 03:48:32 +00:00
|
|
|
au BufNewFile *.py 0r ~/.config/nvim/templates/py.skeleton
|
|
|
|
au BufNewFile *.sh 0r ~/.config/nvim/templates/sh.skeleton
|
2018-11-04 23:36:14 +00:00
|
|
|
aug END
|
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
aug file_types
|
2020-04-28 18:34:58 +00:00
|
|
|
au FileType typescript,json setlocal formatexpr=CocAction('formatSelected')
|
|
|
|
au FileType help setlocal statusline=%!LocalStatusLine()
|
|
|
|
au FileType json syntax match Comment +\/\/.\+$+
|
|
|
|
au BufNewFile,BufRead requirements*.txt set syntax=python
|
|
|
|
au FileType make setlocal noexpandtab
|
|
|
|
aug END
|
2018-11-04 23:36:14 +00:00
|
|
|
endif
|
|
|
|
" }}}
|
2019-06-23 03:48:32 +00:00
|
|
|
" REPL {{{
|
2020-04-06 17:07:13 +00:00
|
|
|
let g:slime_paste_file = '$HOME/.cache/slime_paste'
|
2020-02-29 07:00:08 +00:00
|
|
|
let g:slime_target = 'neovim'
|
|
|
|
let g:slime_python_ipython = 1
|
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
let g:my_active_terminal_job_id = -1
|
|
|
|
|
|
|
|
function! LaunchTerminal() range
|
|
|
|
silent exe "normal! :12split\n"
|
|
|
|
silent exe "normal! :terminal\n"
|
|
|
|
call SetActiveTerminalJobID()
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! LaunchSC() range abort
|
|
|
|
silent exe "normal! :tabnew\n"
|
|
|
|
silent exe "normal! :terminal\n"
|
|
|
|
call SetActiveTerminalJobID()
|
|
|
|
call jobsend(g:my_active_terminal_job_id, "scsynth -u 57110\r")
|
|
|
|
sleep 2200ms
|
2020-02-29 07:00:08 +00:00
|
|
|
silent exe "normal! G"
|
2019-06-23 03:48:32 +00:00
|
|
|
silent exe "normal! :vsplit\n"
|
|
|
|
silent exe "normal! :terminal\n"
|
|
|
|
call SetActiveTerminalJobID()
|
2020-04-14 04:07:37 +00:00
|
|
|
call jobsend(g:my_active_terminal_job_id, "sclang -D ~/doc/Algorave/foxdot.scd\r")
|
2019-06-23 03:48:32 +00:00
|
|
|
silent exe "normal! :tabprev\n"
|
2019-07-16 19:34:46 +00:00
|
|
|
silent exe "normal! <cr>\n"
|
2019-06-23 03:48:32 +00:00
|
|
|
sleep 2200ms
|
2020-04-06 17:07:13 +00:00
|
|
|
silent exe "normal! G"
|
2019-06-23 03:48:32 +00:00
|
|
|
endfunction
|
|
|
|
|
2020-02-29 07:00:08 +00:00
|
|
|
function! LaunchIpython() range abort
|
|
|
|
call LaunchTerminal()
|
|
|
|
call jobsend(g:my_active_terminal_job_id, "ipython\r")
|
|
|
|
sleep 2200ms
|
|
|
|
silent exe "normal! G"
|
|
|
|
endfunction
|
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
function! LaunchFoxDot() range abort
|
|
|
|
call LaunchTerminal()
|
|
|
|
call jobsend(g:my_active_terminal_job_id, "ipython\r")
|
|
|
|
sleep 2200ms
|
|
|
|
call jobsend(g:my_active_terminal_job_id, "from FoxDot import *\r")
|
2019-12-12 17:21:10 +00:00
|
|
|
silent exe 'normal! G'
|
2019-06-23 03:48:32 +00:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! SetActiveTerminalJobID()
|
|
|
|
let g:my_active_terminal_job_id = b:terminal_job_id
|
2020-02-29 07:00:08 +00:00
|
|
|
echom "Active terminal job ID set to " . g:my_active_terminal_job_id
|
2019-06-23 03:48:32 +00:00
|
|
|
endfunction
|
|
|
|
|
2020-02-29 07:00:08 +00:00
|
|
|
map <silent> <Leader>xi :call LaunchIpython()<CR>
|
2019-06-23 03:48:32 +00:00
|
|
|
map <silent> <Leader>xs :call LaunchSC()<CR>
|
|
|
|
map <silent> <Leader>xd :call LaunchFoxDot()<CR>
|
|
|
|
map <silent> <Leader>xf :set filetype=foxdot<CR>
|
|
|
|
"}}}
|
2018-08-31 04:12:16 +00:00
|
|
|
"Mappings {{{
|
2019-05-30 15:00:26 +00:00
|
|
|
"Normal {{{
|
2019-08-22 01:42:47 +00:00
|
|
|
" Ñ master race
|
|
|
|
nnoremap ñ ;
|
|
|
|
nnoremap Ñ ,
|
|
|
|
|
2020-03-11 19:16:16 +00:00
|
|
|
" Rearrange Splits
|
2020-04-14 04:07:37 +00:00
|
|
|
nnoremap <silent> <S-Left> <C-W>H
|
|
|
|
nnoremap <silent> <S-Right> <C-W>L
|
|
|
|
nnoremap <silent> <S-Up> <C-W>K
|
|
|
|
nnoremap <silent> <S-Down> <C-W>J
|
2020-03-11 19:16:16 +00:00
|
|
|
|
2019-12-12 17:21:10 +00:00
|
|
|
" Resize splits
|
2018-04-04 18:12:51 +00:00
|
|
|
nnoremap <silent> <Left> :vertical resize -2<CR>
|
|
|
|
nnoremap <silent> <Right> :vertical resize +2<CR>
|
2018-07-21 04:46:57 +00:00
|
|
|
nnoremap <silent> <Up> :resize -1<CR>
|
|
|
|
nnoremap <silent> <Down> :resize +1<CR>
|
2019-12-12 17:21:10 +00:00
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
" Alt to switch windows
|
|
|
|
nnoremap <M-j> <C-W><C-J>
|
|
|
|
nnoremap <M-k> <C-W><C-K>
|
|
|
|
nnoremap <M-l> <C-W><C-L>
|
|
|
|
nnoremap <M-h> <C-W><C-H>
|
2018-07-21 04:46:57 +00:00
|
|
|
|
2018-08-31 04:12:16 +00:00
|
|
|
" Edit and source config file
|
2018-07-21 04:46:57 +00:00
|
|
|
nnoremap <silent> <leader>ev :vsplit $MYVIMRC<CR>
|
|
|
|
nnoremap <silent> <leader>sv :source $MYVIMRC<CR>
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2020-04-28 18:34:58 +00:00
|
|
|
" Gotta Go Fast (save, buffer close, quit, SOF, EOF, messages)
|
2019-09-28 15:34:59 +00:00
|
|
|
nnoremap <silent> <leader>w :w!<CR>
|
2019-11-28 17:05:32 +00:00
|
|
|
nnoremap <silent> <leader>b :bdelete<CR>
|
2019-09-28 15:34:59 +00:00
|
|
|
nnoremap <silent> <leader>q :q!<CR>
|
2019-12-03 14:50:43 +00:00
|
|
|
nnoremap <silent> <leader>Q :qa!<CR>
|
2020-02-29 07:00:08 +00:00
|
|
|
nnoremap <Bar> gg
|
2020-03-11 19:16:16 +00:00
|
|
|
nnoremap ¿ G
|
|
|
|
nnoremap <silent> <leader>m :messsages<CR>
|
2020-02-29 07:00:08 +00:00
|
|
|
|
2018-08-31 04:12:16 +00:00
|
|
|
" Splits
|
2020-02-29 07:00:08 +00:00
|
|
|
nnoremap <silent> <leader>T :call LaunchTerminal()<CR>
|
|
|
|
nnoremap <silent> <leader>s :split<CR>
|
|
|
|
nnoremap <silent> <leader>v :vsplit<CR>
|
|
|
|
nnoremap <silent> <leader>nv :vnew<CR>
|
|
|
|
nnoremap <silent> <leader>ns :new<CR>
|
2018-04-04 18:12:51 +00:00
|
|
|
|
|
|
|
" My vim wants to enter all the time, enter all the time
|
|
|
|
nnoremap <silent> <CR> i<CR><ESC>
|
|
|
|
|
2018-08-28 16:13:36 +00:00
|
|
|
" Quote words under cursor
|
|
|
|
nnoremap <leader>" viW<esc>a"<esc>gvo<esc>i"<esc>gvo<esc>3l
|
|
|
|
nnoremap <leader>' viW<esc>a'<esc>gvo<esc>i'<esc>gvo<esc>3l
|
|
|
|
|
|
|
|
" Move a line of text using Shift+[jk]
|
2019-12-03 14:50:43 +00:00
|
|
|
nnoremap <silent> <S-j> mz:m+<cr>`z
|
|
|
|
nnoremap <silent> <S-k> mz:m-2<cr>`z
|
2018-07-21 04:46:57 +00:00
|
|
|
|
2018-04-04 18:12:51 +00:00
|
|
|
" Unhighlight search terms
|
2018-07-04 19:27:13 +00:00
|
|
|
nnoremap <silent> <leader><space> :noh<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2018-07-21 04:46:57 +00:00
|
|
|
" j = gj :: k = gk while preserving numbered jumps ie. 12j or 30k
|
|
|
|
nnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
|
|
|
|
nnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2018-08-31 04:12:16 +00:00
|
|
|
" Line movements
|
2018-04-04 18:12:51 +00:00
|
|
|
noremap <silent> <Home> g<Home>
|
|
|
|
noremap <silent> <End> g<End>
|
2019-05-30 15:00:26 +00:00
|
|
|
nnoremap Y 0y$
|
|
|
|
nnoremap <leader>y y$
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2019-05-30 15:00:26 +00:00
|
|
|
" Tab movement
|
|
|
|
nnoremap tn :tabnew<cr>
|
|
|
|
nnoremap th :tabfirst<cr>
|
|
|
|
nnoremap tl :tablast<cr>
|
2019-12-28 16:20:17 +00:00
|
|
|
nnoremap tx :tabclose<cr>
|
2019-05-30 15:00:26 +00:00
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
" Center view on search result
|
|
|
|
nnoremap n nzz
|
|
|
|
nnoremap N Nzz
|
|
|
|
nnoremap * *zz
|
|
|
|
nnoremap # #zz
|
|
|
|
nnoremap g* g*zz
|
|
|
|
nnoremap g# g#zz
|
2019-08-22 01:42:47 +00:00
|
|
|
|
2020-04-28 18:34:58 +00:00
|
|
|
" Prevent x from overriding what's in the clipboard.
|
|
|
|
nnoremap x "_x
|
|
|
|
nnoremap X "_x
|
|
|
|
|
|
|
|
" Prevent selecting and pasting from overwriting what you originally copied.
|
|
|
|
xnoremap p pgvy
|
|
|
|
|
2019-12-03 14:50:43 +00:00
|
|
|
" What about the Q
|
|
|
|
nnoremap Q <nop>
|
|
|
|
map q <nop>
|
2019-05-30 15:00:26 +00:00
|
|
|
"}}}
|
|
|
|
"Insert {{{
|
|
|
|
" Ensure that ctrl+u in insert mode can be reversed
|
|
|
|
" http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U
|
|
|
|
inoremap <c-u> <c-g>u<c-u>
|
|
|
|
inoremap <c-w> <c-g>u<c-w>
|
|
|
|
|
2020-04-14 04:07:37 +00:00
|
|
|
" Exit insert, dd line, enter insert
|
2019-05-30 15:00:26 +00:00
|
|
|
inoremap <c-d> <esc>ddi
|
|
|
|
|
|
|
|
" Line movements
|
|
|
|
inoremap <silent> <Home> <C-o>g<Home>
|
|
|
|
inoremap <silent> <End> <C-o>g<End>
|
|
|
|
|
|
|
|
" Alt to switch windows
|
2018-08-03 10:50:24 +00:00
|
|
|
inoremap <A-h> <Esc><C-w>h
|
|
|
|
inoremap <A-j> <Esc><C-w>j
|
|
|
|
inoremap <A-k> <Esc><C-w>k
|
|
|
|
inoremap <A-l> <Esc><C-w>l
|
2019-05-30 15:00:26 +00:00
|
|
|
"}}}
|
|
|
|
"Visual {{{
|
2020-02-29 07:00:08 +00:00
|
|
|
" Fast beginning and end of document
|
|
|
|
vnoremap ¿ G
|
|
|
|
vnoremap <Bar> gg
|
|
|
|
|
2019-08-22 01:42:47 +00:00
|
|
|
" Visual mode pressing # searches for the current selection
|
2019-05-30 15:00:26 +00:00
|
|
|
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
|
2018-04-04 18:12:51 +00:00
|
|
|
|
2019-05-30 15:00:26 +00:00
|
|
|
" Move a line of text using Shift+[jk]
|
|
|
|
vnoremap <S-j> :m'>+<cr>`<my`>mzgv`yo`z
|
|
|
|
vnoremap <S-k> :m'<-2<cr>`>my`<mzgv`yo`z
|
2018-08-28 16:13:36 +00:00
|
|
|
|
2019-05-30 15:00:26 +00:00
|
|
|
" j = gj :: k = gk while preserving numbered jumps ie. 12j or 30k
|
|
|
|
vnoremap <buffer><silent><expr>j v:count ? 'j' : 'gj'
|
|
|
|
vnoremap <buffer><silent><expr>k v:count ? 'k' : 'gk'
|
|
|
|
|
|
|
|
" Line movements
|
|
|
|
vnoremap $ $h
|
|
|
|
|
2019-06-23 03:48:32 +00:00
|
|
|
" Fix indentation without leaving visual mode
|
|
|
|
vnoremap > >gv
|
|
|
|
vnoremap < <gv
|
|
|
|
|
2020-04-28 18:34:58 +00:00
|
|
|
" Keep cursor at the bottom of the visual selection after you yank it.
|
|
|
|
vmap y ygv<Esc>
|
|
|
|
|
2019-05-30 15:00:26 +00:00
|
|
|
" Delete current visual selection and dump in black hole buffer before pasting
|
|
|
|
" Used when you want to paste over something without it getting copied to
|
|
|
|
" Vim's default buffer
|
|
|
|
vnoremap <leader>p "_dP
|
|
|
|
"}}}
|
|
|
|
"Terminal {{{
|
2018-04-04 18:12:51 +00:00
|
|
|
" Terminal movement
|
|
|
|
tnoremap <Esc> <C-\><C-n>
|
|
|
|
tnoremap <M-h> <C-\><C-n><C-w>h
|
|
|
|
tnoremap <M-j> <C-\><C-n><C-w>j
|
|
|
|
tnoremap <M-k> <C-\><C-n><C-w>k
|
|
|
|
tnoremap <M-l> <C-\><C-n><C-w>l
|
2019-05-30 15:00:26 +00:00
|
|
|
"}}}
|
|
|
|
"}}}
|
2019-06-23 03:48:32 +00:00
|
|
|
" Functions {{{
|
2018-08-28 16:13:36 +00:00
|
|
|
function! CmdLine(str)
|
2019-12-12 17:21:10 +00:00
|
|
|
call feedkeys(':' . a:str)
|
2018-08-28 16:13:36 +00:00
|
|
|
endfunction
|
|
|
|
|
2018-07-21 04:46:57 +00:00
|
|
|
" global replace
|
|
|
|
vnoremap <Leader>sw "hy
|
|
|
|
\ :let b:sub = input('global replacement: ') <Bar>
|
|
|
|
\ if b:sub !=? '' <Bar>
|
2018-08-31 04:12:16 +00:00
|
|
|
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
|
2018-07-21 04:46:57 +00:00
|
|
|
\ execute '%s/'.b:rep."/".b:sub.'/g' <Bar>
|
|
|
|
\ unlet b:sub b:rep <Bar>
|
|
|
|
\ endif <CR>
|
|
|
|
nnoremap <Leader>sw
|
|
|
|
\ :let b:sub = input('global replacement: ') <Bar>
|
|
|
|
\ if b:sub !=? '' <Bar>
|
|
|
|
\ execute "%s/<C-r><C-w>/".b:sub.'/g' <Bar>
|
|
|
|
\ unlet b:sub <Bar>
|
|
|
|
\ endif <CR>
|
|
|
|
|
|
|
|
" prompt before each replace
|
|
|
|
vnoremap <Leader>cw "hy
|
|
|
|
\ :let b:sub = input('interactive replacement: ') <Bar>
|
|
|
|
\ if b:sub !=? '' <Bar>
|
|
|
|
\ let b:rep = substitute(getreg('h'), '/', '\\/', 'g') <Bar>
|
|
|
|
\ execute '%s/'.b:rep.'/'.b:sub.'/gc' <Bar>
|
|
|
|
\ unlet b:sub b:rep <Bar>
|
|
|
|
\ endif <CR>
|
|
|
|
nnoremap <Leader>cw
|
|
|
|
\ :let b:sub = input('interactive replacement: ') <Bar>
|
|
|
|
\ if b:sub !=? '' <Bar>
|
|
|
|
\ execute "%s/<C-r><C-w>/".b:sub.'/gc' <Bar>
|
|
|
|
\ unlet b:sub <Bar>
|
|
|
|
\ endif <CR>
|
|
|
|
" }}}
|
2019-05-05 15:19:30 +00:00
|
|
|
" vim:foldmethod=marker:foldlevel=0
|