feat: almost add debugger

main
jaredgoldman 2024-08-06 00:26:50 -04:00
parent 697bc4bb2c
commit a94738e4a4
44 changed files with 129 additions and 387 deletions

0
.github/CONTRIBUTING.md vendored 100644 → 100755
View File

0
.github/FUNDING.yml vendored 100644 → 100755
View File

0
.github/ISSUE_TEMPLATE/bug_report.md vendored 100644 → 100755
View File

0
.github/ISSUE_TEMPLATE/config.yml vendored 100644 → 100755
View File

0
.github/ISSUE_TEMPLATE/feature_request.md vendored 100644 → 100755
View File

0
.github/PULL_REQUEST_TEMPLATE/feature.md vendored 100644 → 100755
View File

0
.github/PULL_REQUEST_TEMPLATE/plugin.md vendored 100644 → 100755
View File

0
.github/README.md vendored 100644 → 100755
View File

0
.github/workflows/stale.yml vendored 100644 → 100755
View File

0
README.md 100644 → 100755
View File

6
init.lua 100644 → 100755
View File

@ -1,6 +1,4 @@
require("plugins")
require("colorscheme")
require("lsp")
require("config.telescope")
require("config.comment")
require("config.mason")
@ -13,6 +11,10 @@ require("config.harpoon")
require("config.autopairs")
require("config.autotags")
require("config.conform")
-- require("config.dapui")
require("colorscheme")
require("options")
require("keymaps")
require("commands")
require("lsp")
require("dap_config")

21
lazy-lock.json 100644 → 100755
View File

