spf13 and omnisharp (vim) - vim

I am using spf13 and I want to use omnisharp so I installed (and build) it as explained. Now I donrt how to integrate it with spf13.
It seems there already are something which handle "omni completion" but I also want issue tracker.
spf13 .vimrc:
" PIV {
let g:DisableAutoPHPFolding = 0
let g:PIVAutoClose = 0
" }
" Misc {
let g:NERDShutUp=1
let b:match_ignorecase = 1
" }
" OmniComplete {
" To disable omni complete, add the following to your .vimrc.before.local file:
" let g:spf13_no_omni_complete = 1
if !exists('g:spf13_no_omni_complete')
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\if &omnifunc == "" |
\setlocal omnifunc=syntaxcomplete#Complete |
\endif
endif
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
" Some convenient mappings
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
" Automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menu,preview,longest
endif
" }
So I want to fully integrated in vim too.

Omnisharp doesn't perform omnicompletion by itself. It just provides the omnifunc that you can use to plug into whatever completion mechanism you like (YCM, Neocomplete, supertab) etc.
I've never used spf13 but I would imagine that all you would need is
autocmd FileType cs setlocal omnifunc=OmniSharp#Complete
as it looks as if spf13 has it's own omnicompletion system. If that doesn't work, try Ctrl-X, Ctrl-O to trigger omnicompletion manually.

Related

CoC: Diagnostic window takes over screen

