diff --git a/vim/.vim/lua/config/blaze.lua b/vim/.vim/lua/config/blaze.lua deleted file mode 100644 index 3af4b56..0000000 --- a/vim/.vim/lua/config/blaze.lua +++ /dev/null @@ -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 ud :call UnusedDeps() -]]) diff --git a/vim/.vim/lua/config/fig.lua b/vim/.vim/lua/config/fig.lua deleted file mode 100644 index c1694e9..0000000 --- a/vim/.vim/lua/config/fig.lua +++ /dev/null @@ -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", "fs", [[lua require('telescope').extensions.fig.status{}]]) - - -- [F]ig [X]l - map("n", "fx", [[lua require('telescope').extensions.fig.xl{}]]) - - -- [F]ig [W]hatsout - map("n", "fw", [[lua require('telescope').extensions.fig.status{whatsout=true}]]) - - -- [F]ig [A]mend - map("n", "fa", [[Hg amend]]) - - -- [F]ig [A]mend - map("n", "fe", [[Hg evolve]]) - - -- [F]ig [N]ext - map("n", "fn", [[Hg next]]) - -- - -- [F]ig [P]rev - map("n", "fp", [[Hg prev]]) - -- - -- [F]ig [U]pload - map("n", "fu", [[Hg upload tree]]) - - -- map('n', 'f', ':Figtree', { silent = true }) -end diff --git a/vim/.vim/lua/config/google.lua b/vim/.vim/lua/config/google.lua deleted file mode 100644 index e69de29..0000000 diff --git a/vim/.vim/lua/config/nerdcommenter.lua b/vim/.vim/lua/config/nerdcommenter.lua deleted file mode 100644 index c24d0a8..0000000 --- a/vim/.vim/lua/config/nerdcommenter.lua +++ /dev/null @@ -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 diff --git a/vim/.vim/lua/config/nvim-tree.lua b/vim/.vim/lua/config/nvim-tree.lua deleted file mode 100644 index 5df7738..0000000 --- a/vim/.vim/lua/config/nvim-tree.lua +++ /dev/null @@ -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", "", api.node.open.replace_tree_buffer, opts("Open: In Place")) - vim.keymap.set("n", "", api.node.show_info_popup, opts("Info")) - vim.keymap.set("n", "", api.fs.rename_sub, opts("Rename: Omit Filename")) - vim.keymap.set("n", "", api.node.open.tab, opts("Open: New Tab")) - vim.keymap.set("n", "", api.node.open.vertical, opts("Open: Vertical Split")) - vim.keymap.set("n", "", api.node.open.horizontal, opts("Open: Horizontal Split")) - vim.keymap.set("n", "", api.node.navigate.parent_close, opts("Close Directory")) - vim.keymap.set("n", "", api.node.open.edit, opts("Open")) - vim.keymap.set("n", "", 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", "", ":NvimTreeToggle") -map("n", "", ":NvimTreeFindFileToggle") diff --git a/vim/.vim/lua/config/refactoring.lua b/vim/.vim/lua/config/refactoring.lua deleted file mode 100644 index e6fb745..0000000 --- a/vim/.vim/lua/config/refactoring.lua +++ /dev/null @@ -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", - "rr", - "lua require('telescope').extensions.refactoring.refactors()", - { noremap = true } -) - --- Remaps for the refactoring operations currently offered by the plugin -vim.api.nvim_set_keymap( - "v", - "rx", - [[ lua require('refactoring').refactor('Extract Function')]], - { noremap = true, silent = true, expr = false } -) -vim.api.nvim_set_keymap( - "v", - "rxf", - [[ lua require('refactoring').refactor('Extract Function To File')]], - { noremap = true, silent = true, expr = false } -) -vim.api.nvim_set_keymap( - "v", - "rxv", - [[ lua require('refactoring').refactor('Extract Variable')]], - { noremap = true, silent = true, expr = false } -) -vim.api.nvim_set_keymap( - "v", - "ri", - [[ lua require('refactoring').refactor('Inline Variable')]], - { noremap = true, silent = true, expr = false } -) - --- Extract block doesn't need visual mode -vim.api.nvim_set_keymap( - "n", - "rxb", - [[ lua require('refactoring').refactor('Extract Block')]], - { noremap = true, silent = true, expr = false } -) -vim.api.nvim_set_keymap( - "n", - "rxbf", - [[ lua require('refactoring').refactor('Extract Block To File')]], - { 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", - "ri", - [[ lua require('refactoring').refactor('Inline Variable')]], - { noremap = true, silent = true, expr = false } -) -vim.api.nvim_set_keymap( - "n", - "rx", - [[ lua require('refactoring').refactor('Extract Variable')]], - { noremap = true, silent = true, expr = false } -) diff --git a/vim/.vim/lua/config/telekasten.lua b/vim/.vim/lua/config/telekasten.lua deleted file mode 100644 index c6baaa5..0000000 --- a/vim/.vim/lua/config/telekasten.lua +++ /dev/null @@ -1,43 +0,0 @@ -local home = vim.fn.expand("~/zettelkasten") - -require("telekasten").setup({ - home = home, -}) - -vim.cmd([[ -nnoremap zf :lua require('telekasten').find_notes() -nnoremap zd :lua require('telekasten').find_daily_notes() -nnoremap zg :lua require('telekasten').search_notes() -nnoremap zz :lua require('telekasten').follow_link() -autocmd FileType markdown nnoremap :lua require('telekasten').follow_link() -autocmd FileType markdown vnoremap zf :lua require('telekasten').follow_link() -nnoremap zT :lua require('telekasten').goto_today() -nnoremap zW :lua require('telekasten').goto_thisweek() -nnoremap zw :lua require('telekasten').find_weekly_notes() -nnoremap zn :lua require('telekasten').new_note() -nnoremap zN :lua require('telekasten').new_templated_note() -nnoremap zy :lua require('telekasten').yank_notelink() -nnoremap zc :lua require('telekasten').show_calendar() -nnoremap zC :CalendarT -nnoremap zi :lua require('telekasten').paste_img_and_link() -nnoremap zt :lua require('telekasten').toggle_todo() -nnoremap zb :lua require('telekasten').show_backlinks() -nnoremap zF :lua require('telekasten').find_friends() -nnoremap zI :lua require('telekasten').insert_img_link({ i=true }) -nnoremap zp :lua require('telekasten').preview_img() -nnoremap zm :lua require('telekasten').browse_media() -nnoremap za :lua require('telekasten').show_tags() -nnoremap # :lua require('telekasten').show_tags() -nnoremap zr :lua require('telekasten').rename_note() - -" on hesitation, bring up the panel -nnoremap z :lua require('telekasten').panel() - -" 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 :norm ysiw\]ysa\]\] lua require('telekasten').follow_link() diff --git a/vim/.vim/lua/plugins/conform.lua b/vim/.vim/lua/plugins/conform.lua deleted file mode 100644 index 3a5080f..0000000 --- a/vim/.vim/lua/plugins/conform.lua +++ /dev/null @@ -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 - { "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" }, - }, - }, - }, - }, -} diff --git a/vim/.vim/lua/plugins/google.lua b/vim/.vim/lua/plugins/google.lua index 920a4fd..955e327 100644 --- a/vim/.vim/lua/plugins/google.lua +++ b/vim/.vim/lua/plugins/google.lua @@ -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, }, diff --git a/vim/.vim/lua/plugins/nvim-treesitter.lua b/vim/.vim/lua/plugins/nvim-treesitter.lua index 98299ac..c52fba2 100644 --- a/vim/.vim/lua/plugins/nvim-treesitter.lua +++ b/vim/.vim/lua/plugins/nvim-treesitter.lua @@ -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, diff --git a/vim/.vim/lua/plugins/telescope.lua b/vim/.vim/lua/plugins/telescope.lua index 4ce598d..021dd6c 100644 --- a/vim/.vim/lua/plugins/telescope.lua +++ b/vim/.vim/lua/plugins/telescope.lua @@ -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 = { - { "e", ":lua search_cwd()", desc = "Find Files in Buffer Directory" }, + { "e", ":lua search_cwd()", desc = "Find Files in Buffer Directory" }, { "ts", require('telescope.builtin').live_grep }, - { "TS", [[lua require('telescope.builtin').live_grep{default_text = vim.fn.expand("")}]], }, - { "t.", ":lua find_dotfiles()", desc = "Find Dotfiles" }, + { "TS", function() require('telescope.builtin').live_grep { default_text = vim.fn.expand("") } end, }, + { + "t.", + function() + require("telescope.builtin").git_files({ + cwd = vim.fn.expand("$HOME/dotfiles"), }) + end + , + desc = "Find Dotfiles" + }, { "tc", ":Telescope textcase", desc = "Text case" }, { "tC", ":CritiqueUnresolvedCommentsTelescope", desc = "Critique unresolved comments" }, { "tca", ":CritiqueCommentsTelescope", 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 = { - { "?", "lua require('actions-preview').code_actions()" }, - }, - }, - { - "smartpde/telescope-recent-files", - config = function() - require("telescope").load_extension("recent_files") - end, - keys = { - { "to", [[lua require('telescope').extensions.recent_files.pick()]] }, - }, - }, - { - "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 { - { "i", ":Telescope import" }, - } - 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 = { + { "?", "lua require('actions-preview').code_actions()" }, + }, + }, + { + "smartpde/telescope-recent-files", + config = function() + require("telescope").load_extension("recent_files") + end, + keys = { + { "to", [[lua require('telescope').extensions.recent_files.pick()]] }, + }, + }, + { + "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 { + { "i", ":Telescope import" }, + } + 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 = { - [""] = "close", - [""] = "close", - }, - i = { - -- [""] = function(bufnr) - -- require("telescope.actions.set").edit(bufnr, "tab drop") - -- end, - [""] = "close", - [""] = "close", - [""] = "cycle_history_next", - [""] = "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 = { + [""] = "close", + [""] = "close", + }, + i = { + -- [""] = function(bufnr) + -- require("telescope.actions.set").edit(bufnr, "tab drop") + -- end, + [""] = "close", + [""] = "close", + [""] = "cycle_history_next", + [""] = "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, + }, } diff --git a/vim/.vim/lua/utils.lua b/vim/.vim/lua/utils.lua index 46a9696..594c76b 100644 --- a/vim/.vim/lua/utils.lua +++ b/vim/.vim/lua/utils.lua @@ -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")