Compare commits

..

6 commits

Author SHA1 Message Date
70defe1866 Working on small NestJS 2024-01-01 17:33:05 -05:00
9d71ab4be4 Trying to get debugging going for JS/TS 2024-01-01 11:27:24 -05:00
938ff36c6b [dap] Some progress
Looks like we can load the launch.json. But it seems the debugger
is being started twice, as I get an EADDRINUSE error on
:DapContinue
2023-12-29 16:40:11 -05:00
c3109dcf17 Trying to rig up dap for NestJS/TS 2023-12-26 16:41:21 -05:00
84a790c53f Minor updates 2023-12-26 16:40:14 -05:00
8ed7eab826 [neovim] Some tweaks 2023-12-23 19:49:59 -05:00
4 changed files with 648 additions and 261 deletions

View file

@ -164,7 +164,7 @@ local function set_wallpaper(s)
-- Wallpaper -- Wallpaper
if beautiful.wallpaper then if beautiful.wallpaper then
-- local wallpaper = beautiful.wallpaper -- local wallpaper = beautiful.wallpaper
local wallpaper = "/home/adam/Pictures/wallpapers/shared/cemetery_sunray.jpeg" local wallpaper = "/home/adam/Pictures/wallpapers/shared/montauk-light-01.jpg"
-- If wallpaper is a function, call it with the screen -- If wallpaper is a function, call it with the screen
if type(wallpaper) == "function" then if type(wallpaper) == "function" then
wallpaper = wallpaper(s) wallpaper = wallpaper(s)

225
neovim/init-dap.lua Normal file
View file

@ -0,0 +1,225 @@
-- Minimal init.lua to test out nvim-dap (for Node.js, really NestJS)
-- lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local js_based_languages = { "javascript", "typescript" }
require("lazy").setup({
{ "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap" },
{
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
-- local Config = require("lazyvim.config")
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
--[[
for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
--]]
for _, language in ipairs({ "javascript", "typescript" }) do
dap.configurations[language] = {
-- Debug single nodejs files
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
},
-- Debug nodejs processes (make sure to add --inspect when you run the process)
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = vim.fn.getcwd(),
sourceMaps = true,
},
-- Debug web applications (client side)
{
type = "pwa-chrome",
request = "launch",
name = "Launch & Debug Chrome",
url = function()
local co = coroutine.running()
return coroutine.create(function()
vim.ui.input({
prompt = "Enter URL: ",
default = "http://localhost:3000",
}, function(url)
if url == nil or url == "" then
return
else
coroutine.resume(co, url)
end
end)
end)
end,
webRoot = vim.fn.getcwd(),
protocol = "inspector",
sourceMaps = true,
userDataDir = false,
},
-- Divider for the launch.json derived configs
{
name = "----- ↓ launch.json configs ↓ -----",
type = "",
request = "launch",
},
}
end
end,
keys = {
{
"<leader>dO",
function()
require("dap").step_out()
end,
desc = "Step Out",
},
{
"<leader>do",
function()
require("dap").step_over()
end,
desc = "Step Over",
},
{
"<leader>da",
function()
if vim.fn.filereadable(".vscode/launch.json") then
local dap_vscode = require("dap.ext.vscode")
dap_vscode.load_launchjs(nil, {
["pwa-node"] = js_based_languages,
["chrome"] = js_based_languages,
["pwa-chrome"] = js_based_languages,
})
end
require("dap").continue()
end,
desc = "Run with Args",
},
},
dependencies = {
-- Install the vscode-js-debug adapter
{
"microsoft/vscode-js-debug",
-- After install, build it and rename the dist directory to out
build = "npm install --legacy-peer-deps --no-save && npx gulp vsDebugServerBundle && rm -rf out && mv dist out",
version = "1.*",
},
{
"mxsdev/nvim-dap-vscode-js",
config = function()
---@diagnostic disable-next-line: missing-fields
require("dap-vscode-js").setup({
-- Path of node executable. Defaults to $NODE_PATH, and then "node"
-- node_path = "node",
-- Path to vscode-js-debug installation.
debugger_path = vim.fn.resolve(vim.fn.stdpath("data") .. "/lazy/vscode-js-debug"),
-- Command to use to launch the debug server. Takes precedence over "node_path" and "debugger_path"
-- debugger_cmd = { "js-debug-adapter" },
-- which adapters to register in nvim-dap
adapters = {
"chrome",
"pwa-node",
"pwa-chrome",
"pwa-msedge",
"pwa-extensionHost",
"node-terminal",
},
-- Path for file logging
-- log_file_path = "(stdpath cache)/dap_vscode_js.log",
-- Logging level for output to file. Set to false to disable logging.
-- log_file_level = false,
-- Logging level for output to console. Set to false to disable console output.
-- log_console_level = vim.log.levels.ERROR,
})
end,
},
{
"Joakker/lua-json5",
build = "./install.sh",
},
},
},
"leoluz/nvim-dap-go",
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
})
--[[ mason
Mason manages external editor plugins such as LSP servers, DAP servers,
linters, and formatters. There are further recommended plugins for better
integration.
--]]
require('mason').setup()
require('mason-lspconfig').setup()
-- setup adapters
--[[
require('dap-vscode-js').setup({
node_path = 'node',
debugger_path = vim.fn.stdpath('data') .. '/mason/packages/js-debug-adapter',
debugger_cmd = { 'js-debug-adapter' },
adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' },
log_file_path = vim.fn.stdpath('cache') .. '/dap_vscode_js.log',
log_file_level = 1,
log_console_level = vim.log.levels.TRACE,
})
local dap = require('dap')
for _, language in ipairs({ "typescript", "javascript" }) do
dap.configurations[language] = {
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = "${workspaceFolder}",
},
{
type = "pwa-node",
request = "launch",
name = "Debug Nest Framework",
args = { "${workspaceFolder}/src/main.ts" },
runtimeArgs = { "--nolazy", "-r", "ts-node/register" },
sourceMaps = true,
cwd = "${workspaceRoot}",
protocol = "inspector",
}
}
end
--]]
require('dap-go').setup()
require('dapui').setup()

