This commit is contained in:
Christian Nieves
2024-12-12 16:28:32 +00:00
parent 3d4f13be75
commit ce6295b69a
12 changed files with 170 additions and 504 deletions

View File

@ -1,7 +0,0 @@
vim.cmd([[
function UnusedDeps() abort
exe VimuxRunCommand("unused_deps --nouse_build_api --blaze_options='--config=gmscore_tap' " . join(blaze#GetTargets(), ' '))
endfunction
nnoremap <Leader>ud :call UnusedDeps()<cr>
]])

View File

@ -1,30 +0,0 @@
local map = require("utils").map
local use_google = require("utils").use_google
if use_google() then
-- [F]ig [S]tatus
map("n", "<leader>fs", [[<cmd>lua require('telescope').extensions.fig.status{}<CR>]])
-- [F]ig [X]l
map("n", "<leader>fx", [[<cmd>lua require('telescope').extensions.fig.xl{}<CR>]])
-- [F]ig [W]hatsout
map("n", "<leader>fw", [[<cmd>lua require('telescope').extensions.fig.status{whatsout=true}<CR>]])
-- [F]ig [A]mend
map("n", "<leader>fa", [[<cmd>Hg amend<CR>]])
-- [F]ig [A]mend
map("n", "<leader>fe", [[<cmd>Hg evolve<CR>]])
-- [F]ig [N]ext
map("n", "<leader>fn", [[<cmd>Hg next<CR>]])
--
-- [F]ig [P]rev
map("n", "<leader>fp", [[<cmd>Hg prev<CR>]])
--
-- [F]ig [U]pload
map("n", "<leader>fu", [[<cmd>Hg upload tree<CR>]])
-- map('n', '<Leader>f', ':Figtree<CR>', { silent = true })
end

View File

@ -1,24 +0,0 @@
--------- NERD Commenter
-- Create default mappings
vim.g.NERDCreateDefaultMappings = 0
-- Add spaces after comment delimiters by default
vim.g.NERDSpaceDelims = 1
-- Use compact syntax for prettified multi-line comments
vim.g.NERDCompactSexyComs = 1
-- Align line-wise comment delimiters flush left instead of following code indentation
vim.g.NERDDefaultAlign = "left"
-- Set a language to use its alternate delimiters by default
vim.g.NERDAltDelims_java = 1
-- Allow commenting and inverting empty lines (useful when commenting a region)
vim.g.NERDCommentEmptyLines = 1
-- Enable trimming of trailing whitespace when uncommenting
vim.g.NERDTrimTrailingWhitespace = 1
--Enable NERDCommenterToggle to check all selected lines is commented or not
vim.g.NERDToggleCheckAllLines = 1

View File

@ -1,75 +0,0 @@
local map = require("utils").map
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
function on_attach(bufnr)
vim.keymap.set("n", "O", api.tree.change_root_to_node, opts("CD"))
vim.keymap.set("n", "?", api.tree.toggle_help, opts("Help"))
-- put some default mappings here
vim.keymap.set("n", "<C-e>", api.node.open.replace_tree_buffer, opts("Open: In Place"))
vim.keymap.set("n", "<C-k>", api.node.show_info_popup, opts("Info"))
vim.keymap.set("n", "<C-r>", api.fs.rename_sub, opts("Rename: Omit Filename"))
vim.keymap.set("n", "<C-t>", api.node.open.tab, opts("Open: New Tab"))
vim.keymap.set("n", "<C-v>", api.node.open.vertical, opts("Open: Vertical Split"))
vim.keymap.set("n", "<C-x>", api.node.open.horizontal, opts("Open: Horizontal Split"))
vim.keymap.set("n", "<BS>", api.node.navigate.parent_close, opts("Close Directory"))
vim.keymap.set("n", "<CR>", api.node.open.edit, opts("Open"))
vim.keymap.set("n", "<Tab>", api.node.open.preview, opts("Open Preview"))
vim.keymap.set("n", ">", api.node.navigate.sibling.next, opts("Next Sibling"))
vim.keymap.set("n", "<", api.node.navigate.sibling.prev, opts("Previous Sibling"))
vim.keymap.set("n", ".", api.node.run.cmd, opts("Run Command"))
vim.keymap.set("n", "-", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "a", api.fs.create, opts("Create"))
vim.keymap.set("n", "bmv", api.marks.bulk.move, opts("Move Bookmarked"))
vim.keymap.set("n", "B", api.tree.toggle_no_buffer_filter, opts("Toggle No Buffer"))
vim.keymap.set("n", "c", api.fs.copy.node, opts("Copy"))
-- vim.keymap.set('n', 'C', api.tree.toggle_git_clean_filter, opts('Toggle Git Clean'))
-- vim.keymap.set('n', '[c', api.node.navigate.git.prev, opts('Prev Git'))
-- vim.keymap.set('n', ']c', api.node.navigate.git.next, opts('Next Git'))
vim.keymap.set("n", "d", api.fs.remove, opts("Delete"))
vim.keymap.set("n", "D", api.fs.trash, opts("Trash"))
vim.keymap.set("n", "E", api.tree.expand_all, opts("Expand All"))
vim.keymap.set("n", "e", api.fs.rename_basename, opts("Rename: Basename"))
vim.keymap.set("n", "]e", api.node.navigate.diagnostics.next, opts("Next Diagnostic"))
vim.keymap.set("n", "[e", api.node.navigate.diagnostics.prev, opts("Prev Diagnostic"))
vim.keymap.set("n", "F", api.live_filter.clear, opts("Clean Filter"))
vim.keymap.set("n", "f", api.live_filter.start, opts("Filter"))
vim.keymap.set("n", "g?", api.tree.toggle_help, opts("Help"))
vim.keymap.set("n", "gy", api.fs.copy.absolute_path, opts("Copy Absolute Path"))
vim.keymap.set("n", "H", api.tree.toggle_hidden_filter, opts("Toggle Dotfiles"))
vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore"))
vim.keymap.set("n", "J", api.node.navigate.sibling.last, opts("Last Sibling"))
vim.keymap.set("n", "K", api.node.navigate.sibling.first, opts("First Sibling"))
vim.keymap.set("n", "m", api.marks.toggle, opts("Toggle Bookmark"))
vim.keymap.set("n", "o", api.node.open.edit, opts("Open"))
-- vim.keymap.set('n', 'O', api.node.open.no_window_picker, opts('Open: No Window Picker'))
vim.keymap.set("n", "p", api.fs.paste, opts("Paste"))
vim.keymap.set("n", "P", api.node.navigate.parent, opts("Parent Directory"))
vim.keymap.set("n", "q", api.tree.close, opts("Close"))
vim.keymap.set("n", "r", api.fs.rename, opts("Rename"))
vim.keymap.set("n", "R", api.tree.reload, opts("Refresh"))
vim.keymap.set("n", "s", api.node.run.system, opts("Run System"))
vim.keymap.set("n", "S", api.tree.search_node, opts("Search"))
vim.keymap.set("n", "U", api.tree.toggle_custom_filter, opts("Toggle Hidden"))
vim.keymap.set("n", "W", api.tree.collapse_all, opts("Collapse"))
vim.keymap.set("n", "x", api.fs.cut, opts("Cut"))
vim.keymap.set("n", "y", api.fs.copy.filename, opts("Copy Name"))
vim.keymap.set("n", "Y", api.fs.copy.relative_path, opts("Copy Relative Path"))
end
require("nvim-tree").setup({
on_attach = on_attach,
update_focused_file = {
enable = true,
update_root = false,
ignore_list = {},
},
})
map("n", "<C-T>", ":NvimTreeToggle<CR>")
map("n", "<C-F>", ":NvimTreeFindFileToggle<CR>")

View File

@ -1,66 +0,0 @@
require("refactoring").setup({})
-- load refactoring Telescope extension
require("telescope").load_extension("refactoring")
-- remap to open the Telescope refactoring menu in visual mode
vim.api.nvim_set_keymap(
"v",
"<leader>rr",
"<Esc><cmd>lua require('telescope').extensions.refactoring.refactors()<CR>",
{ noremap = true }
)
-- Remaps for the refactoring operations currently offered by the plugin
vim.api.nvim_set_keymap(
"v",
"<leader>rx",
[[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]],
{ noremap = true, silent = true, expr = false }
)
vim.api.nvim_set_keymap(
"v",
"<leader>rxf",
[[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]],
{ noremap = true, silent = true, expr = false }
)
vim.api.nvim_set_keymap(
"v",
"<leader>rxv",
[[ <Esc><Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]],
{ noremap = true, silent = true, expr = false }
)
vim.api.nvim_set_keymap(
"v",
"<leader>ri",
[[ <Esc><Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]],
{ noremap = true, silent = true, expr = false }
)
-- Extract block doesn't need visual mode
vim.api.nvim_set_keymap(
"n",
"<leader>rxb",
[[ <Cmd>lua require('refactoring').refactor('Extract Block')<CR>]],
{ noremap = true, silent = true, expr = false }
)
vim.api.nvim_set_keymap(
"n",
"<leader>rxbf",
[[ <Cmd>lua require('refactoring').refactor('Extract Block To File')<CR>]],
{ noremap = true, silent = true, expr = false }
)
-- Inline variable can also pick up the identifier currently under the cursor without visual mode
vim.api.nvim_set_keymap(
"n",
"<leader>ri",
[[ <Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]],
{ noremap = true, silent = true, expr = false }
)
vim.api.nvim_set_keymap(
"n",
"<leader>rx",
[[ <Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]],
{ noremap = true, silent = true, expr = false }
)

View File

@ -1,43 +0,0 @@
local home = vim.fn.expand("~/zettelkasten")
require("telekasten").setup({
home = home,
})
vim.cmd([[
nnoremap <leader>zf :lua require('telekasten').find_notes()<CR>
nnoremap <leader>zd :lua require('telekasten').find_daily_notes()<CR>
nnoremap <leader>zg :lua require('telekasten').search_notes()<CR>
nnoremap <leader>zz :lua require('telekasten').follow_link()<CR>
autocmd FileType markdown nnoremap <Enter> :lua require('telekasten').follow_link()<CR>
autocmd FileType markdown vnoremap <leader>zf :lua require('telekasten').follow_link()<CR>
nnoremap <leader>zT :lua require('telekasten').goto_today()<CR>
nnoremap <leader>zW :lua require('telekasten').goto_thisweek()<CR>
nnoremap <leader>zw :lua require('telekasten').find_weekly_notes()<CR>
nnoremap <leader>zn :lua require('telekasten').new_note()<CR>
nnoremap <leader>zN :lua require('telekasten').new_templated_note()<CR>
nnoremap <leader>zy :lua require('telekasten').yank_notelink()<CR>
nnoremap <leader>zc :lua require('telekasten').show_calendar()<CR>
nnoremap <leader>zC :CalendarT<CR>
nnoremap <leader>zi :lua require('telekasten').paste_img_and_link()<CR>
nnoremap <leader>zt :lua require('telekasten').toggle_todo()<CR>
nnoremap <leader>zb :lua require('telekasten').show_backlinks()<CR>
nnoremap <leader>zF :lua require('telekasten').find_friends()<CR>
nnoremap <leader>zI :lua require('telekasten').insert_img_link({ i=true })<CR>
nnoremap <leader>zp :lua require('telekasten').preview_img()<CR>
nnoremap <leader>zm :lua require('telekasten').browse_media()<CR>
nnoremap <leader>za :lua require('telekasten').show_tags()<CR>
nnoremap <leader># :lua require('telekasten').show_tags()<CR>
nnoremap <leader>zr :lua require('telekasten').rename_note()<CR>
" on hesitation, bring up the panel
nnoremap <leader>z :lua require('telekasten').panel()<CR>
" colors
hi tklink ctermfg=72 guifg=#689d6a cterm=bold,underline gui=bold,underline
hi tkBrackets ctermfg=gray guifg=gray
hi tkTagSep ctermfg=gray guifg=gray
hi tkTag ctermfg=175 guifg=#d3869B
]])
-- autocmd FileType markdown vnoremap <Enter> :norm ysiw\]ysa\]\] lua require('telekasten').follow_link()<CR>

