Make nvim great again
This commit is contained in:
parent
6cf3d0015e
commit
d5f881f96a
34
init.lua
34
init.lua
|
|
@ -861,30 +861,20 @@ require('lazy').setup({
|
||||||
-- Check out: https://github.com/echasnovski/mini.nvim
|
-- Check out: https://github.com/echasnovski/mini.nvim
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- Highlight, edit, and navigate code
|
{ -- Highlight, edit, and navigate code
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
build = ':TSUpdate',
|
config = function()
|
||||||
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
local filetypes =
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
{ 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'typescript', 'javascript', 'graphql' }
|
||||||
opts = {
|
require('nvim-treesitter').install(filetypes)
|
||||||
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'typescript', 'javascript' },
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
-- Autoinstall languages that are not installed
|
pattern = filetypes,
|
||||||
auto_install = true,
|
callback = function()
|
||||||
highlight = {
|
vim.treesitter.start()
|
||||||
enable = true,
|
end,
|
||||||
-- 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
|
end,
|
||||||
-- 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
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
-- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
return {
|
|
||||||
{
|
|
||||||
'CopilotC-Nvim/CopilotChat.nvim',
|
|
||||||
dependencies = {
|
|
||||||
{ 'github/copilot.vim' },
|
|
||||||
{ 'nvim-lua/plenary.nvim', branch = 'master' },
|
|
||||||
},
|
|
||||||
build = 'make tiktoken',
|
|
||||||
opts = {},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -23,10 +23,12 @@ return {
|
||||||
|
|
||||||
-- Add your own debuggers here
|
-- Add your own debuggers here
|
||||||
'leoluz/nvim-dap-go',
|
'leoluz/nvim-dap-go',
|
||||||
'mxsdev/nvim-dap-vscode-js',
|
|
||||||
|
|
||||||
-- Virtual text
|
-- Virtual text
|
||||||
'theHamsta/nvim-dap-virtual-text',
|
'theHamsta/nvim-dap-virtual-text',
|
||||||
|
|
||||||
|
-- JSON5 parser for .vscode/launch.json (supports comments and trailing commas)
|
||||||
|
'Joakker/lua-json5',
|
||||||
},
|
},
|
||||||
keys = {
|
keys = {
|
||||||
-- Basic debugging keymaps, feel free to change to your liking!
|
-- Basic debugging keymaps, feel free to change to your liking!
|
||||||
|
|
@ -37,6 +39,19 @@ return {
|
||||||
end,
|
end,
|
||||||
desc = 'Debug: Start/Continue',
|
desc = 'Debug: Start/Continue',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'<S-F5>',
|
||||||
|
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',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'<F1>',
|
'<F1>',
|
||||||
function()
|
function()
|
||||||
|
|
@ -80,6 +95,18 @@ return {
|
||||||
end,
|
end,
|
||||||
desc = 'Debug: See last session result.',
|
desc = 'Debug: See last session result.',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'<leader>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()
|
config = function()
|
||||||
local dap = require 'dap'
|
local dap = require 'dap'
|
||||||
|
|
@ -103,8 +130,13 @@ return {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Read .vscode/launch.json
|
-- Enable JSON5 parser for .vscode/launch.json to support comments and trailing commas
|
||||||
require('dap.ext.vscode').load_launchjs(nil, {})
|
-- 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!
|
-- Basic debugging keymaps, feel free to change to your liking!
|
||||||
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
|
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
|
||||||
|
|
@ -116,6 +148,16 @@ return {
|
||||||
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
||||||
end, { desc = 'Debug: Set Breakpoint' })
|
end, { desc = 'Debug: Set Breakpoint' })
|
||||||
|
|
||||||
|
-- Terminate session (with force close after timeout)
|
||||||
|
vim.keymap.set('n', '<leader>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
|
-- Dap virtual text setup
|
||||||
require('nvim-dap-virtual-text').setup()
|
require('nvim-dap-virtual-text').setup()
|
||||||
|
|
||||||
|
|
@ -192,37 +234,80 @@ return {
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
||||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
dap.listeners.after.event_terminated['dapui_config'] = dapui.close
|
||||||
dap.listeners.before.event_exited['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'] = {
|
dap.adapters['pwa-node'] = {
|
||||||
type = 'server',
|
type = 'server',
|
||||||
host = '::1',
|
host = 'localhost',
|
||||||
port = '${port}',
|
port = '${port}',
|
||||||
executable = {
|
executable = {
|
||||||
command = 'js-debug-adapter',
|
command = vim.fn.stdpath 'data' .. '/mason/bin/js-debug-adapter',
|
||||||
args = { '${port}' },
|
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
|
for _, language in ipairs(js_based_languages) do
|
||||||
dap.configurations[language] = {
|
dap.configurations[language] = {
|
||||||
-- {
|
{
|
||||||
-- type = 'pwa-node',
|
type = 'pwa-node',
|
||||||
-- request = 'launch',
|
request = 'launch',
|
||||||
-- name = 'Launch file',
|
name = 'Launch Current File (Node)',
|
||||||
-- program = '${file}',
|
program = '${file}',
|
||||||
-- cwd = '${workspaceFolder}',
|
cwd = '${workspaceFolder}',
|
||||||
-- },
|
sourceMaps = true,
|
||||||
-- {
|
protocol = 'inspector',
|
||||||
-- type = 'pwa-node',
|
console = 'integratedTerminal',
|
||||||
-- request = 'attach',
|
},
|
||||||
-- name = 'Attach',
|
{
|
||||||
-- processId = require('dap.utils').pick_process,
|
type = 'pwa-node',
|
||||||
-- cwd = '${workspaceFolder}',
|
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
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue