Compare commits
2 Commits
7206fae3b7
...
afbe9737b7
Author | SHA1 | Date | |
---|---|---|---|
afbe9737b7 | |||
22e5f66830 |
@ -1,3 +1,3 @@
|
|||||||
set tabstop=10
|
set tabstop=2
|
||||||
set softtabstop=10
|
set softtabstop=2
|
||||||
set shiftwidth=10
|
set shiftwidth=2
|
||||||
|
@ -67,7 +67,7 @@ function M.setup(capabilities)
|
|||||||
end
|
end
|
||||||
|
|
||||||
lspconfig.ciderlsp.setup({
|
lspconfig.ciderlsp.setup({
|
||||||
capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
capabilities = capabilities,
|
||||||
on_attach = cider_on_attach,
|
on_attach = cider_on_attach,
|
||||||
handlers = cider_lsp_handlers,
|
handlers = cider_lsp_handlers,
|
||||||
})
|
})
|
||||||
|
118
vim/.vim/lua/plugins/blink.lua
Normal file
118
vim/.vim/lua/plugins/blink.lua
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
local use_google = require("utils").use_google
|
||||||
|
local flags = require("utils").flags
|
||||||
|
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
"saghen/blink.compat",
|
||||||
|
-- use the latest release, via version = '*', if you also use the latest release for blink.cmp
|
||||||
|
version = "*",
|
||||||
|
-- lazy.nvim will automatically load the plugin when it's required by blink.cmp
|
||||||
|
lazy = true,
|
||||||
|
-- make sure to set opts so that lazy.nvim calls blink.compat's setup
|
||||||
|
opts = {},
|
||||||
|
cond = flags.blink,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"saghen/blink.cmp",
|
||||||
|
lazy = false, -- lazy loading handled internally
|
||||||
|
cond = flags.blink,
|
||||||
|
dependencies = {
|
||||||
|
"Exafunction/codeium.nvim",
|
||||||
|
"mikavilpas/blink-ripgrep.nvim",
|
||||||
|
"hrsh7th/cmp-cmdline",
|
||||||
|
-- "FelipeLema/cmp-async-path",
|
||||||
|
"chrisgrieser/cmp-nerdfont",
|
||||||
|
"hrsh7th/cmp-emoji",
|
||||||
|
"rafamadriz/friendly-snippets", -- optional: provides snippets for the snippet source
|
||||||
|
},
|
||||||
|
version = "v0.*", -- use a release tag to download pre-built binaries
|
||||||
|
-- build = 'cargo build --release',
|
||||||
|
|
||||||
|
---@module 'blink.cmp'
|
||||||
|
---@type blink.cmp.Config
|
||||||
|
opts = {
|
||||||
|
keymap = {
|
||||||
|
["<C-space>"] = { "show", "show_documentation", "hide_documentation" },
|
||||||
|
["<C-e>"] = { "hide", "fallback" },
|
||||||
|
["<CR>"] = { "accept", "fallback" },
|
||||||
|
|
||||||
|
["<Tab>"] = { "snippet_forward", "fallback" },
|
||||||
|
["<S-Tab>"] = { "snippet_backward", "fallback" },
|
||||||
|
|
||||||
|
["<Up>"] = { "select_prev", "fallback" },
|
||||||
|
["<Down>"] = { "select_next", "fallback" },
|
||||||
|
|
||||||
|
["<S-Up>"] = { "scroll_documentation_up", "fallback" },
|
||||||
|
["<S-Down>"] = { "scroll_documentation_down", "fallback" },
|
||||||
|
},
|
||||||
|
sources = {
|
||||||
|
providers = function()
|
||||||
|
local providerToEnable = {
|
||||||
|
"lsp",
|
||||||
|
"path",
|
||||||
|
"crates",
|
||||||
|
"snippets",
|
||||||
|
"buffer",
|
||||||
|
"ripgrep",
|
||||||
|
"emoji",
|
||||||
|
"nerdfont",
|
||||||
|
}
|
||||||
|
print("sources")
|
||||||
|
if use_google() then
|
||||||
|
table.insert(providerToEnable, "nvim_ciderlsp")
|
||||||
|
table.insert(providerToEnable, "buganizer")
|
||||||
|
else
|
||||||
|
table.insert(providerToEnable, "codeium")
|
||||||
|
end
|
||||||
|
return providerToEnable
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
providers = {
|
||||||
|
-- dont show LuaLS require statements when lazydev has items
|
||||||
|
lsp = { fallback_for = { "lazydev" } },
|
||||||
|
lazydev = { name = "LazyDev", module = "lazydev.integrations.blink" },
|
||||||
|
ripgrep = {
|
||||||
|
module = "blink-ripgrep",
|
||||||
|
name = "Ripgrep",
|
||||||
|
-- the options below are optional, some default values are shown
|
||||||
|
---@module "blink-ripgrep"
|
||||||
|
---@type blink-ripgrep.Options
|
||||||
|
opts = {
|
||||||
|
prefix_min_len = 3,
|
||||||
|
context_size = 5,
|
||||||
|
max_filesize = "1M",
|
||||||
|
additional_rg_options = {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
nvim_ciderlsp = {
|
||||||
|
name = "nvim_ciderlsp",
|
||||||
|
module = "blink.compat.source",
|
||||||
|
},
|
||||||
|
buganizer = {
|
||||||
|
name = "nvim_buganizer",
|
||||||
|
module = "blink.compat.source",
|
||||||
|
},
|
||||||
|
codeium = {
|
||||||
|
name = "codeium",
|
||||||
|
module = "blink.compat.source",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- experimental signature help support
|
||||||
|
signature = { enabled = true },
|
||||||
|
completion = {
|
||||||
|
trigger = {
|
||||||
|
show_on_x_blocked_trigger_characters = { "'", '"', "(", "{" },
|
||||||
|
},
|
||||||
|
menu = {
|
||||||
|
draw = {
|
||||||
|
-- columns = { { "label", "label_description", gap = 1 }, { "kind_icon", "kind" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
-- allows extending the providers array elsewhere in your config
|
||||||
|
-- without having to redefine it
|
||||||
|
opts_extend = { "sources.default" },
|
||||||
|
},
|
||||||
|
}
|
@ -1,22 +1,11 @@
|
|||||||
local use_google = require("utils").use_google
|
local use_google = require("utils").use_google
|
||||||
|
local flags = require("utils").flags
|
||||||
local function compare_by_ciderlsp_score(entry1, entry2)
|
|
||||||
if entry1.completion_item.score ~= nil and entry2.completion_item.score ~= nil then
|
|
||||||
print("LSP score " .. entry1.completion_item.score)
|
|
||||||
print("LSP score " .. entry2.completion_item.score)
|
|
||||||
return entry1.completion_item.score > entry2.completion_item.score
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local has_words_before = function()
|
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
event = { "InsertEnter", "CmdlineEnter" },
|
event = { "InsertEnter", "CmdlineEnter" },
|
||||||
|
cond = not flags.blink,
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"Exafunction/codeium.nvim",
|
"Exafunction/codeium.nvim",
|
||||||
"FelipeLema/cmp-async-path",
|
"FelipeLema/cmp-async-path",
|
||||||
|
@ -42,6 +42,6 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
keys = { { "<C-Space>", ":Dashboard<CR>" } },
|
-- keys = { { "<C-Space>", ":Dashboard<CR>" } },
|
||||||
dependencies = { { "nvim-tree/nvim-web-devicons" } },
|
dependencies = { { "nvim-tree/nvim-web-devicons" } },
|
||||||
}
|
}
|
||||||
|
11
vim/.vim/lua/plugins/lazydev.lua
Normal file
11
vim/.vim/lua/plugins/lazydev.lua
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
return {
|
||||||
|
"folke/lazydev.nvim",
|
||||||
|
ft = "lua", -- only load on lua files
|
||||||
|
opts = {
|
||||||
|
library = {
|
||||||
|
-- See the configuration section for more details
|
||||||
|
-- Load luvit types when the `vim.uv` word is found
|
||||||
|
{ path = "${3rd}/luv/library", words = { "vim%.uv" } },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
local use_google = require("utils").use_google
|
local use_google = require("utils").use_google
|
||||||
|
local flags = require("utils").flags
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
@ -21,7 +22,7 @@ return {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"kosayoda/nvim-lightbulb",
|
"kosayoda/nvim-lightbulb",
|
||||||
commit = "1cae7b7153ae98dcf1b11173a443ac1b6d8e3d49",
|
commit = "1cae7b7153ae98dcf1b11173a443ac1b6d8e3d49",
|
||||||
event = { "LspAttach" },
|
event = { "LspAttach" },
|
||||||
opts = {
|
opts = {
|
||||||
autocmd = { enabled = true },
|
autocmd = { enabled = true },
|
||||||
@ -66,8 +67,9 @@ return {
|
|||||||
},
|
},
|
||||||
-- cond = not use_google(),
|
-- cond = not use_google(),
|
||||||
config = function()
|
config = function()
|
||||||
local capabilities =
|
local capabilities = flags.blink
|
||||||
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
capabilities.offsetEncoding = { "utf-16" }
|
capabilities.offsetEncoding = { "utf-16" }
|
||||||
require("go").setup({
|
require("go").setup({
|
||||||
lsp_cfg = { capabilities = capabilities },
|
lsp_cfg = { capabilities = capabilities },
|
||||||
@ -87,7 +89,6 @@ return {
|
|||||||
group = format_sync_grp,
|
group = format_sync_grp,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
event = { "CmdlineEnter" },
|
|
||||||
ft = { "go", "gomod" },
|
ft = { "go", "gomod" },
|
||||||
build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries
|
build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries
|
||||||
},
|
},
|
||||||
@ -118,11 +119,9 @@ return {
|
|||||||
local lsp_status = require("lsp-status")
|
local lsp_status = require("lsp-status")
|
||||||
lsp_status.register_progress()
|
lsp_status.register_progress()
|
||||||
|
|
||||||
vim.opt.spell = true
|
local capabilities = flags.blink
|
||||||
vim.opt.spelllang = { "en_us" }
|
and require("blink.cmp").get_lsp_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
or require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
local capabilities =
|
|
||||||
require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
|
||||||
capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities)
|
capabilities = vim.tbl_extend("keep", capabilities or {}, lsp_status.capabilities)
|
||||||
capabilities.offsetEncoding = { "utf-16" }
|
capabilities.offsetEncoding = { "utf-16" }
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ return {
|
|||||||
TableConcat(lsps, {
|
TableConcat(lsps, {
|
||||||
"pyright",
|
"pyright",
|
||||||
"omnisharp_mono",
|
"omnisharp_mono",
|
||||||
"tsserver",
|
|
||||||
"docker_compose_language_service",
|
"docker_compose_language_service",
|
||||||
"dockerls",
|
"dockerls",
|
||||||
"graphql",
|
"graphql",
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
return {
|
|
||||||
"folke/neodev.nvim",
|
|
||||||
config = function()
|
|
||||||
require("neodev").setup({
|
|
||||||
library = { plugins = { "nvim-dap-ui" }, types = true },
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
return {
|
|
||||||
"smartpde/neoscopes",
|
|
||||||
config = function()
|
|
||||||
require("neoscopes").setup({
|
|
||||||
scopes = {
|
|
||||||
{
|
|
||||||
name = "earlycheckin",
|
|
||||||
dirs = {
|
|
||||||
"java/com/google/android/gmscore/tools/earlycheckin/",
|
|
||||||
"javatests/com/google/android/gmscore/tools/earlycheckin/",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{ name = "experimental", dirs = { "experimental/users/cnieves" } },
|
|
||||||
},
|
|
||||||
-- add_dirs_to_all_scopes = {
|
|
||||||
-- "~/dotfiles",
|
|
||||||
-- },
|
|
||||||
})
|
|
||||||
|
|
||||||
local scopes = require("neoscopes")
|
|
||||||
scopes.add_startup_scope()
|
|
||||||
end,
|
|
||||||
}
|
|
@ -1,18 +1,4 @@
|
|||||||
return {
|
return {
|
||||||
-- {
|
|
||||||
-- "dstein64/nvim-scrollview",
|
|
||||||
-- config = function()
|
|
||||||
-- require("scrollview").setup({
|
|
||||||
-- excluded_filetypes = { "nerdtree" },
|
|
||||||
-- current_only = true,
|
|
||||||
-- -- base = "buffer",
|
|
||||||
-- -- column = 80,
|
|
||||||
-- signs_on_startup = { "all" },
|
|
||||||
-- diagnostics_severities = { vim.diagnostic.severity.ERROR },
|
|
||||||
-- })
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
|
|
||||||
{
|
{
|
||||||
"petertriho/nvim-scrollbar",
|
"petertriho/nvim-scrollbar",
|
||||||
config = function()
|
config = function()
|
||||||
@ -30,22 +16,4 @@ return {
|
|||||||
end,
|
end,
|
||||||
lazy = false,
|
lazy = false,
|
||||||
},
|
},
|
||||||
-- {
|
|
||||||
-- "kevinhwang91/nvim-hlslens",
|
|
||||||
-- config = function()
|
|
||||||
-- require("hlslens").setup({
|
|
||||||
-- nearest_only = true,
|
|
||||||
-- build_position_cb = function(plist, _, _, _)
|
|
||||||
-- require("scrollbar.handlers.search").handler.show(plist.start_pos)
|
|
||||||
-- end,
|
|
||||||
-- })
|
|
||||||
--
|
|
||||||
-- vim.cmd([[
|
|
||||||
-- augroup scrollbar_search_hide
|
|
||||||
-- autocmd!
|
|
||||||
-- autocmd CmdlineLeave : lua require('scrollbar.handlers.search').handler.hide()
|
|
||||||
-- augroup END
|
|
||||||
-- ]])
|
|
||||||
-- end,
|
|
||||||
-- },
|
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,39 @@
|
|||||||
local use_google = require("utils").use_google
|
local use_google = require("utils").use_google
|
||||||
local exec = require("utils").exec
|
local exec = require("utils").exec
|
||||||
local TableConcat = require("utils").TableConcat
|
local TableConcat = require("utils").TableConcat
|
||||||
local scopes = require("neoscopes")
|
|
||||||
|
|
||||||
_G.find_files = function(search_dirs)
|
_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
|
end
|
||||||
-- Helper functions to fetch the current scope and set `search_dirs`
|
-- Helper functions to fetch the current scope and set `search_dirs`
|
||||||
_G.find_dotfiles = function()
|
_G.find_dotfiles = function() end
|
||||||
end
|
|
||||||
|
|
||||||
_G.search_cwd = function()
|
_G.search_cwd = function()
|
||||||
local builtin = require("telescope.builtin")
|
local builtin = require("telescope.builtin")
|
||||||
local utils = require("telescope.utils")
|
local utils = require("telescope.utils")
|
||||||
builtin.find_files({ cwd = utils.buffer_dir() })
|
builtin.find_files({ cwd = utils.buffer_dir() })
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.live_grep = function(search_dirs)
|
_G.live_grep = function(search_dirs)
|
||||||
require("telescope.builtin").live_grep({
|
require("telescope.builtin").live_grep({
|
||||||
search_dirs = search_dirs,
|
search_dirs = search_dirs,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
_G.live_grep_cword = function(search_dirs)
|
_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
|
end
|
||||||
|
|
||||||
local function exe(cmd)
|
local function exe(cmd)
|
||||||
return vim.split(vim.fn.system(cmd), "\n")
|
return vim.split(vim.fn.system(cmd), "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
function fig_modified()
|
function fig_modified()
|
||||||
return exe("hg pstatus -ma -n --no-status --template= | sort")
|
return exe("hg pstatus -ma -n --no-status --template= | sort")
|
||||||
end
|
end
|
||||||
|
|
||||||
function fig_all_modified()
|
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
|
end
|
||||||
|
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
@ -63,8 +61,8 @@ local keys = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if use_google() then
|
if use_google() then
|
||||||
local find_files = require("telescope.builtin").find_files
|
local find_files = require("telescope.builtin").find_files
|
||||||
local cs_query = require("telescope").extensions.codesearch.find_query
|
local cs_query = require("telescope").extensions.codesearch.find_query
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
TableConcat(keys, {
|
TableConcat(keys, {
|
||||||
{ "<leader>tm", function() find_files({ search_dirs = fig_modified() }) end, desc = "list modified Fig files." },
|
{ "<leader>tm", function() find_files({ search_dirs = fig_modified() }) end, desc = "list modified Fig files." },
|
||||||
@ -79,144 +77,144 @@ if use_google() then
|
|||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"aznhe21/actions-preview.nvim",
|
"aznhe21/actions-preview.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("actions-preview").setup({
|
require("actions-preview").setup({
|
||||||
telescope = {
|
telescope = {
|
||||||
sorting_strategy = "ascending",
|
sorting_strategy = "ascending",
|
||||||
layout_strategy = "vertical",
|
layout_strategy = "vertical",
|
||||||
layout_config = {
|
layout_config = {
|
||||||
width = 0.8,
|
width = 0.8,
|
||||||
height = 0.9,
|
height = 0.9,
|
||||||
prompt_position = "top",
|
prompt_position = "top",
|
||||||
preview_cutoff = 20,
|
preview_cutoff = 20,
|
||||||
preview_height = function(_, _, max_lines)
|
preview_height = function(_, _, max_lines)
|
||||||
return max_lines - 15
|
return max_lines - 15
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
keys = {
|
keys = {
|
||||||
{ "?", "<cmd>lua require('actions-preview').code_actions()<cr>" },
|
{ "?", "<cmd>lua require('actions-preview').code_actions()<cr>" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"smartpde/telescope-recent-files",
|
"smartpde/telescope-recent-files",
|
||||||
config = function()
|
config = function()
|
||||||
require("telescope").load_extension("recent_files")
|
require("telescope").load_extension("recent_files")
|
||||||
end,
|
end,
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>to", [[<cmd>lua require('telescope').extensions.recent_files.pick()<CR>]] },
|
{ "<leader>to", [[<cmd>lua require('telescope').extensions.recent_files.pick()<CR>]] },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"piersolenski/telescope-import.nvim",
|
"piersolenski/telescope-import.nvim",
|
||||||
dependencies = "nvim-telescope/telescope.nvim",
|
dependencies = "nvim-telescope/telescope.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("telescope").load_extension("import")
|
require("telescope").load_extension("import")
|
||||||
end,
|
end,
|
||||||
keys = function()
|
keys = function()
|
||||||
if not use_google() then
|
if not use_google() then
|
||||||
return {
|
return {
|
||||||
{ "<leader>i", ":Telescope import<CR>" },
|
{ "<leader>i", ":Telescope import<CR>" },
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
"smartpde/telescope-recent-files",
|
"smartpde/telescope-recent-files",
|
||||||
"rcarriga/nvim-dap-ui",
|
"rcarriga/nvim-dap-ui",
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require("telescope").setup({
|
require("telescope").setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
-- The vertical layout strategy is good to handle long paths like those in
|
-- 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.
|
-- google3 repos because you have nearly the full screen to display a file path.
|
||||||
-- The caveat is that the preview area is smaller.
|
-- The caveat is that the preview area is smaller.
|
||||||
layout_strategy = "vertical",
|
layout_strategy = "vertical",
|
||||||
-- Common paths in google3 repos are collapsed following the example of Cider
|
-- 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
|
-- 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.
|
-- telescope-codesearch because it can be reused by other telescope pickers.
|
||||||
path_display = function(opts, path)
|
path_display = function(opts, path)
|
||||||
-- Do common substitutions
|
-- Do common substitutions
|
||||||
path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1)
|
path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1)
|
||||||
path = path:gsub("^google3/java/com/google/", "//j/c/g/", 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/javatests/com/google/", "//jt/c/g/", 1)
|
||||||
path = path:gsub("^google3/third_party/", "//3p/", 1)
|
path = path:gsub("^google3/third_party/", "//3p/", 1)
|
||||||
path = path:gsub("^google3/", "//", 1)
|
path = path:gsub("^google3/", "//", 1)
|
||||||
|
|
||||||
-- Do truncation. This allows us to combine our custom display formatter
|
-- Do truncation. This allows us to combine our custom display formatter
|
||||||
-- with the built-in truncation.
|
-- with the built-in truncation.
|
||||||
-- `truncate` handler in transform_path memoizes computed truncation length in opts.__length.
|
-- `truncate` handler in transform_path memoizes computed truncation length in opts.__length.
|
||||||
-- Here we are manually propagating this value between new_opts and opts.
|
-- Here we are manually propagating this value between new_opts and opts.
|
||||||
-- We can make this cleaner and more complicated using metatables :)
|
-- We can make this cleaner and more complicated using metatables :)
|
||||||
local new_opts = {
|
local new_opts = {
|
||||||
path_display = {
|
path_display = {
|
||||||
truncate = true,
|
truncate = true,
|
||||||
},
|
},
|
||||||
__length = opts.__length,
|
__length = opts.__length,
|
||||||
}
|
}
|
||||||
path = require("telescope.utils").transform_path(new_opts, path)
|
path = require("telescope.utils").transform_path(new_opts, path)
|
||||||
opts.__length = new_opts.__length
|
opts.__length = new_opts.__length
|
||||||
return path
|
return path
|
||||||
end,
|
end,
|
||||||
mappings = {
|
mappings = {
|
||||||
n = {
|
n = {
|
||||||
["<C-c>"] = "close",
|
["<C-c>"] = "close",
|
||||||
["<Esc>"] = "close",
|
["<Esc>"] = "close",
|
||||||
},
|
},
|
||||||
i = {
|
i = {
|
||||||
-- ["<cr>"] = function(bufnr)
|
-- ["<cr>"] = function(bufnr)
|
||||||
-- require("telescope.actions.set").edit(bufnr, "tab drop")
|
-- require("telescope.actions.set").edit(bufnr, "tab drop")
|
||||||
-- end,
|
-- end,
|
||||||
["<C-c>"] = "close",
|
["<C-c>"] = "close",
|
||||||
["<Esc>"] = "close",
|
["<Esc>"] = "close",
|
||||||
["<S-Down>"] = "cycle_history_next",
|
["<S-Down>"] = "cycle_history_next",
|
||||||
["<S-Up>"] = "cycle_history_prev",
|
["<S-Up>"] = "cycle_history_prev",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
extensions = {
|
extensions = {
|
||||||
codesearch = {
|
codesearch = {
|
||||||
experimental = true, -- enable results from google3/experimental
|
experimental = true, -- enable results from google3/experimental
|
||||||
},
|
},
|
||||||
recent_files = {
|
recent_files = {
|
||||||
-- This function rewrites all file paths to the current workspace.
|
-- This function rewrites all file paths to the current workspace.
|
||||||
-- For example, if w2 is the current workspace, then
|
-- For example, if w2 is the current workspace, then
|
||||||
-- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc,
|
-- /google/.../w1/google3/my_file.cc becomes /google/.../w2/google3/my_file.cc,
|
||||||
transform_file_path = function(path)
|
transform_file_path = function(path)
|
||||||
local neocitc = require("neocitc")
|
local neocitc = require("neocitc")
|
||||||
local path_func = neocitc.path_in_current_workspace_or_head
|
local path_func = neocitc.path_in_current_workspace_or_head
|
||||||
or neocitc.path_in_current_workspace
|
or neocitc.path_in_current_workspace
|
||||||
return path_func(path)
|
return path_func(path)
|
||||||
end,
|
end,
|
||||||
-- This is a useful option to speed up Telescope by avoiding the check
|
-- This is a useful option to speed up Telescope by avoiding the check
|
||||||
-- for file existence.
|
-- for file existence.
|
||||||
stat_files = false,
|
stat_files = false,
|
||||||
-- Ignore common patterns that can show up from other google plugins
|
-- Ignore common patterns that can show up from other google plugins
|
||||||
ignore_patterns = {
|
ignore_patterns = {
|
||||||
"/%.git/COMMIT_EDITING$",
|
"/%.git/COMMIT_EDITING$",
|
||||||
"/%.git/COMMIT_EDITMSG$",
|
"/%.git/COMMIT_EDITMSG$",
|
||||||
"/%.git/MERGE_MSG$",
|
"/%.git/MERGE_MSG$",
|
||||||
"^/tmp/%.pipertmp-",
|
"^/tmp/%.pipertmp-",
|
||||||
"/Related_Files$",
|
"/Related_Files$",
|
||||||
"^term:",
|
"^term:",
|
||||||
";#toggleterm#",
|
";#toggleterm#",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
persisted = {},
|
persisted = {},
|
||||||
import = {
|
import = {
|
||||||
-- Add imports to the top of the file keeping the cursor in place
|
-- Add imports to the top of the file keeping the cursor in place
|
||||||
insert_at_top = true,
|
insert_at_top = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
keys = keys,
|
keys = keys,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,99 +1,102 @@
|
|||||||
local M = {
|
local M = {
|
||||||
use_google_cache = nil,
|
use_google_cache = nil,
|
||||||
|
flags = {
|
||||||
|
blink = false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.exec(command, args)
|
function M.exec(command, args)
|
||||||
local Job = require("plenary.job")
|
local Job = require("plenary.job")
|
||||||
local job = Job:new({
|
local job = Job:new({
|
||||||
command = command,
|
command = command,
|
||||||
args = args,
|
args = args,
|
||||||
})
|
})
|
||||||
job:sync()
|
job:sync()
|
||||||
job:wait()
|
job:wait()
|
||||||
return job:result()
|
return job:result()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.map(mode, lhs, rhs, opts)
|
function M.map(mode, lhs, rhs, opts)
|
||||||
local options = { noremap = true }
|
local options = { noremap = true }
|
||||||
if opts then
|
if opts then
|
||||||
options = vim.tbl_extend("force", options, opts)
|
options = vim.tbl_extend("force", options, opts)
|
||||||
end
|
end
|
||||||
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
-- vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||||
vim.keymap.set(mode, lhs, rhs, options)
|
vim.keymap.set(mode, lhs, rhs, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.use_google()
|
function M.use_google()
|
||||||
if M.use_google_cache == nil then
|
if M.use_google_cache == nil then
|
||||||
M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google")
|
M.use_google_cache = M.file_exists(os.getenv("HOME") .. "/use_google")
|
||||||
end
|
end
|
||||||
return M.use_google_cache
|
return M.use_google_cache
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.file_exists(name)
|
function M.file_exists(name)
|
||||||
local f = io.open(name, "r")
|
local f = io.open(name, "r")
|
||||||
if f ~= nil then
|
if f ~= nil then
|
||||||
io.close(f)
|
io.close(f)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.dump(o)
|
function M.dump(o)
|
||||||
if type(o) == "table" then
|
if type(o) == "table" then
|
||||||
local s = "{ "
|
local s = "{ "
|
||||||
for k, v in pairs(o) do
|
for k, v in pairs(o) do
|
||||||
if type(k) ~= "number" then
|
if type(k) ~= "number" then
|
||||||
k = '"' .. k .. '"'
|
k = '"' .. k .. '"'
|
||||||
end
|
end
|
||||||
s = s .. "[" .. k .. "] = " .. M.dump(v) .. ","
|
s = s .. "[" .. k .. "] = " .. M.dump(v) .. ","
|
||||||
end
|
end
|
||||||
return s .. "} "
|
return s .. "} "
|
||||||
else
|
else
|
||||||
return tostring(o)
|
return tostring(o)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.tprint(tbl, indent)
|
function M.tprint(tbl, indent)
|
||||||
if not indent then
|
if not indent then
|
||||||
indent = 0
|
indent = 0
|
||||||
end
|
end
|
||||||
local toprint = string.rep(" ", indent) .. "{\r\n"
|
local toprint = string.rep(" ", indent) .. "{\r\n"
|
||||||
indent = indent + 2
|
indent = indent + 2
|
||||||
for k, v in pairs(tbl) do
|
for k, v in pairs(tbl) do
|
||||||
toprint = toprint .. string.rep(" ", indent)
|
toprint = toprint .. string.rep(" ", indent)
|
||||||
if type(k) == "number" then
|
if type(k) == "number" then
|
||||||
toprint = toprint .. "[" .. k .. "] = "
|
toprint = toprint .. "[" .. k .. "] = "
|
||||||
elseif type(k) == "string" then
|
elseif type(k) == "string" then
|
||||||
toprint = toprint .. k .. "= "
|
toprint = toprint .. k .. "= "
|
||||||
end
|
end
|
||||||
if type(v) == "number" then
|
if type(v) == "number" then
|
||||||
toprint = toprint .. v .. ",\r\n"
|
toprint = toprint .. v .. ",\r\n"
|
||||||
elseif type(v) == "string" then
|
elseif type(v) == "string" then
|
||||||
toprint = toprint .. '"' .. v .. '",\r\n'
|
toprint = toprint .. '"' .. v .. '",\r\n'
|
||||||
elseif type(v) == "table" then
|
elseif type(v) == "table" then
|
||||||
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
|
toprint = toprint .. M.tprint(v, indent + 2) .. ",\r\n"
|
||||||
else
|
else
|
||||||
toprint = toprint .. '"' .. tostring(v) .. '",\r\n'
|
toprint = toprint .. '"' .. tostring(v) .. '",\r\n'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
toprint = toprint .. string.rep(" ", indent - 2) .. "}"
|
toprint = toprint .. string.rep(" ", indent - 2) .. "}"
|
||||||
return toprint
|
return toprint
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.log(message)
|
function M.log(message)
|
||||||
local log_file_path = vim.fn.expand("$HOME/nvim.log")
|
local log_file_path = vim.fn.expand("$HOME/nvim.log")
|
||||||
local log_file = io.open(log_file_path, "a")
|
local log_file = io.open(log_file_path, "a")
|
||||||
io.output(log_file)
|
io.output(log_file)
|
||||||
io.write(message .. "\n")
|
io.write(message .. "\n")
|
||||||
io.close(log_file)
|
io.close(log_file)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.TableConcat(t1, t2)
|
function M.TableConcat(t1, t2)
|
||||||
for i = 1, #t2 do
|
for i = 1, #t2 do
|
||||||
t1[#t1 + 1] = t2[i]
|
t1[#t1 + 1] = t2[i]
|
||||||
end
|
end
|
||||||
return t1
|
return t1
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
25
vim/.vimrc
25
vim/.vimrc
@ -8,13 +8,7 @@ set undofile
|
|||||||
set nobackup
|
set nobackup
|
||||||
set formatoptions+=j
|
set formatoptions+=j
|
||||||
set nowritebackup
|
set nowritebackup
|
||||||
au BufWritePre * let &bex = '@' . strftime("%F.%H:%M")
|
|
||||||
|
|
||||||
set termguicolors
|
set termguicolors
|
||||||
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
|
||||||
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
|
||||||
let &t_AB="\e[48;5;%dm"
|
|
||||||
let &t_AF="\e[38;5;%dm"
|
|
||||||
|
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
set cmdheight=1
|
set cmdheight=1
|
||||||
@ -43,8 +37,11 @@ set hlsearch " highlight matches
|
|||||||
set splitright " Puts new vsplit windows to the right of the current
|
set splitright " Puts new vsplit windows to the right of the current
|
||||||
set splitbelow " Puts new split windows to the bottom of the current
|
set splitbelow " Puts new split windows to the bottom of the current
|
||||||
|
|
||||||
|
" When set to a negative number from -1 to -100 this is used as the
|
||||||
|
" percentage of the window height. Thus -50 scrolls half the window
|
||||||
|
" height.
|
||||||
set scrolljump=5 " Line to scroll when cursor leaves screen
|
set scrolljump=5 " Line to scroll when cursor leaves screen
|
||||||
set scrolloff=3 " Minimum lines to keep above and below cursor
|
" set scrolloff=3 " Minimum lines to keep above and below cursor
|
||||||
|
|
||||||
set shortmess=A " disable swapg
|
set shortmess=A " disable swapg
|
||||||
set shortmess+=O
|
set shortmess+=O
|
||||||
@ -52,19 +49,10 @@ set modifiable
|
|||||||
set noscrollbind
|
set noscrollbind
|
||||||
set expandtab
|
set expandtab
|
||||||
|
|
||||||
source ~/.vim/prefs/mappings.vim
|
|
||||||
source ~/.vim/prefs/leader.vim
|
|
||||||
|
|
||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
|
|
||||||
set t_Co=256
|
set t_Co=256
|
||||||
|
|
||||||
let base16colorspace=256
|
let base16colorspace=256
|
||||||
set colorcolumn=100
|
set colorcolumn=100
|
||||||
|
|
||||||
if (has("termguicolors"))
|
|
||||||
set termguicolors
|
|
||||||
endif
|
|
||||||
set background=dark
|
set background=dark
|
||||||
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
||||||
|
|
||||||
@ -96,3 +84,8 @@ let g:loaded_remote_plugins = 1
|
|||||||
|
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
syntax on
|
syntax on
|
||||||
|
|
||||||
|
source ~/.vim/prefs/mappings.vim
|
||||||
|
source ~/.vim/prefs/leader.vim
|
||||||
|
source ~/.vim/prefs/mappings.vim
|
||||||
|
source ~/.vim/prefs/leader.vim
|
||||||
|
Reference in New Issue
Block a user