telescope mappings
This commit is contained in:
@ -18,7 +18,7 @@ if use_google() then
|
|||||||
configs.ciderlsp = {
|
configs.ciderlsp = {
|
||||||
default_config = {
|
default_config = {
|
||||||
cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-cmp", "--forward_sync_responses" },
|
cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-cmp", "--forward_sync_responses" },
|
||||||
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl", "typescript"},
|
||||||
-- root_dir = lspconfig.util.root_pattern("BUILD"),
|
-- root_dir = lspconfig.util.root_pattern("BUILD"),
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
||||||
@ -30,7 +30,7 @@ if use_google() then
|
|||||||
configs.analysislsp = {
|
configs.analysislsp = {
|
||||||
default_config = {
|
default_config = {
|
||||||
cmd = { '/google/bin/users/lerm/glint-ale/analysis_lsp/server', '--lint_on_save=false', '--max_qps=10' },
|
cmd = { '/google/bin/users/lerm/glint-ale/analysis_lsp/server', '--lint_on_save=false', '--max_qps=10' },
|
||||||
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl", "markdown","typescript", "javascript"},
|
||||||
-- root_dir = lspconfig.util.root_pattern('BUILD'),
|
-- root_dir = lspconfig.util.root_pattern('BUILD'),
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
||||||
|
@ -1,104 +1,85 @@
|
|||||||
require('telescope').setup {
|
local use_google = require("utils").use_google
|
||||||
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
|
require('telescope').setup {
|
||||||
-- with the built-in truncation.
|
defaults = {
|
||||||
-- `truncate` handler in transform_path memoizes computed truncation length in opts.__length.
|
-- The vertical layout strategy is good to handle long paths like those in
|
||||||
-- Here we are manually propagating this value between new_opts and opts.
|
-- google3 repos because you have nearly the full screen to display a file path.
|
||||||
-- We can make this cleaner and more complicated using metatables :)
|
-- The caveat is that the preview area is smaller.
|
||||||
local new_opts = {
|
layout_strategy = 'vertical',
|
||||||
path_display = {
|
-- Common paths in google3 repos are collapsed following the example of Cider
|
||||||
truncate = true,
|
-- 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.
|
||||||
__length = opts.__length,
|
path_display = function(opts, path)
|
||||||
}
|
-- Do common substitutions
|
||||||
path = require('telescope.utils').transform_path(new_opts, path)
|
path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1)
|
||||||
opts.__length = new_opts.__length
|
path = path:gsub("^google3/java/com/google/", "g3/j/c/g/", 1)
|
||||||
return path
|
path = path:gsub("^google3/javatests/com/google/", "g3/jt/c/g/", 1)
|
||||||
end,
|
path = path:gsub("^google3/third_party/", "g3/3rdp/", 1)
|
||||||
},
|
path = path:gsub("^google3/", "g3/", 1)
|
||||||
extensions = { -- this block is optional, and if omitted, defaults will be used
|
|
||||||
|
-- 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 = {
|
codesearch = {
|
||||||
experimental = true -- enable results from google3/experimental
|
experimental = true -- enable results from google3/experimental
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local map = require("utils").map
|
local map = require("utils").map
|
||||||
|
|
||||||
-- These custom mappings let you open telescope-codesearch quickly:
|
if use_google() then
|
||||||
map('n', '<C-P>',
|
-- These custom mappings let you open telescope-codesearch quickly:
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
map('n', '<C-P>',
|
||||||
{ noremap = true, silent=true }
|
[[<cmd>lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
||||||
)
|
{ noremap = true, silent=true }
|
||||||
|
)
|
||||||
|
|
||||||
-- Search using codesearch queries.
|
-- Search using codesearch queries.
|
||||||
map(
|
map(
|
||||||
"n",
|
"n",
|
||||||
"<leader>cs",
|
"<leader>cs",
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||||
{ noremap = true, silent = true }
|
{ noremap = true, silent = true }
|
||||||
)
|
)
|
||||||
--
|
|
||||||
-- Search for files using codesearch queries.
|
|
||||||
map(
|
|
||||||
"n",
|
|
||||||
"<leader>cf",
|
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
|
||||||
{ noremap = true, silent = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Search for the word under cursor.
|
-- Search for the word under cursor.
|
||||||
map(
|
map(
|
||||||
"n",
|
"n",
|
||||||
"<leader>CS",
|
"<leader>CS",
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_query{default_text_expand='<cword>'}<CR>]],
|
[[<cmd>lua require('telescope').extensions.codesearch.find_query{default_text_expand='<cword>'}<CR>]],
|
||||||
{ noremap = true, silent = true }
|
{ noremap = true, silent = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Search for a file having word under cursor in its name.
|
-- Search for text selected in Visual mode.
|
||||||
map(
|
map(
|
||||||
"n",
|
"v",
|
||||||
"<leader>CF",
|
"<leader>cs",
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{default_text_expand='<cword>'}<CR>]],
|
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||||
{ noremap = true, silent = true }
|
{ noremap = true, silent = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
-- Search for text selected in Visual mode.
|
-- map("n",
|
||||||
map(
|
-- "<leader>ps",
|
||||||
"v",
|
-- [[:Telescope find_files find_command=hg,pstatus,-ma,-n,--template=<CR>]])
|
||||||
"<leader>cs",
|
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
|
||||||
{ noremap = true, silent = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
-- Search for file having text selected in Visual mode.
|
map("n", "<leader>tw", ":Telescope citc workspaces<CR>")
|
||||||
map(
|
map("n", "<leader>tm", ":Telescope citc modified<CR>")
|
||||||
"v",
|
map("n", "<leader>tb", ":Telescope file_browser<CR>")
|
||||||
"<leader>cf",
|
map("n", "<leader>tf", ":lua require('telescope').extensions.frecency.frecency({ workspace = 'CWD' })<CR>", {noremap = true, silent = true})
|
||||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
|
||||||
{ noremap = true, silent = true }
|
|
||||||
)
|
|
||||||
|
|
||||||
map("n",
|
|
||||||
"<leader>ps",
|
|
||||||
[[:Telescope find_files find_command=hg,pstatus,-ma,-n,--template=<CR>]])
|
|
||||||
|
|
||||||
map( "n", "<space>tb", ":Telescope file_browser")
|
|
||||||
map( "n", "<space>fb", ":Telescope file_browser")
|
|
||||||
map("n", "<leader><leader>", "<Cmd>lua require('telescope').extensions.frecency.frecency({ workspace = 'CWD' })<CR>", {noremap = true, silent = true})
|
|
||||||
|
|
||||||
|
end
|
||||||
|
@ -131,15 +131,12 @@ require('packer').startup(function(use)
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
use {
|
|
||||||
'sso://googler@user/vintharas/telescope-codesearch.nvim',
|
|
||||||
disable = not use_google(),
|
|
||||||
}
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
'sso://googler@user/piloto/cmp-nvim-ciderlsp',
|
'sso://googler@user/piloto/cmp-nvim-ciderlsp',
|
||||||
'sso://googler@user/kdark/ciderlsp-nvim',
|
'sso://googler@user/kdark/ciderlsp-nvim',
|
||||||
|
'sso://googler@user/vintharas/telescope-codesearch.nvim',
|
||||||
|
'sso://googler@user/aktau/telescope-citc.nvim',
|
||||||
|
|
||||||
disable = not use_google(),
|
disable = not use_google(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,3 +183,5 @@ nnoremap <leader>ws :CorpWebCs <cword> <CR>
|
|||||||
nnoremap <leader>wf :CorpWebCsFile<CR>
|
nnoremap <leader>wf :CorpWebCsFile<CR>
|
||||||
|
|
||||||
nmap <leader>rbs ss <leader>rb
|
nmap <leader>rbs ss <leader>rb
|
||||||
|
|
||||||
|
nmap <leader>yb :let @" = join(blaze#GetTargets(), ' ')<cr>
|
||||||
|
Reference in New Issue
Block a user