nvim stuff

This commit is contained in:
doyle 2022-06-19 01:50:33 +10:00
parent 502844d1e0
commit d8d50d8d12
2 changed files with 117 additions and 47 deletions

View File

@ -5,12 +5,15 @@ call plug#begin(stdpath('config') . '/plugged')
" vim-dispatch allows running async jobs in vim (i.e. builds in the background) " vim-dispatch allows running async jobs in vim (i.e. builds in the background)
Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/tpope/vim-dispatch' Plug 'https://github.com/tpope/vim-dispatch'
Plug 'https://github.com/nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
" Fast fuzzy searcher, the .vim repository pulls in sane defaults for " TODO: 2022-06-19 Treesitter is too slow on large C++ files
" setting up fzf in vim. " Plug 'https://github.com/nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'https://github.com/junegunn/fzf' Plug 'https://github.com/bfrg/vim-cpp-modern'
Plug 'https://github.com/junegunn/fzf.vim'
" Telescope file picker, sorter and previewer
Plug 'https://github.com/nvim-lua/plenary.nvim'
Plug 'https://github.com/nvim-telescope/telescope.nvim'
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' }
" nvim-lspconfig sets up sane defaults for LSP servers (i.e. clangd) " nvim-lspconfig sets up sane defaults for LSP servers (i.e. clangd)
" nvim-cmp is a more powerful autocomplete engine " nvim-cmp is a more powerful autocomplete engine
@ -30,11 +33,39 @@ call plug#begin(stdpath('config') . '/plugged')
" odin for syntax highlighting " odin for syntax highlighting
Plug 'https://github.com/Tetralux/odin.vim' Plug 'https://github.com/Tetralux/odin.vim'
Plug 'https://github.com/sainnhe/gruvbox-material' Plug 'https://github.com/sainnhe/gruvbox-material'
" Lua cache to speed up load times
Plug 'https://github.com/lewis6991/impatient.nvim'
call plug#end() call plug#end()
" Lua Setup " Lua Setup
" ============================================================================== " ==============================================================================
lua <<EOF lua <<EOF
require('impatient')
require('telescope').load_extension('fzf')
require('telescope').setup {
defaults = {
layout_config = {
horizontal = { width = 0.95 }
},
mappings = {
i = {
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
},
n = {
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
},
},
},
pickers = {
find_files = {
find_command = { "fd", "--unrestricted", "--strip-cwd-prefix" }
},
}
}
-- Vim Options -- Vim Options
-- =========================================================================== -- ===========================================================================
vim.opt.autowrite=true -- Automatically save before cmds like :next and :prev vim.opt.autowrite=true -- Automatically save before cmds like :next and :prev
@ -81,9 +112,6 @@ lua <<EOF
local bufopts = { noremap=true, silent=true, buffer=bufnr } local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', 'gs', vim.lsp.buf.signature_help, bufopts) vim.keymap.set('n', 'gs', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', 'ga', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gR', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', 'gR', vim.lsp.buf.rename, bufopts)
@ -149,27 +177,28 @@ lua <<EOF
}, },
} }
require('nvim-treesitter.configs').setup { -- TODO: 2022-06-19 Treesitter is too slow on large C++ files
ensure_installed = { "c", "cpp" }, -- A list of parser names, or "all" -- require('nvim-treesitter.configs').setup {
sync_install = false, -- Install parsers synchronously (only applied to `ensure_installed`) -- ensure_installed = { "c", "cpp" }, -- A list of parser names, or "all"
ignore_install = { }, -- List of parsers to ignore installing (for "all") -- sync_install = false, -- Install parsers synchronously (only applied to `ensure_installed`)
-- ignore_install = { }, -- List of parsers to ignore installing (for "all")
highlight = { -- highlight = {
enable = false, -- `false` will disable the whole extension -- enable = false, -- `false` will disable the whole extension
-- NOTE: these are the names of the parsers and not the filetype. (for example if you want to -- -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to
-- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is -- -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is
-- the name of the parser) -- -- the name of the parser)
-- list of language that will be disabled -- -- list of language that will be disabled
disable = { }, -- disable = { },
-- Setting this to true will run `:h syntax` and tree-sitter at the same time. -- -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation). -- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
-- Using this option may slow down your editor, and you may see some duplicate highlights. -- -- Using this option may slow down your editor, and you may see some duplicate highlights.
-- Instead of true it can also be a list of languages -- -- Instead of true it can also be a list of languages
additional_vim_regex_highlighting = false, -- additional_vim_regex_highlighting = false,
}, -- },
} -- }
EOF EOF
" Theme " Theme
@ -180,8 +209,23 @@ let g:gruvbox_material_disable_italic_comment=1
let g:gruvbox_material_enable_italic=0 let g:gruvbox_material_enable_italic=0
let g:gruvbox_material_enable_bold=0 let g:gruvbox_material_enable_bold=0
let g:gruvbox_material_diagnostic_virtual_text='colored' let g:gruvbox_material_diagnostic_virtual_text='colored'
let g:gruvbox_material_better_performance=1
colorscheme gruvbox-material colorscheme gruvbox-material
" Vim-cpp-modern customisation
" Disable function highlighting (affects both C and C++ files)
let g:cpp_function_highlight = 1
" Enable highlighting of C++11 attributes
let g:cpp_attributes_highlight = 1
" Highlight struct/class member variables (affects both C and C++ files)
let g:cpp_member_highlight = 0
" Put all standard C and C++ keywords under Vim's highlight group 'Statement'
" (affects both C and C++ files)
let g:cpp_simple_highlight = 1
" Options " Options
" ============================================================================== " ==============================================================================
" Show EOL type and last modified timestamp, right after the filename " Show EOL type and last modified timestamp, right after the filename
@ -226,6 +270,19 @@ augroup end
" General Key Bindings " General Key Bindings
" ============================================================================== " ==============================================================================
" Telescope Bindings
nnoremap <leader>f <cmd>Telescope find_files<cr>
nnoremap <leader>g <cmd>Telescope live_grep<cr>
nnoremap <leader>ta <cmd>Telescope tags<cr>
nnoremap <leader>te <cmd>Telescope<cr>
nnoremap <leader>b <cmd>Telescope buffers<cr>
nnoremap <leader>h <cmd>Telescope help_tags<cr>
nnoremap <leader>ls <cmd>Telescope lsp_dynamic_workspace_symbols<cr>
nnoremap gd <cmd>Telescope lsp_definitions<cr>
nnoremap gt <cmd>Telescope lsp_type_definitions<cr>
nnoremap gr <cmd>Telescope lsp_references<cr>
" Map Ctrl+HJKL to navigate buffer window " Map Ctrl+HJKL to navigate buffer window
nmap <silent> <C-h> :wincmd h<CR> nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-j> :wincmd j<CR> nmap <silent> <C-j> :wincmd j<CR>
@ -254,14 +311,6 @@ nnoremap <A-k> :cp<CR>
" FZF " FZF
" ============================================================================== " ==============================================================================
nnoremap <leader>f :FzfFiles<CR>
nnoremap <leader>F :FzfFiles
nnoremap <leader>t :FzfTags<CR>
nnoremap <leader>r :FzfRg<R>
nnoremap <leader>r :FzfRg
nnoremap <leader>b :FzfBuffers<CR>
nnoremap <leader>l :FzfLines<CR>
" Empty value to disable preview window altogether " Empty value to disable preview window altogether
let g:fzf_preview_window = [] let g:fzf_preview_window = []