I am setting up neovim, with CoC.
It seems to work well, but with one big problem: My diagnostic windows are very large
I am not sure why this is. I would expect this to be only a few lines. Ideally, it should show up somewhere not directly over the code, but I'm not sure how to configure this.
This is my neovim config:
call plug#begin('~/.config/nvim/autoload')
Plug 'easymotion/vim-easymotion' " Get to where you want to go fast
Plug 'nanotech/jellybeans.vim' " Pretty theme
Plug 'scrooloose/nerdtree'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim' " Fuzzy search
Plug 'jiangmiao/auto-pairs', { 'tag': 'v2.0.0' } " auto-pairs of parens
Plug 'Olical/conjure', {'tag': 'v4.15.0'} " Interactive Clojure Eval
Plug 'guns/vim-sexp' " paredi for vim
Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'clojure-vim/clojure.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release'} " Language servers for vim!
Plug 'w0rp/ale' " linter -- TODO: maybe lsp obviates the need for this?
call plug#end()
" vim:foldmethod=marker:foldlevel=0
" Stopa's vimrc -- my magic sauce for getting things done!
" -----------------------------------------------------------------------------
" Vim settings {{{1
" Important {{{2
set nocompatible " Enable Vim features
syntax on " Turn on syntax highlighting
let mapleader = "," " Set <leader> character
let maplocalleader = "," " Set <localleader> character
colorscheme jellybeans " Favorite so far
set encoding=utf-8 " Use utf-8 when reading files
set fileencoding=utf-8 " Files are written using utf-8
set lazyredraw " Don't redraw on macros -- boosts performance
set ttyfast " Faster redraws and smoother vim
set modelines=1 " Read the modeline at the top
" Ignore these files in Vim's file explorer {{{2
set wildignore+="/tmp/*,*.so,*.swp,*.zip
" Make clipboard the default register {{{2
set clipboard=unnamed
" Highlight column 81 {{{2
set colorcolumn=81
highlight ColorColumn ctermbg=234
" General {{{2
set autoread " Reload files when outside changes made
set backspace=indent,eol,start " Allow backspace in insert mode
set foldnestmax=2 " Sets max fold level.
set gcr=a:blinkon0 " Disable cursor blink
set hidden " Buffers can exist in background
set history=1000 " keep 100 lines of command line history
set laststatus=2 " lightline needs this to display status when opening first buffer
set noshowmode " using Lightline to show status bar instead
set noswapfile " Disable swap files. I don't use them
set number " Line numbers!
set ruler " show the cursor position all the time
set scrolloff=8 " Start scrolling 8 lines away from bottom
set shortmess+=I " Remove Vim startup message for empty file
set showcmd " Show incomplete commands at bottom
set showmode " Show current mode down the bottom
set splitbelow " Default horizontal split below
set splitright " Default vertical split right
set visualbell " Disable sounds
" Wrap {{{2
set wrap
set linebreak " Wrap lines at convienent points
set textwidth=0
set wrapmargin=0
" Searching {{{2
set hlsearch " highlight searching
set incsearch " do incremental searching
set ignorecase " searches are case insensitive
set smartcase " unless you search with a capital letter
" Tabs and Spaces {{{2
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
" Auto adjust window sizes when they become current {{{2
set winwidth=84
set winheight=5
set winminheight=5
set winheight=999
" }}} End section
" Key mappings {{{1
" Highlight initials in notes {{{2
:match Todo /JA:/
" Easy Navigating {{{2
:inoremap jk <Esc>
:nnoremap j gj
:nnoremap k gk
" Easy window cycling {{{2
:nnoremap <C-h> <C-w>h
:nnoremap <C-j> <C-w>j
:nnoremap <C-k> <C-w>k
:nnoremap <C-l> <C-w>l
" Easy save/quit {{{2
:noremap <leader>w :w<CR>
:nnoremap <leader>q :q!<CR>
:nnoremap <leader>zz :qa!<CR>
" Reload vimrc file {{{2
:nnoremap <silent><leader>sv :so $MYVIMRC<CR>
" Edit useful files {{{2
:nnoremap <silent><leader>ev :e $MYVIMRC<CR>
:nnoremap <silent><leader>et :e $MYTMUXCONF<CR>
:nnoremap <silent><leader>ez :e $MYZSH<CR>
:nnoremap <silent><leader>ep :e $MYPROFILE<CR>
:nnoremap <silent><leader>ed :e $MYTODOS<CR>
" Clear search {{{2
:nnoremap <silent><leader>/ :nohlsearch<CR>
" Easy command Mode {{{2
:nnoremap ; :
" Easy begin/end line navigation {{{2
:nnoremap H 0w
:nnoremap L $
" Easy clipboard copy {{{2
:vnoremap <silent><leader>c :w !pbcopy<CR><CR>
" Easy clipboard paste {{{2
:nnoremap <silent><leader>v :r !pbpaste<CR><CR>
" Easy grep under cursor {{{2
:nmap <silent><leader>r viw"ry:Ag! <C-R>r<CR><CR>
" Easy code folding {{{2
:nnoremap <Space> za
" Focus fold {{{2
:nnoremap <leader>f zMzA
" Toggle lint errors/warnings
:nnoremap <leader>A :ALEToggle<CR><CR>
" Quick newline {{{2
:nnoremap <CR> o<Esc>
" Toggle NERDTree {{{2
:nnoremap <leader>nt :NERDTree<CR>
"
" Toggle show formatting {{{2
:nnoremap <leader>l :set list!<CR>
" Window manipulation {{{2
:nnoremap <leader>\ :vsp<CR>
:nnoremap <leader>m :vertical resize 80<CR>
" Fugitive shortcuts {{{2
:nnoremap <leader>gb :Gblame<CR>
" Tab switching {{{2
:nnoremap <leader>1 1gt
:nnoremap <leader>2 2gt
:nnoremap <leader>3 3gt
:nnoremap <leader>4 4gt
:nnoremap <leader>5 5gt
:nnoremap <leader>6 6gt
:nnoremap <leader>7 7gt
:nnoremap <leader>8 8gt
:nnoremap <leader>9 9gt
:nnoremap <leader>0 :tablast<CR>
:nnoremap <leader>x :tabclose<CR>
:nnoremap <leader>t :0tabnew<CR>
" Easy fzf {{{2
nmap ; :Buffers<CR>
nmap <leader>p :Files<CR>
" Toggle paste mode {{{2
:nnoremap <leader>P :set invpaste!<CR>
" Ctags navigation {{{2
:nnoremap <leader>g <C-]>
:nnoremap <leader>b <C-t>
" Easy Ack/Ag {{{2
:nnoremap <leader>a :Ag
" Easy commenting {{{2
:nnoremap // :TComment<CR>
:vnoremap // :TComment<CR>
" Prevent overwriting default register (system clipboard) when inconvenient {{{2
:vnoremap x "_x
:vnoremap c "_c
:vnoremap p "_dP
" Don't use arrow keys in normal mode :) {{{2
:nnoremap <Left> <NOP>
:nnoremap <Right> <NOP>
:nnoremap <Up> <NOP>
:nnoremap <Down> <NOP>
" In insert or command mode, move normally by using Ctrl {{{2
inoremap <C-h> <Left>
inoremap <C-j> <Down>
inoremap <C-k> <Up>
inoremap <C-l> <Right>
cnoremap <C-h> <Left>
cnoremap <C-j> <Down>
cnoremap <C-k> <Up>
cnoremap <C-l> <Right>
" Enables filetype detection and loads indent files {{{2
" Note: It's important this called after vim/bundle is added to vim's
" runtime path so that ftdetect will be loaded
" Thanks: http://stackoverflow.com/a/19314347
filetype plugin indent on
" Set path for fzf
set rtp+=/usr/local/opt/fzf
" Use Omni-Completion
set omnifunc=syntaxcomplete#Complete
" Plugins {{{1
" Ag {{{2
if executable('ag')
" Use ag over grep
set grepprg=ag\ --nogroup\ --nocolor
" use ag over ack
let g:ackprg = 'ag --vimgrep'
endif
" Lightline {{{2
" General settings
let g:lightline = {
\ 'colorscheme': 'jellybeans',
\ 'mode_map': { 'c': 'NORMAL' },
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'MyFugitive'
\ },
\ 'separator': { 'left': "", 'right': '' },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
" NERDTree {{{2
" Files and directories I don't want to see
" Note the use of vim-style regex
let NERDTreeIgnore = [
\ '\.\(pyc\|swp\|db\|coverage\|DS_Store\)$',
\ '\.\(git\|hg\|svn\|egg-info\)$[[dir]]',
\ '\(coverage\|pytests\)\.xml$',
\ ]
" I do want to see dotfiles (like .gitignore)
let NERDTreeShowHidden=1
" Pretty NERDTree
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
" vim-javascript {{{2
" Enable syntax highlighting for flow
let g:javascript_plugin_flow = 1
" ale {{{2
" Configure error and warning formatting
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_lint_on_enter = 0 " Don't lint files on open
let g:ale_sign_column_always = 1 " Keep column open by default
" Linters
let g:ale_linters = {
\ 'javascript': ['eslint'],
\}
let g:ale_linters_explicit = 1
" Fixers
let g:ale_fixers = {
\ 'javascript': ['eslint']
\ }
" vim-jsx-pretty {{{2
" Colorful style
let g:vim_jsx_pretty_colorful_config = 1
" vim-prettier {{{2
" Run prettier async
let g:prettier#exec_cmd_async = 1
" Custom functions {{{1
" Strip whitespace and save cursor position {{{2
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=#/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let #/=_s
call cursor(l, c)
endfunction
" Displays current git branch in powerline {{{2
function! MyFugitive()
if &ft !~? 'vimfiler\|gundo' && exists("*fugitive#head")
let _ = fugitive#head()
return strlen(_) ? "\u00A7 "._ : ''
endif
return ''
endfunction
" }}}
" Autocommands {{{1
augroup configgroup
" Clear previous autocmds
autocmd!
" White Space Settings for different file types {{{2
autocmd FileType python setlocal ts=4 sts=4 sw=4 et
autocmd FileType javascript,jsx,tsx setlocal ts=2 sts=2 sw=2 et
autocmd FileType css setlocal ts=2 sts=2 sw=2 et
autocmd FileType ruby setlocal ts=2 sts=2 sw=2 et
autocmd FileType html,htmljinja setlocal ts=2 sts=2 sw=2 et
" Clean up trailing white spaces {{{2
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" Python folding {{{2
au FileType python setlocal foldmethod=indent
au FileType python setlocal foldlevel=0
" Javascript folding {{{2
au FileType javascript,jsx,tsx setlocal foldmethod=syntax
au FileType javascript,jsx,tsx setlocal foldlevel=1
" Rainbow-ify parens/brackets for selected file types {{{2
au FileType javascriptreact,jsx call rainbow#load()
" Enable vim-jinja highlighting for .jinja files {{{2
autocmd BufNewFile,BufRead *.jinja set filetype=htmljinja
" Trigger autoread whenever I switch buffer or when focusing vim again {{{2
" Thanks: http://stackoverflow.com/questions/2490227/how-does-vims-autoread-work/20418591#20418591
au FocusGained,BufEnter * :silent! !
" Save whenever switching between windows and buffers {{{2
au FocusLost,BufLeave,WinLeave * :silent! w
" Close the Omni-Completion tip window when a selection is made {{{2
" These lines close it on movement in insert mode or when leaving insert mode
" Thanks:
" http://stackoverflow.com/questions/3105307/how-do-you-automatically-remove-the-preview-window-after-autocompletion-in-vim
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" }}} End section
augroup END
" COC {{{1
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" 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()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-#> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <leader>u <Plug>(coc-references)
nmap <leader>rn <Plug>(coc-rename)
command! -nargs=0 Format :call CocAction('format')
" Diagnostics
inoremap <silent><expr> <c-space> coc#refresh()
nmap <silent> [l <Plug>(coc-diagnostic-prev)
nmap <silent> ]l <Plug>(coc-diagnostic-next)
nmap <silent> [k :CocPrev<cr>
nmap <silent> ]k :CocNext<cr>
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Fix autofix problem of current line
nmap <leader>aq <Plug>(coc-fix-current)
" Show documentation
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
autocmd BufReadCmd,FileReadCmd,SourceCmd jar:file://* call s:LoadClojureContent(expand("<amatch>"))
function! s:LoadClojureContent(uri)
setfiletype clojure
let content = CocRequest('clojure-lsp', 'clojure/dependencyContents', {'uri': a:uri})
call setline(1, split(content, "\n"))
setl nomodified
setl readonly
endfunction
" }}} End Section
" Source private vimrc {{{1
if filereadable(expand("~/.vim/vimrc.private.after"))
source ~/.vim/vimrc.private.after
endif
Help would be much appreciated. Mainky:
Why is the diagnostic window full-screen?
Is there a way I could configure this to be smaller, or to show up somewhere else? (perhaps below the main pane)
Problem was
" Auto adjust window sizes when they become current {{{2
set winwidth=84
set winheight=5
set winminheight=5
set winheight=999
" }}} End section
Removing this did the trick

