diff --git a/custom_snippets/lua.snippets b/custom_snippets/lua.snippets index 7cf0ba4..dd8d806 100644 --- a/custom_snippets/lua.snippets +++ b/custom_snippets/lua.snippets @@ -2,3 +2,7 @@ snippet fn function() $0 end + +snippet lm + local M = {} + $0 diff --git a/last_stable_nvim_version b/last_stable_nvim_version index cddad4e..39fa4ab 100644 --- a/last_stable_nvim_version +++ b/last_stable_nvim_version @@ -1,8 +1,8 @@ -NVIM v0.8.0-dev-1194-ga80ab395a +NVIM v0.9.0-dev-77-gf175ca9f7 Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/gcc-10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/cmake.config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include -Compiled by runner@fv-az220-425 +Compiled by runner@fv-az47-468 Features: +acl +iconv +tui See ":help feature-compile" diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index ff0ffa5..0777be9 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -27,7 +27,16 @@ M.general = { --{{{ },--}}} n = {--{{{ - [""] = { " noh ", "no highlight" }, + [""] = { + function() + if vim.o.filetype == "qf" then + vim.cmd("q") + else + vim.cmd("noh") + end + end, + "no highlight" + }, -- switch between windows [""] = { "h", "window left" }, @@ -146,8 +155,9 @@ M.general = { --{{{ }, -- quick close window - [""] = {"c", "close window"}, - + [""] = {"c", "close window"}, + + -- Increase number is with double and decrease with simple C-x -- yank from cusor to eol to system and primary clipboard @@ -493,11 +503,19 @@ M.general = { --{{{ n = { ["ds"] = { function() - if vim.o.filetype == "go" then - local spdap = require("spike.dap") - spdap.setup() - spdap.go_debug() + local mydap = require("spike.dap") + + mydap.setup() + require('spike.dap.utils').init_breakpoints() + -- set a breakpoint at current line if there are none in + -- the project + if vim.o.filetype == "go" then + mydap.go_debug() + elseif vim.o.filetype == "rust" then + local rt = require("rust-tools") + -- make sure lsp is running ? + rt.debuggables.debuggables() end end, "start dap session" @@ -524,10 +542,18 @@ M.general = { --{{{ }, ["dm"] = { function() - require("spike.dapmode").start() + require('spike.dap.dapmode').start() end, "enter dap mode" - } + }, + ["dr"] = {"lua require'dap'.run_last()", "[dap] rerun last"}, + ["dl"] = { + function() + require('spike.dap.utils').dap_logpoint() + end, + "[dap] add log point" + }, + ["dt"] = {"lua require'dapui'.toggle()", "[dap] toggle UI"}, }, }-- }}} diff --git a/lua/core/options.lua b/lua/core/options.lua index 22c8b37..0cade04 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -98,6 +98,7 @@ g.netrw_winsize = 20 -- width of the window (25%) opt.signcolumn = "yes" +opt.signcolumn = "auto:1-3" -- accommodate up to 3 icons opt.splitbelow = true opt.splitright = true opt.termguicolors = true diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua index 0e4e105..78a8c29 100644 --- a/lua/custom/chadrc.lua +++ b/lua/custom/chadrc.lua @@ -9,134 +9,142 @@ local M = {} -- vim.tbl_deep_extend("force", M.ui.hl_add, custom_theme) M.ui = { - theme = "monekai", - theme_toggle = { "monekai", "gruvbox_light" }, - hl_override = { - CursorLine = { - bg = "one_bg3" + theme = "monekai", + theme_toggle = { "monekai", "gruvbox_light" }, + hl_override = { + CursorLine = { + bg = "one_bg3" + }, + DiagnosticWarn = { + fg = "yellow", + italic = true, + }, + St_LspWarning = { + fg = "yellow" + }, + DiagnosticHint = { + fg = "purple", + italic = true, + }, + St_LspHints = { + fg = "pruple", + }, + DiagnosticError = { + italic = true, + }, + St_LspInfo = { + fg = "white" + }, }, - DiagnosticWarn = { - fg = "yellow", - italic = true, - }, - St_LspWarning = { - fg = "yellow" - }, - DiagnosticHint = { - fg = "purple", - italic = true, - }, - St_LspHints = { - fg = "pruple", - }, - DiagnosticError = { - italic = true, - }, - St_LspInfo = { - fg = "white" - }, - }, - hl_add = { - Visual = { - bg = "blue", - fg = "black", - }, - BookmarkSign = { - fg = "blue", - }, - BookmarkAnnotationSign = { - fg = "yellow", - }, - BookmarkAnnotationLine = { - fg = "black", - bg = "yellow" - }, - DiagnosticInfo = { -- nvchad uses DiagnosticInformation wrong hi group for lsp - fg = "white", - italic = true, - }, - DiagnosticFloatingInfo = { - fg="white", - italic=true, - }, - DiagnosticUnderlineError = { - fg="black", - bg="pink", - }, - -- Code Lens related colors - LspCodeLens = { - fg = "vibrant_green", - underline = true, - }, - LspDiagnosticsSignHint = { -- LspDiagnostics Code Action - fg = "vibrant_green", - italic = true, - }, - -- end of code lens colors - DiffText = { - bg = "vigrant_green" - }, - St_DapMode = { - fg = "black2", - bg = "baby_pink", - }, - St_DapModeSep = { - fg = "baby_pink", - bg = "one_bg3", + hl_add = { + Visual = { + bg = "blue", + fg = "black", + }, + BookmarkSign = { + fg = "blue", + }, + BookmarkAnnotationSign = { + fg = "yellow", + }, + BookmarkAnnotationLine = { + fg = "black", + bg = "yellow" + }, + DiagnosticInfo = { -- nvchad uses DiagnosticInformation wrong hi group for lsp + fg = "white", + italic = true, + }, + DiagnosticFloatingInfo = { + fg = "white", + italic = true, + }, + DiagnosticUnderlineError = { + fg = "black", + bg = "pink", + }, + -- Code Lens related colors + LspCodeLens = { + fg = "vibrant_green", + underline = true, + }, + LspDiagnosticsSignHint = { -- LspDiagnostics Code Action + fg = "vibrant_green", + italic = true, + }, + -- end of code lens colors + DiffText = { + bg = "vigrant_green" + }, + St_DapMode = { + fg = "black2", + bg = "baby_pink", + }, + St_DapModeSep = { + fg = "baby_pink", + bg = "one_bg3", + }, + St_DapModeSep2 = { + fg = "grey", + bg = "baby_pink", + }, + DapBreakpoint = { + fg = "green" + }, + DapStopped = { + fg = "#ff4848" + }, + DapLogPoint = { + fg = "vibrant_green" + }, + DapBreakpointCondition = { + fg = "cyan" + }, + DapBreakpointRejected = { + fg = "purple" + } }, - St_DapModeSep2 = { - fg = "grey", - bg = "baby_pink", + -- hl_override = { + -- CursorLine = { + -- underline = 1 + -- } + -- }, + myicons = { + lsp = { + diagnostic_head = '', -- default diagnostic head on dialogs + diagnostic_err = '', -- severity 1 + diagnostic_warn = '', -- 2 + diagnostic_info = '', -- 3 + diagnostic_hint = '', -- 4 + } }, -}, - -- hl_override = { - -- CursorLine = { - -- underline = 1 - -- } - -- }, - myicons = { - lsp = { - diagnostic_head = '', -- default diagnostic head on dialogs - diagnostic_err = '', -- severity 1 - diagnostic_warn = '', -- 2 - diagnostic_info = '', -- 3 - diagnostic_hint = '', -- 4 - } - }, } M.plugins = { - user = require "custom.plugins", - override = { - ["folke/which-key.nvim"] = { - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - i = { "j", "k" }, - v = { "j", "k" }, - }, - }, - ["NvChad/ui"] = { - -- tabufline = { - -- lazyload = false, - -- }, - statusline = { - overriden_modules = function() - return require "custom.plugins.nvchadui" - end - } + user = require "custom.plugins", + override = { + ["NvChad/ui"] = { + -- tabufline = { + -- lazyload = false, + -- }, + statusline = { + overriden_modules = function() + return require "custom.plugins.nvchadui" + end + } - }, - ["windwp/nvim-autopairs"] = { - disable_filetype = { - "TelescopePrompt", - "vim", - "guihua", - "guihua_rust", - "clap_input" - } - }, - ["nvim-treesitter/nvim-treesitter"] = require "custom.plugins.configs.treesitter", + }, + ["windwp/nvim-autopairs"] = { + disable_filetype = { + "TelescopePrompt", + "vim", + "guihua", + "guihua_rust", + "clap_input" + } + }, + ["nvim-treesitter/nvim-treesitter"] = require "custom.plugins.configs.treesitter", } } diff --git a/lua/custom/init.lua b/lua/custom/init.lua index 113c5d0..00933e5 100644 --- a/lua/custom/init.lua +++ b/lua/custom/init.lua @@ -37,13 +37,14 @@ vim.cmd [[ -- suckless { vim.cmd [[ " Autocompile suckless - let dwm_file_patterns = expand("$HOME/.local/src/suckless/*/{config.h,*.c}") + " NOTE: symlinks do not work with autocommand patterns + let dwm_file_patterns = expand("/data/source/suckless/*/{config.h,*.c}") augroup DWM au! execute "au BufEnter " . dwm_file_patterns . " :lcd %:p:h" - execute "au BufWrite " . dwm_file_patterns . " :AsyncRun! make clean && make && sudo make install" + execute "au BufWritePost " . dwm_file_patterns . " :AsyncRun! make clean && make && sudo make install" "au BufWrite */src/*/dwm*/{*.h,dwm.c} :AsyncRun! make clean && make && sudo make install augroup END ]] diff --git a/lua/custom/plugins/configs/dap.lua b/lua/custom/plugins/configs/dap.lua new file mode 100644 index 0000000..d8b8b74 --- /dev/null +++ b/lua/custom/plugins/configs/dap.lua @@ -0,0 +1,10 @@ +-- local dap = require("dap") + +local M = {} +local opts = { + +} + +M.setup = function() +end +return M diff --git a/lua/custom/plugins/configs/dapui.lua b/lua/custom/plugins/configs/dapui.lua new file mode 100644 index 0000000..2add3e5 --- /dev/null +++ b/lua/custom/plugins/configs/dapui.lua @@ -0,0 +1,82 @@ +local dapui = require('dapui') + +local M = {} +local opts = { + icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + -- Expand lines larger than the window + -- Requires >= 0.7 + expand_lines = vim.fn.has("nvim-0.7") == 1, + -- Layouts define sections of the screen to place windows. + -- The position can be "left", "right", "top" or "bottom". + -- The size specifies the height/width depending on position. It can be an Int + -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while + -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) + -- Elements are the elements shown in the layout (in order). + -- Layouts are opened in order so that earlier layouts take priority in window sizing. + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "scopes", size = 0.25 }, + "breakpoints", + "stacks", + -- "watches", + }, + size = 40, -- 40 columns + position = "left", + }, + { + elements = { + "repl", + "watches" + -- "console", + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, + controls = { + -- Requires Neovim nightly (or 0.8 when released) + enabled = true, + -- Display controls in this element + element = "repl", + icons = { + pause = "", + play = "", + step_into = "", + step_over = "", + step_out = "", + step_back = "", + run_last = "↻", + terminate = "", + }, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "" }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + max_value_lines = 100, -- Can be integer or nil. + } +} + +M.setup = function() + dapui.setup(opts) +end + +return M diff --git a/lua/custom/plugins/configs/live-command.lua b/lua/custom/plugins/configs/live-command.lua new file mode 100644 index 0000000..7d8f9b6 --- /dev/null +++ b/lua/custom/plugins/configs/live-command.lua @@ -0,0 +1,42 @@ +local M = {} + + +local opts = { + defaults = { + enable_highlighting = true, + inline_highlighting = true, + hl_groups = { + insertion = "DiffAdd", + deletion = "DiffDelete", + change = "DiffChange", + }, + }, + + debug = true, + commands = { + Norm = { cmd = "norm" }, + Reg = { + cmd = "norm", + -- This will transform ":5Reg a" into ":norm 5@a" + args = function(opts) + return (opts.count == -1 and "" or opts.count) .. "@" .. opts.args + end, + range = "", + }, + } +} + +function M.get_cmds() + local cmds = {} + for cmd, _ in pairs(opts.commands) do + table.insert(cmds, cmd) + end + + return cmds +end + +function M.setup() + require("live-command").setup(opts) +end + +return M diff --git a/lua/custom/plugins/configs/navigator.lua b/lua/custom/plugins/configs/navigator.lua index 2941e3e..74fd203 100644 --- a/lua/custom/plugins/configs/navigator.lua +++ b/lua/custom/plugins/configs/navigator.lua @@ -47,7 +47,7 @@ local config = { { key = 'gL', func = require('navigator.diagnostics').show_diagnostics, desc = 'lsp show_diagnostics' }, { key = 'gG', func = require('navigator.diagnostics').show_buf_diagnostics, desc = 'lsp show_buf_diagnostics' }, -- { key = 'dt', func = require('navigator.diagnostics').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, - { key = 'dt', func = require('spike.lsp').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, + { key = 'td', func = require('spike.lsp').toggle_diagnostics, desc = 'lsp toggle_diagnostics' }, { key = ']d', func = vim.diagnostic.goto_next, desc = 'lsp next diagnostics' }, { key = '[d', func = vim.diagnostic.goto_prev, desc = 'lsp prev diagnostics' }, { key = ']O', func = vim.diagnostic.set_loclist, desc = 'lsp diagnostics set loclist' }, @@ -56,13 +56,13 @@ local config = { { key = '', func = vim.lsp.buf.definition, desc = 'lsp definition' }, { key = 'g', func = vim.lsp.buf.implementation, desc = 'lsp implementation' }, { key = 'k', func = require('navigator.dochighlight').hi_symbol, desc = 'lsp hi_symbol' }, - { key = 'wa', func = require('navigator.workspace').add_workspace_folder, desc = 'lsp add_workspace_folder' }, + { key = 'wa', func = require('navigator.workspace').add_workspace_folder, desc = 'lsp add_workspace_folder' }, { - key = 'wr', + key = 'wr', func = require('navigator.workspace').remove_workspace_folder, desc = 'lsp lsp remove_workspace_folder', }, - { key = 'ff', func = vim.lsp.buf.format, mode = 'n', desc = 'lsp format' }, + { key = 'fm', func = vim.lsp.buf.format, mode = 'n', desc = 'lsp format' }, -- { key = 'ff', func = vim.lsp.buf.range_formatting, mode = 'v', desc = 'lsp range format' }, -- DEPRECATED -- { @@ -71,8 +71,8 @@ local config = { -- mode = 'n', -- desc = 'lsp range format operator e.g gmip', -- }, - { key = 'wl', func = require('navigator.workspace').list_workspace_folders, desc = 'lsp list_workspace_folders' }, - { key = 'la', mode = 'n', func = require('navigator.codelens').run_action, desc = 'lsp run code lens action' }, + { key = 'wl', func = require('navigator.workspace').list_workspace_folders, desc = 'lsp list_workspace_folders' }, + { key = 'll', mode = 'n', func = require('navigator.codelens').run_action, desc = 'lsp run code lens action' }, }, icons = { diff --git a/lua/custom/plugins/configs/rust-tools.lua b/lua/custom/plugins/configs/rust-tools.lua index 0bc1ef8..eae24c0 100644 --- a/lua/custom/plugins/configs/rust-tools.lua +++ b/lua/custom/plugins/configs/rust-tools.lua @@ -171,6 +171,7 @@ local opts = { type = "executable", command = "lldb-vscode", name = "rt_lldb", + console = "integratedTerminal", }, }, } diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index 9f6fd0f..b1f0c52 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -33,474 +33,506 @@ return { - -- My Plugins - - ["~/.config/nvim/my_packages/perproject"] = {-- {{{ - opt = true, - after = {"nvim-lspconfig", "navigator.lua"}, - require = {"nvim-lspconfig", "navigator.lua"}, - config = function() - require("perproject").setup() - -- callbacks = { - -- foo = function() - -- print("FOO") - -- end - -- } - -- }) - end - },-- }}} - - - -- treesitter - - ["nvim-treesitter/nvim-treesitter"] = {-- {{{ - -- custom config in chadrc -> custom.configs.treesitter - setup = function() - require("core.lazy_load").on_file_open "nvim-treesitter" - require("core.lazy_load").on_file_open "nvim-treesitter-textobjects" - require("core.lazy_load").on_file_open "nvim-treesitter-textsubjects" - require("core.lazy_load").on_file_open "nvim-treesitter-context" - -- require("core.lazy_load").on_file_open "nvim-ts-rainbow" - end, - }, - ["nvim-treesitter/nvim-treesitter-textobjects"] = { - opt = true, - }, - ["RRethy/nvim-treesitter-textsubjects"] = { - opt = true, - }, - - -- Treesitter dev/exploration tool - ["nvim-treesitter/playground"] = { - opt = true, - }, - - ["nvim-treesitter/nvim-treesitter-context"] = { - opt = true, - config = function() - require("custom.plugins.configs.treesitter-context").setup() - end - },-- }}} - - - -- autocomplete - - ["hrsh7th/cmp-buffer"] = {-- {{{ - config = function () - local disabled_ft = { - "guihua", - "clap_input", - "guihua_rust,", - "TelescopePrompt" - } - - require("cmp").setup.buffer { - enabled = function () - for _, v in ipairs(disabled_ft) do - if vim.o.ft == v then return false end - end - return true + -- My Plugins + + ["~/.config/nvim/my_packages/perproject"] = { -- {{{ + opt = true, + after = { "nvim-lspconfig", "navigator.lua" }, + require = { "nvim-lspconfig", "navigator.lua" }, + config = function() + require("perproject").setup() + -- callbacks = { + -- foo = function() + -- print("FOO") + -- end + -- } + -- }) end - } - end - },-- }}} - - -- snippets - ["honza/vim-snippets"] = {-- {{{ - module = {"cmp", "cmp_nvim_lsp"}, - event = "InsertEnter", - }, - - ["L3MON4D3/LuaSnip"] = { - lock = false, - config = function() - -- load default config first - require("plugins.configs.others").luasnip() - - vim.g.my_snippets_paths = {"./custom_snippets"} - require("luasnip").filetype_extend("markdown", { "markdown_zk" }) - - -- load snippets from "honza/vim-snippets" - -- includes ultisnips and snipmate snippets - require("luasnip.loaders.from_snipmate").lazy_load({ override_priority = 800 }) - require("luasnip.loaders.from_snipmate").lazy_load { - paths = vim.g.my_snippets_paths, - override_priority = 800 - } - end - },-- }}} - - -- text formatting - - ["folke/todo-comments.nvim"] = { -- {{{ - after = "nvim-treesitter", - config = function() - require("custom.plugins.configs.todo-comments").setup() - end - }, - - ["tpope/vim-surround"] = {}, - - ["godlygeek/tabular"] = { - cmd = "Tabularize" - },-- }}} - - - -- ["p00f/nvim-ts-rainbow"] = { - -- opt = true, - -- }, - -- - - -- dap - - ["mfussenegger/nvim-dap"] = {-- {{{ - lock = true, - module = "dap", - setup = function() - require("core.utils").load_mappings "dap" - end, - }, - - ["rcarriga/nvim-dap-ui"] = { - tag = "*", - after = "nvim-dap", - }, - - ["theHamsta/nvim-dap-virtual-text"] = { - lock = true, - after = "nvim-dap" - },-- }}} - - -- User Interface / UX - - ["folke/which-key.nvim"] = {-- {{{ - lock = true, - disable = false, - keys = {"", "", ""} - }, - - -- repeat operator for plugin commands - ["tpope/vim-repeat"] = { - keys = {"."}, - }, - - ["nvim-telescope/telescope.nvim"] = { - -- lock = true, - after = "vim-hardtime", - - disable = false, - }, - ["tom-anders/telescope-vim-bookmarks.nvim"] = { - opt = true, - module = "telescope", - after = {"telescope.nvim", "vim-bookmarks"}, - -- cmd = "Telescope", - -- requires = "vim-bookmarks", - -- after = {"vim-bookmarks", "telescope"}, - -- module = "telescope", - config = function() - require("telescope").load_extension("vim_bookmarks") - end - }, - ["nvim-telescope/telescope-fzf-native.nvim"] = { - opt = true, - module = "telescope", - after = {"telescope.nvim"}, - run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', - }, - ["ibhagwan/fzf-lua"] = { - lock = true, - after = "ui", - config = function() - require("custom.plugins.configs.fzflua") - require("plugins.configs.others").devicons() - end, - setup = function() - require("core.utils").load_mappings "fzf_lua" - end - },-- }}} - - -- Theme customization - ["uga-rosa/ccc.nvim"] = { - commit = "427471b", - cmd = {"Ccc*", "(ccc-insert)"}, - setup = function() - require("core.utils").load_mappings "ccc" - end, - config = function() - require("ccc").setup({}) - end - }, - - -- navigation / jumps - -- ["justinmk/vim-sneak"] = { - -- lock = true, - -- keys = {"s", "S"}, - -- }, - - ["ggandor/leap.nvim"] = {-- {{{ - config = function() - require "custom.plugins.configs.leap" - end - },-- }}} - - -- tmux helpers - ["christoomey/vim-tmux-navigator"] = { - cond = function() - return vim.env.TMUX ~= nil - end - }, + }, -- }}} + + + -- treesitter + + ["nvim-treesitter/nvim-treesitter"] = { -- {{{ + -- custom config in chadrc -> custom.configs.treesitter + setup = function() + require("core.lazy_load").on_file_open "nvim-treesitter" + require("core.lazy_load").on_file_open "nvim-treesitter-textobjects" + require("core.lazy_load").on_file_open "nvim-treesitter-textsubjects" + require("core.lazy_load").on_file_open "nvim-treesitter-context" + -- require("core.lazy_load").on_file_open "nvim-ts-rainbow" + end, + }, + ["nvim-treesitter/nvim-treesitter-textobjects"] = { + opt = true, + }, + ["RRethy/nvim-treesitter-textsubjects"] = { + opt = true, + }, + + -- Treesitter dev/exploration tool + ["nvim-treesitter/playground"] = { + opt = true, + }, + + ["nvim-treesitter/nvim-treesitter-context"] = { + opt = true, + config = function() + require("custom.plugins.configs.treesitter-context").setup() + end + }, -- }}} + + + -- autocomplete + + ["hrsh7th/cmp-buffer"] = { -- {{{ + config = function() + local disabled_ft = { + "guihua", + "clap_input", + "guihua_rust,", + "TelescopePrompt" + } + + require("cmp").setup.buffer { + enabled = function() + for _, v in ipairs(disabled_ft) do + if vim.o.ft == v then return false end + end + return true + end + } + end + }, -- }}} + + -- snippets + ["honza/vim-snippets"] = { -- {{{ + module = { "cmp", "cmp_nvim_lsp" }, + event = "InsertEnter", + }, + + ["L3MON4D3/LuaSnip"] = { + lock = false, + config = function() + -- load default config first + require("plugins.configs.others").luasnip() + + vim.g.my_snippets_paths = { "./custom_snippets" } + require("luasnip").filetype_extend("markdown", { "markdown_zk" }) + + -- load snippets from "honza/vim-snippets" + -- includes ultisnips and snipmate snippets + require("luasnip.loaders.from_snipmate").lazy_load({ override_priority = 800 }) + require("luasnip.loaders.from_snipmate").lazy_load { + paths = vim.g.my_snippets_paths, + override_priority = 800 + } + end + }, -- }}} + + -- text formatting + + ["folke/todo-comments.nvim"] = { -- {{{ + after = "nvim-treesitter", + config = function() + require("custom.plugins.configs.todo-comments").setup() + end + }, + + ["tpope/vim-surround"] = {}, + + ["godlygeek/tabular"] = { + lcmd = "Tabularize" + }, -- }}} + + + -- ["p00f/nvim-ts-rainbow"] = { + -- opt = true, + -- }, + -- + + -- dap + + ["mfussenegger/nvim-dap"] = { -- {{{ + lock = true, + module = "dap", + setup = function() + require("core.utils").load_mappings "dap" + require('spike.dap').setup() + end, + config = function() + require("custom.plugins.configs.dap").setup() + end + }, + + ["rcarriga/nvim-dap-ui"] = { + tag = "*", + after = "nvim-dap", + config = function() + require('custom.plugins.configs.dapui').setup() + end + }, + + ["theHamsta/nvim-dap-virtual-text"] = { + lock = true, + after = "nvim-dap" + }, -- }}} + + -- User Interface / UX + -- + -- allows to preview commands after they are registerd by plugin + -- the current registerd norm command works by first selecting a visual selection + -- then doing the changes, it's an enhanced multi cursor + ["smjonas/live-command.nvim"] = { + cmd = require("custom.plugins.configs.live-command").get_cmds(), + opt = true, + config = function() + require("custom.plugins.configs.live-command").setup() + end + }, + + ["folke/which-key.nvim"] = { -- {{{ + lock = true, + disable = false, + keys = { "", "", "", "\"", "`", "'", "z", "g" } + }, + + -- repeat operator for plugin commands + ["tpope/vim-repeat"] = { + keys = { "." }, + }, + + ["nvim-telescope/telescope.nvim"] = { + -- lock = true, + disable = false, + }, + ["tom-anders/telescope-vim-bookmarks.nvim"] = { + opt = true, + module = "telescope", + after = { "telescope.nvim", "vim-bookmarks" }, + -- cmd = "Telescope", + -- requires = "vim-bookmarks", + -- after = {"vim-bookmarks", "telescope"}, + -- module = "telescope", + config = function() + require("telescope").load_extension("vim_bookmarks") + end + }, + ["nvim-telescope/telescope-fzf-native.nvim"] = { + opt = true, + module = "telescope", + after = { "telescope.nvim" }, + run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build', + }, + ["ibhagwan/fzf-lua"] = { + lock = true, + after = "ui", + config = function() + require("custom.plugins.configs.fzflua") + require("plugins.configs.others").devicons() + end, + setup = function() + require("core.utils").load_mappings "fzf_lua" + end + }, -- }}} + + -- Theme customization + ["uga-rosa/ccc.nvim"] = { -- {{{{{{ + commit = "427471b", + cmd = { "Ccc*", "(ccc-insert)" }, + setup = function() + require("core.utils").load_mappings "ccc" + end, + config = function() + require("ccc").setup({}) + end + }, -- }}}}}} + + -- navigation / jumping / buffer modification + + -- ["justinmk/vim-sneak"] = { + -- lock = true, + -- keys = {"s", "S"}, + -- }, + + ["ggandor/leap.nvim"] = { -- {{{ + config = function() + require "custom.plugins.configs.leap" + end + }, -- }}} - --[[ ["preservim/vimux"] = { + -- tmux helpers + ["christoomey/vim-tmux-navigator"] = { + cond = function() + return vim.env.TMUX ~= nil + end + }, + + --[[ ["preservim/vimux"] = { cond = function() return vim.env.TMUX ~= nil end }, ]] - -- Job management (use nvim startjob ) - -- Run async commands (make & errors) - - ["skywind3000/asyncrun.vim"] = {-- {{{ - lock = true, - cmd = "AsyncRun", - setup = function() - require("core.utils").load_mappings "asyncrun" - vim.g.asyncrun_open = 8 - end - },-- }}} - - -- Git - ["tpope/vim-fugitive"] = { - cmd = {"G", "Git", "G*"} - }, - - -- session and view - ["vim-scripts/restore_view.vim"] = {}, -- TODO: check if still needed - - -- ["rmagatti/auto-session"] = { - -- config = function () - -- require("auto-session").setup { - -- log_level = "error", - -- auto_session_suppress_dirs = {"~/", "~/projects", "/"}, - -- auto_save_enabled = false, - -- } - -- end - -- }, - - - -- - -- Misc / General plugins - - -- Read info files - ["https://gitlab.com/HiPhish/info.vim.git"] = { - cmd = "Info", - }, - - - ["MattesGroeger/vim-bookmarks"] = { - config = function() - require("core.utils").load_mappings "vim_bookmarks" - end - }, - - -- create new vim modes - ["Iron-E/nvim-libmodal"] = { - lock = true, - }, - - -- get rid of bad habits - ["takac/vim-hardtime"] = { - -- keys = { "h", "j", "k", "l" }, - setup = function() - vim.g.hardtime_default_on = 1 - vim.g.hardtime_showmsg = 1 - vim.g.list_of_normal_keys = {"h","j","k","l"} - vim.g.list_of_visual_keys = {"h","j","k","l"} - vim.g.hardtime_ignore_quickfix = 1 - vim.g.hardtime_ignore_buffer_patterns = { - "NERD.*", - "netrw", - "TelescopePrompt", - "fugitive", - "guihua*", - } - vim.g.hardtime_maxcount = 2 - end, - }, - - -- ["chentoast/marks.nvim"] = { - -- opt = true, - -- keys = {"m", "d"}, - -- cmd = {"Marks*", "Bookmarks*"}, - -- config = function () - -- require("custom.plugins.configs.marks").setup() - -- end - -- }, - - -- ------------------ - -- LSP - -- ------------------ - - ["neovim/nvim-lspconfig"] = {-- {{{ - after = {"lua-dev.nvim", "mason.nvim", "mason-lspconfig.nvim"}, - module = {"lspconfig"}, - lock = false, - config = function() - require("plugins.configs.lspconfig").setup() - end - }, - ["williamboman/mason-lspconfig.nvim"] = { - lock = false, - requires = {"williamboman/mason.nvim", "nvim-lspconfig"}, - -- after = "mason.nvim", - module = {"mson-lspconfig.nvim", "mason.nvim"}, - config = function() - require("mason-lspconfig").setup({}) - end, - }, - ["ray-x/guihua.lua"] = { - lock = true, - module = {"navigator"}, - run = "cd lua/fzy && make", - config = function() - require("guihua.maps").setup { - maps = { - close_view = "", - } - } - end - - }, - -- ["https://git.sp4ke.xyz/sp4ke/navigator.lua"] = + -- Job management (use nvim startjob ) + -- Run async commands (make & errors) + + -- TODO: replace with https://github.com/skywind3000/asynctasks.vim + ["skywind3000/asyncrun.vim"] = { -- {{{ + lock = true, + cmd = "AsyncRun", + setup = function() + require("core.utils").load_mappings "asyncrun" + vim.g.asyncrun_open = 8 + end + }, -- }}} + + -- Git + ["tpope/vim-fugitive"] = { + cmd = { "G", "Git", "G*" } + }, + + -- session and view + ["vim-scripts/restore_view.vim"] = {}, -- TODO: check if still needed + + -- ["rmagatti/auto-session"] = { + -- config = function () + -- require("auto-session").setup { + -- log_level = "error", + -- auto_session_suppress_dirs = {"~/", "~/projects", "/"}, + -- auto_save_enabled = false, + -- } + -- end + -- }, + + -- - ["ray-x/navigator.lua"] = { - lock = true, - opt = true, - module = "navigator", - after = { "nvim-lspconfig", "base46", "ui", "mason.nvim", "mason-lspconfig.nvim", "lua-dev.nvim" }, - requires = {"neovim/nvim-lspconfig", "ray-x/guihua.lua", "nvim-treesitter/nvim-treesitter"}, - setup = function() - require("core.lazy_load").on_file_open "navigator.lua" - require("core.utils").load_mappings "navigator" - end, - config = function() - require("custom.plugins.configs.navigator").setup() - require("base46").load_highlight "lsp" - - -- TODO: use nvchadui_lsp features manually - -- require("nvchad_ui.lsp") - end - }, - - ["ray-x/lsp_signature.nvim"] = { - lock = true, - after = {"navigator.lua"}, - config = function() - require("custom.plugins.configs.lsp_signature").setup() - end - - },-- }}} - - -- side panel with symbols (replaced by Navigator :LspSymbols cmd) - -- ["liuchengxu/vista.vim"] = { - -- cmd = "Vista", - -- setup = function() - -- require("core.utils").load_mappings "vista" - -- end - -- }, - -- - - -- ------------------------------------------------------- - -- Programming Languages Plugins - -- ------------------------------------------------------- - - -- ------- - -- lua dev - -- ------- - - -- Eval Lua lines/selections - - -- ["bfredl/nvim-luadev"] = {{{{ - -- lock = true, - -- cmd = "Luadev", - -- keys = { - -- "(Luadev-RunLine)", - -- "(Luadev-Run)", - -- "(Luadev-RunWord)", - -- "(Luadev-Complete)", - -- }, - -- setup = function() - -- local autocmd = vim.api.nvim_create_autocmd - -- autocmd("FileType", { - -- pattern = "lua", - -- callback = function () - -- vim.keymap.set({'n', 'i'}, 'r', '(Luadev-RunLine)', { - -- desc = "Luadev RunLine" - -- }) - -- end, - -- }) - -- end - -- },}}} - - -- power Repl {{{ - ["hkupty/iron.nvim"] = { - loack = true, - cmd = {"Iron*"}, - setup = function() - require("core.utils").load_mappings "iron" - end, - config = function() - require("custom.plugins.configs.iron").setup() - end - }, - - -- REPL for Lua development - ["ii14/neorepl.nvim"] = { - lock = true, - cmd = "Repl", - after = "nvim-cmp", - config = function () - local autocmd = vim.api.nvim_create_autocmd - autocmd("FileType",{ - pattern = "neorepl", - callback = function () - require('cmp').setup.buffer({enabled = false}) - - -- custom keymap example - -- activate corresponding section in mappings - -- mappings = require("custom.utils").set_plugin_mappings "neorepl" + -- Misc / General plugins + + -- Read info files + ["https://gitlab.com/HiPhish/info.vim.git"] = { -- {{{{{{ + cmd = "Info", + }, -- }}}}}} + + + ["MattesGroeger/vim-bookmarks"] = { -- {{{ + config = function() + require("core.utils").load_mappings "vim_bookmarks" end - }) - end - }, - - -- Lua dev env - -- check setup in configs/navigator.lua - ["folke/lua-dev.nvim"] = { - lock = true, - module = "lua-dev", - },-- }}} - - -- golang dev - - ["ray-x/go.nvim"] = {-- {{{ - lock = true, - -- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"}, - ft = {"go"}, - opt = true, - config = function() - require("custom.plugins.configs.gonvim").setup() - end - },-- }}} - - -- Rust dev - ["simrat39/rust-tools.nvim"] = {-- {{{ - lock = true, - ft = {"rust"}, - opt = true, - config = function() - require("custom.plugins.configs.rust-tools").setup() - end - }-- }}} + }, -- }}} + + -- create new vim modes + ["Iron-E/nvim-libmodal"] = { -- {{{ + lock = true, + }, -- }}} + + -- get rid of bad habits + -- ["ja-ford/delaytrain.nvim"] = { + ["~/src/delaytrain.nvim"] = { + config = function() + require('delaytrain').setup({ + delay_ms = 1000, -- How long repeated usage of a key should be prevented + grace_period = 1, -- How many repeated keypresses are allowed + keys = { -- Which keys (in which modes) should be delayed + ['nv'] = { 'h', 'j', 'k', 'l' }, + -- ['nvi'] = { '', '', '', '' }, + }, + ignore_filetypes = {"qf", "NvimTree", "help", "qf", "netrw"}, + }) + end + }, + -- ["takac/vim-hardtime"] = {-- {{{ + -- -- keys = { "h", "j", "k", "l" }, + -- setup = function() + -- vim.g.hardtime_default_on = 1 + -- vim.g.hardtime_showmsg = 1 + -- vim.g.list_of_normal_keys = {"h","j","k","l"} + -- vim.g.list_of_visual_keys = {"h","j","k","l"} + -- vim.g.hardtime_ignore_quickfix = 1 + -- vim.g.hardtime_ignore_buffer_patterns = { + -- "NERD.*", + -- "netrw", + -- "TelescopePrompt", + -- "fugitive", + -- "guihua*", + -- } + -- vim.g.hardtime_maxcount = 2 + -- end, + -- },-- }}} + + -- ["chentoast/marks.nvim"] = { + -- opt = true, + -- keys = {"m", "d"}, + -- cmd = {"Marks*", "Bookmarks*"}, + -- config = function () + -- require("custom.plugins.configs.marks").setup() + -- end + -- }, + + -- ------------------ + -- LSP + -- ------------------ + + ["neovim/nvim-lspconfig"] = { -- {{{ + after = { "lua-dev.nvim", "mason.nvim", "mason-lspconfig.nvim" }, + module = { "lspconfig" }, + lock = false, + config = function() + require("plugins.configs.lspconfig").setup() + end + }, + ["williamboman/mason-lspconfig.nvim"] = { + lock = false, + requires = { "williamboman/mason.nvim", "nvim-lspconfig" }, + -- after = "mason.nvim", + module = { "mson-lspconfig.nvim", "mason.nvim" }, + config = function() + require("mason-lspconfig").setup({}) + end, + }, + ["ray-x/guihua.lua"] = { + lock = true, + module = { "navigator" }, + run = "cd lua/fzy && make", + config = function() + require("guihua.maps").setup { + maps = { + close_view = "", + } + } + end + + }, + -- ["https://git.sp4ke.xyz/sp4ke/navigator.lua"] = + -- + ["ray-x/navigator.lua"] = { + lock = true, + opt = true, + module = "navigator", + after = { "nvim-lspconfig", "base46", "ui", "mason.nvim", "mason-lspconfig.nvim", "lua-dev.nvim" }, + requires = { "neovim/nvim-lspconfig", "ray-x/guihua.lua", "nvim-treesitter/nvim-treesitter" }, + setup = function() + require("core.lazy_load").on_file_open "navigator.lua" + require("core.utils").load_mappings "navigator" + end, + config = function() + require("custom.plugins.configs.navigator").setup() + require("base46").load_highlight "lsp" + + -- TODO: use nvchadui_lsp features manually + -- require("nvchad_ui.lsp") + end + }, + + ["ray-x/lsp_signature.nvim"] = { + lock = true, + after = { "navigator.lua" }, + config = function() + require("custom.plugins.configs.lsp_signature").setup() + end + + }, -- }}} + + -- side panel with symbols (replaced by Navigator :LspSymbols cmd) + -- ["liuchengxu/vista.vim"] = { + -- cmd = "Vista", + -- setup = function() + -- require("core.utils").load_mappings "vista" + -- end + -- }, + -- + + -- ------------------------------------------------------- + -- Programming Languages Plugins + -- ------------------------------------------------------- + + -- ------- + -- lua dev + -- ------- + + -- Eval Lua lines/selections + + -- ["bfredl/nvim-luadev"] = {{{{ + -- lock = true, + -- cmd = "Luadev", + -- keys = { + -- "(Luadev-RunLine)", + -- "(Luadev-Run)", + -- "(Luadev-RunWord)", + -- "(Luadev-Complete)", + -- }, + -- setup = function() + -- local autocmd = vim.api.nvim_create_autocmd + -- autocmd("FileType", { + -- pattern = "lua", + -- callback = function () + -- vim.keymap.set({'n', 'i'}, 'r', '(Luadev-RunLine)', { + -- desc = "Luadev RunLine" + -- }) + -- end, + -- }) + -- end + -- },}}} + + -- power Repl {{{ + ["hkupty/iron.nvim"] = { + loack = true, + cmd = { "Iron*" }, + setup = function() + require("core.utils").load_mappings "iron" + end, + config = function() + require("custom.plugins.configs.iron").setup() + end + }, + + -- REPL for Lua development + ["ii14/neorepl.nvim"] = { + lock = true, + cmd = "Repl", + after = "nvim-cmp", + config = function() + local autocmd = vim.api.nvim_create_autocmd + autocmd("FileType", { + pattern = "neorepl", + callback = function() + require('cmp').setup.buffer({ enabled = false }) + + -- custom keymap example + -- activate corresponding section in mappings + -- mappings = require("custom.utils").set_plugin_mappings "neorepl" + end + }) + end + }, + + -- Lua dev env + -- check setup in configs/navigator.lua + ["folke/lua-dev.nvim"] = { + lock = true, + module = "lua-dev", + }, -- }}} + + -- golang dev + + ["ray-x/go.nvim"] = { -- {{{ + lock = true, + -- after = {"nvim-lspconfig", "navigator.lua", "guihua.lua"}, + ft = { "go" }, + opt = true, + config = function() + require("custom.plugins.configs.gonvim").setup() + end + }, -- }}} + + -- Rust dev + ["simrat39/rust-tools.nvim"] = { -- {{{ + lock = true, + ft = { "rust" }, + opt = true, + config = function() + require("custom.plugins.configs.rust-tools").setup() + end + } -- }}} } diff --git a/lua/custom/plugins/nvchadui.lua b/lua/custom/plugins/nvchadui.lua index 4bc8252..60e7d04 100644 --- a/lua/custom/plugins/nvchadui.lua +++ b/lua/custom/plugins/nvchadui.lua @@ -37,7 +37,7 @@ local modes = { } local function is_dapmode() - return require("spike.dapmode").is_active() + return require("spike.dap.dapmode").is_active() -- return false end diff --git a/lua/plugins/configs/cmp.lua b/lua/plugins/configs/cmp.lua index bf502ce..99eca8d 100644 --- a/lua/plugins/configs/cmp.lua +++ b/lua/plugins/configs/cmp.lua @@ -65,8 +65,14 @@ local options = { [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), + -- Try to emulate native neovim C-x completion style behavior + [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false, diff --git a/lua/plugins/configs/whichkey.lua b/lua/plugins/configs/whichkey.lua index 131b550..3bdbf8c 100644 --- a/lua/plugins/configs/whichkey.lua +++ b/lua/plugins/configs/whichkey.lua @@ -1,40 +1,41 @@ local present, wk = pcall(require, "which-key") if not present then - return + return end require("base46").load_highlight "whichkey" local options = { - - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "  ", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, - - window = { - border = "none", -- none/single/double/shadow - }, - - layout = { - spacing = 6, -- spacing between columns - }, - - hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, - - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - i = { "j", "k" }, - v = { "j", "k" }, - n = { "`", "'", "\"", "@"}, - }, + registers = true, + + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "  ", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + + popup_mappings = { + scroll_down = "", -- binding to scroll down inside the popup + scroll_up = "", -- binding to scroll up inside the popup + }, + + window = { + border = "none", -- none/single/double/shadow + }, + + layout = { + spacing = 6, -- spacing between columns + }, + + hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, + + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + i = { "j", "k" }, + v = { "j", "k" }, + -- n = { "\"", "@" }, -- disable registers + }, } options = require("core.utils").load_override(options, "folke/which-key.nvim") diff --git a/lua/spike/dap.lua b/lua/spike/dap.lua deleted file mode 100644 index 075247e..0000000 --- a/lua/spike/dap.lua +++ /dev/null @@ -1,33 +0,0 @@ -local dapmode = require("spike.dapmode") - -local M = {} - -local function register_listeners() - local present, dap = pcall(require, "dap") - if not present then - print("nvim-dap missing !") - return - end - - dap.listeners.before['event_initialized']['spike-dap'] = function(session, body) - dapmode.start() - end - - dap.listeners.after['event_terminated']['spike-dap'] = function(session, body) - -- print("dap session ended") - dapmode.stop() - end -end - -function M.go_debug() - local present, gdap = pcall(require, "go.dap") - if not present then return end - gdap.run() -end - -function M.setup() - dapmode.setup({}) - register_listeners() -end - -return M diff --git a/lua/spike/dapmode.lua b/lua/spike/dap/dapmode.lua similarity index 68% rename from lua/spike/dapmode.lua rename to lua/spike/dap/dapmode.lua index 6349f61..0be8931 100644 --- a/lua/spike/dapmode.lua +++ b/lua/spike/dap/dapmode.lua @@ -1,30 +1,32 @@ -local libmodal = require "libmodal" +local libmodal = require 'libmodal' +local daputils = require 'spike.dap.utils' M = {} M.layer = nil + local config = { mappings = { n = - { - t = { rhs = ' DapToggleBreakpoint', desc= "[dap] toggle breakpoint" }, + { + t = { rhs = ' DapToggleBreakpoint', desc= '[dap] toggle breakpoint' }, T = { rhs = function() require('dap').set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, - desc = "[dap] conditional breakpoint", + desc = '[dap] conditional breakpoint', }, c = { rhs = function() require('dap').continue() end, - desc = "[dap] continue" + desc = '[dap] continue' }, n = { rhs = function() require('dap').step_over() end, - desc = "[dap] step over" + desc = '[dap] step over' }, s = { rhs = function() @@ -40,46 +42,46 @@ local config = { }, r = { rhs = function() - require('go.dap').run() + require('dap').run_last() end, - desc = '[dap] run' + desc = '[dap] restart' }, S = { rhs = function() - require('go.dap').stop() + daputils.disconnect_dap() end, - desc = "[dap] stop" + desc = '[dap] stop' }, C = { rhs = function() require('dap').run_to_cursor() end, - desc = "[dap] run to curosr" + desc = '[dap] run to curosr' }, W = { rhs = function() - require("dapui").float_element('watches') + require('dapui').float_element('watches') end, desc = '[dapui] float watches' }, B = { rhs = function() - require("dapui").float_element('breakpoints') + require('dapui').float_element('breakpoints') end, desc = '[dapui] float breakpoints' }, O = { rhs = function() - require("dapui").float_element('scopes') + require('dapui').float_element('scopes') end, desc = '[dapui] float scopes' }, - ["Q"] = { + ['Q'] = { rhs = function() M.layer:exit() end, - desc = "[dap] exit dap mode" - } + desc = '[dap] exit dap mode' + } } } } @@ -97,7 +99,7 @@ function M.stop() end function M.setup (opts) - config = vim.tbl_deep_extend("force", config, opts or {}) + config = vim.tbl_deep_extend('force', config, opts or {}) end function M.is_active() @@ -110,5 +112,6 @@ end -- -- -- layer:enter() -- +M.disconnect_dap = disconnect_dap return M diff --git a/lua/spike/dap/init.lua b/lua/spike/dap/init.lua new file mode 100644 index 0000000..fff9913 --- /dev/null +++ b/lua/spike/dap/init.lua @@ -0,0 +1,70 @@ +local dapmode = require("spike.dap.dapmode") +local daputils = require('spike.dap.utils') +local dapui = require("dapui") + +local M = {} +M.signs = { + DapBreakpoint = { + icon = '', + hl = 'DapBreakpoint' + }, + DapLogPoint = { + icon = 'ﳁ', + hl = 'DapLogPoint', + }, + DapStopped = { + icon = '', + hl = 'DapStopped', + }, + DapBreakpointCondition = { + icon = '', + hl = 'DapBreakpointCondition', + }, + DapBreakpointRejected = { + icon = '', + hl = 'DapBreakpointRejected' + } +} + +local function register_listeners() + local present, dap = pcall(require, "dap") + if not present then + print("nvim-dap missing !") + return + end + + dap.listeners.before['event_initialized']['spike-dap'] = function(session, body) + dapmode.start() + dapui.open() + end + + dap.listeners.after['event_terminated']['spike-dap'] = function(session, body) + -- print("dap session ended") + dapmode.stop() + dapui.close() + end +end + +function M.go_debug() + local present, gdap = pcall(require, "go.dap") + if not present then return end + gdap.run() +end + +local function set_signs() + for sign, conf in pairs(M.signs) do + vim.fn.sign_define(sign, {text = conf.icon, texthl=conf.hl}) + end +end + +function M.prepare_launch() +end + +function M.setup() + dapmode.setup({}) + register_listeners() + set_signs() +end + + +return M diff --git a/lua/spike/dap/utils.lua b/lua/spike/dap/utils.lua new file mode 100644 index 0000000..674c2a4 --- /dev/null +++ b/lua/spike/dap/utils.lua @@ -0,0 +1,35 @@ +local ok, dap = pcall(require, 'dap') +if not ok then + vim.notify('dap module missing') +end +local M = {} + +M.disconnect_dap = function() + local has_dap, dap = pcall(require, 'dap') + if has_dap then + dap.disconnect() + dap.repl.close() + vim.cmd('sleep 100m') -- allow cleanup + else + vim.notify('dap not found') + end +end + +M.dap_logpoint = function() + vim.ui.input({ prompt = 'Logpoint message> '}, function (input) + dap.set_breakpoint(nil,nil,input) + end) +end + +-- if there are no breakpoints in the project set a breakpoint on the current +-- line +M.init_breakpoints = function() + -- see https://github.com/rcarriga/nvim-dap-ui/blob/master/lua/dapui/state.lua + -- for a reference to access dap breakpoint details + local breakpoints = require('dap.breakpoints').get() or {} + if #breakpoints == 0 then + dap.set_breakpoint() + end +end + +return M diff --git a/lua/spike/globals.lua b/lua/spike/globals.lua index d516cf7..24b57e2 100644 --- a/lua/spike/globals.lua +++ b/lua/spike/globals.lua @@ -18,3 +18,13 @@ R = function(name) RELOAD(name) return require(name) end + +TBL_HASVAL = function(tab, val) + for index, value in ipairs(tab) do + if value == val then + return true + end + end + + return false +end