From f074fcd53e6090473659c1486201e1d2c03f1d12 Mon Sep 17 00:00:00 2001 From: Stevan Freeborn <65925598+StevanFreeborn@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:43:53 -0600 Subject: [PATCH] feat: fix eslint and add ts/js debugging --- lua/plugins/debugging.lua | 117 +++++++++++++++++--------- lua/plugins/lsp.lua | 173 +++++++++++++++++++++++--------------- lua/plugins/none-ls.lua | 4 - 3 files changed, 182 insertions(+), 112 deletions(-) diff --git a/lua/plugins/debugging.lua b/lua/plugins/debugging.lua index 2a64adc..87d4db9 100644 --- a/lua/plugins/debugging.lua +++ b/lua/plugins/debugging.lua @@ -1,46 +1,85 @@ return { - "mfussenegger/nvim-dap", - dependencies = { - "rcarriga/nvim-dap-ui", - "nvim-neotest/nvim-nio", - }, - config = function() - local dap = require("dap") - local dapui = require("dapui") + "mfussenegger/nvim-dap", + dependencies = { + "rcarriga/nvim-dap-ui", + "nvim-neotest/nvim-nio", + }, + config = function() + local dap = require("dap") + local dapui = require("dapui") - dapui.setup() + dapui.setup() - dap.adapters.coreclr = { - type = 'executable', - command = 'C:/Users/sfree/AppData/Local/nvim-data/mason/packages/netcoredbg/netcoredbg/netcoredbg.exe', - args = {'--interpreter=vscode'} - } + dap.adapters["pwa-node"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "node", + args = { "C:/Users/sfree/AppData/Local/nvim-data/vscode-js-debug/src/dapDebugServer.js", "${port}" }, + }, + } - dap.configurations.cs = { - { - type = "coreclr", - name = "launch - netcoredbg", - request = "launch", - program = function() - return vim.fn.input('Path to dll', vim.fn.getcwd() .. '/bin/Debug/', 'file') - end, - }, - } - - dap.listeners.before.attach.dapui_config = function() - dapui.open() - end - dap.listeners.before.launch.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() + 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 = "attach", + name = "Attach", + processId = require('dap.utils').pick_process, + cwd = "${workspaceFolder}", + } + } end - vim.keymap.set("n", "dt", dap.toggle_breakpoint, {}) - vim.keymap.set("n", "dc", dap.continue, {}) - end, + dap.configurations.javascript = { + { + type = "pwa-node", + request = "launch", + name = "Launch file", + program = "${file}", + cwd = "${workspaceFolder}", + }, + } + + dap.adapters.coreclr = { + type = "executable", + command = "C:/Users/sfree/AppData/Local/nvim-data/mason/packages/netcoredbg/netcoredbg/netcoredbg.exe", + args = { "--interpreter=vscode" }, + } + + dap.configurations.cs = { + { + type = "coreclr", + name = "launch - netcoredbg", + request = "launch", + program = function() + return vim.fn.input("Path to dll", vim.fn.getcwd() .. "/bin/Debug/", "file") + end, + }, + } + + dap.listeners.before.attach.dapui_config = function() + dapui.open() + end + dap.listeners.before.launch.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", "dt", dap.toggle_breakpoint, {}) + vim.keymap.set("n", "dc", dap.continue, {}) + end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index abc9b9d..b55d219 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,81 +1,116 @@ return { - { - "williamboman/mason.nvim", - config = function() - require("mason").setup() - end - }, - { - "williamboman/mason-lspconfig.nvim", - lazy = false, - opts = { - auto_install = true, - } - }, - { - "neovim/nvim-lspconfig", - dependencies = { 'hoffs/omnisharp-extended-lsp.nvim' }, - lazy = false, - config = function() - local lspconfig = require("lspconfig") - local capabilities = require("cmp_nvim_lsp").default_capabilities() + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "williamboman/mason-lspconfig.nvim", + lazy = false, + opts = { + auto_install = true, + }, + }, + { + "neovim/nvim-lspconfig", + dependencies = { "hoffs/omnisharp-extended-lsp.nvim" }, + lazy = false, + config = function() + local lspconfig = require("lspconfig") + local capabilities = require("cmp_nvim_lsp").default_capabilities() - lspconfig.omnisharp.setup({ - handlers = { - ["textDocument/definition"] = require("omnisharp_extended").handler, - }, - cmd = { "dotnet", "C:/Users/sfree/AppData/Local/nvim-data/omnisharp/OmniSharp.dll" }, - capabilities = capabilities, - settings = { - FormattingOptions = { - EnableEditorConfigSupport = true, - OrganizeImports = true, - }, - Sdk = { - IncludePrereleases = true, - }, - }, + lspconfig.eslint.setup({ + on_attach = function(_, bufnr) + vim.api.nvim_create_autocmd("BufWritePre", { + buffer = bufnr, + command = "EslintFixAll", + }) + end, }) - lspconfig.lua_ls.setup({ - capabilities = capabilities, - }) + lspconfig.omnisharp.setup({ + handlers = { + ["textDocument/definition"] = require("omnisharp_extended").handler, + }, + cmd = { "dotnet", "C:/Users/sfree/AppData/Local/nvim-data/omnisharp/OmniSharp.dll" }, + capabilities = capabilities, + settings = { + FormattingOptions = { + EnableEditorConfigSupport = true, + OrganizeImports = true, + }, + Sdk = { + IncludePrereleases = true, + }, + }, + }) - lspconfig.ts_ls.setup({ - capabilities = capabilities, - }) + lspconfig.lua_ls.setup({ + capabilities = capabilities, + }) - lspconfig.html.setup({ - capabilities = capabilities, - }) + lspconfig.ts_ls.setup({ + capabilities = capabilities, + }) - lspconfig.cssls.setup({ - capabilities = capabilities, - }) + lspconfig.html.setup({ + capabilities = capabilities, + }) - lspconfig.cssmodules_ls.setup({ - capabilities = capabilities, - }) + lspconfig.cssls.setup({ + capabilities = capabilities, + }) - vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('UserLspConfig', {}), - callback = function(ev) - local client = vim.lsp.get_client_by_id(ev.data.client_id) - local omnisharp = require('omnisharp_extended'); + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + local client = vim.lsp.get_client_by_id(ev.data.client_id) + local omnisharp = require("omnisharp_extended") - if client.name == "omnisharp" then - vim.keymap.set('n', 'gd', omnisharp.lsp_definition, { desc = "Go to definition", buffer = ev.buf }) - vim.keymap.set('n', 'gi', omnisharp.lsp_implementation, { desc = "Go to implementation", buffer = ev.buf }) - vim.keymap.set('n', 'D', omnisharp.lsp_type_definition, { desc = "Go to type definition", buffer = ev.buf }) - else - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = "Go to definition", buffer = ev.buf }) - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, { desc = "Go to declaration", buffer = ev.buf }) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = "Go to implementation", buffer = ev.buf }) - end + if client.name == "omnisharp" then + vim.keymap.set( + "n", + "gd", + omnisharp.lsp_definition, + { desc = "Go to definition", buffer = ev.buf } + ) + vim.keymap.set( + "n", + "gi", + omnisharp.lsp_implementation, + { desc = "Go to implementation", buffer = ev.buf } + ) + vim.keymap.set( + "n", + "D", + omnisharp.lsp_type_definition, + { desc = "Go to type definition", buffer = ev.buf } + ) + else + vim.keymap.set( + "n", + "gd", + vim.lsp.buf.definition, + { desc = "Go to definition", buffer = ev.buf } + ) + vim.keymap.set( + "n", + "gD", + vim.lsp.buf.declaration, + { desc = "Go to declaration", buffer = ev.buf } + ) + vim.keymap.set( + "n", + "gi", + vim.lsp.buf.implementation, + { desc = "Go to implementation", buffer = ev.buf } + ) + end - vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "Display symbol info", buffer = ev.buf }) - end - }) - end - } + vim.keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Display symbol info", buffer = ev.buf }) + end, + }) + end, + }, } diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 1e853c0..539edab 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -1,8 +1,5 @@ return { "nvimtools/none-ls.nvim", - dependencies = { - "nvimtools/none-ls-extras.nvim", - }, config = function() local null_ls = require("null-ls") @@ -12,7 +9,6 @@ return { null_ls.builtins.formatting.prettier, null_ls.builtins.formatting.black, null_ls.builtins.formatting.isort, - require("none-ls.diagnostics.eslint_d"), null_ls.builtins.diagnostics.pylint, null_ls.builtins.completion.spell, }