Orgnanize lua config
This commit is contained in:
37
vim/.vim/lua/config/google-comments.lua
Normal file
37
vim/.vim/lua/config/google-comments.lua
Normal file
@ -0,0 +1,37 @@
|
||||
-- Here are all the options and their default values:
|
||||
require('google.comments').setup {
|
||||
-- The command for fetching comments, refer to `get_comments.par --help` to
|
||||
-- see all the options.
|
||||
-- command = {'/google/bin/releases/editor-devtools/get_comments.par', '--full', '--json', "-x=''"},
|
||||
stubby = true,
|
||||
--
|
||||
command = {'/google/bin/releases/editor-devtools/get_comments.par', '--json', '--full', '--noresolved', '--cl_comments', '--file_comments'},
|
||||
-- /google/bin/releases/editor-devtools/get_comments.par --json --full --noresolved --cl_comments --file_comments -x "" --cl 487267122
|
||||
-- command = {'stubby --output_json call blade:codereview-rpc CodereviewRpcService.GetComments "changelist_number: $(/google/data/ro/teams/fig/bin/vcstool pending-change-number)"'},
|
||||
-- Define your own icon by `vim.fn.sign_define('ICON_NAME', {text = ' '})`.
|
||||
-- See :help sign_define
|
||||
-- The sign property passed to setup should be the 'ICON_NAME' in the define
|
||||
-- example above.
|
||||
sign = 'COMMENT_ICON',
|
||||
-- Fetch the comments after calling `setup`.
|
||||
auto_fetch = true,
|
||||
display = {
|
||||
-- The width of the comment display window.
|
||||
width = 50,
|
||||
-- When showing file paths, use relative paths or not.
|
||||
relative_path = true,
|
||||
},
|
||||
--- Enable viewing comments through floating window
|
||||
floating = true,
|
||||
--- Options used when creating the floating window.
|
||||
floating_window_options = require('google.comments.options').default_floating_window_options,
|
||||
}
|
||||
|
||||
local map = require("utils").map
|
||||
-- here are some mappings you might want:
|
||||
map('n', '<Leader>nc', [[<Cmd>lua require('google.comments').goto_next_comment()<CR>]])
|
||||
map('n', '<Leader>pc', [[<Cmd>lua require('google.comments').goto_prev_comment()<CR>]])
|
||||
map('n', '<Leader>lc', [[<Cmd>lua require('google.comments').toggle_line_comments()<CR>]])
|
||||
map('n', '<Leader>ac', [[<Cmd>lua require('google.comments').toggle_all_comments()<CR>]])
|
||||
|
||||
vim.fn.sign_define('COMMENT_ICON', {text = ''})
|
366
vim/.vim/lua/config/lsp.lua
Normal file
366
vim/.vim/lua/config/lsp.lua
Normal file
@ -0,0 +1,366 @@
|
||||
local use_google = require("utils").use_google
|
||||
local notify = require 'notify'
|
||||
|
||||
local lsp_status = require('lsp-status')
|
||||
lsp_status.register_progress()
|
||||
|
||||
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup({
|
||||
ensure_installed = { "sumneko_lua", "rust_analyzer" }
|
||||
})
|
||||
|
||||
local lsp = require('lsp-zero')
|
||||
lsp.preset('manual-setup')
|
||||
|
||||
lsp.nvim_workspace()
|
||||
lsp.setup()
|
||||
|
||||
-- Initialize rust_analyzer with rust-tools
|
||||
local rust_lsp = lsp.build_options('rust_analyzer', {})
|
||||
require('rust-tools').setup({server = rust_lsp})
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local configs = require("lspconfig.configs")
|
||||
if use_google() then
|
||||
configs.ciderlsp = {
|
||||
default_config = {
|
||||
cmd = { "/google/bin/releases/cider/ciderlsp/ciderlsp", "--tooltag=nvim-cmp", "--forward_sync_responses" },
|
||||
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl" },
|
||||
-- root_dir = lspconfig.util.root_pattern("BUILD"),
|
||||
root_dir = function(fname)
|
||||
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
||||
end;
|
||||
settings = {},
|
||||
},
|
||||
}
|
||||
|
||||
configs.analysislsp = {
|
||||
default_config = {
|
||||
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" },
|
||||
-- root_dir = lspconfig.util.root_pattern('BUILD'),
|
||||
root_dir = function(fname)
|
||||
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
|
||||
end;
|
||||
settings = {},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
local cider_lsp_handlers = {
|
||||
["textDocument/publishDiagnostics"] = vim.lsp.with(
|
||||
vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
underline = true,
|
||||
})
|
||||
}
|
||||
|
||||
cider_lsp_handlers["$/syncResponse"] = function(_, result, ctx)
|
||||
-- is_cider_lsp_attached has been setup via on_init, but hasn't received
|
||||
-- sync response yet.
|
||||
local first_fire = vim.b['is_cider_lsp_attached'] == 'no'
|
||||
vim.b['is_cider_lsp_attached'] = 'yes'
|
||||
if first_fire then
|
||||
notify('CiderLSP attached', 'info', {timeout=500})
|
||||
require('lualine').refresh()
|
||||
end
|
||||
end
|
||||
|
||||
cider_lsp_handlers["workspace/diagnostic/refresh"] = function(_, result, ctx)
|
||||
notify('result:'..result, 'info', {timeout=900})
|
||||
notify('ctx:'..ctx, 'info', {timeout=900})
|
||||
end
|
||||
|
||||
cider_lsp_handlers['window/showMessage'] = function(_, result, ctx)
|
||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||
local lvl = ({
|
||||
'ERROR',
|
||||
'WARN',
|
||||
'INFO',
|
||||
'DEBUG',
|
||||
})[result.type]
|
||||
notify({ result.message }, lvl, {
|
||||
title = 'LSP | ' .. client.name,
|
||||
timeout = 1000,
|
||||
keep = function()
|
||||
return lvl == 'ERROR' or lvl == 'WARN'
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- 3. Set up CiderLSP
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.b['is_cider_lsp_attached'] = 'no'
|
||||
require('lualine').refresh()
|
||||
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
if vim.lsp.formatexpr then -- Neovim v0.6.0+ only.
|
||||
vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr")
|
||||
end
|
||||
if vim.lsp.tagfunc then
|
||||
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||
end
|
||||
|
||||
if client.server_capabilities.document_highlight then
|
||||
vim.api.nvim_command("autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()")
|
||||
vim.api.nvim_command("autocmd CursorHoldI <buffer> lua vim.lsp.buf.document_highlight()")
|
||||
vim.api.nvim_command("autocmd CursorMoved <buffer> lua vim.lsp.util.buf_clear_references()")
|
||||
end
|
||||
|
||||
lsp_status.on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "L", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "g0", "<cmd>lua vim.lsp.buf.document_symbol()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "gW", "<cmd>lua vim.lsp.buf.workspace_symbol()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "gD", "<cmd>tab split | lua vim.lsp.buf.definition()<CR>", opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "grf", "<cmd>lua vim.lsp.buf.references()<CR>", opts) -- diagnostics controls references
|
||||
vim.api.nvim_set_keymap("n", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("i", "<C-g>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
|
||||
vim.api.nvim_set_keymap("n", "gt", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
|
||||
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
capabilities['codeLens'] = {dynamicRegistration=false}
|
||||
capabilities.textDocument.publishDiagnostics={
|
||||
relatedInformation=true,
|
||||
versionSupport=false,
|
||||
tagSupport={
|
||||
valueSet={
|
||||
1,
|
||||
2
|
||||
}
|
||||
},
|
||||
codeDescriptionSupport=true,
|
||||
dataSupport=true,
|
||||
layeredDiagnostics=true
|
||||
}
|
||||
|
||||
capabilities = vim.tbl_extend('keep', capabilities or {}, lsp_status.capabilities)
|
||||
|
||||
local runtime_path = vim.split(package.path, ";")
|
||||
table.insert(runtime_path, "lua/?.lua")
|
||||
table.insert(runtime_path, "lua/?/init.lua")
|
||||
|
||||
lspconfig.sumneko_lua.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if use_google() then
|
||||
capabilities = require('cmp_nvim_ciderlsp').update_capabilities(capabilities)
|
||||
capabilities.workspace.codeLens = {refreshSupport=true}
|
||||
capabilities.workspace.diagnostics = {refreshSupport=true}
|
||||
lspconfig.ciderlsp.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
handlers = cider_lsp_handlers,
|
||||
})
|
||||
lspconfig.analysislsp.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
})
|
||||
end
|
||||
|
||||
local lspkind = require("lspkind")
|
||||
lspkind.init()
|
||||
local cmp = require("cmp")
|
||||
|
||||
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
|
||||
|
||||
local feedkey = function(key, mode)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true)
|
||||
end
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp_document_symbol' }
|
||||
},{
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
|
||||
local conditionalSources = {
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "path" },
|
||||
{ name = "treesitter" },
|
||||
{ name = "crates" },
|
||||
{ name = "vim_vsnip" },
|
||||
{ name = 'nvim_lsp_signature_help' },
|
||||
{ name = "buffer", keyword_length = 5 },
|
||||
{
|
||||
name = 'spell',
|
||||
option = {
|
||||
keep_all_entries = false,
|
||||
enable_in_context = function()
|
||||
return true
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local use_google = require("utils").use_google
|
||||
if use_google() then
|
||||
table.insert(conditionalSources, { name = 'nvim_ciderlsp', priority = 9 })
|
||||
table.insert(conditionalSources, { name = 'analysislsp', priority = 9 })
|
||||
else
|
||||
table.insert(conditionalSources, {name = 'cmp_tabnine'})
|
||||
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
["<C-m>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<S-Tab>"] = cmp.mapping(function()
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#jumpable"](-1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
["<Up>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-jump-prev)", "")
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end),
|
||||
|
||||
["<Down>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif vim.fn["vsnip#available"](1) == 1 then
|
||||
feedkey("<Plug>(vsnip-expand-or-jump)", "")
|
||||
else
|
||||
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
|
||||
end
|
||||
end),
|
||||
},
|
||||
|
||||
sources = conditionalSources,
|
||||
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.offset,
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
function(entry1, entry2)
|
||||
local _, entry1_under = entry1.completion_item.label:find("^_+")
|
||||
local _, entry2_under = entry2.completion_item.label:find("^_+")
|
||||
entry1_under = entry1_under or 0
|
||||
entry2_under = entry2_under or 0
|
||||
if entry1_under > entry2_under then
|
||||
return false
|
||||
elseif entry1_under < entry2_under then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
},
|
||||
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
|
||||
formatting = {
|
||||
format = lspkind.cmp_format({
|
||||
with_text = true,
|
||||
maxwidth = 40, -- half max width
|
||||
menu = {
|
||||
nvim_ciderlsp = "",
|
||||
buffer = "",
|
||||
crates = "📦",
|
||||
nvim_lsp = "[CiderLSP]",
|
||||
cmp_tabnine = "[TabNine]",
|
||||
nvim_lua = "[API]",
|
||||
path = "[path]",
|
||||
tmux = "[TMUX]",
|
||||
vim_vsnip = "[snip]",
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
experimental = {
|
||||
native_menu = false,
|
||||
ghost_text = true,
|
||||
},
|
||||
})
|
||||
|
||||
vim.cmd([[
|
||||
augroup CmpZsh
|
||||
au!
|
||||
autocmd Filetype zsh lua require'cmp'.setup.buffer { sources = { { name = "zsh" }, } }
|
||||
augroup END
|
||||
]])
|
||||
|
98
vim/.vim/lua/config/lualine.lua
Normal file
98
vim/.vim/lua/config/lualine.lua
Normal file
@ -0,0 +1,98 @@
|
||||
local split = function (inputstr, sep)
|
||||
local t={}
|
||||
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
|
||||
table.insert(t, str)
|
||||
end
|
||||
return t
|
||||
end
|
||||
local function getCitc()
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
if string.find(fname, '/google/src/cloud/', 1, true) then
|
||||
local parts = split(fname, '/')
|
||||
return parts[5]
|
||||
end
|
||||
end
|
||||
local function isCiderLspAttached()
|
||||
if vim.b['is_cider_lsp_attached'] then
|
||||
if vim.b['is_cider_lsp_attached'] == 'yes' then
|
||||
return '✓'
|
||||
else
|
||||
return 'x'
|
||||
end
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
|
||||
local function getLightbulb()
|
||||
return require('nvim-lightbulb').get_status_text()
|
||||
end
|
||||
|
||||
local function getLGTMs()
|
||||
local comments = require("google.comments")
|
||||
local tracker = require("google.comments.tracker")
|
||||
local dump = require("utils").dump
|
||||
|
||||
print(dump(tracker.get_all_comments()))
|
||||
local lgtm = comments.get_lgtms()
|
||||
local appr = comments.get_approvals()
|
||||
print("lgtms"..dump(lgtm))
|
||||
print("approvals"..dump(appr))
|
||||
return "LGTM:"..table.concat(lgtm, ",").." Approval:"..table.concat(appr, ",")
|
||||
end
|
||||
|
||||
local lsp_status = require('lsp-status')
|
||||
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
theme = 'auto',
|
||||
globalstatus = false,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {'mode'},
|
||||
lualine_b = {'branch', 'diff', getCitc, isCiderLspAttached},
|
||||
lualine_c = {getLightbulb, 'filename'},
|
||||
lualine_x = {
|
||||
{ 'diagnostics', sources = {"nvim_lsp"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
||||
'encoding',
|
||||
'filetype'
|
||||
},
|
||||
lualine_y = {'searchcount'},
|
||||
lualine_z = {'location'}
|
||||
},
|
||||
tabline = {
|
||||
lualine_a = {{'tabs', mode = 1}},
|
||||
-- lualine_b = {'branch'},
|
||||
-- lualine_c = {'filename'},
|
||||
lualine_c = {
|
||||
{ 'diagnostics', sources = {"nvim_lsp", "nvim_workspace_diagnostic"}, symbols = {error = ' ', warn = ' ', info = ' ', hint = ' '} },
|
||||
},
|
||||
-- lualine_y = { getLGTMs }
|
||||
},
|
||||
-- default
|
||||
-- sections = {
|
||||
-- lualine_a = {'mode'},
|
||||
-- lualine_b = {'branch', 'diff', 'diagnostics'},
|
||||
-- lualine_c = {'filename'},
|
||||
-- lualine_x = {'encoding', 'fileformat', 'filetype'},
|
||||
-- lualine_y = {'progress'},
|
||||
-- lualine_z = {'location'}
|
||||
-- },
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
-- lualine_c = {'filename'},
|
||||
lualine_x = {'location'},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
-- tabline = {},
|
||||
-- winbar = {},
|
||||
-- inactive_winbar = {},
|
||||
-- extensions = {}
|
||||
}
|
5
vim/.vim/lua/config/notify.lua
Normal file
5
vim/.vim/lua/config/notify.lua
Normal file
@ -0,0 +1,5 @@
|
||||
local colors = require("catppuccin.palettes").get_palette()
|
||||
require("notify").setup({
|
||||
background_colour = colors.base,
|
||||
})
|
||||
vim.notify = require("notify")
|
25
vim/.vim/lua/config/null-ls.lua
Normal file
25
vim/.vim/lua/config/null-ls.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
local sources = {
|
||||
-- Catch insensitive, inconsiderate writing.
|
||||
null_ls.builtins.diagnostics.alex,
|
||||
|
||||
-- buildifier is a tool for formatting and linting bazel BUILD, WORKSPACE, and .bzl files.
|
||||
null_ls.builtins.diagnostics.buildifier,
|
||||
|
||||
-- Codespell finds common misspellings in text files.
|
||||
-- null_ls.builtins.diagnostics.codespell,
|
||||
-- null_ls.builtins.diagnostics.cspell, null_ls.builtins.code_actions.cspell,
|
||||
|
||||
-- An English prose linter. Can fix some issues via code actions.
|
||||
null_ls.builtins.code_actions.proselint,
|
||||
|
||||
-- Reformats Java source code according to Google Java Style.
|
||||
null_ls.builtins.formatting.google_java_format
|
||||
|
||||
}
|
||||
|
||||
|
||||
null_ls.setup({
|
||||
sources = sources,
|
||||
})
|
28
vim/.vim/lua/config/nvim-treesitter.lua
Normal file
28
vim/.vim/lua/config/nvim-treesitter.lua
Normal file
@ -0,0 +1,28 @@
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- A list of parser names, or "all"
|
||||
-- ensure_installed = { "c", "lua", "vim", "java", "kotlin"},
|
||||
ensure_installed = "all",
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
highlight = {
|
||||
-- `false` will disable the whole extension
|
||||
enable = true,
|
||||
indent = {
|
||||
enable = true
|
||||
},
|
||||
disable = {"java"},
|
||||
--
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
-- Using this option may slow down your editor, and you may see some duplicate highlights.
|
||||
-- Instead of true it can also be a list of languages
|
||||
-- additional_vim_regex_highlighting = true,
|
||||
-- additional_vim_regex_highlighting = {"java"},
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
}
|
||||
}
|
24
vim/.vim/lua/config/symbols-outline.lua
Normal file
24
vim/.vim/lua/config/symbols-outline.lua
Normal file
@ -0,0 +1,24 @@
|
||||
require("symbols-outline").setup(
|
||||
{
|
||||
show_relative_numbers = true,
|
||||
keymaps = { -- These keymaps can be a string or a table for multiple keys
|
||||
-- close = {"<Esc>", "q"},
|
||||
-- goto_location = "<Cr>",
|
||||
-- focus_location = "o",
|
||||
-- hover_symbol = "<C-space>",
|
||||
toggle_preview = "L",
|
||||
-- rename_symbol = "r",
|
||||
-- code_actions = "a",
|
||||
-- fold = "h",
|
||||
-- unfold = "l",
|
||||
fold_all = "H",
|
||||
unfold_all = "L",
|
||||
fold_reset = "R",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
local map = require("utils").map
|
||||
|
||||
|
||||
map('n', '<leader>so', ':SymbolsOutline<cr>')
|
43
vim/.vim/lua/config/telekasten.lua
Normal file
43
vim/.vim/lua/config/telekasten.lua
Normal file
@ -0,0 +1,43 @@
|
||||
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>
|
104
vim/.vim/lua/config/telescope.lua
Normal file
104
vim/.vim/lua/config/telescope.lua
Normal file
@ -0,0 +1,104 @@
|
||||
require('telescope').setup {
|
||||
defaults = {
|
||||
-- The vertical layout strategy is good to handle long paths like those in
|
||||
-- google3 repos because you have nearly the full screen to display a file path.
|
||||
-- The caveat is that the preview area is smaller.
|
||||
layout_strategy = 'vertical',
|
||||
-- Common paths in google3 repos are collapsed following the example of Cider
|
||||
-- It is nice to keep this as a user config rather than part of
|
||||
-- telescope-codesearch because it can be reused by other telescope pickers.
|
||||
path_display = function(opts, path)
|
||||
-- Do common substitutions
|
||||
path = path:gsub("^/google/src/cloud/[^/]+/[^/]+/google3/", "google3/", 1)
|
||||
path = path:gsub("^google3/java/com/google/", "g3/j/c/g/", 1)
|
||||
path = path:gsub("^google3/javatests/com/google/", "g3/jt/c/g/", 1)
|
||||
path = path:gsub("^google3/third_party/", "g3/3rdp/", 1)
|
||||
path = path:gsub("^google3/", "g3/", 1)
|
||||
|
||||
-- Do truncation. This allows us to combine our custom display formatter
|
||||
-- with the built-in truncation.
|
||||
-- `truncate` handler in transform_path memoizes computed truncation length in opts.__length.
|
||||
-- Here we are manually propagating this value between new_opts and opts.
|
||||
-- We can make this cleaner and more complicated using metatables :)
|
||||
local new_opts = {
|
||||
path_display = {
|
||||
truncate = true,
|
||||
},
|
||||
__length = opts.__length,
|
||||
}
|
||||
path = require('telescope.utils').transform_path(new_opts, path)
|
||||
opts.__length = new_opts.__length
|
||||
return path
|
||||
end,
|
||||
},
|
||||
extensions = { -- this block is optional, and if omitted, defaults will be used
|
||||
codesearch = {
|
||||
experimental = true -- enable results from google3/experimental
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
local map = require("utils").map
|
||||
|
||||
-- These custom mappings let you open telescope-codesearch quickly:
|
||||
map('n', '<C-P>',
|
||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{}<CR>]],
|
||||
{ noremap = true, silent=true }
|
||||
)
|
||||
|
||||
-- Search using codesearch queries.
|
||||
map(
|
||||
"n",
|
||||
"<leader>cs",
|
||||
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
|
||||
{ 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.
|
||||
map(
|
||||
"n",
|
||||
"<leader>CS",
|
||||
[[<cmd>lua require('telescope').extensions.codesearch.find_query{default_text_expand='<cword>'}<CR>]],
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
|
||||
-- Search for a file having word under cursor in its name.
|
||||
map(
|
||||
"n",
|
||||
"<leader>CF",
|
||||
[[<cmd>lua require('telescope').extensions.codesearch.find_files{default_text_expand='<cword>'}<CR>]],
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
|
||||
-- Search for text selected in Visual mode.
|
||||
map(
|
||||
"v",
|
||||
"<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(
|
||||
"v",
|
||||
"<leader>cf",
|
||||
[[<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})
|
||||
|
25
vim/.vim/lua/config/trouble.lua
Normal file
25
vim/.vim/lua/config/trouble.lua
Normal file
@ -0,0 +1,25 @@
|
||||
-- Diagnostics
|
||||
require("trouble").setup({
|
||||
signs = {
|
||||
-- icons / text used for a diagnostic
|
||||
error = ' ',
|
||||
warning = ' ',
|
||||
hint = ' ',
|
||||
information = ' ',
|
||||
other = "?",
|
||||
},
|
||||
use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client
|
||||
})
|
||||
|
||||
-- Mappings
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_set_keymap("n", "gr", "<Cmd>Trouble lsp_references<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<Leader>xx", "<Cmd>Trouble<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<Leader>xw", "<Cmd>Trouble workspace_diagnostics<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<Leader>xd", "<Cmd>Trouble document_diagnostics<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<Leader>xl", "<Cmd>Trouble loclist<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "<Leader>xq", "<Cmd>Trouble quickfix<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "[g", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
||||
vim.api.nvim_set_keymap("n", "]g", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
||||
|
||||
vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
|
Reference in New Issue
Block a user