View File

@ -1,69 +0,0 @@
local use_google = require("utils").use_google
if use_google() then
return {}
end
vim.g.disable_autoformat = false
vim.api.nvim_create_user_command("FormatDisable", function(args)
if args.bang then
-- FormatDisable! will disable formatting just for this buffer
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
end, {
desc = "Disable autoformat-on-save",
bang = true,
})
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
end, {
desc = "Re-enable autoformat-on-save",
})
return {
{
"stevearc/conform.nvim",
event = { "BufWritePre" },
cmd = { "ConformInfo", "Format", "FormatDisable", "FormatEnable" },
keys = {
-- stylua: ignore
{ "<leader>fmt", function() require("conform").format({ async = true, lsp_fallback = true }) end, mode = "", desc = "Format buffer", },
},
opts = {
formatters_by_ft = {
rust = { "rustfmt", lsp_format = "fallback" },
-- Conform will run multiple formatters sequentially
-- go = { "goimports", "gofmt" },
-- Use a sub-list to run only the first available formatter
-- javascript = { { "prettierd", "prettier" } },
lua = { "stylua" },
-- Conform will run multiple formatters sequentially
python = { "isort", "black" },
-- Use a sub-list to run only the first available formatter
javascript = { { "prettierd", "prettier" } },
gdscript = { "gdformat" },
dashboard = {},
-- Use the "*" filetype to run formatters on all filetypes.
["*"] = { "codespell" },
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
format_on_save = function(bufnr)
-- Disable with a global or buffer-local variable
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
return { timeout_ms = 500, lsp_format = "fallback" }
end,
formatters = {
gdformat = {
prepend_args = { "-l", "100" },
},
},
},
},
}

View File

@ -328,7 +328,6 @@ return {
url = "sso://googler@user/smwang/hg.nvim",
dependencies = { "ipod825/libp.nvim" },
config = function()
require("config.fig")
require("hg").setup()
end,
},

View File

@ -48,21 +48,6 @@ return {
if lang == "gdrama" then
return true
end
local file_too_large = require("utils").file_too_large
local fname = vim.api.nvim_buf_get_name(buf)
if file_too_large(fname) then
vim.schedule(function()
vim.notify(
string.format(
"Disabling treesitter for buffer. File %s exceeds maximum configured size.",
fname
)
)
end)
return true
end
return false
end,

View File

@ -4,62 +4,67 @@ local TableConcat = require("utils").TableConcat
local scopes = require("neoscopes")
_G.find_files = function(search_dirs)
require("telescope.builtin").find_files({
search_dirs = search_dirs,
})
require("telescope.builtin").find_files({
search_dirs = search_dirs,
})
end
-- Helper functions to fetch the current scope and set `search_dirs`
_G.find_dotfiles = function()
require("telescope.builtin").git_files({
cwd = vim.fn.expand("$HOME/dotfiles"),
})
end
_G.search_cwd = function()
local builtin = require("telescope.builtin")
local utils = require("telescope.utils")
builtin.find_files({ cwd = utils.buffer_dir() })
local builtin = require("telescope.builtin")
local utils = require("telescope.utils")
builtin.find_files({ cwd = utils.buffer_dir() })
end
_G.live_grep = function(search_dirs)
require("telescope.builtin").live_grep({
search_dirs = search_dirs,
})
require("telescope.builtin").live_grep({
search_dirs = search_dirs,
})
end
_G.live_grep_cword = function(search_dirs)
require("telescope.builtin").live_grep({
search_dirs = search_dirs,
})
require("telescope.builtin").live_grep({
search_dirs = search_dirs,
})
end
local function exe(cmd)
return vim.split(vim.fn.system(cmd), "\n")
return vim.split(vim.fn.system(cmd), "\n")
end
local function get_visual_selection()
-- Yank current visual selection into the 'v' register
--
-- Note that this makes no effort to preserve this register
vim.cmd('noau normal! "vy"')
-- Yank current visual selection into the 'v' register
--
-- Note that this makes no effort to preserve this register
vim.cmd('noau normal! "vy"')
return vim.fn.getreg("v")
return vim.fn.getreg("v")
end
function fig_modified()
return exe("hg pstatus -ma -n --no-status --template= | sort")
return exe("hg pstatus -ma -n --no-status --template= | sort")
end
function fig_all_modified()
return exe("hg status -ma -n --rev p4base --no-status --template= | sort")
return exe("hg status -ma -n --rev p4base --no-status --template= | sort")
end
-- stylua: ignore
local keys = {
{ "<leader>e", ":lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>e", ":lua search_cwd()<CR>", desc = "Find Files in Buffer Directory" },
{ "<leader>ts", require('telescope.builtin').live_grep },
{ "<leader>TS", [[<cmd>lua require('telescope.builtin').live_grep{default_text = vim.fn.expand("<cword>")}<CR>]], },
{ "<leader>t.", ":lua find_dotfiles()<CR>", desc = "Find Dotfiles" },
{ "<leader>TS", function() require('telescope.builtin').live_grep { default_text = vim.fn.expand("<cword>") } end, },
{
"<leader>t.",
function()
require("telescope.builtin").git_files({
cwd = vim.fn.expand("$HOME/dotfiles"), })
end
,
desc = "Find Dotfiles"
},
{ "<leader>tc", ":Telescope textcase<CR>", desc = "Text case" },
{ "<leader>tC", ":CritiqueUnresolvedCommentsTelescope<CR>", desc = "Critique unresolved comments" },
{ "<leader>tca", ":CritiqueCommentsTelescope<CR>", desc = "Critique all comments" },
@ -85,144 +90,144 @@ if use_google() then
end
return {
{
"aznhe21/actions-preview.nvim",
config = function()
require("actions-preview").setup({
telescope = {
sorting_strategy = "ascending",
layout_strategy = "vertical",
layout_config = {
width = 0.8,
height = 0.9,
prompt_position = "top",
preview_cutoff = 20,
preview_height = function(_, _, max_lines)
return max_lines - 15
end,
},
},
})
end,
keys = {
{ "?", "<cmd>lua require('actions-preview').code_actions()<cr>" },
},
},
{
"smartpde/telescope-recent-files",
config = function()
require("telescope").load_extension("recent_files")
end,
keys = {
{ "<leader>to", [[<cmd>lua require('telescope').extensions.recent_files.pick()<CR>]] },
},
},
{
"piersolenski/telescope-import.nvim",
dependencies = "nvim-telescope/telescope.nvim",
config = function()
require("telescope").load_extension("import")
end,
keys = function()
if not use_google() then
return {
{ "<leader>i", ":Telescope import<CR>" },
}
end
end,
},
{
"nvim-telescope/telescope.nvim",
dependencies = {
"mfussenegger/nvim-dap",
"smartpde/telescope-recent-files",
"rcarriga/nvim-dap-ui",
},
config = function()
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/", "//j/c/g/", 1)
path = path:gsub("^google3/javatests/com/google/", "//jt/c/g/", 1)
path = path:gsub("^google3/third_party/", "//3p/", 1)
path = path:gsub("^google3/", "//", 1)
{
"aznhe21/actions-preview.nvim",
config = function()
require("actions-preview").setup({
telescope = {
sorting_strategy = "ascending",
layout_strategy = "vertical",
layout_config = {
width = 0.8,
height = 0.9,
prompt_position = "top",
preview_cutoff = 20,
preview_height = function(_, _, max_lines)
return max_lines - 15
end,
},
},
})
end,
keys = {
{ "?", "<cmd>lua require('actions-preview').code_actions()<cr>" },
},
},
{
"smartpde/telescope-recent-files",
config = function()
require("telescope").load_extension("recent_files")
end,
keys = {
{ "<leader>to", [[<cmd>lua require('telescope').extensions.recent_files.pick()<CR>]] },
},
},
{
"piersolenski/telescope-import.nvim",
dependencies = "nvim-telescope/telescope.nvim",
config = function()
require("telescope").load_extension("import")
end,
keys = function()
if not use_google() then
return {
{ "<leader>i", ":Telescope import<CR>" },
}
end
end,
},
{
"nvim-telescope/telescope.nvim",
dependencies = {
"mfussenegger/nvim-dap",
"smartpde/telescope-recent-files",
"rcarriga/nvim-dap-ui",
},
config = function()
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/", "//j/c/g/", 1)
path = path:gsub("^google3/javatests/com/google/", "//jt/c/g/", 1)
path = path:gsub("^google3/third_party/", "//3p/", 1)
path = path:gsub("^google3/", "//", 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,
mappings = {
n = {
["<C-c>"] = "close",
["<Esc>"] = "close",
},
i = {
-- ["<cr>"] = function(bufnr)
-- require("telescope.actions.set").edit(bufnr, "tab drop")
-- end,
["<C-c>"] = "close",
["<Esc>"] = "close",
["<S-Down>"] = "cycle_history_next",
["<S-Up>"] = "cycle_history_prev",
},
},
},
extensions = {
codesearch = {
experimental = true, -- enable results from google3/experimental
},
recent_files = {
-- This function rewrites all file paths to the current workspace.
-- For example, if w2 is the current workspace, then
-- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc,
transform_file_path = function(path)
local neocitc = require("neocitc")
local path_func = neocitc.path_in_current_workspace_or_head
or neocitc.path_in_current_workspace
return path_func(path)
end,
-- This is a useful option to speed up Telescope by avoiding the check
-- for file existence.
stat_files = false,
-- Ignore common patterns that can show up from other google plugins
ignore_patterns = {
"/%.git/COMMIT_EDITING$",
"/%.git/COMMIT_EDITMSG$",
"/%.git/MERGE_MSG$",
"^/tmp/%.pipertmp-",
"/Related_Files$",
"^term:",
";#toggleterm#",
},
},
persisted = {},
import = {
-- Add imports to the top of the file keeping the cursor in place
insert_at_top = true,
},
},
})
end,
keys = keys,
},
-- 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,
mappings = {
n = {
["<C-c>"] = "close",
["<Esc>"] = "close",
},
i = {
-- ["<cr>"] = function(bufnr)
-- require("telescope.actions.set").edit(bufnr, "tab drop")
-- end,
["<C-c>"] = "close",
["<Esc>"] = "close",
["<S-Down>"] = "cycle_history_next",
["<S-Up>"] = "cycle_history_prev",
},
},
},
extensions = {
codesearch = {
experimental = true, -- enable results from google3/experimental
},
recent_files = {
-- This function rewrites all file paths to the current workspace.
-- For example, if w2 is the current workspace, then
-- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc,
transform_file_path = function(path)
local neocitc = require("neocitc")
local path_func = neocitc.path_in_current_workspace_or_head
or neocitc.path_in_current_workspace
return path_func(path)
end,
-- This is a useful option to speed up Telescope by avoiding the check
-- for file existence.
stat_files = false,
-- Ignore common patterns that can show up from other google plugins
ignore_patterns = {
"/%.git/COMMIT_EDITING$",
"/%.git/COMMIT_EDITMSG$",
"/%.git/MERGE_MSG$",
"^/tmp/%.pipertmp-",
"/Related_Files$",
"^term:",
";#toggleterm#",
},
},
persisted = {},
import = {
-- Add imports to the top of the file keeping the cursor in place
insert_at_top = true,
},
},
})
end,
keys = keys,
},
}

View File

@ -22,15 +22,6 @@ function M.map(mode, lhs, rhs, opts)
vim.keymap.set(mode, lhs, rhs, options)
end
function M.file_too_large(filename)
local max_filesize = 2000 * 1024 -- 2MB
local ok, stats = pcall(vim.loop.fs_stat, filename)
if ok and stats and stats.size > max_filesize then
return true
end
return false
end
function M.use_google()
if M.use_google_cache == nil then
M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google")