diff options
Diffstat (limited to '.config/nvim')
| -rw-r--r-- | .config/nvim/init.lua | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/colorscheme.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/dap.lua | 382 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 182 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp_lines.lua | 21 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/statuscol.lua | 28 | ||||
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 21 | ||||
| -rw-r--r-- | .config/nvim/lua/user/pack.lua | 26 |
8 files changed, 505 insertions, 164 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 04c63b0..4a5f5eb 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -82,6 +82,8 @@ local modules = { "plugins.neoscroll", --"plugins.null-ls", "plugins.lsp", + "plugins.lsp_lines", + "plugins.statuscol", "plugins.goto-preview", "plugins.autopairs", "plugins.navic", @@ -92,7 +94,7 @@ local modules = { "plugins.toggleterm", "plugins.trouble", "plugins.dashboard", - --"plugins.dap", + "plugins.dap", --"plugins.modify-blend", --"plugins.floatterm", } diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index 1ad9ce8..2735204 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/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!") @@ -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") diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua index 3d7059a..a3e40df 100644 --- a/.config/nvim/lua/plugins/dap.lua +++ b/.config/nvim/lua/plugins/dap.lua @@ -1,57 +1,208 @@ local dap = require('dap') -dap.adapters.lldb = { +--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 = '/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 = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', + command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7', } --- cpp (c,c++,rust) +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 = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", + args = {'--port', '${port}'}, + }, + --detached = true, +} + +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', + name = "lldb" +} dap.configurations.cpp = { { - name = 'Launch', - type = 'lldb', - request = 'launch', - --program = function() - -- return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + name = "Launch file", + --type = "lldb", + --type = "cppdbg", + type = "codelldb", + request = "launch", + --request = "Attach", + --processId = function() + -- return tonumber(vim.fn.input({ prompt = "Pid: "})) --end, - terminal = 'integrated', - console = 'integratedTerminal', + cwd = '${workspaceFolder}', 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, + --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 = false, + --console = 'integratedTerminal', + + --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 + -- } + --}, +}, } +-- 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'; @@ -71,44 +222,149 @@ 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", "<Esc>" }, + }, + }, }) -- setup dapui dapui.setup({ - mappings = { - expand = "<CR>", - open = "o", - remove = "D", - edit = "e", - repl = "r", - toggle = "t", + mappings = { + expand = "<CR>", + 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", + }, + { + elements = { "console", "repl" }, + position = "bottom", + size = 15, }, - layouts = { - { elements = { "scopes", "breakpoints", "stacks" }, size = 0.33, position = "right" }, - { elements = { "repl", "watches" }, size = 0.27, position = "bottom" }, + }, + 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", "<Esc>" }, }, - icons = { expanded = "-", collapsed = "$" }, - controls = { enabled = false }, - floating = { border = "rounded", mappings = { close = { "q", "<esc>", "<c-o>" } } }, + }, + --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() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +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 = "<module", -- filter references (not definitions) pattern when all_references is activated (Lua gmatch pattern, default filters out Python modules) + -- 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) , + -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()` +}) + +vim.cmd([[ + autocmd TermClose * if !v:event.status | exe 'bdelete! '..expand('<abuf>') | endif +]]) -- options +--dap.set_exception_breakpoints("default") dap.defaults.fallback.focus_terminal = false dap.defaults.fallback.terminal_win_cmd = '10split new' - diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index 6c40c9c..44f1999 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,48 +1,50 @@ require('mason').setup() local lspconfig = require 'lspconfig' +local mason_lspconfig = require 'mason-lspconfig' local null_ls = require 'null-ls' 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 +55,39 @@ local on_attach = function(client, bufnr) -- Enable completion triggered by <c-x><c-o> 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", "<Cmd>lua vim.lsp.buf.hover()<CR>") + map("n", "K", "<Cmd>lua vim.lsp.buf.hover()<CR>") --map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") map("n", "gd", "<cmd>lua require('goto-preview').goto_preview_definition()<CR>") - --map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") - map("n", "gi", "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>") - --map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") - map("n", "gr", "<cmd>lua require('goto-preview').goto_preview_references()<CR>") - map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. - map("n", "<leader>k", "<Cmd>lua vim.lsp.buf.signature_help()<CR>") - --map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") - map("n", "gt", "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>") - map("n", "gn", "<Cmd>lua vim.lsp.buf.rename()<CR>") - map("n", "ga", "<Cmd>lua vim.lsp.buf.code_action()<CR>") + --map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") + map("n", "gi", "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>") + --map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") + map("n", "gr", "<cmd>lua require('goto-preview').goto_preview_references()<CR>") + map("n", "gD", "<Cmd>lua vim.lsp.buf.declaration()<CR>") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map("n", "<leader>k", "<Cmd>lua vim.lsp.buf.signature_help()<CR>") + --map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") + map("n", "gt", "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>") + map("n", "gn", "<Cmd>lua vim.lsp.buf.rename()<CR>") + map("n", "ga", "<Cmd>lua vim.lsp.buf.code_action()<CR>") map("n", "gf", "<Cmd>lua vim.lsp.buf.formatting()<CR>") - map("n", "go", "<Cmd>lua vim.diagnostic.open_float()<CR>") - map("n", "<leader>go", ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") - map("n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>") - map("n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>") - map("n", "gs", "<Cmd>lua vim.lsp.buf.document_symbol()<CR>") - map("n", "gw", "<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>") - map("n", "<leader>wa", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>") - map("n", "<leader>wr", "<Cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>") - map("n", "<leader>wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end) + map("n", "go", "<Cmd>lua vim.diagnostic.open_float()<CR>") + map("n", "<leader>go", + ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") + map("n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>") + map("n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>") + map("n", "gs", "<Cmd>lua vim.lsp.buf.document_symbol()<CR>") + map("n", "gw", "<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>") + map("n", "<leader>wa", "<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>") + map("n", "<leader>wr", "<Cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>") + map("n", "<leader>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 +166,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,12 +201,16 @@ local servers = { 'typescript', 'typescriptreact', 'typescript.tsx' - }, }, + }, + }, vimls = {}, 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 @@ -289,7 +297,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 +320,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, } diff --git a/.config/nvim/lua/plugins/lsp_lines.lua b/.config/nvim/lua/plugins/lsp_lines.lua new file mode 100644 index 0000000..5adcb8e --- /dev/null +++ b/.config/nvim/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 +}) diff --git a/.config/nvim/lua/plugins/statuscol.lua b/.config/nvim/lua/plugins/statuscol.lua new file mode 100644 index 0000000..24a2308 --- /dev/null +++ b/.config/nvim/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", + }, +}) diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index c0592da..8e16d03 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -29,6 +29,7 @@ map("n", "<leader><CR>", --------------- 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? @@ -78,6 +79,14 @@ map("n", "<leader>%", ":NumbersOnOff<CR>") --map("n", "<C-K>", "<C-W><C-K>") --map("n", "<C-L>", "<C-W><C-L>") --map("n", "<C-H>", "<C-W><C-H>") +map("t", "<C-[>", "<C-\\><C-N>") +map("t", "<C-h>", "<C-\\><C-N><C-h>") +map("t", "<C-j>", "<C-\\><C-N><C-j>") +map("t", "<C-k>", "<C-\\><C-N><C-k>") +map("t", "<C-l>", "<C-\\><C-N><C-l>") +map("t", "<C-x>", "<C-c>") +map("n", "<C-x>", "<C-c>") +--map("n", "<C-r>", ":<C-u>call MyFunc(v:count)<CR>") -- Split window map("n", "<leader>h", ":split<CR>") @@ -146,7 +155,7 @@ map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>') map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') -- Toggle Diff -map("n", "<leader>dt", "<Cmd>call utils#ToggleDiff()<CR>") +map("n", "<leader>td", "<Cmd>call utils#ToggleDiff()<CR>") -- Map delete to Ctrl+l map("i", "<C-l>", "<Del>") @@ -162,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", "<C-X>", "<Esc>`.``gvP``P") +--map("v", "<C-X>", "<Esc>`.``gvP``P") -- Change Working Directory to current project map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") @@ -357,14 +366,20 @@ end) -- Set breakpoints, get variable values, step into/out of functions, etc. map("n", "<leader>dl", require("dap.ui.widgets").hover) map("n", "<leader>dc", dap.continue) +map("n", "<leader>dC", dap.close) +map("n", "<leader>dt", dap.terminate) map("n", "<leader>db", dap.toggle_breakpoint) map("n", "<leader>dn", dap.step_over) map("n", "<leader>di", dap.step_into) map("n", "<leader>do", dap.step_out) -map("n", "<leader>dC", function() +map("n", "<leader>dB", function() dap.clear_breakpoints() require("notify")("Breakpoints cleared", "warn") end) +--vim.keymap.set("n", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>") +--vim.keymap.set("v", "<leader>B", ":lua require'dap'.set_breakpoint(vim.fn.input('Breakpoint condition: '))<CR>") +--vim.keymap.set("n", "<leader>lp", ":lua require'dap'.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))<CR>") +--vim.keymap.set("n", "<leader>dr", ":lua require'dap'.repl.open()<CR>") -- Close debugger and clear breakpoints map("n", "<leader>de", function() diff --git a/.config/nvim/lua/user/pack.lua b/.config/nvim/lua/user/pack.lua index 951e9f7..f71e114 100644 --- a/.config/nvim/lua/user/pack.lua +++ b/.config/nvim/lua/user/pack.lua @@ -73,9 +73,13 @@ 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 + use("theHamsta/nvim-dap-virtual-text") use("gabrielpoca/replacer.nvim") use({ "jayp0521/mason-nvim-dap.nvim", @@ -114,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 @@ -200,13 +205,20 @@ 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'}) -- Fold code + 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', |
