From b39610bd69f5c2acdcbc05a4713117f45af86698 Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Thu, 16 Jun 2022 19:19:23 +0000 Subject: [PATCH] More plugins --- config/.config/nvim/lua/lsp.lua | 17 ++- config/.config/nvim/lua/telescope_config.lua | 117 +++++++++++++++++++ vim/.vim/prefs/cmp.vim | 1 + vim/.vim/prefs/google.vim | 7 +- vim/.vim/prefs/plug_prefs.vim | 2 +- vim/.vim/prefs/plugins.vim | 4 + vim/.vim/prefs/telescope.vim | 0 vim/.vimrc | 7 +- 8 files changed, 145 insertions(+), 10 deletions(-) create mode 100644 config/.config/nvim/lua/telescope_config.lua create mode 100644 vim/.vim/prefs/telescope.vim diff --git a/config/.config/nvim/lua/lsp.lua b/config/.config/nvim/lua/lsp.lua index 6e30109..03d1fbe 100644 --- a/config/.config/nvim/lua/lsp.lua +++ b/config/.config/nvim/lua/lsp.lua @@ -3,7 +3,9 @@ local nvim_lsp = require("lspconfig") local configs = require("lspconfig.configs") configs.ciderlsp = { default_config = { - cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-lsp", "--noforward_sync_responses", "--enable_semantic_tokens" }, + cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-lsp", "--noforward_sync_responses", + "--enable_semantic_tokens", + "--relay_mode=true", "--hub_addr=blade:languageservices-staging" }, filetypes = { "c", "cpp", "java", "kotlin", "proto", "textproto", "go", "python", "bzl" }, root_dir = nvim_lsp.util.root_pattern("BUILD"), settings = {}, @@ -172,7 +174,18 @@ local on_attach = function(client, bufnr) vim.api.nvim_command("augroup END") end +local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) +capabilities.textDocument.codeAction = { + codeActionLiteralSupport = { + codeActionKind = { + valueSet = { + '', 'quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source', 'source.organizeImports' + } + } + } +} +capabilities.textDocument.publishDiagnostics['versionSupport'] = false nvim_lsp.ciderlsp.setup({ - capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = capabilities, on_attach = on_attach, }) diff --git a/config/.config/nvim/lua/telescope_config.lua b/config/.config/nvim/lua/telescope_config.lua new file mode 100644 index 0000000..29abd95 --- /dev/null +++ b/config/.config/nvim/lua/telescope_config.lua @@ -0,0 +1,117 @@ +require('telescope').setup { + defaults = { + -- The vertical layout strategy is good to handle long paths like those in + -- google3 repos because you have nearly the full screen to display a file path. + -- The caveat is that the preview area is smaller. + layout_strategy = 'vertical', + -- Common paths in google3 repos are collapsed following the example of Cider + -- It is nice to keep this as a user config rather than part of + -- telescope-codesearch because it can be reused by other telescope pickers. + path_display = function(opts, path) + -- Do common substitutions + path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1) + path = path:gsub("^google3/java/com/google/", "g3/j/c/g/", 1) + path = path:gsub("^google3/javatests/com/google/", "g3/jt/c/g/", 1) + path = path:gsub("^google3/third_party/", "g3/3rdp/", 1) + path = path:gsub("^google3/", "g3/", 1) + + -- Do truncation. This allows us to combine our custom display formatter + -- with the built-in truncation. + -- `truncate` handler in transform_path memoizes computed truncation length in opts.__length. + -- Here we are manually propagating this value between new_opts and opts. + -- We can make this cleaner and more complicated using metatables :) + local new_opts = { + path_display = { + truncate = true, + }, + __length = opts.__length, + } + path = require('telescope.utils').transform_path(new_opts, path) + opts.__length = new_opts.__length + return path + end, + }, + extensions = { -- this block is optional, and if omitted, defaults will be used + codesearch = { + experimental = true -- enable results from google3/experimental + } + } +} + +-- These custom mappings let you open telescope-codesearch quickly: +-- Fuzzy find files in codesearch. +vim.api.nvim_set_keymap('n', 'ss', + [[lua require('telescope').extensions.codesearch.find_files{}]], + { noremap = true, silent=true } +) + +vim.api.nvim_set_keymap('n', '', + [[lua require('telescope').extensions.codesearch.find_files{}]], + { noremap = true, silent=true } +) + +-- Search using codesearch queries. +vim.api.nvim_set_keymap('n', 'sd', + [[lua require('telescope').extensions.codesearch.find_query{}]], + { noremap = true, silent=true } +) + +-- Search for the word under cursor. +vim.api.nvim_set_keymap('n', 'sD', +[[lua require('telescope').extensions.codesearch.find_query{default_text_expand=''}]], +{ noremap = true, silent=true } +) + +-- Search for a file having word under cursor in its name. +vim.api.nvim_set_keymap('n', 'sS', +[[lua require('telescope').extensions.codesearch.find_files{default_text_expand=''}]], +{ noremap = true, silent=true } +) + +-- Search for text selected in Visual mode. +vim.api.nvim_set_keymap('v', 'sd', +[[lua require('telescope').extensions.codesearch.find_query{}]], +{ noremap = true, silent=true } +) + + + + +vim.api.nvim_set_keymap( + "n", + "cs", + [[lua require('telescope').extensions.codesearch.find_files{}]], + { noremap = true, silent = true } +) + +-- Search using codesearch queries. +vim.api.nvim_set_keymap( + "n", + "csd", + [[lua require('telescope').extensions.codesearch.find_query{}]], + { noremap = true, silent = true } +) + +-- Search for the word under cursor. +vim.api.nvim_set_keymap( + "n", + "CS", + [[lua require('telescope').extensions.codesearch.find_query{default_text_expand=''}]], + { noremap = true, silent = true } +) + +-- Search for a file having word under cursor in its name. +vim.api.nvim_set_keymap( + "n", + "csS", + [[lua require('telescope').extensions.codesearch.find_files{default_text_expand=''}]], + { noremap = true, silent = true } +) + +-- Search for text selected in Visual mode. +vim.api.nvim_set_keymap( + "v", + "csd", + [[lua require('telescope').extensions.codesearch.find_query{}]], + { noremap = true, silent = true } +) diff --git a/vim/.vim/prefs/cmp.vim b/vim/.vim/prefs/cmp.vim index 3641f8b..928bab8 100644 --- a/vim/.vim/prefs/cmp.vim +++ b/vim/.vim/prefs/cmp.vim @@ -2,4 +2,5 @@ lua << EOF require 'lspconfig' require("lsp") require("diagnostics") + require("telescope") EOF diff --git a/vim/.vim/prefs/google.vim b/vim/.vim/prefs/google.vim index 84758ce..fc9136f 100644 --- a/vim/.vim/prefs/google.vim +++ b/vim/.vim/prefs/google.vim @@ -163,13 +163,14 @@ endfunction com! -nargs=? -complete=file Blame :call G4Blame() -nnoremap cs :FzfCs +" nnoremap cs :FzfCs " The buffer n can be replaced by any other unused buffer. " removes the visual range because csearch doesn't support ranges. " Removes newlines to allow the entire line search using V-LINE mode. -vnoremap cs "ny:FzfCs "=substitute(@n, '\n', '', '')" +" vnoremap cs "ny:FzfCs "=substitute(@n, '\n', '', '')" nnoremap csi :CsImporter -nnoremap CS :FzfCs +" nnoremap CS :FzfCs + nnoremap cc :CritiqueUnresolvedComments nnoremap s :call CitCObsession() nnoremap g :GoogleOutlineWindow diff --git a/vim/.vim/prefs/plug_prefs.vim b/vim/.vim/prefs/plug_prefs.vim index fdfbfa4..3763453 100644 --- a/vim/.vim/prefs/plug_prefs.vim +++ b/vim/.vim/prefs/plug_prefs.vim @@ -2,7 +2,7 @@ let pyxversion = 3 " -------- FZF -------- -nmap :FZF +" nmap :FZF nmap (fzf-maps-n) xmap (fzf-maps-x) diff --git a/vim/.vim/prefs/plugins.vim b/vim/.vim/prefs/plugins.vim index 8ebf266..3d1256a 100644 --- a/vim/.vim/prefs/plugins.vim +++ b/vim/.vim/prefs/plugins.vim @@ -16,6 +16,10 @@ Plug 'folke/trouble.nvim' Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} +Plug 'nvim-lua/plenary.nvim' " lua helpers +Plug 'nvim-telescope/telescope.nvim' " actual plugin +Plug 'sso://user/vintharas/telescope-codesearch.nvim' + " UI EXTENSIONS Plug 'ntpeters/vim-better-whitespace' "auto-set tab/space size Plug 'junegunn/fzf.vim' diff --git a/vim/.vim/prefs/telescope.vim b/vim/.vim/prefs/telescope.vim new file mode 100644 index 0000000..e69de29 diff --git a/vim/.vimrc b/vim/.vimrc index 1bff497..fadaf39 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -94,9 +94,6 @@ call plug#begin('~/.vim/plugged') source ~/.vim/prefs/golang.vim source ~/.vim/prefs/ultisnips.vim source ~/.vim/prefs/ripgrep.vim - " source ~/.vim/prefs/coc.vim - " source ~/.vim/prefs/asynclsp.vim - " source ~/.vim/prefs/ycm.vim call plug#end() " required " Require CiderLSP and Diagnostics modules @@ -109,13 +106,14 @@ lua << EOF require("lsp") require("diagnostics") require("treesitter") + require("telescope_config") + EOF source ~/.vim/prefs/cmp.vim if filereadable(expand("~/.vim/prefs/use_google.vim")) source ~/.vim/prefs/google_comments.vim endif -" source ~/.vim/prefs/ale.vim filetype plugin on " redundant? filetype plugin indent on @@ -155,3 +153,4 @@ let $NVIM_TUI_ENABLE_TRUE_COLOR=1 colorscheme quantum let g:airline_theme='quantum' set modifiable +set omnifunc= completeopt=menuone,noinsert,noselect