From d8d50d8d127b170418bd90c7a54a6d80a95454b1 Mon Sep 17 00:00:00 2001 From: doyle Date: Sun, 19 Jun 2022 01:50:33 +1000 Subject: [PATCH] nvim stuff --- Installer/os_nvim_init.vim | 117 ++++++++++++++++++++++++++----------- win_install.bat | 47 ++++++++++----- 2 files changed, 117 insertions(+), 47 deletions(-) diff --git a/Installer/os_nvim_init.vim b/Installer/os_nvim_init.vim index 4a5e323..0f66bd0 100644 --- a/Installer/os_nvim_init.vim +++ b/Installer/os_nvim_init.vim @@ -5,12 +5,15 @@ call plug#begin(stdpath('config') . '/plugged') " 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/tpope/vim-dispatch' - Plug 'https://github.com/nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} - " Fast fuzzy searcher, the .vim repository pulls in sane defaults for - " setting up fzf in vim. - Plug 'https://github.com/junegunn/fzf' - Plug 'https://github.com/junegunn/fzf.vim' + " TODO: 2022-06-19 Treesitter is too slow on large C++ files + " Plug 'https://github.com/nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} + Plug 'https://github.com/bfrg/vim-cpp-modern' + + " 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-cmp is a more powerful autocomplete engine @@ -30,11 +33,39 @@ call plug#begin(stdpath('config') . '/plugged') " odin for syntax highlighting Plug 'https://github.com/Tetralux/odin.vim' Plug 'https://github.com/sainnhe/gruvbox-material' + + " Lua cache to speed up load times + Plug 'https://github.com/lewis6991/impatient.nvim' call plug#end() " Lua Setup " ============================================================================== lua <"] = require('telescope.actions').move_selection_next, + [""] = require('telescope.actions').move_selection_previous, + }, + n = { + [""] = require('telescope.actions').move_selection_next, + [""] = require('telescope.actions').move_selection_previous, + }, + }, + }, + pickers = { + find_files = { + find_command = { "fd", "--unrestricted", "--strip-cwd-prefix" } + }, + } + } + -- Vim Options -- =========================================================================== vim.opt.autowrite=true -- Automatically save before cmds like :next and :prev @@ -81,9 +112,6 @@ lua <f Telescope find_files +nnoremap g Telescope live_grep +nnoremap ta Telescope tags +nnoremap te Telescope +nnoremap b Telescope buffers +nnoremap h Telescope help_tags + +nnoremap ls Telescope lsp_dynamic_workspace_symbols +nnoremap gd Telescope lsp_definitions +nnoremap gt Telescope lsp_type_definitions +nnoremap gr Telescope lsp_references + " Map Ctrl+HJKL to navigate buffer window nmap :wincmd h nmap :wincmd j @@ -254,14 +311,6 @@ nnoremap :cp " FZF " ============================================================================== -nnoremap f :FzfFiles -nnoremap F :FzfFiles -nnoremap t :FzfTags -nnoremap r :FzfRg -nnoremap r :FzfRg -nnoremap b :FzfBuffers -nnoremap l :FzfLines - " Empty value to disable preview window altogether let g:fzf_preview_window = [] diff --git a/win_install.bat b/win_install.bat index 818ba67..6593eea 100644 --- a/win_install.bat +++ b/win_install.bat @@ -588,22 +588,23 @@ set fzf_version=0.30.0 set fzf_label=fzf_win64_!fzf_version! set fzf_zip=!downloads_dir!\!fzf_label!.zip -set fzf_dir=!tools_dir!\!fzf_label! -set fzf_exe=!fzf_dir!\fzf.exe +set fzf_dir=!tools_dir! +set fzf_exe=!fzf_dir!\fzf_win64_!fzf_version!.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 :FileHashCheck sha256 "!fzf_zip!" "!fzf_sha256!" || 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 :MakeBatchShortcutInBinDir "fzf" "!fzf_exe!" 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_COMMAND=rg --files --no-ignore-vcs --hidden>> "!tmp_terminal_script!" +echo set FZF_DEFAULT_COMMAND=fd --unrestricted>> "!tmp_terminal_script!" REM ---------------------------------------------------------------------------- REM NVIM @@ -793,7 +794,33 @@ if not exist "!rg_exe!" ( ) 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 Ethereum @@ -951,14 +978,8 @@ REM ---------------------------------------------------------------------------- :Unzip set zip_file=%~1 set dest=%~2 -set msg=[Unzip] !zip_file! to !dest! - -if exist !dest! ( - echo - [Cached] !msg! -) else ( - echo - !msg! - call !zip7_dir!\7z.exe x -y -spe -o!dest! !zip_file! -) +echo [Unzip] !zip_file! to !dest! +call !zip7_dir!\7z.exe x -y -spe -o!dest! !zip_file! exit /B !ERRORLEVEL! REM ------------------------------------------------------------------------------------------------