From 53123f954c6719599b1e3cbb7fb3bbe07bd12512 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 27 Apr 2020 21:58:30 -0400 Subject: added vscode support --- general/settings.vim | 85 +++++++++++++++++++++++++++------------------------- init.vim | 37 +++++++++++++++-------- keys/mappings.vim | 79 +++++++++++++++++++++++++----------------------- vim-plug/plugins.vim | 7 +++-- vscode/windows.vim | 67 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 183 insertions(+), 92 deletions(-) create mode 100644 vscode/windows.vim diff --git a/general/settings.vim b/general/settings.vim index ae86008f..5ea7d1ff 100644 --- a/general/settings.vim +++ b/general/settings.vim @@ -1,46 +1,51 @@ " set leader key map -syntax enable " Enables syntax highlighing -set hidden " Required to keep multiple buffers open multiple buffers -set nowrap " Display long lines as just one line -set encoding=utf-8 " The encoding displayed -set pumheight=10 " Makes popup menu smaller -set fileencoding=utf-8 " The encoding written to file -set ruler " Show the cursor position all the time -set cmdheight=2 " More space for displaying messages -set iskeyword+=- " treat dash separated words as a word text object" -set mouse=a " Enable your mouse -set splitbelow " Horizontal splits will automatically be below -set splitright " Vertical splits will automatically be to the right -set t_Co=256 " Support 256 colors -set conceallevel=0 " So that I can see `` in markdown files -set foldcolumn=2 " Folding abilities -set tabstop=2 " Insert 2 spaces for a tab -set shiftwidth=2 " Change the number of space characters inserted for indentation -set smarttab " Makes tabbing smarter will realize you have 2 vs 4 -set expandtab " Converts tabs to spaces -set smartindent " Makes indenting smart -set autoindent " Good auto indent -set laststatus=0 " Always display the status line -set number " Line numbers -set cursorline " Enable highlighting of the current line -set background=dark " tell vim what the background color looks like -set showtabline=2 " Always show tabs -set noshowmode " We don't need to see things like -- INSERT -- anymore -set nobackup " This is recommended by coc -set nowritebackup " This is recommended by coc -set shortmess+=c " Don't pass messages to |ins-completion-menu|. -set signcolumn=yes " Always show the signcolumn, otherwise it would shift the text each time -set updatetime=300 " Faster completion -set timeoutlen=100 " By default timeoutlen is 1000 ms -set formatoptions-=cro " Stop newline continution of comments -set clipboard=unnamedplus " Copy paste between vim and everything else -"set autochdir " Your working directory will always be the same as your working directory +if !exists('g:vscode') + syntax enable " Enables syntax highlighing + set hidden " Required to keep multiple buffers open multiple buffers + set nowrap " Display long lines as just one line + set encoding=utf-8 " The encoding displayed + set pumheight=10 " Makes popup menu smaller + set fileencoding=utf-8 " The encoding written to file + set ruler " Show the cursor position all the time + set cmdheight=2 " More space for displaying messages + set iskeyword+=- " treat dash separated words as a word text object" + set mouse=a " Enable your mouse + set splitbelow " Horizontal splits will automatically be below + set splitright " Vertical splits will automatically be to the right + set t_Co=256 " Support 256 colors + set conceallevel=0 " So that I can see `` in markdown files + set tabstop=2 " Insert 2 spaces for a tab + set shiftwidth=2 " Change the number of space characters inserted for indentation + set smarttab " Makes tabbing smarter will realize you have 2 vs 4 + set expandtab " Converts tabs to spaces + set smartindent " Makes indenting smart + set autoindent " Good auto indent + set laststatus=0 " Always display the status line + set number " Line numbers + set cursorline " Enable highlighting of the current line + set background=dark " tell vim what the background color looks like + set showtabline=2 " Always show tabs + set noshowmode " We don't need to see things like -- INSERT -- anymore + set nobackup " This is recommended by coc + set nowritebackup " This is recommended by coc + set shortmess+=c " Don't pass messages to |ins-completion-menu|. + set signcolumn=yes " Always show the signcolumn, otherwise it would shift the text each time + set updatetime=300 " Faster completion + set timeoutlen=100 " By default timeoutlen is 1000 ms + set formatoptions-=cro " Stop newline continution of comments + set clipboard=unnamedplus " Copy paste between vim and everything else + set incsearch + " set autochdir " Your working directory will always be the same as your working directory + " set foldcolumn=2 " Folding abilities -au! BufWritePost $MYVIMRC source % " auto source when writing to init.vm alternatively you can run :source $MYVIMRC -autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + au! BufWritePost $MYVIMRC source % " auto source when writing to init.vm alternatively you can run :source $MYVIMRC + autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o + + + " You can't stop me + cmap w!! w !sudo tee % +endif -" You can't stop me -cmap w!! w !sudo tee % diff --git a/init.vim b/init.vim index f7675969..c0bc365c 100644 --- a/init.vim +++ b/init.vim @@ -1,16 +1,29 @@ -" Viml Plugins +" ____ _ __ _ +" / _/___ (_) /__ __(_)___ ___ +" / // __ \/ / __/ | / / / __ `__ \ +" _/ // / / / / /__| |/ / / / / / / / +"/___/_/ /_/_/\__(_)___/_/_/ /_/ /_/ + + +" Always source these source $HOME/.config/nvim/vim-plug/plugins.vim source $HOME/.config/nvim/general/settings.vim -source $HOME/.config/nvim/general/paths.vim source $HOME/.config/nvim/keys/mappings.vim -source $HOME/.config/nvim/themes/syntax.vim -source $HOME/.config/nvim/themes/onedark.vim -source $HOME/.config/nvim/themes/airline.vim -source $HOME/.config/nvim/plug-config/coc.vim -source $HOME/.config/nvim/plug-config/rnvimr.vim -source $HOME/.config/nvim/plug-config/fzf.vim -source $HOME/.config/nvim/plug-config/commentary.vim -source $HOME/.config/nvim/plug-config/rainbow.vim +source $HOME/.config/nvim/general/paths.vim -" Lua Plugins -lua require'plug-colorizer' +" Source depending on if VSCode is our client +if exists('g:vscode') + " VSCode extension + source $HOME/.config/nvim/vscode/windows.vim +else + " ordinary neovim + source $HOME/.config/nvim/themes/syntax.vim + source $HOME/.config/nvim/themes/onedark.vim + source $HOME/.config/nvim/themes/airline.vim + source $HOME/.config/nvim/plug-config/coc.vim + source $HOME/.config/nvim/plug-config/rnvimr.vim + source $HOME/.config/nvim/plug-config/fzf.vim + source $HOME/.config/nvim/plug-config/commentary.vim + source $HOME/.config/nvim/plug-config/rainbow.vim + lua require'plug-colorizer' +endif diff --git a/keys/mappings.vim b/keys/mappings.vim index 57a763f1..b1740c0d 100644 --- a/keys/mappings.vim +++ b/keys/mappings.vim @@ -1,42 +1,45 @@ -" Better nav for omnicomplete -inoremap ("\") -inoremap ("\") - -" Use alt + hjkl to resize windows -nnoremap :resize -2 -nnoremap :resize +2 -nnoremap :vertical resize -2 -nnoremap :vertical resize +2 - -" I hate escape more than anything else -inoremap jk -inoremap kj - -" Easy CAPS -inoremap viwUi -nnoremap viwU - -" TAB in general mode will move to text buffer -nnoremap :bnext -" SHIFT-TAB will go back -nnoremap :bprevious - -" Alternate way to save -nnoremap :w -" Alternate way to quit -nnoremap :wq! -" Use control-c instead of escape -nnoremap -" : completion. -inoremap pumvisible() ? "\" : "\" + +if !exists('g:vscode') + " Better nav for omnicomplete + inoremap ("\") + inoremap ("\") + + " I hate escape more than anything else + inoremap jk + inoremap kj + + " Easy CAPS + " inoremap viwUi + " nnoremap viwU + + " TAB in general mode will move to text buffer + nnoremap :bnext + " SHIFT-TAB will go back + nnoremap :bprevious + + " Alternate way to save + nnoremap :w + " Alternate way to quit + nnoremap :wq! + " Use control-c instead of escape + nnoremap + " : completion. + inoremap pumvisible() ? "\" : "\" + + + " Better window navigation + nnoremap h + nnoremap j + nnoremap k + nnoremap l + + " Use alt + hjkl to resize windows + nnoremap :resize -2 + nnoremap :resize +2 + nnoremap :vertical resize -2 + nnoremap :vertical resize +2 +endif " Better tabbing vnoremap < >gv - -" Better window navigation -nnoremap h -nnoremap j -nnoremap k -nnoremap l - diff --git a/vim-plug/plugins.vim b/vim-plug/plugins.vim index e394b58e..c48b6c57 100644 --- a/vim-plug/plugins.vim +++ b/vim-plug/plugins.vim @@ -8,13 +8,16 @@ endif call plug#begin('~/.config/nvim/autoload/plugged') + if !exists('g:vscode') + " VSCode extension + " ordinary neovim " Better Syntax Support Plug 'sheerun/vim-polyglot' " Auto pairs for '(' '[' '{' Plug 'jiangmiao/auto-pairs' " Themes Plug 'christianchiarulli/onedark.vim' - Plug 'kaicataldo/material.vim' + " Plug 'kaicataldo/material.vim' " Intellisense Plug 'neoclide/coc.nvim', {'branch': 'release'} " Status Line @@ -31,7 +34,7 @@ call plug#begin('~/.config/nvim/autoload/plugged') " Add some color Plug 'norcalli/nvim-colorizer.lua' Plug 'junegunn/rainbow_parentheses.vim' - + endif call plug#end() diff --git a/vscode/windows.vim b/vscode/windows.vim new file mode 100644 index 00000000..436bf981 --- /dev/null +++ b/vscode/windows.vim @@ -0,0 +1,67 @@ + +"VSCode +function! s:split(...) abort + let direction = a:1 + let file = a:2 + call VSCodeCall(direction == 'h' ? 'workbench.action.splitEditorDown' : 'workbench.action.splitEditorRight') + if file != '' + call VSCodeExtensionNotify('open-file', expand(file), 'all') + endif +endfunction + +function! s:splitNew(...) + let file = a:2 + call s:split(a:1, file == '' ? '__vscode_new__' : file) +endfunction + +function! s:closeOtherEditors() + call VSCodeNotify('workbench.action.closeEditorsInOtherGroups') + call VSCodeNotify('workbench.action.closeOtherEditors') +endfunction + +function! s:manageEditorSize(...) + let count = a:1 + let to = a:2 + for i in range(1, count ? count : 1) + call VSCodeNotify(to == 'increase' ? 'workbench.action.increaseViewSize' : 'workbench.action.decreaseViewSize') + endfor +endfunction + +command! -complete=file -nargs=? Split call split('h', ) +command! -complete=file -nargs=? Vsplit call split('v', ) +command! -complete=file -nargs=? New call split('h', '__vscode_new__') +command! -complete=file -nargs=? Vnew call split('v', '__vscode_new__') +command! -bang Only if == '!' | call closeOtherEditors() | else | call VSCodeNotify('workbench.action.joinAllGroups') | endif + +nnoremap s :call split('h') +xnoremap s :call split('h') + +nnoremap v :call split('v') +xnoremap v :call split('v') + +nnoremap n :call splitNew('h', '__vscode_new__') +xnoremap n :call splitNew('h', '__vscode_new__') + +nnoremap :call VSCodeNotify('workbench.action.focusBelowGroup') +xnoremap :call VSCodeNotify('workbench.action.focusBelowGroup') +nnoremap :call VSCodeNotify('workbench.action.focusAboveGroup') +xnoremap :call VSCodeNotify('workbench.action.focusAboveGroup') +nnoremap :call VSCodeNotify('workbench.action.focusLeftGroup') +xnoremap :call VSCodeNotify('workbench.action.focusLeftGroup') +nnoremap :call VSCodeNotify('workbench.action.focusRightGroup') +xnoremap :call VSCodeNotify('workbench.action.focusRightGroup') + +nnoremap = :call VSCodeNotify('workbench.action.evenEditorWidths') +xnoremap = :call VSCodeNotify('workbench.action.evenEditorWidths') + +nnoremap > :call manageEditorSize(v:count, 'increase') +xnoremap > :call manageEditorSize(v:count, 'increase') +nnoremap + :call manageEditorSize(v:count, 'increase') +xnoremap + :call manageEditorSize(v:count, 'increase') +nnoremap < :call manageEditorSize(v:count, 'decrease') +xnoremap < :call manageEditorSize(v:count, 'decrease') +nnoremap - :call manageEditorSize(v:count, 'decrease') +xnoremap - :call manageEditorSize(v:count, 'decrease') + +nnoremap _ :call VSCodeNotify('workbench.action.toggleEditorWidths') + -- cgit v1.2.3