@ -1,7 +1,7 @@
{
"FTerm.nvim": { "branch": "master", "commit": "d1320892cc2ebab472935242d9d992a2c9570180" },
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"catppuccin": { "branch": "main", "commit": "10eda02ea4faa7d1f94e77a3410a4ae91c25c5f5" },
"catppuccin": { "branch": "main", "commit": "e1268d1c0351aa5a42ea00a680ce84de2ba080fc" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
@ -11,25 +11,28 @@
"dashboard-nvim": { "branch": "master", "commit": "fabf5feec96185817c732d47d363f34034212685" },
"git-blame.nvim": { "branch": "master", "commit": "50543e3993f4b996eea01ff5ccc8fe2a354c5388" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lspkind.nvim": { "branch": "master", "commit": "cff4ae321a91ee3473a92ea1a8c637e3a9510aec" },
"lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4ba55f9755ebe8297d92c419b90a946123292ae6" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "62360f061d45177dda8afc1b0fd1327328540301" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"monokai.nvim": { "branch": "master", "commit": "b8bd44d5796503173627d7a1fc51f77ec3a08a63" },
"nvim-autopairs": { "branch": "master", "commit": "e38c5d837e755ce186ae51d2c48e1b387c4425c6" },
"nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
"nvim-dap": { "branch": "master", "commit": "bc03b83c94d0375145ff5ac6a6dcf28c1241e06f" },
"nvim-dap": { "branch": "master", "commit": "dcc85d12d6e2c18c5fa0f9a304d9f5e767e1401a" },
"nvim-dap-ui": { "branch": "master", "commit": "a5606bc5958db86f8d92803bea7400ee26a8d7e4" },
"nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" },
"nvim-grey": { "branch": "main", "commit": "b57f62baddc5a295bd0ffd61ff9a671a149df95a" },
"nvim-lspconfig": { "branch": "master", "commit": "f95d371c1a274f60392edfd8ea5121b42dca736e" },
"nvim-lspconfig": { "branch": "master", "commit": "81a19de18990208b678be084597613e2dbe66912" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-tree.lua": { "branch": "master", "commit": "48d0e82f9434691cc50d970898142a8c084a49d6" },
"nvim-treesitter": { "branch": "master", "commit": "2d5133f67429f82547ea5fad33a0b1e7d4f78a1c" },
"nvim-treesitter": { "branch": "master", "commit": "1aad04ecde5ebf8f2b3eea5c6f39d38b251757f5" },
"nvim-ts-autotag": { "branch": "main", "commit": "dc5e1687ab76ee02e0f11c5ce137f530b36e98b3" },
"nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"telescope.nvim": { "branch": "master", "commit": "6312868392331c9c0f22725041f1ec2bef57c751" },
"themery.nvim": { "branch": "main", "commit": "f745a49d9c103babde35e1111b91faa6bc591d5c" },
"vim-maximizer": { "branch": "master", "commit": "2e54952fe91e140a2e69f35f22131219fcd9c5f1" },
"vscode-js-debug": { "branch": "main", "commit": "14b430024ccadd5e573228214a39fac7781bd759" }
"vscode-js-debug": { "branch": "main", "commit": "ca1c6450490dab5d742eac16a08d593533a1a13d" }
}

8
lua/colorscheme.lua 100644 → 100755
View File

@ -6,3 +6,11 @@ if not is_ok then
vim.notify('colorscheme ' .. colorscheme .. ' not found!')
return
end
vim.api.nvim_create_augroup('WinHighlight', {clear = true})
vim.api.nvim_create_autocmd({'ColorScheme'}, {
group = 'WinHighlight',
callback = function()
vim.api.nvim_set_hl(0, 'VertSplit', {fg = '#ff0000'})
end
})

0
lua/commands.lua 100644 → 100755
View File

0
lua/config/autopairs.lua 100644 → 100755
View File

0
lua/config/autotags.lua 100644 → 100755
View File

0
lua/config/comment.lua 100644 → 100755
View File

0
lua/config/conform.lua 100644 → 100755
View File

View File

@ -0,0 +1,13 @@
local dap, dapui = require("dap"), require("dapui")
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
vim.keymap.set("n", "<leader>ui", require("dapui").toggle)

View File

@ -1,30 +0,0 @@
require("dap-vscode-js").setup({
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
-- debugger_path = "(runtimedir)/site/pack/packer/opt/vscode-js-debug", -- Path to vscode-js-debug installation.
-- debugger_cmd = { "js-debug-adapter" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, -- which adapters to register in nvim-dap
-- log_file_path = "(stdpath cache)/dap_vscode_js.log" -- Path for file logging
-- log_file_level = false -- Logging level for output to file. Set to false to disable file logging.
-- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output.
})
for _, language in ipairs({ "typescript", "javascript" }) do
require("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}",
}
}
}
end

0
lua/config/dashboard.lua 100644 → 100755
View File

0
lua/config/fterm.lua 100644 → 100755
View File

0
lua/config/harpoon.lua 100644 → 100755
View File

0
lua/config/lualine.lua 100644 → 100755
View File

0
lua/config/mason.lua 100644 → 100755
View File

0
lua/config/nvim-cmp.lua 100644 → 100755
View File

0
lua/config/nvim-tree.lua 100644 → 100755
View File

0
lua/config/telescope.lua 100644 → 100755
View File

0
lua/config/theme.lua 100644 → 100755
View File

0
lua/config/themery.lua 100644 → 100755
View File

View File

@ -1,70 +0,0 @@
---@type ChadrcConfig
local M = {}
-- Path to overriding theme and highlights files
local highlights = require "custom.highlights"
M.ui = {
theme = "catppuccin",
theme_toggle = { "catppuccin", "one_light" },
hl_override = highlights.override,
hl_add = highlights.add,
tabufline = {
enabled = false,
},
}
M.plugins = "custom.plugins"
M.mappings = require "custom.mappings"
-- M.options = require "custom.options"
local opt = vim.opt
local api = vim.api
-- line numbers
opt.number = true
-- tabs & indentation
opt.tabstop = 4
opt.shiftwidth = 4
opt.expandtab = true
opt.smartindent = true
opt.autoindent = true
opt.cindent = true
opt.softtabstop = 4
-- lne wrapping
opt.wrap = false
-- search settings
opt.ignorecase = true
opt.smartcase = true
-- cursor line
opt.cursorline = true
-- backspace
opt.backspace = "indent,eol,start"
-- autoread
opt.autoread = true
-- Function to set autocmd
local function set_autocmd(event, pattern, command)
vim.cmd(string.format("autocmd %s %s %s", event, pattern, command))
end
-- Trigger 'checktime' on 'CursorHold' event
set_autocmd("CursorHold", "*", "checktime")
-- Show trailing whitespace
api.nvim_set_option("list", true)
api.nvim_set_option("listchars", "eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<")
-- remove whitespace on save
api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[if &filetype !~# 'lsp' | %s/\s\+$//e | endif]],
})
return M

View File

