From e6524fc825c9d055bb389f3ef0b23842d1c99ece Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 4 May 2023 00:12:29 +0200 Subject: Add folke/neodev.nvim --- lua/user/pack.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 951e9f7..cc0de0b 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -73,6 +73,9 @@ return packer.startup(function(use) }) use("rmagatti/goto-preview") + -- neodev + use("folke/neodev.nvim") + -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim use("rcarriga/nvim-dap-ui") -- UI for nvim-dap -- cgit v1.2.3 From 07c4d02200ea7fa6de9fbeeab3a18343952383bb Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 4 May 2023 00:27:57 +0200 Subject: Add nvim-ufo, promise-async and statuscol.nvim --- lua/user/pack.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index cc0de0b..19841c7 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -210,6 +210,20 @@ return packer.startup(function(use) -- require'alpha'.setup(require'alpha.themes.startify'.config) -- end --}) + use ({'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}) + use ({"luukvbaal/statuscol.nvim", + config = function() + local builtin = require "statuscol.builtin" + require("statuscol").setup { + relculright = true, + segments = { + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.lnumfunc, " " }, click = "v:lua.ScLa" }, + }, + } + end + }) use({ 'glepnir/dashboard-nvim', event = 'VimEnter', -- cgit v1.2.3 From bfd6d83ef02489bc996a2bd2a51a310c9fdde25b Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 4 May 2023 00:28:37 +0200 Subject: Add TODO to Conditional 'q' to not work in Zen Mode --- lua/user/keys.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index c0592da..ad9ca6d 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -29,6 +29,7 @@ map("n", "", --------------- Extended Operations --------------- -- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros +-- TODO: Have a list of if available on system/packages, example "Zen Mode" to not work on it (quit Zen Mode) map('n', 'q', function() local config = vim.api.nvim_win_get_config(0) if config.relative ~= "" then -- is_floating_window? -- cgit v1.2.3 From 80a4783ae358ffb479dc89738a11d41f3e3098bc Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 4 May 2023 00:29:03 +0200 Subject: Re-enable dap --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 04c63b0..039486d 100644 --- a/init.lua +++ b/init.lua @@ -92,7 +92,7 @@ local modules = { "plugins.toggleterm", "plugins.trouble", "plugins.dashboard", - --"plugins.dap", + "plugins.dap", --"plugins.modify-blend", --"plugins.floatterm", } -- cgit v1.2.3 From e530664441053b4a8c0a5de6d231e65176fd71a3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Thu, 4 May 2023 22:38:23 +0200 Subject: Commented out highlight group for CursorLineSign --- lua/plugins/colorscheme.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 1ad9ce8..9271022 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -12,7 +12,7 @@ vim.api.nvim_command("syntax on") vim.api.nvim_command("highlight Normal guibg=none") vim.api.nvim_command("highlight SignColumn guibg=none") --vim.api.nvim_command("highlight FoldColumn guibg=none") -vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") +--vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") vim.api.nvim_command("highlight Title guibg=none gui=bold") vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") @@ -20,7 +20,6 @@ vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") vim.api.nvim_command("highlight WinBar guibg=none gui=bold") vim.api.nvim_command("highlight NormalFloat guibg=none") vim.api.nvim_command("highlight LineNr guibg=none") -vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") --vim.api.nvim_command("highlight FoldColumn guibg=none") --vim.api.nvim_command("highlight SignColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") -- cgit v1.2.3 From 7684755aed98983c2bd3e342d426b5a3634269a3 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 5 May 2023 12:52:20 +0200 Subject: Using vscode-cpptools now --- lua/plugins/dap.lua | 198 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 159 insertions(+), 39 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 3d7059a..03e37e5 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,57 +1,177 @@ local dap = require('dap') +dap.defaults.fallback.external_terminal = { + command = '/usr/bin/wezterm'; + args = {'-e'}; +} +--dap.adapters.lldb = { +-- type = 'executable', +-- --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path +-- --command = '/usr/bin/vscode-lldb', -- adjust as needed, must be absolute path +-- command = 'codelldb', +-- --command = 'lldb', +-- --command = codelldb_root, +-- --command = vim.fn.stdpath("data") .. '/mason/bin/codelldb', +-- name = 'lldb', +-- host = '127.0.0.1', +-- port = 13000 +--} +-- +--local lldb = { +-- name = "Launch lldb", +-- type = "lldb", -- matches the adapter +-- request = "launch", -- could also attach to a currently running process +-- program = function() +-- return vim.fn.input( +-- "Path to executable: ", +-- vim.fn.getcwd() .. "/", +-- "file" +-- ) +-- end, +-- cwd = "${workspaceFolder}", +-- stopOnEntry = false, +-- args = {}, +-- runInTerminal = false, +-- --type = 'server', +-- port = "${port}", +-- executable = { +-- --command = vim.fn.stdpath("data") .. '/mason/bin/codelldb', +-- args = { "--port", "${port}" }, +-- } +--} +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + --command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', + command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7', +} + +dap.adapters.codelldb = { + type = 'server', + port = "${port}", + executable = { + command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', + args = {"--port", "${port}"}, + } +} + dap.adapters.lldb = { type = 'executable', - --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path - --command = '/usr/bin/vscode-lldb', -- adjust as needed, must be absolute path - command = 'codelldb', - --command = 'lldb', - --command = codelldb_root, - name = 'lldb' + command = '/usr/bin/lldb-vscode', + name = "lldb" } --- cpp (c,c++,rust) dap.configurations.cpp = { { - name = 'Launch', - type = 'lldb', - request = 'launch', - --program = function() - -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') - --end, - terminal = 'integrated', - console = 'integratedTerminal', + name = "Launch file", + type = "cppdbg", + --request = "launch", + request = "Attach", + processId = function() + return tonumber(vim.fn.input({ prompt = "Pid: "})) + end, program = function() - return vim.fn.input('program: ', vim.loop.cwd() .. '/', 'file') + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - args = {}, - }, + stopAtEntry = true, + MIMode = 'gdb', + --miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = 'gdb-oneapi', + --miDebuggerPath = '/usr/bin/gdb', + externalConsole = true, + setupCommands = { + { + text = '-enable-pretty-printing', + description = 'enable pretty printing', + ignoreFailures = false + } + }, + cwd = '${workspaceFolder}', +}, } +-- dap.adapters.cppdbg = { +-- name = 'cppdbg', +-- type = 'executable', +-- command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', +-- } +-- dap.configurations.cpp = { +-- { +-- name = 'Launch', +-- type = 'cppdbg', +-- request = 'launch', +-- --request = 'attach', +-- MIMode = 'gdb', +-- --cwd = '${workspaceFolder}', +-- -- udb='live', +-- -- miDebuggerPath = 'udb', +-- setupCommands= { +-- { +-- description= "Enable pretty-printing for gdb", +-- text= "-enable-pretty-printing", +-- ignoreFailures= true, +-- } +-- }, +-- program = '${file}', +-- cwd = vim.fn.getcwd(), +-- --attach = { +-- -- pidProperty = "processId", +-- -- pidSelect = "ask" +-- --}, +-- stopAtEntry = true, +-- --program = 'main', +-- --program = '${workspaceFolder}/main' +-- --program = '${file}', +-- --program = function() +-- -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +-- --end, +-- }, +-- } + +--require('dap').configurations.c = { +-- lldb -- different debuggers or more configurations can be used here +--} + +-- cpp (c,c++,rust) +--dap.configurations.c = { +-- { +-- name = 'Launch', +-- type = 'lldb', +-- request = 'launch', +-- --program = function() +-- -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') +-- --end, +-- terminal = 'integrated', +-- console = 'integratedTerminal', +-- program = function() +-- return vim.fn.input('program: ', vim.loop.cwd() .. '/', 'file') +-- end, +-- cwd = "${workspaceFolder}", +-- stopOnEntry = false, +-- args = {}, +-- }, +--} -- 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 - -- javascript -dap.adapters.node2 = { - type = 'executable', - command = 'node-debug2-adapter', - args = {}, -} +--dap.adapters.node2 = { +-- type = 'executable', +-- command = 'node-debug2-adapter', +-- args = {}, +--} -dap.configurations.javascript = { - { - name = 'Launch', - type = 'node2', - request = 'attach', - program = '${file}', - cwd = vim.fn.getcwd(), - sourceMaps = true, - protocol = 'inspector', - console = 'integratedTerminal', - }, -} +--dap.configurations.javascript = { +-- { +-- name = 'Launch', +-- type = 'node2', +-- request = 'attach', +-- program = '${file}', +-- cwd = vim.fn.getcwd(), +-- sourceMaps = true, +-- protocol = 'inspector', +-- console = 'integratedTerminal', +-- }, +--} dap.adapters.python = { type = 'executable'; @@ -97,7 +217,7 @@ dapui.setup({ { elements = { "repl", "watches" }, size = 0.27, position = "bottom" }, }, icons = { expanded = "-", collapsed = "$" }, - controls = { enabled = false }, + --controls = { enabled = false }, floating = { border = "rounded", mappings = { close = { "q", "", "" } } }, }) -- cgit v1.2.3 From e2d8386915af4517ecc856799851d5f1bd866ba9 Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 5 May 2023 23:09:00 +0200 Subject: Configure codelldb and set it as type to use --- lua/plugins/dap.lua | 55 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 03e37e5..c4aec62 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -47,10 +47,12 @@ dap.adapters.cppdbg = { dap.adapters.codelldb = { type = 'server', - port = "${port}", + port = '${port}', executable = { - command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', - args = {"--port", "${port}"}, + --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', + --command = vim.env.HOME .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", + command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", + args = {'--port', '${port}'}, } } @@ -59,32 +61,34 @@ dap.adapters.lldb = { command = '/usr/bin/lldb-vscode', name = "lldb" } - dap.configurations.cpp = { { name = "Launch file", - type = "cppdbg", - --request = "launch", - request = "Attach", - processId = function() - return tonumber(vim.fn.input({ prompt = "Pid: "})) - end, + --type = "cppdbg", + type = "codelldb", + request = "launch", + --request = "Attach", + --processId = function() + -- return tonumber(vim.fn.input({ prompt = "Pid: "})) + --end, program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, stopAtEntry = true, - MIMode = 'gdb', + args = {}, + runInTerminal = false, + --MIMode = 'gdb', --miDebuggerServerAddress = 'localhost:1234', - miDebuggerPath = 'gdb-oneapi', + --miDebuggerPath = 'gdb-oneapi', --miDebuggerPath = '/usr/bin/gdb', - externalConsole = true, - setupCommands = { - { - text = '-enable-pretty-printing', - description = 'enable pretty printing', - ignoreFailures = false - } - }, + --externalConsole = true, + --setupCommands = { + -- { + -- text = '-enable-pretty-printing', + -- description = 'enable pretty printing', + -- ignoreFailures = false + -- } + --}, cwd = '${workspaceFolder}', }, } @@ -228,7 +232,16 @@ vim.fn.sign_define("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticE vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) vim.fn.sign_define("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +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 + -- options dap.defaults.fallback.focus_terminal = false dap.defaults.fallback.terminal_win_cmd = '10split new' - -- cgit v1.2.3 From a6d640834eb9e9b630731e26fb69b4a79346c86c Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 5 May 2023 23:54:03 +0200 Subject: Add options that are commented out in order to test such as host, port (specific) and detached = true --- lua/plugins/dap.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index c4aec62..9b790d9 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -48,12 +48,15 @@ dap.adapters.cppdbg = { dap.adapters.codelldb = { type = 'server', port = '${port}', + --host = '127.0.0.1', + --port = 13000, -- 💀 Use the port printed out or specified with `--port` executable = { --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', --command = vim.env.HOME .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", args = {'--port', '${port}'}, - } + }, + --detached = true, } dap.adapters.lldb = { @@ -76,12 +79,15 @@ dap.configurations.cpp = { end, stopAtEntry = true, args = {}, - runInTerminal = false, + runInTerminal = true, + --runInTerminal = false, + --console = 'integratedTerminal', + --MIMode = 'gdb', --miDebuggerServerAddress = 'localhost:1234', --miDebuggerPath = 'gdb-oneapi', --miDebuggerPath = '/usr/bin/gdb', - --externalConsole = true, + externalConsole = true, --setupCommands = { -- { -- text = '-enable-pretty-printing', -- cgit v1.2.3 From cdae33c380235b06bc9b7e06477b955760a7ee7d Mon Sep 17 00:00:00 2001 From: srdusr Date: Fri, 5 May 2023 23:54:43 +0200 Subject: Changed colorscheme to doom-one --- lua/plugins/colorscheme.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index 9271022..2735204 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,7 +1,7 @@ -- Colorscheme -- Available colorschemes: -- [[ nightfly ayu onedark doom-one nvimgelion ]] -local colorscheme = "nvimgelion" +local colorscheme = "doom-one" local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) if not status_ok then vim.notify("colorscheme " .. colorscheme .. " not found!") -- cgit v1.2.3 From 64bc81623a6aad2f9d7d580dbb16f24a2ab1d412 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 11:06:17 +0200 Subject: Install "theHamsta/nvim-dap-virtual-text" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 19841c7..9545f64 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -79,6 +79,7 @@ return packer.startup(function(use) -- Debugger use("mfussenegger/nvim-dap") -- Debug Adapter Protocol client implementation for Neovim use("rcarriga/nvim-dap-ui") -- UI for nvim-dap + use("theHamsta/nvim-dap-virtual-text") use("gabrielpoca/replacer.nvim") use({ "jayp0521/mason-nvim-dap.nvim", -- cgit v1.2.3 From 356e8ec9fcb3c08df3a8f940c3ca286457e7789b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 11:07:47 +0200 Subject: Install "rcarriga/cmp-dap" --- lua/user/pack.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index 9545f64..e618a3d 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -118,6 +118,7 @@ return packer.startup(function(use) use("hrsh7th/cmp-calc") -- Completion source for math calculation use("saadparwaiz1/cmp_luasnip") -- Completion source for snippets, specifically for luasnip use("hrsh7th/cmp-nvim-lsp-signature-help") -- Completion source for displaying function signatures with the current parameter emphasized + use("rcarriga/cmp-dap") -- Snippets use("L3MON4D3/LuaSnip") -- Snippet engine -- cgit v1.2.3 From 3a3a3824c8c1fc18cbd5a30e5cfef027f2b5a049 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 11:14:29 +0200 Subject: Update FloatBorders UI --- lua/plugins/lsp.lua | 176 +++++++++++++++++++++++++++------------------------- 1 file changed, 90 insertions(+), 86 deletions(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 6c40c9c..04d07ba 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -6,43 +6,44 @@ local keymap = vim.keymap local cmd = vim.cmd local border = { - { '🭽', 'FloatBorder' }, - { '▔', 'FloatBorder' }, - { '🭾', 'FloatBorder' }, - { '▕', 'FloatBorder' }, - { '🭿', 'FloatBorder' }, - { '▁', 'FloatBorder' }, - { '🭼', 'FloatBorder' }, - { '▏', 'FloatBorder' }, + { "┌", "FloatBorder" }, + { "─", "FloatBorder" }, + { "┐", "FloatBorder" }, + { "│", "FloatBorder" }, + { "┘", "FloatBorder" }, + { "─", "FloatBorder" }, + { "└", "FloatBorder" }, + { "│", "FloatBorder" }, } + local signs = { Error = " ", Warn = "▲", Info = "􀅳", Hint = "⚑" } for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) end vim.diagnostic.config({ - underline = false, - signs = true, - virtual_text = false, - virtual_lines = { only_current_line = true }, - float = { - show_header = true, - source = 'if_many', - --border = 'rounded', - border = border, - focusable = true, - }, - update_in_insert = false, -- default to false - severity_sort = false, -- default to false + underline = false, + signs = true, + virtual_text = false, + virtual_lines = { only_current_line = true }, + float = { + show_header = true, + source = 'if_many', + --border = 'rounded', + border = border, + focusable = true, + }, + update_in_insert = false, -- default to false + severity_sort = false, -- default to false }) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { - underline = false, - virtual_text = false, - signs = true, - update_in_insert = false, + underline = false, + virtual_text = false, + signs = true, + update_in_insert = false, }) vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" }) @@ -53,38 +54,39 @@ local on_attach = function(client, bufnr) -- Enable completion triggered by vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') local map = function(mode, l, r, opts) - opts = opts or {} - opts.silent = true + opts = opts or {} + opts.silent = true opts.noremap = true - opts.buffer = bufnr - keymap.set(mode, l, r, opts) + opts.buffer = bufnr + keymap.set(mode, l, r, opts) end -- Mappings - map("n", "K", "lua vim.lsp.buf.hover()") + map("n", "K", "lua vim.lsp.buf.hover()") --map("n", "gd", "lua vim.lsp.buf.definition()") map("n", "gd", "lua require('goto-preview').goto_preview_definition()") - --map("n", "gi", "lua vim.lsp.buf.implementation()") - map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") - --map("n", "gr", "lua vim.lsp.buf.references()") - map("n", "gr", "lua require('goto-preview').goto_preview_references()") - map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. - map("n", "k", "lua vim.lsp.buf.signature_help()") - --map("n", "gt", "lua vim.lsp.buf.type_definition()") - map("n", "gt", "lua require('goto-preview').goto_preview_type_definition()") - map("n", "gn", "lua vim.lsp.buf.rename()") - map("n", "ga", "lua vim.lsp.buf.code_action()") + --map("n", "gi", "lua vim.lsp.buf.implementation()") + map("n", "gi", "lua require('goto-preview').goto_preview_implementation()") + --map("n", "gr", "lua vim.lsp.buf.references()") + map("n", "gr", "lua require('goto-preview').goto_preview_references()") + map("n", "gD", "lua vim.lsp.buf.declaration()") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map("n", "k", "lua vim.lsp.buf.signature_help()") + --map("n", "gt", "lua vim.lsp.buf.type_definition()") + map("n", "gt", "lua require('goto-preview').goto_preview_type_definition()") + map("n", "gn", "lua vim.lsp.buf.rename()") + map("n", "ga", "lua vim.lsp.buf.code_action()") map("n", "gf", "lua vim.lsp.buf.formatting()") - map("n", "go", "lua vim.diagnostic.open_float()") - map("n", "go", ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") - map("n", "[d", "lua vim.diagnostic.goto_prev()") - map("n", "]d", "lua vim.diagnostic.goto_next()") - map("n", "gs", "lua vim.lsp.buf.document_symbol()") - map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") - map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") - map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") - map("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) + map("n", "go", "lua vim.diagnostic.open_float()") + map("n", "go", + ":call utils#ToggleDiagnosticsOpenFloat() | :echom ('Toggle Diagnostics Float open/close...') | :sl! | echo ('')") + map("n", "[d", "lua vim.diagnostic.goto_prev()") + map("n", "]d", "lua vim.diagnostic.goto_next()") + map("n", "gs", "lua vim.lsp.buf.document_symbol()") + map("n", "gw", "lua vim.lsp.buf.workspace_symbol()") + map("n", "wa", "lua vim.lsp.buf.add_workspace_folder()") + map("n", "wr", "lua vim.lsp.buf.remove_workspace_folder()") + map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) -- TODO: Use the nicer new API for autocommands cmd 'augroup lsp_aucmds' @@ -163,32 +165,33 @@ local servers = { }, }, lua_ls = ({ - on_attach = on_attach, - capabilities = capabilities, + on_attach = on_attach, + capabilities = capabilities, debounce_text_changes = 500, - settings = { - Lua = { - runtime = { - version = "LuaJIT", + settings = { + Lua = { + runtime = { + version = "LuaJIT", path = vim.split(package.path, ';'), - }, - diagnostics = { + }, + diagnostics = { enable = true, - globals = { "vim" }, - }, - workspace = { + globals = { "vim" }, + }, + workspace = { maxPreload = 2000, - preloadFileSize = 50000, + preloadFileSize = 50000, checkThirdParty = false, - }, - }, - }, - }), - sqlls = {}, - tsserver = { capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + }, + }, + }, + }), + sqlls = {}, + tsserver = { + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), on_attach = function(client) - client.server_capabilities.document_formatting = false - client.server_capabilities.document_range_formatting = false + client.server_capabilities.document_formatting = false + client.server_capabilities.document_range_formatting = false end, filetypes = { 'javascript', @@ -197,7 +200,8 @@ local servers = { 'typescript', 'typescriptreact', 'typescript.tsx' - }, }, + }, + }, vimls = {}, yamlls = {}, } @@ -289,7 +293,7 @@ null_ls.setup { -- null_ls.builtins.formatting.prettier, builtins.formatting.prettier.with({ filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", - "css", "scss", "less", "graphql", "vue", "svelte" }, + "css", "scss", "less", "graphql", "vue", "svelte" }, extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, }), --null_ls.builtins.formatting.prettierd, @@ -312,16 +316,16 @@ null_ls.setup { builtins.hover.dictionary, builtins.hover.printenv, }, - on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - vim.lsp.buf.format() - end - }) + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() end - end, + }) + end + end, } -- cgit v1.2.3 From c0a98ab1876f29ca7adc6ca78a85a5871977c2f0 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:31:52 +0200 Subject: Add Terminal keys for exiting, switching windows and couple of nvim-dap keys, changed toggle diff keybinding --- lua/user/keys.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lua/user/keys.lua b/lua/user/keys.lua index ad9ca6d..8e16d03 100644 --- a/lua/user/keys.lua +++ b/lua/user/keys.lua @@ -79,6 +79,14 @@ map("n", "%", ":NumbersOnOff") --map("n", "", "") --map("n", "", "") --map("n", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("t", "", "") +map("n", "", "") +--map("n", "", ":call MyFunc(v:count)") -- Split window map("n", "h", ":split") @@ -147,7 +155,7 @@ map("n", "", ':let save_a=@a"add"ap:let @a=save_a') map("v", "sr", 'y:%s/"//gc') -- Toggle Diff -map("n", "dt", "call utils#ToggleDiff()") +map("n", "td", "call utils#ToggleDiff()") -- Map delete to Ctrl+l map("i", "", "") @@ -163,7 +171,7 @@ map("v", "p", '"_dP') -- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in -- visual mode to select text to swap with -map("v", "", "`.``gvP``P") +--map("v", "", "`.``gvP``P") -- Change Working Directory to current project map("n", "cd", ":cd %:p:h:pwd") @@ -358,14 +366,20 @@ end) -- Set breakpoints, get variable values, step into/out of functions, etc. map("n", "dl", require("dap.ui.widgets").hover) map("n", "dc", dap.continue) +map("n", "dC", dap.close) +map("n", "dt", dap.terminate) map("n", "db", dap.toggle_breakpoint) map("n", "dn", dap.step_over) map("n", "di", dap.step_into) map("n", "do", dap.step_out) -map("n", "dC", function() +map("n", "dB", function() dap.clear_breakpoints() require("notify")("Breakpoints cleared", "warn") end) +--vim.keymap.set("n", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") +--vim.keymap.set("v", "B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))") +--vim.keymap.set("n", "lp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))") +--vim.keymap.set("n", "dr", ":lua require'dap'.repl.open()") -- Close debugger and clear breakpoints map("n", "de", function() -- cgit v1.2.3 From a3dccf501dae3cfa8645784d09bd2fd3f703863c Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:37:11 +0200 Subject: Add statuscol.lua --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index 039486d..e1e0089 100644 --- a/init.lua +++ b/init.lua @@ -82,6 +82,7 @@ local modules = { "plugins.neoscroll", --"plugins.null-ls", "plugins.lsp", + "plugins.statuscol", "plugins.goto-preview", "plugins.autopairs", "plugins.navic", -- cgit v1.2.3 From 36c2f520a387176996c6082bf0e6e31c49eec278 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:37:39 +0200 Subject: Add lsp_lines.lua --- init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/init.lua b/init.lua index e1e0089..4a5f5eb 100644 --- a/init.lua +++ b/init.lua @@ -82,6 +82,7 @@ local modules = { "plugins.neoscroll", --"plugins.null-ls", "plugins.lsp", + "plugins.lsp_lines", "plugins.statuscol", "plugins.goto-preview", "plugins.autopairs", -- cgit v1.2.3 From 8dfd2e2ac634c30a2411f3e8c8ac4ae4c6a0c163 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:37:54 +0200 Subject: Add lsp_lines.lua --- lua/plugins/lsp_lines.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lua/plugins/lsp_lines.lua diff --git a/lua/plugins/lsp_lines.lua b/lua/plugins/lsp_lines.lua new file mode 100644 index 0000000..5adcb8e --- /dev/null +++ b/lua/plugins/lsp_lines.lua @@ -0,0 +1,21 @@ +local status_ok, lsp_lines = pcall(require, "lsp_lines") +if not status_ok then + return +end + +lsp_lines.setup() + +vim.keymap.set("n", "g?", function() + local lines_enabled = not vim.diagnostic.config().virtual_lines + vim.diagnostic.config( + { + virtual_lines = lines_enabled, + virtual_text = not lines_enabled + } + ) +end, { noremap = true, silent = true }) + +vim.diagnostic.config({ + virtual_text = true, + virtual_lines = false +}) -- cgit v1.2.3 From 96302cf05bda366671d831e31878beafbf8a1757 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:38:04 +0200 Subject: Add statuscol.lua --- lua/plugins/statuscol.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lua/plugins/statuscol.lua diff --git a/lua/plugins/statuscol.lua b/lua/plugins/statuscol.lua new file mode 100644 index 0000000..24a2308 --- /dev/null +++ b/lua/plugins/statuscol.lua @@ -0,0 +1,28 @@ +local status, statuscol = pcall(require, "statuscol") + +if not status then + vim.notify("statuscol not found") + return +end + +local builtin = require("statuscol.builtin") + +statuscol.setup({ + segments = { + { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + }, + ft_ignore = { + "NvimTree", + "packer", + "NeogitStatus", + "toggleterm", + "dapui_scopes", + "dapui_breakpoints", + "dapui_stacks", + "dapui_watches", + "dapui_console", + "dapui_repl", + }, +}) -- cgit v1.2.3 From 695ee0bd9c901b508af7c516010836cfaa5824f8 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:38:29 +0200 Subject: Add ensure_installed in mason-lspconfig --- lua/plugins/lsp.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 04d07ba..44f1999 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,5 +1,6 @@ require('mason').setup() local lspconfig = require 'lspconfig' +local mason_lspconfig = require 'mason-lspconfig' local null_ls = require 'null-ls' local keymap = vim.keymap @@ -206,7 +207,10 @@ local servers = { yamlls = {}, } - +mason_lspconfig.setup({ + ensure_installed = servers, -- will be installed by mason + automatic_installation = true, +}) for server, config in pairs(servers) do if config.prefer_null_ls then -- cgit v1.2.3 From 66ef08c8f7e2a23eeb761a07d76f64bfdb7a41b5 Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:39:51 +0200 Subject: Add commented code to try out and various changes to the UI which also include nvim-dap-virtual-text setup --- lua/plugins/dap.lua | 181 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 149 insertions(+), 32 deletions(-) diff --git a/lua/plugins/dap.lua b/lua/plugins/dap.lua index 9b790d9..a3e40df 100644 --- a/lua/plugins/dap.lua +++ b/lua/plugins/dap.lua @@ -1,8 +1,8 @@ local dap = require('dap') -dap.defaults.fallback.external_terminal = { - command = '/usr/bin/wezterm'; - args = {'-e'}; -} +--dap.defaults.fallback.external_terminal = { +-- command = '/usr/bin/wezterm'; +-- args = {'-e'}; +--} --dap.adapters.lldb = { -- type = 'executable', -- --command = '/usr/bin/lldb-vscode', -- adjust as needed, must be absolute path @@ -48,11 +48,11 @@ dap.adapters.cppdbg = { dap.adapters.codelldb = { type = 'server', port = '${port}', + --host = "localhost", --host = '127.0.0.1', --port = 13000, -- 💀 Use the port printed out or specified with `--port` executable = { --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', - --command = vim.env.HOME .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", args = {'--port', '${port}'}, }, @@ -67,6 +67,7 @@ dap.adapters.lldb = { dap.configurations.cpp = { { name = "Launch file", + --type = "lldb", --type = "cppdbg", type = "codelldb", request = "launch", @@ -74,12 +75,33 @@ dap.configurations.cpp = { --processId = function() -- return tonumber(vim.fn.input({ prompt = "Pid: "})) --end, + cwd = '${workspaceFolder}', program = function() return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') end, + --program = function() + -- -- First, check if exists CMakeLists.txt + -- local cwd = vim.fn.getcwd() + -- if (file.exists(cwd, "CMakeLists.txt")) then + -- -- Todo. Then invoke cmake commands + -- -- Then ask user to provide execute file + -- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + -- else + -- local fileName = vim.fn.expand("%:t:r") + -- if (not file.exists(cwd, "bin")) then + -- -- create this directory + -- os.execute("mkdir " .. "bin") + -- end + -- local cmd = "!gcc -g % -o bin/" .. fileName + -- -- First, compile it + -- vim.cmd(cmd) + -- -- Then, return it + -- return "${fileDirname}/bin/" .. fileName + -- end + --end, stopAtEntry = true, args = {}, - runInTerminal = true, + --runInTerminal = true, --runInTerminal = false, --console = 'integratedTerminal', @@ -95,7 +117,6 @@ dap.configurations.cpp = { -- ignoreFailures = false -- } --}, - cwd = '${workspaceFolder}', }, } -- dap.adapters.cppdbg = { @@ -201,42 +222,107 @@ dap.configurations.python = { }, } -local dapui = require('dapui') +--local dapui = require('dapui') +local dap_ui_status_ok, dapui = pcall(require, "dapui") +if not dap_ui_status_ok then + return +end -- 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 - } +--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 +-- } +--}) + +dapui.setup({ + layouts = { + { + elements = { + "watches", + }, + size = 0.2, + position = "left", + }, + }, + controls = { + enabled = false, + }, + render = { + max_value_lines = 3, + }, + 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", "" }, + }, + }, }) -- setup dapui dapui.setup({ - mappings = { - expand = "", - open = "o", - remove = "D", - edit = "e", - repl = "r", - toggle = "t", + mappings = { + expand = "", + open = "o", + remove = "D", + edit = "e", + repl = "r", + toggle = "t", + }, + controls = { + enabled = false, + }, + layouts = { + { + elements = { + { id = "scopes", size = 0.5 }, + { id = "watches", size = 0.5 }, + }, + size = 40, + position = "left", }, - layouts = { - { elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" }, - { elements = { "repl", "watches" }, size = 0.27, position = "bottom" }, + { + elements = { "console", "repl" }, + position = "bottom", + size = 15, }, - icons = { expanded = "-", collapsed = "$" }, - --controls = { enabled = false }, - floating = { border = "rounded", mappings = { close = { "q", "", "" } } }, + }, + render = { + max_value_lines = 3, + }, + 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", "" }, + }, + }, + --icons = { expanded = "-", collapsed = "$" }, + icons = { + expanded = "", + collapsed = "", + current_frame = "", + }, }) -- 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' }) +local sign = vim.fn.sign_define +sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) +sign('DapStopped', { text = '', texthl = 'DiagnosticSignHint', numbhl = '', linehl = '' }) +sign("DapBreakpointRejected", { text = '!>', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) +sign("DapBreakpointCondition", { text = "●", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) +sign("DapLogPoint", { text = "◆", texthl = "DapLogPoint", linehl = "", numhl = "" }) + +--sign('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', numbhl = '', linehl = '' }) +--sign("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' }) +--vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) dap.listeners.after.event_initialized["dapui_config"] = function() dapui.open() @@ -247,7 +333,38 @@ end dap.listeners.before.event_exited["dapui_config"] = function() dapui.close() end +dap.listeners.before.disconnect["dapui_config"] = function() + dapui.close() +end + +local dap_virtual_text_status_ok, dap_virtual_text_status = pcall(require, "nvim-dap-virtual-text") +if not dap_virtual_text_status_ok then + return +end +--require("nvim-dap-virtual-text").setup() + +dap_virtual_text_status.setup({ + enabled = true, -- enable this plugin (the default) + enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination) + highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText + highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables) + show_stop_reason = true, -- show stop reason when stopped for exceptions + commented = true, -- prefix virtual text with comment string + only_first_definition = true, -- only show virtual text at first definition (if there are multiple) + all_references = false, -- show virtual text on all all references of the variable (not only definitions) + filter_references_pattern = "') | endif +]]) -- options +--dap.set_exception_breakpoints("default") dap.defaults.fallback.focus_terminal = false dap.defaults.fallback.terminal_win_cmd = '10split new' -- cgit v1.2.3 From eb898ca15568c5fe80c653c03bbd7db480434ede Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 6 May 2023 20:41:03 +0200 Subject: Remove alpha commented out plugin and add comment to nvim-ufo --- lua/user/pack.lua | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lua/user/pack.lua b/lua/user/pack.lua index e618a3d..f71e114 100644 --- a/lua/user/pack.lua +++ b/lua/user/pack.lua @@ -205,14 +205,7 @@ return packer.startup(function(use) -- UI use("kyazdani42/nvim-web-devicons") -- use("onsails/lspkind-nvim") -- - --use({ - -- 'goolord/alpha-nvim', - -- requires = { 'nvim-tree/nvim-web-devicons' }, - -- config = function () - -- require'alpha'.setup(require'alpha.themes.startify'.config) - -- end - --}) - use ({'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}) + use ({'kevinhwang91/nvim-ufo', requires = 'kevinhwang91/promise-async'}) -- Fold code use ({"luukvbaal/statuscol.nvim", config = function() local builtin = require "statuscol.builtin" -- cgit v1.2.3