From d0f618d46fe903359c9eb57a49da78909f23b6db Mon Sep 17 00:00:00 2001 From: Christian Nieves Date: Wed, 1 Nov 2023 18:36:50 +0000 Subject: [PATCH] telescope and dap --- config/.config/nvim/lazy-lock.json | 4 ++ vim/.vim/lua/config/google.lua | 3 +- vim/.vim/lua/plugins/dap.lua | 38 +++++++++++++ vim/.vim/lua/plugins/google.lua | 8 +-- vim/.vim/lua/plugins/telescope.lua | 86 +++++++++++++++++++----------- 5 files changed, 104 insertions(+), 35 deletions(-) create mode 100644 vim/.vim/lua/plugins/dap.lua diff --git a/config/.config/nvim/lazy-lock.json b/config/.config/nvim/lazy-lock.json index 4dac411..cecf755 100644 --- a/config/.config/nvim/lazy-lock.json +++ b/config/.config/nvim/lazy-lock.json @@ -57,6 +57,7 @@ "nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" }, "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, "nvim-cmp-buffer-lines": { "branch": "master", "commit": "924ccc04dc5c919b6baa05d45818025baa82699a" }, + "nvim-dap": { "branch": "master", "commit": "79dbc70eb79271ad801e4ff293887cde324c28d0" }, "nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" }, "nvim-lint": { "branch": "master", "commit": "962a76877a4479a535b935bd7ef35ad41ba308b2" }, "nvim-lspconfig": { "branch": "master", "commit": "d0467b9574b48429debf83f8248d8cee79562586" }, @@ -70,7 +71,10 @@ "registers.nvim": { "branch": "main", "commit": "7a16c6e6fe96f3c9c8bb55b95047d745dd34ca4d" }, "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, "scss-syntax.vim": { "branch": "master", "commit": "bda22a93d1dcfcb8ee13be1988560d9bb5bd0fef" }, + "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, "tabular": { "branch": "master", "commit": "339091ac4dd1f17e225fe7d57b48aff55f99b23a" }, + "telescope-dap.nvim": { "branch": "master", "commit": "4e2d5efb92062f0b865fe59b200b5ed7793833bf" }, + "telescope-smart-history.nvim": { "branch": "master", "commit": "81a4cceaa54d65d5f7c7c26178ee63b634d3e26d" }, "telescope.nvim": { "branch": "master", "commit": "4522d7e3ea75ffddabdc39957168a8a7060b5df0" }, "telescope_citc": { "branch": "main", "commit": "d6421d5bfe058915ece0daec55e488f8ea05f207" }, "telescope_codesearch": { "branch": "main", "commit": "a26077ad3c68cf897ae1c31da903d6516ebb9c92" }, diff --git a/vim/.vim/lua/config/google.lua b/vim/.vim/lua/config/google.lua index 65b8834..4410830 100644 --- a/vim/.vim/lua/config/google.lua +++ b/vim/.vim/lua/config/google.lua @@ -46,8 +46,7 @@ nnoremap br :call BlazeRun() nnoremap bb :call BlazeBuild() nnoremap bt :call BlazeTest() nnoremap btd :call BlazeTestDebug() -nnoremap bc :call BuildCleanerTarget() -nnoremap bcf :call BuildCleanerFile() +nnoremap bc :call BuildCleanerFile() nnoremap ud :call UnusedDeps() let g:asyncrun_open = 1 diff --git a/vim/.vim/lua/plugins/dap.lua b/vim/.vim/lua/plugins/dap.lua new file mode 100644 index 0000000..ed0ce65 --- /dev/null +++ b/vim/.vim/lua/plugins/dap.lua @@ -0,0 +1,38 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + "nvim-telescope/telescope-dap.nvim", + }, + config = function() + -- dl :lua require'dapui'.open() + -- :lua require'dap'.continue() + -- dl :lua require'dap'.run_last() + -- db :lua require'dap'.toggle_breakpoint() + -- dB :lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: ')) + -- dlp :lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: ')) + -- dr :lua require'dap'.repl.open() + -- + require("telescope").load_extension("dap") + local dap = require("dap") + dap.adapters.java = function(callback) + -- FIXME: + -- Here a function needs to trigger the `vscode.java.startDebugSession` LSP command + -- The response to the command must be the `port` used below + callback({ + type = "server", + host = "127.0.0.1", + port = port, + }) + end + + dap.configurations.java = { + { + type = "java", + request = "attach", + name = "Debug (Attach) - Remote", + hostName = "127.0.0.1", + port = 5005, + }, + } + end, +} diff --git a/vim/.vim/lua/plugins/google.lua b/vim/.vim/lua/plugins/google.lua index 1c15b20..b80f9c7 100644 --- a/vim/.vim/lua/plugins/google.lua +++ b/vim/.vim/lua/plugins/google.lua @@ -97,12 +97,14 @@ return { \ Suggest[aidl]=buffer,ripgrep,csearch,prompt ]]) end, - keys = { - { "i", ":ImpSuggest " }, - }, + lazy = false, }, { "flwyd/vim-imp", + lazy = false, + keys = { + { "i", ":ImpSuggest " }, + }, }, { name = "ai.nvim", diff --git a/vim/.vim/lua/plugins/telescope.lua b/vim/.vim/lua/plugins/telescope.lua index 8bf89ee..5d109a9 100644 --- a/vim/.vim/lua/plugins/telescope.lua +++ b/vim/.vim/lua/plugins/telescope.lua @@ -37,6 +37,7 @@ local keys = { { "ff", ":Telescope current_buffer_fuzzy_find", desc = "[T]elescope [F]uzzy [F]ind" }, { "tg", ":Telescope git_files", desc = "[T]elescope [G]it Files" }, + { "tr", ":Telescope resume", desc = "[T]elescope [R]esume" }, { "t*", "lua require('telescope.builtin').grep_string{}", desc = "[T]elescope current [W]ord" }, { "th", "lua require('telescope.builtin').help_tags{}", desc = "[T]elescope [H]elp" }, } @@ -56,41 +57,66 @@ end return { "nvim-telescope/telescope.nvim", - dependencies = {}, + dependencies = { + -- "nvim-telescope/telescope-smart-history.nvim", + -- "kkharji/sqlite.lua", + }, config = function() require("telescope").setup({ - experimental = true, - -- 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) + 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, + -- 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 = { + i = { + [""] = function() + require("telescope.actions").cycle_history_next() + end, + [""] = function() + require("telescope.actions").cycle_history_prev() + end, }, - __length = opts.__length, - } - path = require("telescope.utils").transform_path(new_opts, path) - opts.__length = new_opts.__length - return path - end, + }, + -- history = { + -- path = "~/.local/share/nvim/databases/telescope_history.sqlite3", + -- limit = 200, + -- }, + }, + extensions = { + codesearch = { + experimental = true, -- enable results from google3/experimental + }, + }, }) + + -- require("telescope").load_extension("smart_history") end, keys = keys, }