diff options
Diffstat (limited to '.config/nvim/lua')
| -rw-r--r-- | .config/nvim/lua/plugins/dap.lua | 282 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 1 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/luasnip.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 82 |
4 files changed, 77 insertions, 293 deletions
diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua index dfe8030..3d7059a 100644 --- a/.config/nvim/lua/plugins/dap.lua +++ b/.config/nvim/lua/plugins/dap.lua @@ -1,25 +1,4 @@ local dap = require('dap') ---local home_path = vim.fn.expand('$HOME') - --- Unsafe Defaults ---local mi_mode = "" ---local mi_debugger_path = "" --- ----- Unix ---if vim.loop.os_uname().sysname == 'Linux' then --- mi_mode = "gdb" --- mi_debugger_path = vim.trim(vim.fn.system('which gdb')) ----- MacOS ---elseif vim.loop.os_uname().sysname == 'Darwin' then --- mi_mode = "lldb" --- mi_debugger_path = vim.trim(vim.fn.system('which lldb-mi')) ---else --- error("Unsupported OS") ---end - ---local mason_registry = require("mason-registry") ---local codelldb_root = mason_registry.get_package("codelldb"):get_install_path() .. "/extension/" - dap.adapters.lldb = { type = 'executable', --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path @@ -30,8 +9,7 @@ dap.adapters.lldb = { name = 'lldb' } --- cpp - +-- cpp (c,c++,rust) dap.configurations.cpp = { { name = 'Launch', @@ -51,22 +29,6 @@ dap.configurations.cpp = { }, } - ---dap.configurations.cpp = { --- { --- name = "Launch file", --- type = "cppdbg", --- request = "launch", --- program = function() --- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') --- end, --- cwd = '${workspaceFolder}', --- --stopAtEntry = true, --- --MIMode = mi_mode, --- --miDebuggerPath = mi_debugger_path --- } ---} - -- If you want to use this for Rust and C, add something like this: dap.configurations.c = dap.configurations.cpp dap.configurations.rust = dap.configurations.cpp @@ -111,208 +73,42 @@ dap.configurations.python = { local dapui = require('dapui') - -- setup statusline - - -- setup repl - dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, { - exit = { 'q', 'exit' }, - custom_commands = { - ['.run_to_cursor'] = dap.run_to_cursor, - ['.restart'] = dap.run_last - } - }) - - -- vim.api.nvim_create_augroup('DAPConfig', { clear = true }) - -- vim.api.nvim_create_autocmd('FileType', { - -- group = 'DAPConfig', - -- pattern = 'dap-repl', - -- callback = require('dap.ext.autocompl').attach - -- }) - - -- setup dapui - dapui.setup({ - mappings = { - expand = "<CR>", - open = "o", - remove = "D", - edit = "e", - repl = "r", - toggle = "t", - }, - layouts = { - { elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" }, - { elements = { "repl", "watches" }, size = 0.27, position = "bottom" }, - }, - icons = { expanded = "-", collapsed = "$" }, - controls = { enabled = false }, - floating = { border = "rounded", mappings = { close = { "q", "<esc>", "<c-o>" } } }, - }) - - -- signs - vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' }) - vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) - vim.fn.sign_define("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) - vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) - vim.fn.sign_define("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) - - -- options - dap.defaults.fallback.focus_terminal = false - dap.defaults.fallback.terminal_win_cmd = '10split new' - - -- virtual text setup - --require('nvim-dap-virtual-text').setup({}) - - +-- setup repl +dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, { + exit = { 'q', 'exit' }, + custom_commands = { + ['.run_to_cursor'] = dap.run_to_cursor, + ['.restart'] = dap.run_last + } +}) + +-- setup dapui +dapui.setup({ + mappings = { + expand = "<CR>", + open = "o", + remove = "D", + edit = "e", + repl = "r", + toggle = "t", + }, + layouts = { + { elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" }, + { elements = { "repl", "watches" }, size = 0.27, position = "bottom" }, + }, + icons = { expanded = "-", collapsed = "$" }, + controls = { enabled = false }, + floating = { border = "rounded", mappings = { close = { "q", "<esc>", "<c-o>" } } }, +}) + +-- signs +vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' }) +vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +vim.fn.sign_define("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) +vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +vim.fn.sign_define("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) + +-- options +dap.defaults.fallback.focus_terminal = false +dap.defaults.fallback.terminal_win_cmd = '10split new' ---local debugging = {} --- ---function debugging.setup() --- local dap = require("dap") --- --- local sign = vim.fn.sign_define --- --- -- These are to override the default highlight groups for catppuccin (see https://github.com/catppuccin/nvim/#special-integrations) --- sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) --- sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) --- sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" }) --- --- local mason_registry = require("mason-registry") --- local cpp_dap_executable = mason_registry.get_package("cpptools"):get_install_path() --- .. "/extension/debugAdapters/bin/OpenDebugAD7" --- --- dap.adapters.cpp = { --- id = "cppdbg", --- type = "executable", --- command = cpp_dap_executable, --- } --- --- local codelldb_root = mason_registry.get_package("codelldb"):get_install_path() .. "/extension/" --- local codelldb_path = codelldb_root .. "adapter/codelldb" --- local liblldb_path = codelldb_root .. "lldb/lib/liblldb.so" --- --- dap.adapters.rust = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path) --- --- -- To use the venv for debugpy that is installed with mason, obtain the path and pass it to `setup` as shown below. --- -- I don't think this is the best idea right now, because it requires that the user installs the packages into a venv that they didn't create and may not know of. --- --- -- local debugpy_root = mason_registry.get_package("debugpy"):get_install_path() --- require("dap-python").setup(--[[ debugpy_root.. "/venv/bin/python" --]]) --- require('dap-python').test_runner = 'pytest' --- --- dap.configurations.lua = { --- { --- type = "nlua", --- request = "attach", --- name = "Attach to running Neovim instance", --- }, --- } --- --- dap.adapters.nlua = function(callback, config) --- callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 }) --- end --- --- require("nvim-dap-virtual-text").setup({ --- enabled = true, --- enabled_commands = true, --- highlight_changed_variables = true, --- highlight_new_as_changed = true, --- show_stop_reason = true, --- commented = true, --- only_first_definition = true, --- all_references = true, --- display_callback = function(variable, _buf, _stackframe, _node) --- return " " .. variable.name .. " = " .. variable.value .. " " --- end, --- -- experimental features: --- virt_text_pos = "eol", -- position of virtual text, see `:h nvim_buf_set_extmark()` --- all_frames = false, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine. --- virt_lines = false, -- show virtual lines instead of virtual text (will flicker!) --- virt_text_win_col = nil, -- position the virtual text at a fixed window column (starting from the first text column) , --- }) --- --- local dapui = require("dapui") --- dapui.setup({ --- icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, --- mappings = { --- -- Use a table to apply multiple mappings --- expand = { "<CR>", "<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. --- "breakpoints", --- "stacks", --- "watches", --- { id = "scopes", size = 0.25 }, --- }, --- size = 40, -- 40 columns --- position = "left", --- }, --- { --- elements = { --- "repl", --- "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", "<Esc>" }, --- }, --- }, --- windows = { indent = 1 }, --- render = { --- max_type_length = nil, -- Can be integer or nil. --- max_value_lines = 100, -- Can be integer or nil. --- }, --- }) --- --- dap.listeners.after.event_initialized["dapui_config"] = function() --- dapui.open() --- end --- -- dap.listeners.before.event_terminated["dapui_config"] = function() --- -- dapui.close() --- -- end --- -- dap.listeners.before.event_exited["dapui_config"] = function() --- -- dapui.close() --- -- end ---end --- ---return debugging diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 8fbc03f..a4127e3 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -261,6 +261,7 @@ null_ls.setup { -- this will run every time the source runs, -- so you should prefer caching results if possible }), + builtins.diagnostics.zsh, builtins.diagnostics.todo_comments, builtins.diagnostics.teal, -- null_ls.builtins.diagnostics.vale, diff --git a/.config/nvim/lua/plugins/luasnip.lua b/.config/nvim/lua/plugins/luasnip.lua index de2177e..4cceed1 100644 --- a/.config/nvim/lua/plugins/luasnip.lua +++ b/.config/nvim/lua/plugins/luasnip.lua @@ -62,8 +62,3 @@ end) -- %x hexadecimal digits (\3, \4, ...) -- %z the character with representation 0 -- . Matches any character - - - - - diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index 4b6e9ef..c0592da 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -1,5 +1,4 @@ --[[ key.lua ]] - ------------- Shorten Function Names -------------- local keymap = vim.keymap local map = function(mode, l, r, opts) @@ -10,7 +9,6 @@ local map = function(mode, l, r, opts) end local term_opts = { noremap = true, silent = false } - --------------- Standard Operations --------------- -- Semi-colon as leader key vim.g.mapleader = ";" @@ -25,7 +23,8 @@ vim.g.mapleader = ";" map("i", "jj", "<esc>") -- Reload nvim config -map("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") +map("n", "<leader><CR>", + "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") --------------- Extended Operations --------------- @@ -35,15 +34,15 @@ map('n', 'q', function() if config.relative ~= "" then -- is_floating_window? return ":silent! close!<CR>" elseif - vim.o.buftype == 'quickfix' then + vim.o.buftype == 'quickfix' then return ":quit<CR>" elseif - vim.o.buftype == 'help' then + vim.o.buftype == 'help' then return ":close<CR>" else return "q" end -end, {expr = true, replace_keycodes = true}) +end, { expr = true, replace_keycodes = true }) -- Combine buffers list with buffer name map("n", "<Leader>b", ":buffers<CR>:buffer<Space>") @@ -99,16 +98,10 @@ map("i", "<A-k>", "<up>") map("i", "<A-l>", "<right>") -- Map Alt+(h/j/k/l) in command mode to move directional -map("c", "<A-h>", "<left>") -map("c", "<A-j>", "<down>") -map("c", "<A-k>", "<up>") -map("c", "<A-l>", "<right>") - --- Map Alt+(h/j/k/l) in selection mode to move directional -map("s", "<A-h>", "<left>") -map("s", "<A-j>", "<down>") -map("s", "<A-k>", "<up>") -map("s", "<A-l>", "<right>") +vim.api.nvim_set_keymap('c', '<A-h>', '<Left>', { noremap = true }) +vim.api.nvim_set_keymap('c', '<A-j>', '<Down>', { noremap = true }) +vim.api.nvim_set_keymap('c', '<A-k>', '<Up>', { noremap = true }) +vim.api.nvim_set_keymap('c', '<A-l>', '<Right>', { noremap = true }) -- Create tab, edit and move between them map("n", "<C-T>n", ":tabnew<CR>") @@ -179,13 +172,13 @@ map('n', '<leader>o', ':!xdg-open %<cr><cr>') -- URL handling if vim.fn.has("mac") == 1 then - map("", "gx", '<Cmd>call jobstart(["open", expand("<cfile>")], {"detach": v:true})<CR>', {}) + map("", "gx", '<Cmd>call jobstart(["open", expand("<cfile>")], {"detach": v:true})<CR>', {}) elseif vim.fn.has("unix") == 1 then - map("", "gx", '<Cmd>call jobstart(["xdg-open", expand("<cfile>")], {"detach": v:true})<CR>', {}) + map("", "gx", '<Cmd>call jobstart(["xdg-open", expand("<cfile>")], {"detach": v:true})<CR>', {}) elseif vim.fn.has("wsl") == 1 then - map("", "gx", '<Cmd>call jobstart(["wslview", expand("<cfile>")], {"detach": v:true})<CR>', {}) + map("", "gx", '<Cmd>call jobstart(["wslview", expand("<cfile>")], {"detach": v:true})<CR>', {}) else - map[''].gx = {'<Cmd>lua print("Error: gx is not supported on this OS!")<CR>'} + map[''].gx = { '<Cmd>lua print("Error: gx is not supported on this OS!")<CR>' } end -- Toggle completion @@ -197,15 +190,15 @@ map('i', '<C-p>', '<Nop>') -- Set line wrap map("n", "<M-z>", function() - local wrap_status = vim.api.nvim_exec("set wrap ?", true) - - if wrap_status == "nowrap" then - vim.api.nvim_command("set wrap linebreak") - print("Wrap enabled") - else - vim.api.nvim_command("set wrap nowrap") - print("Wrap disabled") - end + local wrap_status = vim.api.nvim_exec("set wrap ?", true) + + if wrap_status == "nowrap" then + vim.api.nvim_command("set wrap linebreak") + print("Wrap enabled") + else + vim.api.nvim_command("set wrap nowrap") + print("Wrap disabled") + end end, { silent = true }) -- Toggle between folds @@ -251,7 +244,7 @@ map('n', '<C-j>', '<CMD>NavigatorDown<CR>') --map("n", "<leader>tt", "<cmd>ToggleTerm<cr>") -- LazyGit -map({"n", "t"}, "<leader>gg", "<cmd>lua Lazygit_toggle()<CR>") +map({ "n", "t" }, "<leader>gg", "<cmd>lua Lazygit_toggle()<CR>") -- Fugitive git bindings map("n", "<leader>ga", ":Git add %:p<CR><CR>") @@ -284,7 +277,7 @@ map("n", "<leader>gm", ":Gmove<Space>") -- Telescope map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end) -- find all files -map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option +map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>") map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>") map("n", "<leader>fh", "<cmd>lua require('telescope.builtin').help_tags()<cr>") @@ -295,13 +288,13 @@ map("n", "<leader>fp", "<cmd>Telescope pickers<cr>") map("n", "<leader>fr", "<cmd>lua require('telescope.builtin').registers({})<CR>") -- registers picker map("n", "<leader>fd", "<cmd>lua require('telescope.builtin').diagnostics()<cr>") map("n", "<leader>fk", "<cmd>lua require('telescope.builtin').keymaps()<cr>") -map("n", "<leader>fn", [[<Cmd>lua require'plugins.telescope'.find_notes()<CR>]]) -- find notes -map("n", "<leader>fgn", [[<Cmd>lua require'plugins.telescope'.grep_notes()<CR>]]) -- search notes -map("n", "<leader>f.", [[<Cmd>lua require'plugins.telescope'.find_configs()<CR>]]) -- find configs -map("n", "<leader>fs", [[<Cmd>lua require'plugins.telescope'.find_scripts()<CR>]]) -- find scripts -map("n", "<leader>fw", [[<Cmd>lua require'plugins.telescope'.find_projects()<CR>]]) -- find projects +map("n", "<leader>fn", [[<Cmd>lua require'plugins.telescope'.find_notes()<CR>]]) -- find notes +map("n", "<leader>fgn", [[<Cmd>lua require'plugins.telescope'.grep_notes()<CR>]]) -- search notes +map("n", "<leader>f.", [[<Cmd>lua require'plugins.telescope'.find_configs()<CR>]]) -- find configs +map("n", "<leader>fs", [[<Cmd>lua require'plugins.telescope'.find_scripts()<CR>]]) -- find scripts +map("n", "<leader>fw", [[<Cmd>lua require'plugins.telescope'.find_projects()<CR>]]) -- find projects map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") -- find media files -map("n", "<leader>fi", "<cmd>lua require('telescope').extensions.notify.notify({})<cr>") -- find notifications +map("n", "<leader>fi", "<cmd>lua require('telescope').extensions.notify.notify({})<cr>") -- find notifications -- FZF map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>") @@ -335,12 +328,12 @@ map('n', '<Leader>qr', ':lua require("replacer").run()<CR>') -- Quickfix map("n", "<leader>q", function() - if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then - require('plugins.quickfix').close() - else - require('plugins.quickfix').open() - --require("quickfix").open() - end + if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then + require('plugins.quickfix').close() + else + require('plugins.quickfix').open() + --require("quickfix").open() + end end, { desc = "Toggle quickfix window" }) -- Dap (debugging) @@ -348,7 +341,7 @@ local dap_ok, dap = pcall(require, "dap") local dap_ui_ok, ui = pcall(require, "dapui") if not (dap_ok and dap_ui_ok) then - require("notify")("nvim-dap or dap-ui not installed!", "warning") + require("notify")("nvim-dap or dap-ui not installed!", "warning") return end @@ -387,4 +380,3 @@ map("n", "<leader><Space>", "<CMD>Dashboard<CR>") -- Lsp Lines toggle map("", "<Leader>l", require("lsp_lines").toggle, { desc = "Toggle lsp_lines" }) - |
