From ae0acb574c0e0da9bd14b8bedc061cb27f4336a9 Mon Sep 17 00:00:00 2001 From: Carlos Date: Thu, 20 Feb 2025 00:50:00 -0500 Subject: [PATCH] fixing --- lua/cargdev/plugins/dap.lua | 86 +++++++++++++++--------------- lua/cargdev/plugins/formatting.lua | 14 ++++- lua/cargdev/plugins/linting.lua | 58 ++++++++++++++++++-- lua/cargdev/plugins/nvim-tree.lua | 8 ++- lua/cargdev/plugins/treesitter.lua | 1 + 5 files changed, 118 insertions(+), 49 deletions(-) diff --git a/lua/cargdev/plugins/dap.lua b/lua/cargdev/plugins/dap.lua index f2313e0..90c1071 100644 --- a/lua/cargdev/plugins/dap.lua +++ b/lua/cargdev/plugins/dap.lua @@ -144,48 +144,48 @@ return { -- }, -- } - dap.adapters.chrome = { - type = "executable", - command = "node", - args = { os.getenv("HOME") .. "/.local/share/nvim/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js" }, - } - - dap.configurations.typescriptreact = { - { - name = "Attach to Chrome", - type = "chrome", - request = "attach", - program = "${file}", - cwd = vim.fn.getcwd(), - port = 9222, -- 🚀 Chrome debugging port - webRoot = "${workspaceFolder}", - sourceMaps = true, - skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, - }, - { - name = "Launch Chrome with DevTools", - type = "chrome", - request = "launch", - url = "http://localhost:4000", -- Your React app runs on this port - webRoot = "${workspaceFolder}", - runtimeArgs = { "--remote-debugging-port=9222" }, - sourceMaps = true, - skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, - }, - } - - dap.configurations.javascript = { - { - name = "Attach to Chrome", - type = "chrome", - request = "attach", - program = "${file}", - cwd = vim.fn.getcwd(), - port = 9222, -- 🚀 Default Chrome Debug Port - webRoot = "${workspaceFolder}", - sourceMaps = true, - skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, - }, - } + -- dap.adapters.chrome = { + -- type = "executable", + -- command = "node", + -- args = { os.getenv("HOME") .. "/.local/share/nvim/mason/packages/chrome-debug-adapter/out/src/chromeDebug.js" }, + -- } + -- + -- dap.configurations.typescript = { + -- { + -- name = "Attach to Chrome", + -- type = "chrome", + -- request = "attach", + -- program = "${file}", + -- cwd = vim.fn.getcwd(), + -- port = 9222, -- 🚀 Chrome debugging port + -- webRoot = "${workspaceFolder}", + -- sourceMaps = true, + -- skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, + -- }, + -- { + -- name = "Launch Chrome with DevTools", + -- type = "chrome", + -- request = "launch", + -- url = "http://localhost:4000", -- Your React app runs on this port + -- webRoot = "${workspaceFolder}", + -- runtimeArgs = { "--remote-debugging-port=9222" }, + -- sourceMaps = true, + -- skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, + -- }, + -- } + -- + -- dap.configurations.javascript = { + -- { + -- name = "Attach to Chrome", + -- type = "chrome", + -- request = "attach", + -- program = "${file}", + -- cwd = vim.fn.getcwd(), + -- port = 9222, -- 🚀 Default Chrome Debug Port + -- webRoot = "${workspaceFolder}", + -- sourceMaps = true, + -- skipFiles = { "/**", "webpack://_N_E/./node_modules/**" }, + -- }, + -- } end, } diff --git a/lua/cargdev/plugins/formatting.lua b/lua/cargdev/plugins/formatting.lua index 984ef48..dad4926 100644 --- a/lua/cargdev/plugins/formatting.lua +++ b/lua/cargdev/plugins/formatting.lua @@ -5,6 +5,14 @@ return { local conform = require("conform") conform.setup({ + formatters = { + sqlfluff = { + command = "sqlfluff", + args = { "format", "--dialect", "postgres", "-" }, + stdin = true, -- Ensure it uses stdin + cwd = require("conform.util").root_file({ ".git" }), + }, + }, formatters_by_ft = { javascript = { "prettier" }, typescript = { "prettier" }, @@ -21,15 +29,17 @@ return { liquid = { "prettier" }, lua = { "stylua" }, python = { "isort", "black" }, + dbml = { "dbml" }, -- DBML formatting + sql = { "sqlfluff" }, -- SQL formatting }, - format_on_save = false, + format_on_save = false, -- Set to true if you want auto-formatting on save }) vim.keymap.set({ "n", "v" }, "mm", function() conform.format({ lsp_fallback = true, async = false, - timeout_ms = 1000, + timeout_ms = 2000, }) end, { desc = "Format file or range (in visual mode)" }) end, diff --git a/lua/cargdev/plugins/linting.lua b/lua/cargdev/plugins/linting.lua index e9fea9b..c3f8e68 100644 --- a/lua/cargdev/plugins/linting.lua +++ b/lua/cargdev/plugins/linting.lua @@ -3,6 +3,56 @@ return { event = { "BufReadPre", "BufNewFile" }, config = function() local lint = require("lint") + local api = vim.api + local keymap = vim.keymap + + lint.linters.dbml = { + cmd = "dbml", + args = { "lint" }, + stdin = false, + stream = "stdout", + ignore_exitcode = true, + parser = function(output, bufnr) + local diagnostics = {} + for line in output:gmatch("[^\r\n]+") do + local lnum, col, msg = line:match("(%d+):(%d+):%s*(.*)") + if lnum and msg then + table.insert(diagnostics, { + bufnr = bufnr, + lnum = tonumber(lnum) - 1, + col = tonumber(col) - 1, + message = msg, + severity = vim.diagnostic.severity.WARN, + }) + end + end + return diagnostics + end, + } + + lint.linters.sqlfluff = { + cmd = "sqlfluff", + args = { "lint", "--format", "json" }, + stdin = false, + stream = "stdout", + ignore_exitcode = true, + parser = function(output, bufnr) + local diagnostics = {} + local parsed = vim.fn.json_decode(output) + if parsed and parsed[1] and parsed[1].violations then + for _, issue in ipairs(parsed[1].violations) do + table.insert(diagnostics, { + bufnr = bufnr, + lnum = issue.line_no - 1, + col = issue.line_pos - 1, + message = issue.description, + severity = vim.diagnostic.severity.WARN, + }) + end + end + return diagnostics + end, + } lint.linters_by_ft = { javascript = { "eslint_d" }, @@ -11,18 +61,20 @@ return { typescriptreact = { "eslint_d" }, svelte = { "eslint_d" }, python = { "pylint" }, + dbml = { "dbml" }, + sql = { "sqlfluff" }, } - local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + local lint_augroup = api.nvim_create_augroup("lint", { clear = true }) - vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { group = lint_augroup, callback = function() lint.try_lint() end, }) - vim.keymap.set("n", "l", function() + keymap.set("n", "l", function() lint.try_lint() end, { desc = "Trigger linting for current file" }) end, diff --git a/lua/cargdev/plugins/nvim-tree.lua b/lua/cargdev/plugins/nvim-tree.lua index bf4131e..3df4d9f 100644 --- a/lua/cargdev/plugins/nvim-tree.lua +++ b/lua/cargdev/plugins/nvim-tree.lua @@ -63,6 +63,12 @@ return { -- Navigate Forward (Enter a Folder) vim.keymap.set("n", "f", api.tree.change_root_to_node, opts) + -- Reload the tree (useful when files are added/removed) + vim.keymap.set("n", "l", function() + api.tree.reload() -- Reload the tree + print("NvimTree reloaded!") -- Optional confirmation message + end, opts) + -- File Management keybindings vim.keymap.set("n", "a", function() -- Add a new file vim.cmd("set modifiable") -- Ensure modifiable mode is on @@ -91,7 +97,7 @@ return { vim.keymap.set("n", "y", function() -- Copy file vim.cmd("set modifiable") -- Ensure modifiable mode is on - api.fs.copy() + api.fs.copy.node() end, opts) end, }) diff --git a/lua/cargdev/plugins/treesitter.lua b/lua/cargdev/plugins/treesitter.lua index 469293e..c4dec18 100644 --- a/lua/cargdev/plugins/treesitter.lua +++ b/lua/cargdev/plugins/treesitter.lua @@ -39,6 +39,7 @@ return { "markdown_inline", "svelte", "graphql", + "sql", "bash", "lua", "vim",