@ -1,24 +0,0 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require "lspconfig"
-- if you just want default config for the servers then put them in a table
local servers = {
"html",
"cssls",
"tsserver",
"intelephense",
"pyright",
"tailwindcss",
"cssmodules_ls",
"emmet_ls",
"lua_ls",
}
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end

View File

@ -1,33 +0,0 @@
---------------------------------
-- Formatting
---------------------------------
local diagnostics = require("null-ls").builtins.diagnostics
local formatting = require("null-ls").builtins.formatting
local code_actions = require("null-ls").builtins.code_actions
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
require("null-ls").setup {
debug = true,
sources = {
formatting.black,
formatting.rustfmt,
formatting.prettier,
formatting.stylua,
diagnostics.shellcheck.with { diagnostics_format = "#{m} [#{c}]" },
diagnostics.eslint_d.with { diagnostics_format = "#{m} [#{c}]" },
code_actions.eslint,
code_actions.eslint_d,
},
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 { bufnr = bufnr }
end,
})
end
end,
}

View File

@ -1,62 +0,0 @@
local M = {}
M.treesitter = {
ensure_installed = {
"lua",
"css",
"javascript",
"html",
"typescript",
"tsx",
},
indent = {
enable = true,
},
highlight = {
enable = true,
},
autotag = {
enable = true,
},
context_commentstring = {
enable = true,
},
}
M.mason = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"html-lsp",
"json-lsp",
"typescript-language-server",
"deno",
"prettier",
"intelephense",
"tailwindcss",
"lua",
"prisma-language-server",
"graphql",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
return M

View File

@ -1,21 +0,0 @@
-- To find any highlight groups: "<cmd> Telescope highlights"
-- Each highlight group can take a table with variables fg, bg, bold, italic, etc
-- base30 variable names can also be used as colors
local M = {}
---@type Base46HLGroupsList
M.override = {
Comment = {
fg = "#8294c2", -- Lightened color
italic = true,
},
}
---@type HLTable
M.add = {
NvimTreeOpenedFolderName = { fg = "green", bold = true },
}
return M

View File

@ -1,34 +0,0 @@
---@type MappingsTable
--
local M = {}
local opts = { noremap = true, silent = true }
M.general = {
n = {
["<leader>nh"] = { ":nohl<CR>", "nohl", opts },
["<leader>sv"] = { "<C-w>s", "split window vertically", opts },
["<leader>sh"] = { "<C-w>v", "split window horizontally", opts },
["<leader>se"] = { "<C-w>=", "make split windows even width", opts },
["<leader>sx"] = { ":close<CR>", "close current split window", opts },
["<leader>tx"] = { ":tabclose<CR>", "close current tab", opts },
["<leader>e"] = { ":NvimTreeToggle<CR>", "nvim-tree", opts },
["<leader>ls"] = { ":LspStop<CR>", "LSP", opts },
["<leader>lo"] = { ":LspStart<CR>", "LSP", opts },
["<leader>cf"] = { ":NvimTreeCollapse<CR>", "nvim-tree", opts },
},
x = {
["J"] = { ":move '>+1<CR>gv-gv", "Move text up", opts },
["K"] = { ":move '<-2<CR>gv-gv", "Move text down", opts },
["<A-j>"] = { ":move '>+1<CR>gv-gv", "Move text up", opts },
["<A-k>"] = { ":move '<-2<CR>gv-gv", "Move text down", opts },
},
i = {
["C-j"] = { 'copilot#Accept("<CR>")', "Copilot accept", { silent = true, expr = true } },
["<M-l>"] = { "<ESC>", "escape", opts },
},
}
return M

View File

@ -1,34 +0,0 @@
local opt = vim.opt
local api = vim.api
-- line numbers
opt.number = true
-- tabs & indentation
opt.tabstop = 4
opt.shiftwidth = 4
opt.expandtab = true
opt.autoindent = true
opt.softtabstop = 2
-- lne wrapping
opt.wrap = false
-- search settings
opt.ignorecase = true
opt.smartcase = true
-- cursor line
opt.cursorline = true
-- backspace
opt.backspace = "indent,eol,start"
-- Show trailing whitespace
api.nvim_set_option("list", true)
api.nvim_set_option("listchars", "eol:$,nbsp:_,tab:>-,trail:~,extends:>,precedes:<")
-- remove whitespace on save
api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[if &filetype !~# 'lsp' | %s/\s\+$//e | endif]],
})

