Switch completely to nvim

This commit is contained in:
doyle 2022-06-17 17:46:41 +10:00
parent d575105fe2
commit 333524778e
3 changed files with 203 additions and 12 deletions

View File

@ -1,3 +1,154 @@
set runtimepath^=~/.vim runtimepath+=~/.vim/after " Plugins
let &packpath = &runtimepath " ==============================================================================
source ~/.vimrc call plug#begin(stdpath('config') . '/plugged')
Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/junegunn/fzf'
Plug 'https://github.com/junegunn/fzf.vim'
Plug 'https://github.com/Tetralux/odin.vim'
Plug 'https://github.com/morhetz/gruvbox'
call plug#end()
" Theme
" ==============================================================================
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_italic=0
let g:gruvbox_bold=0
colorscheme gruvbox
" Options
" ==============================================================================
set autowrite " Automatically save before commands like :next and :make
set nowrap " Don't wrap lines of text automatically
set ignorecase " Search isn't case sensitive
set splitright " Open new splits to the right of the current one
set visualbell " Flash the screen on error
set expandtab " Replace tabs with spaces
set noswapfile " Disable swapfile (stores the things changed in a file)
set colorcolumn=80,100 " Set a 80 and 100 char column ruler
set cpoptions+=$ " $ as end marker for the change operator
set cursorline " Highlight current line
set linebreak " On wrapped lines, break on the wrapping word intelligently
set list " Show the 'listchar' characters on trailing spaces, tabs e.t.c
set listchars+=tab:>-,trail:■,extends,precedes
set number " Show line numbers
set relativenumber " Show relative line numbers
set shiftwidth=4 " Number of spaces for each autoindent step
set textwidth=80 " On format, format to 80 char long lines
" Show EOL type and last modified timestamp, right after the filename
set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P
set guifont=JetBrains_Mono:h9,Consolas:h9,InputMonoCondensed:h9
" Resize splits when the window is resized
au VimResized * :wincmd =
" File patterns to ignore in command line auto complete
set wildignore+=*.class,*.o
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.obj,*.vcxproj,*.pdb,*.idb
" Setup undo file
set undofile
let &undodir=stdpath('config') . '/undo'
" Enable mouse support
if has('mouse')
set mouse=a
endif
" Functions
" ==============================================================================
" Don't show trailing spaces in insert mode
augroup trailing
au!
au InsertEnter * :set listchars-=trail:■
au InsertLeave * :set listchars+=trail:■
augroup END
" Increase font size using (Ctrl+Up Arrow) or (Ctrl+Down Arrow) if we are using
" gvim Otherwise font size is determined in terminal
nnoremap <C-Up> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)+1)',
\ 'g')<CR>
nnoremap <C-Down> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)-1)',
\ 'g')<CR>
" Formatting options (see :h fo-table)
augroup persistent_settings
au!
au bufenter * :set formatoptions=q1j
augroup end
" Return to the same line when a file is reopened
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup end
" General Key Bindings
" ==============================================================================
" Map Ctrl+HJKL to navigate buffer window
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-l> :wincmd l<CR>
" Move by wrapped lines instead of line numbers
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" Map NERDTree to Ctrl-N
map <C-n> :NERDTreeToggle<CR>
" Change to current buffer's directory
nmap cd :cd <C-R>=expand("%:p:h")<CR><CR>
" Buffer Splitting
nnoremap <leader>s :vs<CR>
" Go to next error
" Go to previous error
nnoremap <A-n> :cn<CR>
nnoremap <A-p> :cp<CR>
" FZF
" ==============================================================================
nnoremap <leader>f :FzfFiles
nnoremap <leader>t :FzfTags<CR>
nnoremap <leader>r :FzfRg
nnoremap <leader>b :FzfBuffers<CR>
nnoremap <leader>l :FzfLines<CR>
" Empty value to disable preview window altogether
let g:fzf_preview_window = []
" Prefix all commands with Fzf for discoverability
let g:fzf_command_prefix = 'Fzf'
" - down / up / left / right
let g:fzf_layout = { 'down': '40%' }
" Clang Format
" ==============================================================================
map <C-I> :py3file ~/clang-format.py<CR>
" Compiler Error Formats
" ==============================================================================
" Error message formats thanks to
" https://forums.handmadehero.org/index.php/forum?view=topic&catid=4&id=704#3982
set errorformat+=\\\ %#%f(%l\\\,%c):\ %m " MSVC: MSBuild
set errorformat+=\\\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m " MSVC: cl.exe
set errorformat+=\\\ %#%t%nxx:\ %m " MSVC: cl.exe, fatal errors is crudely implemented
set errorformat+=\\\ %#LINK\ :\ %m " MSVC: link.exe, can't find link library badly implemented
set errorformat+=\\\ %#%s\ :\ error\ %m " MSVC: link.exe, errors is badly implemented
set errorformat+=\\\ %#%s\ :\ fatal\ error\ %m " MSVC: link.exe, fatal errors is badly implemented
set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m " MSVC: HLSL fxc.exe
set errorformat+=%\\%%(CTIME%\\)%\\@=%m " ctime.exe -stats