View file

@ -6,7 +6,7 @@ vim.opt.clipboard = "unnamedplus,unnamed"
-- Spaces indentation -- Spaces indentation
vim.opt.expandtab = true -- converts tabs to spaces vim.opt.expandtab = true -- converts tabs to spaces
vim.opt.tabstop = 4 -- tab equals 2 spaces vim.opt.tabstop = 4 -- tab equals 4 spaces
vim.opt.shiftwidth = 4 -- indent size in characters vim.opt.shiftwidth = 4 -- indent size in characters
-- Show whitespace (:list) -- Show whitespace (:list)
@ -23,7 +23,7 @@ vim.opt.cursorline = true
-- Enable folding -- Enable folding
vim.opt.foldmethod = "syntax" vim.opt.foldmethod = "syntax"
vim.opt.foldlevel = 0 vim.opt.foldlevel = 5
-- Enable 24-bit RGB color in the TUI -- Enable 24-bit RGB color in the TUI
vim.opt.termguicolors = true vim.opt.termguicolors = true
@ -49,7 +49,7 @@ vim.keymap.set("n", "<c-h>", "<c-w>h", { noremap = true, desc = 'Go to window to
vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { noremap = true, desc = 'Go to window below' }) vim.keymap.set("t", "<c-j>", "<c-\\><c-n><c-w>j", { noremap = true, desc = 'Go to window below' })
vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { noremap = true, desc = 'Go to window above' }) vim.keymap.set("t", "<c-k>", "<c-\\><c-n><c-w>k", { noremap = true, desc = 'Go to window above' })
vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { noremap = true, desc = 'Go to window to the left' }) vim.keymap.set("t", "<c-h>", "<c-\\><c-n><c-w>h", { noremap = true, desc = 'Go to window to the left' })
vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { noremap = true, desc = 'Go to window to the right' }) -- vim.keymap.set("t", "<c-l>", "<c-\\><c-n><c-w>l", { noremap = true, desc = 'Go to window to the right' })
--[[ --[[
vim.keymap.set( vim.keymap.set(
@ -87,6 +87,8 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
local js_based_languages = { "javascript", "typescript" }
require("lazy").setup({ require("lazy").setup({
{ {
url = "https://git.theadamcooper.com/adam/dracula-vim.git", url = "https://git.theadamcooper.com/adam/dracula-vim.git",
@ -128,6 +130,160 @@ require("lazy").setup({
opts = {}, opts = {},
config = function(_, opts) require'lsp_signature'.setup(opts) end config = function(_, opts) require'lsp_signature'.setup(opts) end
}, },
{ "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap" },
{
"mfussenegger/nvim-dap",
config = function()
local dap = require("dap")
-- local Config = require("lazyvim.config")
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
--[[
for name, sign in pairs(Config.icons.dap) do
sign = type(sign) == "table" and sign or { sign }
vim.fn.sign_define(
"Dap" .. name,
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
--]]
for _, language in ipairs({ "javascript", "typescript" }) do
dap.configurations[language] = {
-- Debug single nodejs files
{
type = "pwa-node",
request = "launch",
name = "Launch file",
program = "${file}",
cwd = vim.fn.getcwd(),
sourceMaps = true,
},
-- Debug nodejs processes (make sure to add --inspect when you run the process)
{
type = "pwa-node",
request = "attach",
name = "Attach",
processId = require("dap.utils").pick_process,
cwd = vim.fn.getcwd(),
sourceMaps = true,
},
-- Debug web applications (client side)
{
type = "pwa-chrome",
request = "launch",
name = "Launch & Debug Chrome",
url = function()
local co = coroutine.running()
return coroutine.create(function()
vim.ui.input({
prompt = "Enter URL: ",
default = "http://localhost:3000",
}, function(url)
if url == nil or url == "" then
return
else
coroutine.resume(co, url)
end
end)
end)
end,
webRoot = vim.fn.getcwd(),
protocol = "inspector",
sourceMaps = true,
userDataDir = false,
},
-- Divider for the launch.json derived configs
{
name = "----- ↓ launch.json configs ↓ -----",
type = "",
request = "launch",
},
}
end
end,
keys = {
{
"<leader>dO",
function()
require("dap").step_out()
end,
desc = "Step Out",
},
{
"<leader>do",
function()
require("dap").step_over()
end,
desc = "Step Over",
},
{
"<leader>da",
function()
if vim.fn.filereadable(".vscode/launch.json") then
local dap_vscode = require("dap.ext.vscode")
dap_vscode.load_launchjs(nil, {
["pwa-node"] = js_based_languages,
["chrome"] = js_based_languages,
["pwa-chrome"] = js_based_languages,
})
end
require("dap").continue()
end,
desc = "Run with Args",
},
},
dependencies = {
-- Install the vscode-js-debug adapter
{
"microsoft/vscode-js-debug",
-- After install, build it and rename the dist directory to out
build = "npm install --legacy-peer-deps --no-save && npx gulp vsDebugServerBundle && rm -rf out && mv dist out",
version = "1.*",
},
{
"mxsdev/nvim-dap-vscode-js",
config = function()
---@diagnostic disable-next-line: missing-fields
require("dap-vscode-js").setup({
-- Path of node executable. Defaults to $NODE_PATH, and then "node"
-- node_path = "node",
-- Path to vscode-js-debug installation.
debugger_path = vim.fn.resolve(vim.fn.stdpath("data") .. "/lazy/vscode-js-debug"),
-- Command to use to launch the debug server. Takes precedence over "node_path" and "debugger_path"
-- debugger_cmd = { "js-debug-adapter" },
-- which adapters to register in nvim-dap
adapters = {
"chrome",
"pwa-node",
"pwa-chrome",
"pwa-msedge",
"pwa-extensionHost",
"node-terminal",
},
-- Path for file logging
-- log_file_path = "(stdpath cache)/dap_vscode_js.log",
-- Logging level for output to file. Set to false to disable logging.
-- log_file_level = false,
-- Logging level for output to console. Set to false to disable console output.
-- log_console_level = vim.log.levels.ERROR,
})
end,
},
{
"Joakker/lua-json5",
build = "./install.sh",
},
},
},
"leoluz/nvim-dap-go",
"williamboman/mason.nvim", "williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"nvimdev/lspsaga.nvim", "nvimdev/lspsaga.nvim",
@ -147,6 +303,7 @@ require("lazy").setup({
"hrsh7th/cmp-nvim-lsp-signature-help", "hrsh7th/cmp-nvim-lsp-signature-help",
"tpope/vim-fugitive", "tpope/vim-fugitive",
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
"famiu/bufdelete.nvim",
}) })
--[[ mason --[[ mason
@ -441,6 +598,10 @@ vim.keymap.set('n', '<leader>sl', '<cmd>Lspsaga outline<CR>')
vim.keymap.set('n', '<leader>rn', '<cmd>Lspsaga rename<CR>') vim.keymap.set('n', '<leader>rn', '<cmd>Lspsaga rename<CR>')
vim.keymap.set('n', '<leader>st', '<cmd>Lspsaga term_toggle<CR>') vim.keymap.set('n', '<leader>st', '<cmd>Lspsaga term_toggle<CR>')
require('dap-go').setup()
require('dapui').setup()
-- Tweak GitSigns blame color -- Tweak GitSigns blame color
-- This differentiates the cursorline from the git blame text -- This differentiates the cursorline from the git blame text
vim.cmd("highlight GitSignsCurrentLineBlame gui=bold guifg=#339944") vim.cmd("highlight GitSignsCurrentLineBlame gui=bold guifg=#339944")

View file

@ -10,3 +10,4 @@ leak
leak leak
wolff wolff
baffler baffler
Assange