View File

@ -1,61 +0,0 @@
local overrides = require "custom.configs.overrides"
---@type NvPluginSpec[]
local plugins = {
{
"neovim/nvim-lspconfig",
dependencies = {
-- format & linting
{
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
{
"williamboman/mason.nvim",
opts = overrides.mason,
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring",
},
config = function()
require("ts_context_commentstring").setup {}
end,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
{
"github/copilot.vim",
lazy = false,
},
{
"prettier/vim-prettier",
run = "yarn install",
},
{
"windwp/nvim-ts-autotag",
lazy = false,
config = function()
require("nvim-ts-autotag").setup()
end,
},
{ "akinsho/git-conflict.nvim", version = "*", config = true, lazy = false },
{ "f-person/git-blame.nvim", lazy = false },
}
return plugins

78
lua/dap_config.lua 100755
View File

@ -0,0 +1,78 @@
local dap, dapui = require("dap"), require("dapui")
require("dapui").setup()
-- -- Set keymaps to control the debugger
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F10>", dap.step_over)
vim.keymap.set("n", "<F11>", dap.step_into)
vim.keymap.set("n", "<F12>", dap.step_out)
vim.keymap.set("n", "<leader>b", dap.toggle_breakpoint)
vim.keymap.set("n", "<leader>B", function()
dap.set_breakpoint(vim.fn.input("Breakpoint condition: "))
end)
require("dap-vscode-js").setup({
-- node_path = "node", -- Path of node executable. Defaults to $NODE_PATH, and then "node"
debugger_path = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug", -- Path to vscode-js-debug installation.
-- debugger_cmd = { "extension" }, -- Command to use to launch the debug server. Takes precedence over `node_path` and `debugger_path`.
adapters = {
"chrome",
"pwa-node",
"pwa-chrome",
"pwa-msedge",
"node-terminal",
"pwa-extensionHost",
"node",
"chrome",
}, -- which adapters to register in nvim-dap
log_file_path = "(stdpath cache)/dap_vscode_js.log", -- Path for file logging
-- log_file_level = false -- Logging level for output to file. Set to false to disable file logging.
-- log_console_level = vim.log.levels.ERROR -- Logging level for output to console. Set to false to disable console output.
})
local js_based_languages = { "typescript", "javascript", "typescriptreact" }
for _, language in ipairs(js_based_languages) do
require("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-chrome",
request = "launch",
name = 'Start Chrome with "localhost"',
url = "http://localhost:3000",
webRoot = "${workspaceFolder}",
userDataDir = "${workspaceFolder}/.vscode/vscode-chrome-debug-userdatadir",
},
}
end
dap.listeners.before.attach.dapui_config = function()
print("before attach")
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
print("before launch")
dapui.open()
end
dap.listeners.before.event_terminated.dapui_config = function()
print("before terminated")
dapui.close()
end
dap.listeners.before.event_exited.dapui_config = function()
print("before exited")
dapui.close()
end
vim.keymap.set("n", "<leader>ui", require("dapui").toggle)

1
lua/keymaps.lua 100644 → 100755
View File

@ -39,6 +39,7 @@ local mappings = {
["<F1>"] = "<nop>",
-- Toggle word wrap
["<leader>w"] = "<cmd>ToggleWrap<CR>",
-- Debugger
},
x = {
["<A-j>"] = ":move '>+1<CR>gv-gv",

0
lua/lsp.lua 100644 → 100755
View File

0
lua/options.lua 100644 → 100755
View File

20
lua/plugins.lua 100644 → 100755
View File

@ -83,16 +83,22 @@ require("lazy").setup({
},
"windwp/nvim-ts-autotag",
"nvim-treesitter/nvim-treesitter",
{
"mfussenegger/nvim-dap",
opt = true,
run = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out",
},
"jay-babu/mason-nvim-dap.nvim",
"microsoft/vscode-js-debug",
{
"stevearc/conform.nvim",
opts = {},
},
"f-person/git-blame.nvim",
-- debugger stuff
"mfussenegger/nvim-dap",
{
"mxsdev/nvim-dap-vscode-js",
dependencies = {
"microsoft/vscode-js-debug",
build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out",
},
},
{ "rcarriga/nvim-dap-ui", dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" } },
})
-- require('dap')

0
requirements.md 100644 → 100755
View File