How to change vim command execution priority?

I made :wincmd h<CR> shortcut to <leader>h, and mapleader is <Space> to me
but When I do <leader>h, I feel quite long delay to execute this action,
so I searched commands about <leader>h by :map <leader>h and
I found that I have serveral commands start with <Space>h like below
n <Space>hp #<Plug>(GitGutterPreviewHunk)
n <Space>hu #<Plug>(GitGutterUndoHunk)
n <Space>hs #<Plug>(GitGutterStageHunk)
x <Space>hs #<Plug>(GitGutterStageHunk)
n <Space>h * :wincmd h<CR>
I think because of map priority, <Space>h is performed last,
I want to change execution priority <Space>h to first place.
because <Space>h is the best easy way shortcut to me for :windcmd h.
How do I change priority order of map?
==== edit ====
I think vim wait for next character from h,
then How can I eliminate delay for <Space>h?
<nowait> is not working (I don't know why)
remapping for plugin is not working
==== edit2 ==== (it still not work thought adopt first answer)
init.vim
""Source file
source $HOME/.config/nvim/ascii_art.vim
""Plugin-install
call plug#begin('~/.vim/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'tweekmonster/gofmt.vim'
Plug 'tpope/vim-fugitive'
Plug 'vim-utils/vim-man'
Plug 'mbbill/undotree'
Plug 'sheerun/vim-polyglot'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'stsewd/fzf-checkout.vim'
Plug 'vuciv/vim-bujo'
Plug 'tpope/vim-dispatch'
Plug 'theprimeagen/vim-be-good', {'do': './install.sh'}
Plug 'vim-airline/vim-airline'
Plug 'gruvbox-community/gruvbox'
Plug 'vifm/vifm.vim'
"Theme
Plug 'colepeters/spacemacs-theme.vim'
Plug 'sainnhe/gruvbox-material'
Plug 'phanviet/vim-monokai-pro'
Plug 'flazz/vim-colorschemes'
Plug 'chriskempson/base16-vim'
" fuzzy find files
Plug 'ctrlpvim/ctrlp.vim'
" git gutter
Plug 'airblade/vim-gitgutter'
Plug 'scrooloose/nerdcommenter'
"NerdTree plugins (NerdTree makes vim too slow, so now it unstalled)
"Plug 'scrooloose/nerdtree'
"Plug 'Xuyuanp/nerdtree-git-plugin'
"Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
"Plug 'ryanoasis/vim-devicons'
Plug 'mattn/emmet-vim'
Plug 'vimwiki/vimwiki' "take note
Plug 'mhinz/vim-startify' "easy way to save and load session
call plug#end()
""General-setting
language en_US
syntax on
set number
set relativenumber
set guicursor=
set relativenumber
set nohlsearch
set hidden
set noerrorbells
set tabstop=4 softtabstop=4
set shiftwidth=4 "tab key spaces, = set sw
set expandtab "instead of tab, insert spaces
set smartindent
set nu
set nowrap
set smartcase
set noswapfile
set undofile
set incsearch
set termguicolors
set scrolloff=8 "Scroll offset
set noshowmode
set cmdheight=2
set updatetime=50
set shortmess+=c
set cursorline
set hlsearch "highlight searched words
"NOTE :eol is end of the line
set listchars=eol:↲,tab:→\ ,trail:~,extends:>,precedes:<,space:␣
set nolist "set list => $ is end of the line
"Fold setting: when auto save and load fold
set foldcolumn=2
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent! loadview
highlight ColorColumn ctermbg=0 guibg=lightgrey
""Color Theme
colorscheme gruvbox
"cursorline termguicolors
set background=dark
let g:gruvbox_contrast='soft'
let loaded_matchparen = 1
let mapleader = " "
""Status-line
set statusline=
set statusline+=%#IncSearch#
set statusline+=\ %y
set statusline+=\ %r
set statusline+=%#CursorLineNr#
set statusline+=\ %F
set statusline+=%= "Right side settings
set statusline+=%#Search#
set statusline+=\ %l/%L
set statusline+=\ [%c]
""Key-bindings
nnoremap <leader>gc :GCheckout<CR>
nnoremap <leader>ghw :h <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>prw :CocSearch <C-R>=expand("<cword>")<CR><CR>
nnoremap <leader>pw :Rg <C-R>=expand("<cword>")<CR><CR>
nnoremap <nowait> <leader>j :wincmd j<CR>
nnoremap <nowait> <leader>k :wincmd k<CR>
nnoremap <nowait> <leader>l :wincmd l<CR>
"bug report:: :wincmd h is mapped with below mapping,
"> but can not use shortcuts for GigGutterPreviewHunk, GitGutterUndoHunk, GitGutterStageHunk
autocmd filetype * nnoremap <nowait> <buffer> <leader>h :wincmd h<CR>
"nnoremap <nowait> <leader>h :wincmd h<CR>
nnoremap <leader>u :UndotreeShow<CR>
"nnoremap <leader>pv :wincmd v<bar> :Ex <bar> :vertical resize 30<CR>
nnoremap <leader>pv :call ToggleNetrw() <bar> :vertical resize 30<CR>
nnoremap <Leader>ps :Rg<SPACE>
nnoremap <C-p> :GFiles<CR>
nnoremap <Leader>pf :Files<CR>
nnoremap <Leader><CR> :<c-u>call <sid>Goto_definition() <CR>
nnoremap <F4> :so ~/.config/nvim/init.vim<CR>
nnoremap <Left> :vertical resize -2<CR>
nnoremap <Right> :vertical resize +2<CR>
nnoremap <Up> :resize +2<CR>
nnoremap <Down> :resize -2<CR>
nnoremap <Leader>rp :resize 100<CR>
nnoremap <Leader>ee oif err != nil {<CR>log.Fatalf("%+v\n", err)<CR>}<CR><esc>kkI<esc>
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
vnoremap X "_d
"built-in mapping disable
nnoremap Q <Nop>
" vim TODO
nmap <Leader>tu <Plug>BujoChecknormal
nmap <Leader>th <Plug>BujoAddnormal
let g:bujo#todo_file_path = $HOME . "/.cache/bujo"
" GoTo code navigation.
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gy <Plug>(coc-type-definition)
nmap <leader>gi <Plug>(coc-implementation)
nmap <leader>gr <Plug>(coc-references)
nmap <leader>rr <Plug>(coc-rename)
nmap <leader>g[ <Plug>(coc-diagnostic-prev)
nmap <leader>g] <Plug>(coc-diagnostic-next)
nmap <silent> <leader>gp <Plug>(coc-diagnostic-prev-error)
nmap <silent> <leader>gn <Plug>(coc-diagnostic-next-error)
nnoremap <leader>cr :CocRestart
nnoremap <silent> K :call <SID>show_documentation()<CR>
"quickly enter new line in normal mode
nnoremap <Leader>o o<Esc>
nmap ghs <Plug>(GitGutterStageHunk)
xmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nmap ghp <Plug>(GitGutterPreviewHunk)
"Emmet key
let g:user_emmet_mode="n"
let g:user_emmet_leader_key="," "default leader_key is <c-y> with trailing ,(comma)
" coc config
let g:coc_global_extensions = [
\ 'coc-snippets',
\ 'coc-pairs',
\ 'coc-tsserver',
\ 'coc-eslint',
\ 'coc-prettier',
\ 'coc-json',
\ 'coc-marketplace',
\ ]
"coc snippet
" Use <C-l> for trigger snippet expand.
imap <C-l> <Plug>(coc-snippets-expand)
" Use <C-j> for select text for visual placeholder of snippet.
vmap <C-j> <Plug>(coc-snippets-select)
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
let g:coc_snippet_next = '<c-j>'
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
let g:coc_snippet_prev = '<c-k>'
" Use <C-j> for both expand and jump (make expand higher priority.)
imap <C-j> <Plug>(coc-snippets-expand-jump)
inoremap jk <ESC>
vmap ++ <plug>NERDCommenterToggle
nmap ++ <plug>NERDCommenterToggle
let g:NERDTreeIgnore = ['^node_modules$']
" ctrlp
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" Highlight currently open buffer in NERDTree
autocmd BufEnter * call SyncTree()
" Remap for rename current word
nmap <F2> <Plug>(coc-rename)
"Functions
"show documetation function
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
"sync open file with NERDTree, Check if NERDTree is open or active
function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" Call NERDTreeFind iff NERDTree is active, current window contains a modifiable, file, and we're not in vimdiff
function! SyncTree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
" autocomplete functions for neoclide/coc.nvim
"---------------------------------------------------------------------------
" 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()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-#> coc#refresh()
endif
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
" <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`.
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
"open implementation to the right split view(custom function)
"buggy: If you quit after invoke this function, this function will not work(it will quit your only window)
let s:first_open=1
function! s:Goto_definition() abort
if s:first_open
rightbelow vs "same as :vertical split and :wincmd l
normal K
wincmd h
let s:first_open=0
else
wincmd l "If right split window exists then quit
q
rightbelow vs
normal K
wincmd h
endif
endfunction
"---------------------------------------------------------------------------
"" netrw settings
let g:netrw_liststyle=3 "Tree style
let g:netrw_banner = 0 "Remove banner
let g:netrw_browse_split = 4 "Open file in previous window
let g:netrw_altv = 1 "Open vertical split window to the right side
let g:netrw_preview=1 "Preview in right side
set nocompatible "Limit search for your project
set path+=** "Search all subdirectories with recursively
set wildmenu "Show multifiles on one line when you :find
"Root directory:make current directory to root directory
nnoremap <leader>` :Ntree<CR>
let g:NetrwIsOpen=0
function! ToggleNetrw()
if g:NetrwIsOpen
let i = bufnr("$")
while (i >= 1)
if (getbufvar(i, "&filetype") == "netrw")
silent exe "bwipeout " . i
endif
let i-=1
endwhile
let g:NetrwIsOpen=0
else
let g:NetrwIsOpen=1
silent Lexplore
endif
endfunction
let g:netrw_list_hide= netrw_gitignore#Hide()
"=================Unorganized settings==================
"jsx comment
let g:NERDCustomDelimiters={
\ 'javascript': { 'left': '//', 'right': '', 'leftAlt': '{/*', 'rightAlt': '*/}' },
\}
"vimwiki setup
"let g:vimwiki_list = [{'path': '~/vimwiki/',
"\ 'syntax': 'markdown', 'ext': '.md'}]
=== edit for Result (now working) ===
for :map <leader>h now show like this picture
what I did
add 4 snippets from answer
:PlugUpdate => I was out of date.
remove <nowait>
:echo hasmapto('<Plug>(GitGutterStageHunk)', 'n') output 1
when upto 2 step, it didn't work, but after remove nowait it works
something interfereing commands, but I don't know exact reason.
The mappings that include <Leader>h as a prefix will cause this interference. Vim will wait for a timeout or additional keypress before executing your <Leader>h mapping, since it wants to check whether you meant to press one of the longer mappings...
The easiest way to fix this is set alternate mappings for the vim-gitgutter commands. If you set up different mappings for those in your vimrc, vim-gitgutter itself will not create its mappings which are causing the interference.
The vim-gitgutter README suggests using g as an alternative prefix for these:
To set your own mappings for these, for example if you prefer g-based maps:
nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
So just go ahead and create mappings for the four keybindings that are breaking your <Leader>h. Add these four lines to your vimrc:
nmap ghs <Plug>(GitGutterStageHunk)
xmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nmap ghp <Plug>(GitGutterPreviewHunk)
The xmap (for staging in Visual mode) is technically not required, you could keep using <Leader>hs there without interference... But on the other hand you might want to keep those consistent between Normal and Visual mode, so I'd recommend remapping that one too.
The reason why <noway> doesn't work to fix this is that <nowait> only works on <buffer>-local mappings, when they shadow global mappings. It doesn't work when all your mappings are global. (In that case, Vim prefers to force you to resolve the conflicts, rather than make then longest mappings always unaccessible.)

"line too long (83 > 79 characters) [E501]" message on gvim

So I use Gvim on Window, so i found an .vimrc file and copied on to my
here is the vimrc file
" plugins
let need_to_install_plugins = 0
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
"autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
let need_to_install_plugins = 1
endif
call plug#begin()
Plug 'tpope/vim-sensible'
Plug 'itchyny/lightline.vim'
Plug 'joshdick/onedark.vim'
Plug 'ap/vim-buftabline'
Plug 'airblade/vim-gitgutter'
Plug 'vim-scripts/The-NERD-tree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'scrooloose/syntastic'
Plug 'majutsushi/tagbar'
Plug 'vim-scripts/indentpython.vim'
Plug 'lepture/vim-jinja'
Plug 'pangloss/vim-javascript'
call plug#end()
filetype plugin indent on
syntax on
set rnu
if need_to_install_plugins == 1
echo "Installing plugins..."
silent! PlugInstall
echo "Done!"
q
endif
" always show the status bar
set laststatus=2
" enable 256 colors
set t_Co=256
set t_ut=
" turn on line numbering
set number
" sane text files
set fileformat=unix
set encoding=utf-8
set fileencoding=utf-8
" sane editing
set tabstop=4
set shiftwidth=4
set softtabstop=4
set colorcolumn=80
set expandtab
set viminfo='25,\"50,n~/.viminfo
" word movement
imap <S-Left> <Esc>bi
nmap <S-Left> b
imap <S-Right> <Esc><Right>wi
nmap <S-Right> w
" indent/unindent with tab/shift-tab
nmap <Tab> >>
imap <S-Tab> <Esc><<i
nmap <S-tab> <<
" mouse
set mouse=a
let g:is_mouse_enabled = 1
noremap <silent> <Leader>m :call ToggleMouse()<CR>
function ToggleMouse()
if g:is_mouse_enabled == 1
echo "Mouse OFF"
set mouse=
let g:is_mouse_enabled = 0
else
echo "Mouse ON"
set mouse=a
let g:is_mouse_enabled = 1
endif
endfunction
" color scheme
syntax on
colorscheme onedark
filetype on
filetype plugin indent on
" lightline
set noshowmode
let g:lightline = { 'colorscheme': 'onedark' }
" code folding
set foldmethod=indent
set foldlevel=99
" wrap toggle
setlocal nowrap
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
endif
endfunction
" move through split windows
nmap <leader><Up> :wincmd k<CR>
nmap <leader><Down> :wincmd j<CR>
nmap <leader><Left> :wincmd h<CR>
nmap <leader><Right> :wincmd l<CR>
" move through buffers
nmap <leader>[ :bp!<CR>
nmap <leader>] :bn!<CR>
nmap <leader>x :bd<CR>
" restore place in file from previous session
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" file browser
let NERDTreeIgnore = ['\.pyc$', '__pycache__']
let NERDTreeMinimalUI = 1
let g:nerdtree_open = 0
map <leader>n :call NERDTreeToggle()<CR>
function NERDTreeToggle()
NERDTreeTabsToggle
if g:nerdtree_open == 1
let g:nerdtree_open = 0
else
let g:nerdtree_open = 1
wincmd p
endif
endfunction
" syntastic
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
map <leader>s :SyntasticCheck<CR>
map <leader>d :SyntasticReset<CR>
map <leader>e :lnext<CR>
map <leader>r :lprev<CR>
" tag list
map <leader>t :TagbarToggle<CR>
" copy, cut and paste
vmap <C-c> "+y
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
" disable autoindent when pasting text
" source: https://coderwall.com/p/if9mda/automatically-set-paste-mode-in-vim-when-pasting-in-insert-mode
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
but anyways here are the problem whenever I enter a list or a string that is too long this message pop up.
line too long (83 > 79 characters) [E501]
so i tried to find a solution on the internet but non of it works, so if anyone knows the solution plz help thanks in advance.:)
You might be using a plug-in like Ale to check your files, if that is the case, this might be of help

How to have vim highlight color change for the pattern under cursor?

Is there a way to have the search highlight text in vim under the cursor have a different color compared to the search text not under the cursor?
my .vimrc has this codes:
function! HiInterestingWord(n) " {{{2
" Save our location.
normal! mz
" Yank the current word into the z register.
normal! "zyiw
" Calculate an arbitrary match ID. Hopefully nothing else is using it.
let mid = 77750 + a:n
" Clear existing matches, but don't worry if they don't exist.
"silent! call matchdelete(mid)
try
call matchdelete(mid)
catch 'E803'
" Construct a literal pattern that has to match at boundaries.
let pat = '\V\<' . escape(#z, '\') . '\>'
" Actually match the words.
call matchadd("InterestingWord" . a:n, pat, 1, mid)
endtry
" Move back to our original location.
normal! `z
endfunction
"clear all highlighting
function! ClearAllHi()
for i in range(1,6)
let mid = 77750 + i
silent! call matchdelete(mid)
endfor
endfunction
nnoremap <silent> <leader>0 :call ClearAllHi()<cr>
nnoremap <silent> <leader>1 :call HiInterestingWord(1)<cr>
nnoremap <silent> <leader>2 :call HiInterestingWord(2)<cr>
nnoremap <silent> <leader>3 :call HiInterestingWord(3)<cr>
nnoremap <silent> <leader>4 :call HiInterestingWord(4)<cr>
nnoremap <silent> <leader>5 :call HiInterestingWord(5)<cr>
nnoremap <silent> <leader>6 :call HiInterestingWord(6)<cr>
hi def InterestingWord1 guifg=#000000 ctermfg=16 guibg=#ffa724 ctermbg=214
hi def InterestingWord2 guifg=#000000 ctermfg=16 guibg=#aeee00 ctermbg=154
hi def InterestingWord3 guifg=#000000 ctermfg=16 guibg=#8cffba ctermbg=121
hi def InterestingWord4 guifg=#000000 ctermfg=16 guibg=#b88853 ctermbg=137
hi def InterestingWord5 guifg=#000000 ctermfg=16 guibg=#ff9eb8 ctermbg=211
hi def InterestingWord6 guifg=#000000 ctermfg=16 guibg=#ff2c4b ctermbg=195
"}}}
This allows you to press <leader> + 1-6 to high light word under cursor in different colors; pressing it twice to clear the highlighting. (You can change the color in hi def...) commands. And <leader>+0 clear all highlights.
You can just put the codes in your vimrc to try.
It works like this:
People have used solution based on Damian Conway's talk
" Damian Conway's Die Blinkënmatchen: highlight matches
nnoremap <silent> n n:call HLNext(0.1)<cr>
nnoremap <silent> N N:call HLNext(0.1)<cr>
function! HLNext (blinktime)
let target_pat = '\c\%#'.#/
let ring = matchadd('ErrorMsg', target_pat, 101)
redraw
exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm'
call matchdelete(ring)
redraw
endfunction
But personally, I prefer a simple one, though this highlight whole line
"cursorline and it's highlighting
set cursorline
hi CursorLine cterm=NONE ctermbg=NONE ctermfg=green

Pressing tab in HTML files in vim goes to the next empty tag pair rather than expanding a completion

I'm not sure where the functionality of tabbing to the next empty tag pair in HTML files comes from. I would like to disable it completely.
The problem only comes with using SuperTab and SnipMate together, if I remove SuperTab tab goes back to expanding normally, if I remove SnipMate, tab goes back to showing completions.
In the past I've had both working fine and would like to do so again.
I'm using:
http://github.com/msanders/snipmate.vim
http://github.com/scrooloose/snipmate-snippets
http://github.com/ervandew/supertab
With vim-update-bundles. Default configuration for both. Other options I have enabled are syntax on. autoindent. smartindent. expandtab. nocompatible. filetype indent plugin on.
SnipMate and SuperTab both use ⇥, that makes their combination very annoying and unpredictable.
After years of TextMate, ⇥ expansion was a habit I couldn't/didn't want to drop so I ditched SuperTab quickly and learned to love Vim's native Omni Completion:
inoremap <leader>, <C-x><C-o>
inoremap <leader>: <C-x><C-f>
inoremap <leader>= <C-x><C-l>
For a more streamlined experience, autocomplpop is surprisingly fast and smart.
The solution that fit my needs is neocomplcache.
It's a nice mix between autocomplpop, supertab and snipmate. Well, the snippet part is just a little buggy, but quite usable.
However I don't use ⇥ to expand, the popup omnicompletion comes up after the 3rd written character. You move with ⇥ thru the list, and expand the snippets (a la textmate), with CtrlK, but you can map that to you choice.
These are my .vimrc settings.
""""""""""""""""""""""""""""""
" => neocomplcache plugin
""""""""""""""""""""""""""""""
" TODO: Still need to tweak behavior with <TAB> to expand
" snippets, change throughout the autocompletion list
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Use camel case completion.
let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
let g:neocomplcache_enable_underbar_completion = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
let g:neocomplcache_snippets_dir = '~/.vim/snippet/'
" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
imap <C-k> <Plug>(neocomplcache_snippets_expand)
smap <C-k> <Plug>(neocomplcache_snippets_expand)
inoremap <expr><C-g> neocomplcache#undo_completion()
inoremap <expr><C-l> neocomplcache#complete_common_string()
" SuperTab like snippets behavior.
imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
" Recommended key-mappings.
" <CR>: close popup and save indent.
" inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y> neocomplcache#close_popup()
inoremap <expr><C-e> neocomplcache#cancel_popup()
" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<TAB>"
"inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
"autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
au BufNewFile,BufRead *.snip set syntax=snippet ft=snippet foldmethod=indent

Resources