View File

@ -588,22 +588,23 @@ set fzf_version=0.30.0
set fzf_label=fzf_win64_!fzf_version! set fzf_label=fzf_win64_!fzf_version!
set fzf_zip=!downloads_dir!\!fzf_label!.zip set fzf_zip=!downloads_dir!\!fzf_label!.zip
set fzf_dir=!tools_dir!\!fzf_label! set fzf_dir=!tools_dir!
set fzf_exe=!fzf_dir!\fzf.exe set fzf_exe=!fzf_dir!\fzf_win64_!fzf_version!.exe
if not exist "!fzf_exe!" ( if not exist "!fzf_exe!" (
call :DownloadFile "https://github.com/junegunn/fzf/releases/download/!fzf_version!/fzf-!fzf_version!-windows_amd64.zip" "!fzf_zip!" || exit /B call :DownloadFile "https://github.com/junegunn/fzf/releases/download/!fzf_version!/fzf-!fzf_version!-windows_amd64.zip" "!fzf_zip!" || exit /B
call :FileHashCheck sha256 "!fzf_zip!" "!fzf_sha256!" || exit /B call :FileHashCheck sha256 "!fzf_zip!" "!fzf_sha256!" || exit /B
call :Unzip "!fzf_zip!" "!fzf_dir!" || exit /B call :Unzip "!fzf_zip!" "!fzf_dir!" || exit /B
move /Y "!fzf_dir!\fzf.exe" "!fzf_exe!" 1>NUL || exit /B
) )
call :FileHashCheck sha256 "!fzf_exe!" "!fzf_exe_sha256!" || exit /B call :FileHashCheck sha256 "!fzf_exe!" "!fzf_exe_sha256!" || exit /B
call :MakeBatchShortcutInBinDir "fzf" "!fzf_exe!" call :MakeBatchShortcutInBinDir "fzf" "!fzf_exe!"
REM Terminal REM Terminal
REM Use RG for FZF to make it ultra fast REM Use FD for FZF to make it ultra fast
echo set FZF_DEFAULT_OPTS=--multi --layout=reverse>> "!tmp_terminal_script!" echo set FZF_DEFAULT_OPTS=--multi --layout=reverse>> "!tmp_terminal_script!"
echo set FZF_DEFAULT_COMMAND=rg --files --no-ignore-vcs --hidden>> "!tmp_terminal_script!" echo set FZF_DEFAULT_COMMAND=fd --unrestricted>> "!tmp_terminal_script!"
REM ---------------------------------------------------------------------------- REM ----------------------------------------------------------------------------
REM NVIM REM NVIM
@ -793,7 +794,33 @@ if not exist "!rg_exe!" (
) )
call :FileHashCheck sha256 "!rg_exe!" "!rg_exe_sha256!" || exit /B call :FileHashCheck sha256 "!rg_exe!" "!rg_exe_sha256!" || exit /B
call :MakeBatchShortcutInBinDir "rg" "!rg_exe!"
REM Terminal
echo set PATH=!rg_dir!;%%PATH%%>> "!tmp_terminal_script!"
REM ----------------------------------------------------------------------------
REM fd
REM ----------------------------------------------------------------------------
set fd_sha256=F21BC26C1AB6BDBE4FE43F87A20C792D4ABE629AE97C6F42B25AC8A042F5521F
set fd_exe_sha256=764F31AC5B477707B51DAEC32458E4D66059BA0D17F03032B7CD0C0534703354
set fd_version=8.4.0
set fd_label=fd_win64_!fd_version!
set fd_zip=!downloads_dir!\!fd_label!.zip
set fd_dir=!tools_dir!\!fd_label!
set fd_exe=!fd_dir!\fd.exe
if not exist "!fd_exe!" (
call :DownloadFile "https://github.com/sharkdp/fd/releases/download/v!fd_version!/fd-v!fd_version!-x86_64-pc-windows-msvc.zip" "!fd_zip!" || exit /B
call :FileHashCheck sha256 "!fd_zip!" "!fd_sha256!" || exit /B
call :Unzip "!fd_zip!" "!fd_dir!" || exit /B
call :Move "!fd_dir!\fd-v!fd_version!-x86_64-pc-windows-msvc" "!fd_dir!" || exit /B
)
call :FileHashCheck sha256 "!fd_exe!" "!fd_exe_sha256!" || exit /B
REM Terminal
echo set PATH=!fd_dir!;%%PATH%%>> "!tmp_terminal_script!"
REM ---------------------------------------------------------------------------- REM ----------------------------------------------------------------------------
REM Ethereum REM Ethereum
@ -951,14 +978,8 @@ REM ----------------------------------------------------------------------------
:Unzip :Unzip
set zip_file=%~1 set zip_file=%~1
set dest=%~2 set dest=%~2
set msg=[Unzip] !zip_file! to !dest! echo [Unzip] !zip_file! to !dest!
call !zip7_dir!\7z.exe x -y -spe -o!dest! !zip_file!
if exist !dest! (
echo - [Cached] !msg!
) else (
echo - !msg!
call !zip7_dir!\7z.exe x -y -spe -o!dest! !zip_file!
)
exit /B !ERRORLEVEL! exit /B !ERRORLEVEL!
REM ------------------------------------------------------------------------------------------------ REM ------------------------------------------------------------------------------------------------