Compare commits

..

5 Commits

Author SHA1 Message Date
b83696c4cd update tmuxinator 2023-01-25 16:06:54 +00:00
eb1168ffe3 lsp config 2023-01-23 18:46:55 +00:00
7f70ffda16 telescope-fig 2023-01-11 10:58:49 -06:00
768cd312a7 refactoring stuff 2023-01-11 16:53:52 +00:00
4063d58e4d telescope mappings 2022-12-27 20:04:40 +00:00
9 changed files with 197 additions and 259 deletions

View File

@ -1,3 +1,4 @@
private
handlePackageIntent
for/!
tooling/!

View File

@ -3,7 +3,6 @@ name: dev
windows:
- gmscore:
# layout: 02a8,363x89,0,0[363x74,0,0,14,363x14,0,75{181x14,0,75,15,181x14,182,75,17}]
layout: main-vertical
panes:
- main:
@ -13,7 +12,6 @@ windows:
- hgd gmscore
- experimental:
# layout: 02a8,363x89,0,0[363x74,0,0,14,363x14,0,75{181x14,0,75,15,181x14,182,75,17}]
layout: main-vertical
panes:
- main:
@ -21,24 +19,18 @@ windows:
- vim
- other:
- hgd experimental
- notes:
# layout: 02a8,363x89,0,0[363x74,0,0,14,363x14,0,75{181x14,0,75,15,181x14,182,75,17}]
layout: main-vertical
panes:
- main:
- hgd notes
- cd ../company/users/cnieves/
- vim ~/zettelkasten/
- other:
- hgd notes
- cd ../company/users/cnieves/
- vim ~/zettelkasten/Todo.md
- vim:
# layout: 02a8,363x89,0,0[363x74,0,0,14,363x14,0,75{181x14,0,75,15,181x14,182,75,17}]
- dotfiles:
layout: main-vertical
panes:
- main:
- cd ~/.vim/prefs
- cd ~/dotfiles
- vim
- other:
- cd ~/.vim/prefs
- cd ~/dotfiles

View File

