From d5f881f96abd75f0fd814c2d18ad74420bbd676e Mon Sep 17 00:00:00 2001 From: Krzysiek Wyka Date: Fri, 6 Feb 2026 12:49:40 +0100 Subject: [PATCH] Make nvim great again --- init.lua | 34 +++------ lua/custom/plugins/copilot.lua | 11 --- lua/kickstart/plugins/debug.lua | 129 ++++++++++++++++++++++++++------ 3 files changed, 119 insertions(+), 55 deletions(-) delete mode 100644 lua/custom/plugins/copilot.lua diff --git a/init.lua b/init.lua index 44008d7c..331f2b12 100644 --- a/init.lua +++ b/init.lua @@ -861,30 +861,20 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, + { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', - build = ':TSUpdate', - main = 'nvim-treesitter.configs', -- Sets main module to use for opts - -- [[ Configure Treesitter ]] See `:help nvim-treesitter` - opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'typescript', 'javascript' }, - -- Autoinstall languages that are not installed - auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, - }, - -- There are additional nvim-treesitter modules that you can use to interact - -- with nvim-treesitter. You should go explore a few and see what interests you: - -- - -- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod` - -- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context - -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects + config = function() + local filetypes = + { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'typescript', 'javascript', 'graphql' } + require('nvim-treesitter').install(filetypes) + vim.api.nvim_create_autocmd('FileType', { + pattern = filetypes, + callback = function() + vim.treesitter.start() + end, + }) + end, }, -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua deleted file mode 100644 index b9c3afe0..00000000 --- a/lua/custom/plugins/copilot.lua +++ /dev/null @@ -1,11 +0,0 @@ -return { - { - 'CopilotC-Nvim/CopilotChat.nvim', - dependencies = { - { 'github/copilot.vim' }, - { 'nvim-lua/plenary.nvim', branch = 'master' }, - }, - build = 'make tiktoken', - opts = {}, - }, -} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index d83598c0..c5b730e0 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -23,10 +23,12 @@ return { -- Add your own debuggers here 'leoluz/nvim-dap-go', - 'mxsdev/nvim-dap-vscode-js', -- Virtual text 'theHamsta/nvim-dap-virtual-text', + + -- JSON5 parser for .vscode/launch.json (supports comments and trailing commas) + 'Joakker/lua-json5', }, keys = { -- Basic debugging keymaps, feel free to change to your liking! @@ -37,6 +39,19 @@ return { end, desc = 'Debug: Start/Continue', }, + { + '', + function() + local dap = require('dap') + dap.terminate() + vim.defer_fn(function() + if dap.session() then + dap.close() + end + end, 500) + end, + desc = 'Debug: Stop/Terminate', + }, { '', function() @@ -80,6 +95,18 @@ return { end, desc = 'Debug: See last session result.', }, + { + 'dt', + function() + require('dap').terminate() + vim.defer_fn(function() + if require('dap').session() then + require('dap').close() + end + end, 500) + end, + desc = 'Debug: Terminate Session', + }, }, config = function() local dap = require 'dap' @@ -103,8 +130,13 @@ return { }, } - -- Read .vscode/launch.json - require('dap.ext.vscode').load_launchjs(nil, {}) + -- Enable JSON5 parser for .vscode/launch.json to support comments and trailing commas + -- nvim-dap will automatically load .vscode/launch.json configurations via dap.launch.json provider + -- This allows you to use VSCode-style launch.json files with JavaScript-style comments + local ok, json5 = pcall(require, 'json5') + if ok then + require('dap.ext.vscode').json_decode = json5.parse + end -- Basic debugging keymaps, feel free to change to your liking! vim.keymap.set('n', '', dap.continue, { desc = 'Debug: Start/Continue' }) @@ -116,6 +148,16 @@ return { dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, { desc = 'Debug: Set Breakpoint' }) + -- Terminate session (with force close after timeout) + vim.keymap.set('n', 'dt', function() + dap.terminate() + vim.defer_fn(function() + if dap.session() then + dap.close() + end + end, 500) + end, { desc = 'Debug: Terminate Session' }) + -- Dap virtual text setup require('nvim-dap-virtual-text').setup() @@ -192,37 +234,80 @@ return { -- end dap.listeners.after.event_initialized['dapui_config'] = dapui.open - dap.listeners.before.event_terminated['dapui_config'] = dapui.close - dap.listeners.before.event_exited['dapui_config'] = dapui.close + dap.listeners.after.event_terminated['dapui_config'] = dapui.close + dap.listeners.after.event_exited['dapui_config'] = dapui.close + -- Configure vscode-js-debug adapter (installed via Mason as js-debug-adapter) + -- NOTE: We configure this manually instead of using nvim-dap-vscode-js plugin + -- because that plugin is unmaintained. Direct configuration is the recommended + -- approach in 2026 and provides better control. + -- This adapter supports Node.js debugging dap.adapters['pwa-node'] = { type = 'server', - host = '::1', + host = 'localhost', port = '${port}', executable = { - command = 'js-debug-adapter', + command = vim.fn.stdpath 'data' .. '/mason/bin/js-debug-adapter', args = { '${port}' }, }, + options = { + disconnect_on_terminate = true, + }, } - local js_based_languages = { 'typescript', 'javascript' } + -- Configure debugging for JavaScript/TypeScript + local js_based_languages = { 'typescript', 'javascript', 'typescriptreact', 'javascriptreact' } for _, language in ipairs(js_based_languages) do dap.configurations[language] = { - -- { - -- type = 'pwa-node', - -- request = 'launch', - -- name = 'Launch file', - -- program = '${file}', - -- cwd = '${workspaceFolder}', - -- }, - -- { - -- type = 'pwa-node', - -- request = 'attach', - -- name = 'Attach', - -- processId = require('dap.utils').pick_process, - -- cwd = '${workspaceFolder}', - -- } + { + type = 'pwa-node', + request = 'launch', + name = 'Launch Current File (Node)', + program = '${file}', + cwd = '${workspaceFolder}', + sourceMaps = true, + protocol = 'inspector', + console = 'integratedTerminal', + }, + { + type = 'pwa-node', + request = 'launch', + name = 'Launch Program', + program = '${workspaceFolder}/dist/index.js', + cwd = '${workspaceFolder}', + sourceMaps = true, + protocol = 'inspector', + console = 'integratedTerminal', + preLaunchTask = 'npm: build', + }, + { + type = 'pwa-node', + request = 'attach', + name = 'Attach to Process', + processId = require('dap.utils').pick_process, + cwd = '${workspaceFolder}', + sourceMaps = true, + protocol = 'inspector', + }, + { + type = 'pwa-node', + request = 'launch', + name = 'Debug Jest Tests', + runtimeExecutable = 'node', + runtimeArgs = { + './node_modules/jest/bin/jest.js', + '--runInBand', + '--no-coverage', + '--no-cache', + '--watchAll=false', + }, + rootPath = '${workspaceFolder}', + cwd = '${workspaceFolder}', + console = 'integratedTerminal', + internalConsoleOptions = 'neverOpen', + sourceMaps = true, + }, } end end,