View File

@ -0,0 +1,45 @@
@echo off
REM Merge multiple compilation command files generated by clang -MJ and dump it
REM to standard output as a JSON array.
REM
REM An entry generated by clang -MJ, looks like this:
REM
REM {
REM "directory": "/home/user/dev/llvm/build",
REM "file": "/tmp/foo.cpp",
REM "output": "foo.o",
REM "arguments": ["/usr/bin/clang-5.0", "-xc++", "/tmp/foo.cpp", "--driver-mode=g++", "-Wall", "-I", "/home/user/dev/libcpp/libcpp/include", "-c", "--target=x86_64-unknown-linux-gnu"]
REM }
REM
REM See: https://sarcasm.github.io/notes/dev/compilation-database.html#clang
setlocal EnableDelayedExpansion
if [%1]==[] (
echo Usage: %0 [compilation command files...]
exit /b -1
)
REM Count the number of arguments we received
set arg_count=0
for %%x in (%*) do ( set /A arg_count+=1 )
REM Open a JSON array to splat the JSON compile commands objects into
echo [
REM Append the compile commands in
set arg_next_index=0
for %%x in (%*) do (
set /A arg_next_index+=1
set /P contents=<%%x
REM On the last compile command to append to the array, remove the trailing
REM comma on the JSON object
if !arg_next_index! == !arg_count! (
set contents=!contents:~0,-1!
)
echo !contents!
)
REM Close the JSON array
echo ]

View File

@ -267,10 +267,8 @@ call :MakeBatchShortcutInBinDir "clang++-!llvm_version!" "!llvm_bin_dir!\clang++
call :MakeBatchShortcutInBinDir "clang-cl++-!llvm_version!" "!llvm_bin_dir!\clang-cl++.exe" call :MakeBatchShortcutInBinDir "clang-cl++-!llvm_version!" "!llvm_bin_dir!\clang-cl++.exe"
REM Clang Format REM Clang Format
set clang_format_py_sha256=36ba7aa047f8a8ac8fdc278aaa733de801cc84dea60a4210973fd3e4f0d2a330 set clang_format=!home_dir!\clang-format.py
set vim_clang_format=!vim_dir!\clang-format.py call :CopyAndAlwaysOverwriteFile "!llvm_dir!\share\clang\clang-format.py" "!clang_format!" || exit /B
call :CopyAndAlwaysOverwriteFile "!llvm_dir!\share\clang\clang-format.py" "!vim_clang_format!" || exit /B
call :FileHashCheck sha256 "!vim_clang_format!" "!clang_format_py_sha256!" || exit /B
REM Terminal REM Terminal
echo set PATH=!llvm_bin_dir!;%%PATH%%>> "!tmp_terminal_script!" echo set PATH=!llvm_bin_dir!;%%PATH%%>> "!tmp_terminal_script!"
@ -655,16 +653,13 @@ call :MakeBatchShortcutInBinDir "neovide" "!neovide_exe!"
REM ---------------------------------------------------------------------------- REM ----------------------------------------------------------------------------
REM Vim Configuration REM Vim Configuration
REM ---------------------------------------------------------------------------- REM ----------------------------------------------------------------------------
REM Vim Config REM Nvim Config
call :CopyAndAlwaysOverwriteFile "!installer_dir!\os_vimrc" "!home_dir!\.vimrc"
REM Vim -> Nvim Config
set nvim_init_dir=!home_dir!\AppData\Local\nvim set nvim_init_dir=!home_dir!\AppData\Local\nvim
if not exist "!nvim_init_dir!" mkdir "!nvim_init_dir!" if not exist "!nvim_init_dir!" mkdir "!nvim_init_dir!"
call :CopyAndAlwaysOverwriteFile "!installer_dir!\os_nvim_init.vim" "!nvim_init_dir!\init.vim" call :CopyAndAlwaysOverwriteFile "!installer_dir!\os_nvim_init.vim" "!nvim_init_dir!\init.vim"
REM Vim Package Manager REM Vim Package Manager
set vim_plug_dir=!vim_dir!\autoload set vim_plug_dir=!nvim_init_dir!\autoload
set vim_plug=!vim_plug_dir!\plug.vim set vim_plug=!vim_plug_dir!\plug.vim
if not exist "!vim_plug_dir!" mkdir "!vim_plug_dir!" if not exist "!vim_plug_dir!" mkdir "!vim_plug_dir!"
call :DownloadFile "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" "!vim_plug!" || exit /B call :DownloadFile "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" "!vim_plug!" || exit /B