@ -18,7 +18,7 @@ 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" },
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl", "typescript"},
-- root_dir = lspconfig.util.root_pattern("BUILD"),
root_dir = function(fname)
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
@ -30,7 +30,7 @@ if use_google() then
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" },
filetypes = { "c", "cpp", "java", "kotlin", "objc", "proto", "textproto", "go", "python", "bzl", "markdown","typescript", "javascript"},
-- root_dir = lspconfig.util.root_pattern('BUILD'),
root_dir = function(fname)
return string.match(fname, '(/google/src/cloud/[%w_-]+/[%w_-]+/google3/).+$')
@ -40,46 +40,6 @@ if use_google() then
}
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'
@ -111,6 +71,7 @@ local on_attach = function(client, bufnr)
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", "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)
@ -169,21 +130,6 @@ lspconfig.sumneko_lua.setup({
})
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")
@ -220,12 +166,12 @@ cmp.setup.cmdline(':', {
local conditionalSources = {
{ name = "nvim_lua" },
{ name = "nvim_lsp" },
{ name = 'nvim_lsp_signature_help', priority = 5 },
{ name = "path" },
{ name = "treesitter" },
{ name = "crates" },
{ name = "vim_vsnip" },
{ name = 'nvim_lsp_signature_help' },
{ name = "buffer", keyword_length = 5 },
{ name = "buffer", keyword_length = 5, group_index = 2 },
{
name = 'spell',
option = {
@ -238,59 +184,62 @@ local conditionalSources = {
}
if use_google() then
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
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,
})
table.insert(conditionalSources, { name = 'nvim_ciderlsp', priority = 9 })
table.insert(conditionalSources, { name = 'analysislsp', priority = 9 })
table.insert(conditionalSources, { name = 'analysislsp' })
else
table.insert(conditionalSources, {name = 'cmp_tabnine'})
end
local i = 0
function cmp_format(opts)
if opts == nil then
opts = {}
end
if opts.preset or opts.symbol_map then
lspkind.init(opts)
end
return function(entry, vim_item)
if opts.before then
vim_item = opts.before(entry, vim_item)
end
vim_item.kind = lspkind.symbolic(vim_item.kind, opts)
if i == 0 then
if entry.source.name == "nvim_lsp" then
log(vim.json.encode(entry.source))
i = i + 1
end
end
if opts.menu ~= nil then
vim_item.menu = opts.menu[entry.source.name]
-- if entry.source.client ~= nil then
-- if entry.source.client.name ~= nil then
-- log(entry.source.client.name)
-- end
-- end
-- vim_item.menu = opts.menu[entry.source.name+":"+entry.source.client.name]
end
if opts.maxwidth ~= nil then
if opts.ellipsis_char == nil then
vim_item.abbr = string.sub(vim_item.abbr, 1, opts.maxwidth)
else
local label = vim_item.abbr
local truncated_label = vim.fn.strcharpart(label, 0, opts.maxwidth)
if truncated_label ~= label then
vim_item.abbr = truncated_label .. opts.ellipsis_char
end
end
end
return vim_item
end
end
cmp.setup({
@ -344,6 +293,7 @@ cmp.setup({
sources = conditionalSources,
sorting = {
comparators = {
cmp.config.compare.offset,
@ -364,7 +314,6 @@ cmp.setup({
},
formatting = {
-- format = cmp_format({
format = lspkind.cmp_format({
with_text = true,
maxwidth = 40, -- half max width
@ -388,37 +337,4 @@ cmp.setup({
},
})
local lsp = require('lsp-zero')
-- lsp.preset('lsp-compe')
lsp.set_preferences({
suggest_lsp_servers = true,
setup_servers_on_start = true,
set_lsp_keymaps = false,
configure_diagnostics = true,
cmp_capabilities = true,
manage_nvim_cmp = true,
call_servers = 'local',
sign_icons = {
error = '',
warn = '',
hint = '',
info = ''
}
})
lsp.nvim_workspace()
lsp.on_attach(on_attach)
lsp.setup()
-- Initialize rust_analyzer with rust-tools
local rust_lsp = lsp.build_options('rust_analyzer', {})
require('rust-tools').setup({ server = rust_lsp, })
vim.cmd([[
augroup CmpZsh
au!
autocmd Filetype zsh lua require'cmp'.setup.buffer { sources = { { name = "zsh" }, } }
augroup END
]])
vim.cmd([[ augroup CmpZsh au! autocmd Filetype zsh lua require'cmp'.setup.buffer { sources = { { name = "zsh" }, } } augroup END ]])

View File

@ -0,0 +1,28 @@
-- local lspzero = require('lsp-zero')
-- -- lsp.preset('lsp-compe')
-- lspzero.set_preferences({
-- suggest_lsp_servers = true,
-- setup_servers_on_start = true,
-- set_lsp_keymaps = false,
-- configure_diagnostics = true,
-- cmp_capabilities = true,
-- manage_nvim_cmp = false,
-- call_servers = 'local',
-- sign_icons = {
-- error = '✘',
-- warn = '▲',
-- hint = '⚑',
-- info = ''
-- }
-- })
--
-- lspzero.nvim_workspace()
-- lspzero.on_attach(on_attach)
-- lspzero.setup()
--
-- Initialize rust_analyzer with rust-tools
-- local rust_lsp = lspzero.build_options('rust_analyzer', {})
-- require('rust-tools').setup({ server = rust_lsp, })

View File

@ -0,0 +1,14 @@
require('refactoring').setup({})
-- Remaps for the refactoring operations currently offered by the plugin
vim.api.nvim_set_keymap("v", "<leader>re", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], {noremap = true, silent = true, expr = false})
vim.api.nvim_set_keymap("v", "<leader>rf", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], {noremap = true, silent = true, expr = false})
vim.api.nvim_set_keymap("v", "<leader>rv", [[ <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>rb", [[ <Cmd>lua require('refactoring').refactor('Extract Block')<CR>]], {noremap = true, silent = true, expr = false})
-- vim.api.nvim_set_keymap("n", "<leader>rbf", [[ <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})

View File

@ -1,104 +1,93 @@
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)
local use_google = require("utils").use_google
-- 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
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
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 }
)
if use_google() then
-- 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 using codesearch queries.
map(
"n",
"<leader>cs",
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<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 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 text selected in Visual mode.
map(
"v",
"<leader>cs",
[[<cmd>lua require('telescope').extensions.codesearch.find_query{}<CR>]],
{ noremap = true, silent = true }
)
-- map("n",
-- "<leader>ps",
-- [[:Telescope find_files find_command=hg,pstatus,-ma,-n,--template=<CR>]])
-- 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>tw", ":Telescope citc workspaces<CR>")
map("n", "<leader>tm", ":Telescope citc modified<CR>")
map("n", "<leader>tb", ":Telescope file_browser<CR>")
map("n",
"<leader>ps",
[[:Telescope find_files find_command=hg,pstatus,-ma,-n,--template=<CR>]])
-- [F]ig [S]tatus
map('n', '<leader>fs', [[<cmd>lua require('telescope').extensions.fig.status{}<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})
-- [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>]])
end

View File

@ -98,6 +98,12 @@ require('packer').startup(function(use)
config = [[ require("config.trouble")]]
}
use {
'ThePrimeagen/refactoring.nvim',
config = [[ require("config.refactoring")]]
}
use 'apalmer1377/factorus'
use 'hrsh7th/vim-vsnip'
use 'kosayoda/nvim-lightbulb'
use {'andymass/vim-matchup', event = 'VimEnter'}
@ -113,14 +119,6 @@ require('packer').startup(function(use)
}
use 'nvim-telescope/telescope-file-browser.nvim'
use {
"nvim-telescope/telescope-frecency.nvim",
config = function()
require"telescope".load_extension("frecency")
end,
requires = {"kkharji/sqlite.lua"}
}
use {
'rmagatti/auto-session',
config = function()
@ -131,15 +129,13 @@ require('packer').startup(function(use)
end
}
use {
'sso://googler@user/vintharas/telescope-codesearch.nvim',
disable = not use_google(),
}
use {
'sso://googler@user/piloto/cmp-nvim-ciderlsp',
'sso://googler@user/kdark/ciderlsp-nvim',
'sso://googler@user/vintharas/telescope-codesearch.nvim',
'sso://googler@user/aktau/telescope-citc.nvim',
'sso://googler@user/tylersaunders/telescope-fig.nvim',
disable = not use_google(),
}

View File

@ -183,3 +183,5 @@ nnoremap <leader>ws :CorpWebCs <cword> <CR>
nnoremap <leader>wf :CorpWebCsFile<CR>
nmap <leader>rbs ss <leader>rb
nmap <leader>yb :let @" = join(blaze#GetTargets(), ' ')<cr>