From f3d0de71c1e3d411fc4fad61437d610bd641a826 Mon Sep 17 00:00:00 2001 From: jc <46619361+juancwu@users.noreply.github.com> Date: Tue, 14 Jan 2025 23:13:34 -0500 Subject: [PATCH] (nvim) finalize improved nvim config --- nvim/lazy-lock.json | 10 +- nvim/lua/.luarc.json | 3 + nvim/lua/juancwu/plugins/autocomplete.lua | 93 ++++++ nvim/lua/juancwu/plugins/autopairs.lua | 7 - nvim/lua/juancwu/plugins/conform.lua | 50 ++++ nvim/lua/juancwu/plugins/lsp.lua | 273 +++++++++--------- nvim/lua/juancwu/plugins/mini-icons.lua | 6 - nvim/lua/juancwu/plugins/null-ls.lua | 21 +- nvim/lua/juancwu/plugins/nvim-dap-ui.lua | 22 -- .../juancwu/plugins/nvim-dap-vscode-js.lua | 65 ----- nvim/lua/juancwu/plugins/nvim-dap.lua | 77 ----- nvim/lua/juancwu/plugins/obsidian.lua | 57 ---- 12 files changed, 288 insertions(+), 396 deletions(-) create mode 100644 nvim/lua/juancwu/plugins/autocomplete.lua delete mode 100644 nvim/lua/juancwu/plugins/autopairs.lua create mode 100644 nvim/lua/juancwu/plugins/conform.lua delete mode 100644 nvim/lua/juancwu/plugins/mini-icons.lua delete mode 100644 nvim/lua/juancwu/plugins/nvim-dap-ui.lua delete mode 100644 nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua delete mode 100644 nvim/lua/juancwu/plugins/nvim-dap.lua delete mode 100644 nvim/lua/juancwu/plugins/obsidian.lua diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 37e3a52..07e30d7 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -3,7 +3,11 @@ "LuaSnip": { "branch": "master", "commit": "c9b9a22904c97d0eb69ccb9bab76037838326817" }, "catppuccin": { "branch": "main", "commit": "f67b886d65a029f12ffa298701fb8f1efd89295d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" }, + "fidget.nvim": { "branch": "main", "commit": "a0abbf18084b77d28bc70e24752e4f4fd54aea17" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "git.nvim": { "branch": "main", "commit": "164daed4eff61bd6bee6f1c97cb78144b9374022" }, "gitsigns.nvim": { "branch": "main", "commit": "76d88f3b584e1f83b2aa51663a32cc6ee8d97eff" }, "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, @@ -11,16 +15,13 @@ "kanagawa.nvim": { "branch": "master", "commit": "988082eb00b845e4afbcaa4fd8e903da8a3ab3b9" }, "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, "lazydev.nvim": { "branch": "main", "commit": "8620f82ee3f59ff2187647167b6b47387a13a018" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "9a686513eaaa13d737d0fec8956a18268ead8b29" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "luvit-meta": { "branch": "main", "commit": "55709f183b0742a7e4f47688c284f81148ad4dc0" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "e942edf5c85b6a2ab74059ea566cac5b3e1514a4" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.icons": { "branch": "main", "commit": "1c79feb7478ca773fa3dac5cadf43ced9180e861" }, - "neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" }, "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, - "nvim-autopairs": { "branch": "master", "commit": "3d02855468f94bf435db41b661b58ec4f48a06b7" }, "nvim-cmp": { "branch": "main", "commit": "8c82d0bd31299dbff7f8e780f5e06d2283de9678" }, "nvim-lspconfig": { "branch": "master", "commit": "339ccc81e08793c3af9b83882a6ebd90c9cc0d3b" }, "nvim-treesitter": { "branch": "master", "commit": "984214ef8e4ca18d77639663319aabdfba89632f" }, @@ -28,7 +29,6 @@ "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "aafa5c187a15701a7299a392b907ec15d9a7075f" }, - "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, "onedark.nvim": { "branch": "master", "commit": "67a74c275d1116d575ab25485d1bfa6b2a9c38a6" }, "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "rose-pine": { "branch": "main", "commit": "719ec67bf51efdd778c3a7855a135a8d6d362959" }, diff --git a/nvim/lua/.luarc.json b/nvim/lua/.luarc.json index 156428e..97a8b9c 100644 --- a/nvim/lua/.luarc.json +++ b/nvim/lua/.luarc.json @@ -73,5 +73,8 @@ "/home/jc/ghq/juancwu/dotfiles/nvim/lua", "/home/jc/ghq/juancwu/dotfiles/nvim/lua", "${3rd}/luv/library" + ], + "diagnostics.globals": [ + "vim" ] } \ No newline at end of file diff --git a/nvim/lua/juancwu/plugins/autocomplete.lua b/nvim/lua/juancwu/plugins/autocomplete.lua new file mode 100644 index 0000000..e416535 --- /dev/null +++ b/nvim/lua/juancwu/plugins/autocomplete.lua @@ -0,0 +1,93 @@ +return { -- Autocompletion + "hrsh7th/nvim-cmp", + event = "InsertEnter", + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + { + "L3MON4D3/LuaSnip", + build = (function() + -- Build Step is needed for regex support in snippets. + -- This step is not supported in many windows environments. + -- Remove the below condition to re-enable on windows. + if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then + return + end + return "make install_jsregexp" + end)(), + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + }, + }, + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + }, + config = function() + -- See `:help cmp` + local cmp = require("cmp") + local luasnip = require("luasnip") + luasnip.config.setup({}) + + cmp.setup({ + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + completion = { completeopt = "menu,menuone,noinsert" }, + + -- For an understanding of why these mappings were + -- chosen, you will need to read `:help ins-completion` + -- + -- No, but seriously. Please read `:help ins-completion`, it is really good! + mapping = cmp.mapping.preset.insert({ + -- Select the [n]ext item + [""] = cmp.mapping.select_next_item(), + -- Select the [p]revious item + [""] = cmp.mapping.select_prev_item(), + + -- Scroll the documentation window [b]ack / [f]orward + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + + -- Accept ([y]es) the completion. + -- This will auto-import if your LSP supports it. + -- This will expand snippets if the LSP sent a snippet. + [""] = cmp.mapping.confirm({ select = true }), + + -- Manually trigger a completion from nvim-cmp. + -- Generally you don't need this, because nvim-cmp will display + -- completions whenever it has completion options available. + [""] = cmp.mapping.complete({}), + + -- will move you to the right of each of the expansion locations. + -- is similar, except moving you backwards. + [""] = cmp.mapping(function() + if luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + end + end, { "i", "s" }), + }), + sources = { + { + name = "lazydev", + -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it + group_index = 0, + }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, + }) + end, +} diff --git a/nvim/lua/juancwu/plugins/autopairs.lua b/nvim/lua/juancwu/plugins/autopairs.lua deleted file mode 100644 index a875511..0000000 --- a/nvim/lua/juancwu/plugins/autopairs.lua +++ /dev/null @@ -1,7 +0,0 @@ -return { - "windwp/nvim-autopairs", - event = "InsertEnter", - opts = { - disable_filetype = { "TelescopePrompt", "vim" } - }, -} diff --git a/nvim/lua/juancwu/plugins/conform.lua b/nvim/lua/juancwu/plugins/conform.lua new file mode 100644 index 0000000..bb0ed48 --- /dev/null +++ b/nvim/lua/juancwu/plugins/conform.lua @@ -0,0 +1,50 @@ +return { + "stevearc/conform.nvim", + event = { "BufWritePre" }, + cmd = { "ConformInfo" }, + keys = { + { + "ff", + function() + require("conform").format({ async = true, lsp_format = "fallback" }) + end, + mode = "", + desc = "[F]ormat buffer", + }, + }, + config = function() + require("conform").setup({ + notify_on_error = false, + formatters_by_ft = { + lua = { "stylua" }, + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + css = { "prettier" }, + markdown = { "prettier" }, + go = { "gopls" }, + python = { "autopep8" }, + yaml = { "yamlfmt" }, + }, + format_on_save = function(bufnr) + if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then + return + end + return { timeout_ms = 500, lsp_format = "fallback" } + end, + }) + + vim.api.nvim_create_user_command("FormatDisable", function() + vim.g.disable_autoformat = true + end, { + desc = "Disable autoformat on save", + }) + + vim.api.nvim_create_user_command("FormatEnable", function() + vim.g.disable_autoformat = false + end, { + desc = "Enable autoformat on save", + }) + end, +} diff --git a/nvim/lua/juancwu/plugins/lsp.lua b/nvim/lua/juancwu/plugins/lsp.lua index 982b60c..bc7db36 100644 --- a/nvim/lua/juancwu/plugins/lsp.lua +++ b/nvim/lua/juancwu/plugins/lsp.lua @@ -1,166 +1,151 @@ return { - -- lspconfig - { - "VonHeikemen/lsp-zero.nvim", - branch = "v2.x", - dependencies = { - -- LSP Support - { "neovim/nvim-lspconfig" }, -- Required - { - -- Optional - "williamboman/mason.nvim", - build = function() - pcall(vim.cmd, "MasonUpdate") - end, - }, - { "williamboman/mason-lspconfig.nvim" }, -- Optional + -- lspconfig + "neovim/nvim-lspconfig", + dependencies = { - -- Autocompletion - { "hrsh7th/nvim-cmp" }, -- Required - { "hrsh7th/cmp-nvim-lsp" }, -- Required - { "L3MON4D3/LuaSnip" }, -- Required + { "williamboman/mason.nvim", opts = {} }, + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", - -- Neovim Plugin Development Completions - { - "folke/neodev.nvim", - opts = {}, - }, + -- status updates for LSP + { "j-hui/fidget.nvim", opts = {} }, - -- formatting - { - "stevearc/conform.nvim", - config = function() - require("conform").setup({ - formatters_by_ft = { - lua = { "stylua" }, - javascript = { "prettier" }, - typescript = { "prettier" }, - javascriptreact = { "prettier" }, - typescriptreact = { "prettier" }, - css = { "prettier" }, - markdown = { "prettier" }, - go = { "gofumpt" }, - python = { "autopep8" }, - yaml = { "yamlfmt" }, - }, - format_on_save = function(bufnr) - if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then - return - end - return { timeout_ms = 500, lsp_fallback = true } - end, - }) + { "hrsh7th/cmp-nvim-lsp" }, -- Required + }, + config = function() + -- stole this from kickstart, great config + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), + callback = function(event) + local map = function(keys, func, desc, mode) + mode = mode or "n" + vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) + end - vim.api.nvim_create_user_command("FormatDisable", function() - vim.g.disable_autoformat = true - end, { - desc = "Disable autoformat on save", - }) + -- Jump to the definition of the word under your cursor. + -- This is where a variable was first declared, or where a function is defined, etc. + -- To jump back, press . + map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") - vim.api.nvim_create_user_command("FormatEnable", function() - vim.g.disable_autoformat = false - end, { - desc = "Enable autoformat on save", - }) - end, - }, - }, - config = function() - -- required to setup neodev before lspconfig - require("neodev").setup({}) + -- Find references for the word under your cursor. + map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") - local lspzero = require("lsp-zero") + -- Jump to the implementation of the word under your cursor. + -- Useful when your language has ways of declaring types without an actual implementation. + map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") - lspzero.preset({}) + -- Jump to the type of the word under your cursor. + -- Useful when you're not sure what type a variable is and you want to see + -- the definition of its *type*, not where it was *defined*. + map("D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") - lspzero.on_attach(function(_, bufnr) - lspzero.default_keymaps({ - buffer = bufnr, - omit = { - "gr", - }, - }) + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") - local function nmap(key, action, desc) - vim.keymap.set("n", key, action, { - desc = "LSP: " .. desc, - }) - end + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") - local function format() - require("conform").format({ bufnr = bufnr }) - end + -- Rename the variable under your cursor. + -- Most Language Servers support renaming across files, etc. + map("rn", vim.lsp.buf.rename, "[R]e[n]ame") - nmap("[d", "lua vim.diagnostic.goto_prev()", "Goto Prev Diagnostic") - nmap("]d", "lua vim.diagnostic.goto_next()", "Goto Next Diagnostic") + -- Execute a code action, usually your cursor needs to be on top of an error + -- or a suggestion from your LSP for this to activate. + map("ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) - -- local current_dir = vim.fn.expand("%:p:h") + -- WARN: This is not Goto Definition, this is Goto Declaration. + -- For example, in C this would take you to the header. + map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") - -- vim.keymap.set('n', 'gr', 'Telescope lsp_references', { buffer = true }) + -- The following two autocommands are used to highlight references of the + -- word under your cursor when your cursor rests there for a little while. + -- See `:help CursorHold` for information about when this is executed + -- + -- When you move your cursor, the highlights will be cleared (the second autocommand). + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then + local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.document_highlight, + }) - -- format with space + f - -- vim.keymap.set("n", "fb", "lua vim.lsp.buf.format()", - -- { desc = "[F]ormat [B]uffer" }) - nmap("fb", format, "[F]ormat [B]uffer") + vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { + buffer = event.buf, + group = highlight_augroup, + callback = vim.lsp.buf.clear_references, + }) - vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) - format() - end, { desc = "Format current buffer with LSP" }) - end) + vim.api.nvim_create_autocmd("LspDetach", { + group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), + callback = function(event2) + vim.lsp.buf.clear_references() + vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) + end, + }) + end + end, + }) - local status, lspconfig = pcall(require, "lspconfig") + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - if status then - lspconfig.ts_ls.setup({}) - lspconfig.tailwindcss.setup({ - filetypes = { - "templ", - "html", - "javascript", - "typescript", - "javascriptreact", - "typescriptreact", - }, - init_options = { - userLanguages = { - templ = "html", - }, - }, - }) - lspconfig.zls.setup({}) - lspconfig.rust_analyzer.setup({}) - lspconfig.gopls.setup({}) - -- lspconfig.html.setup({}) - vim.filetype.add({ - extension = { - templ = "templ", - }, - }) - lspconfig.templ.setup({ - filetypes = { - "templ", - }, - }) - lspconfig.intelephense.setup({}) - lspconfig.lua_ls.setup({}) - end + vim.filetype.add({ + extension = { + templ = "templ", + }, + }) - lspzero.setup() + local servers = { + ts_ls = {}, + gopls = {}, + zls = {}, + rust_analyzer = {}, + templ = { + filetypes = { "templ" }, + }, + intelephense = {}, + lua_ls = { + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + tailwindcss = { + filetypes = { + "templ", + "html", + "javascript", + "typescript", + "javascriptreact", + "typescriptreact", + }, + init_options = { + userLanguages = { + templ = "html", + }, + }, + }, + } - local cmp - status, cmp = pcall(require, "cmp") + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "prettier" }) + require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) - if not status then - return - end - - cmp.setup({ - mapping = { - -- press 'enter' to confirm completion/suggestion - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping.abort(), - }, - }) - end, - }, + require("mason-lspconfig").setup({ + handlers = { + function(server_name) + local server = servers[server_name] or {} + server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) + require("lspconfig")[server_name].setup(server) + end, + }, + }) + end, } diff --git a/nvim/lua/juancwu/plugins/mini-icons.lua b/nvim/lua/juancwu/plugins/mini-icons.lua deleted file mode 100644 index 42d0ef1..0000000 --- a/nvim/lua/juancwu/plugins/mini-icons.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "echasnovski/mini.icons", - opts = { - version = false, - }, -} diff --git a/nvim/lua/juancwu/plugins/null-ls.lua b/nvim/lua/juancwu/plugins/null-ls.lua index 5cbdb14..3320bc1 100644 --- a/nvim/lua/juancwu/plugins/null-ls.lua +++ b/nvim/lua/juancwu/plugins/null-ls.lua @@ -1,15 +1,10 @@ return { - "jose-elias-alvarez/null-ls.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - }, - config = function() - local null_ls = require("null-ls") - null_ls.setup({ - sources = { - null_ls.builtins.formatting.prettierd, - -- null_ls.builtins.diagnostics.eslint, - }, - }) - end, + "jose-elias-alvarez/null-ls.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + local null_ls = require("null-ls") + null_ls.setup({}) + end, } diff --git a/nvim/lua/juancwu/plugins/nvim-dap-ui.lua b/nvim/lua/juancwu/plugins/nvim-dap-ui.lua deleted file mode 100644 index 6f5a0db..0000000 --- a/nvim/lua/juancwu/plugins/nvim-dap-ui.lua +++ /dev/null @@ -1,22 +0,0 @@ -return { - "rcarriga/nvim-dap-ui", - enabled = false, - dependencies = { - 'mfussenegger/nvim-dap', - }, - config = function() - local dap, dapui = require("dap"), require("dapui") - dapui.setup({ - width = 50, - }) - 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 - end -} diff --git a/nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua b/nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua deleted file mode 100644 index 608e73f..0000000 --- a/nvim/lua/juancwu/plugins/nvim-dap-vscode-js.lua +++ /dev/null @@ -1,65 +0,0 @@ -local DEBUGGER_PATH = vim.fn.stdpath("data") .. "/lazy/vscode-js-debug" - -return { - { - "microsoft/vscode-js-debug", - lazy = true, - build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", - enabled = false, - }, - { - 'mxsdev/nvim-dap-vscode-js', - enabled = false, - dependencies = { - "mfussenegger/nvim-dap", - }, - config = function() - local dapVsCode = require("dap-vscode-js") - dapVsCode.setup({ - node_path = "node", - debugger_path = DEBUGGER_PATH, - adapters = { - "pwa-node", - "pwa-chrome", - "pwa-msedge", - "pwa-extensionHost", - "node-terminal", - } - }) - - for _, language in ipairs({ "typescript", "javascript" }) do - require("dap").configurations[language] = { - { - type = "pwa-node", - request = "launch", - name = "Launch file (node)", - program = "${file}", - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "attach", - name = "Attach (node)", - processId = require('dap.utils').pick_process, - cwd = "${workspaceFolder}", - }, - { - type = "pwa-node", - request = "launch", - name = "Debug Jest Tests", - trace = true, - runtimeExecutable = "node", - runtimeArgs = { - "./node_modules/jest/bin/jest.js", - "--runInBand", - }, - rootPath = "${workspaceFolder}", - cwd = "${workspaceFolder}", - console = "integratedTerminal", - internalConsoleOptions = "neverOpen", - }, - } - end - end - } -} diff --git a/nvim/lua/juancwu/plugins/nvim-dap.lua b/nvim/lua/juancwu/plugins/nvim-dap.lua deleted file mode 100644 index 2346f8c..0000000 --- a/nvim/lua/juancwu/plugins/nvim-dap.lua +++ /dev/null @@ -1,77 +0,0 @@ -return { - 'mfussenegger/nvim-dap', - enabled = false, - config = function() - local status, wk = pcall(require, "which-key") - - local dap_breakpoints = { - breakpoint = { - text = "", - texthl = "LspDiagnosticsSignError", - linehl = "", - numhl = "", - }, - rejected = { - text = "", - texthl = "LspDiagnosticsSignHint", - linehl = "", - numhl = "", - }, - stopped = { - text = "", - texthl = "LspDiagnosticsSignInformation", - linehl = "DiagnosticUnderlineInfo", - numhl = "LspDiagnosticsSignInformation", - }, - } - - vim.fn.sign_define("DapBreakpoint", dap_breakpoints.breakpoint) - vim.fn.sign_define("DapStopped", dap_breakpoints.stopped) - vim.fn.sign_define("DapBreakpointRejected", dap_breakpoints.rejected) - - if not status then - local function nmap(key, action, desc) - vim.keymap.set( - "n", - "d" .. key, - action, - { - desc = "[D]AP: " .. desc, - noremap = true, - nowait = false, - silent = true - } - ) - end - - nmap("c", "lua require'dap'.continue()", "[C]ontinue") - nmap("b", "lua require'dap'.toggle_breakpoint()", "Toggle [B]reakpoint") - nmap("i", "lua require'dap'.step_into()", "Step [I]nto") - nmap("o", "lua require'dap'.step_over()", "Step [O]ver") - nmap("u", "lua require'dap'.step_out()", "[U] Step Out") - nmap("x", "lua require'dap'.terminate()", "[T]erminate") - nmap("q", "lua require'dap'.close()", "[Q]uit") - else - local keymap = { - { "d", group = "DAP", nowait = false, remap = false }, - { "db", "lua require'dap'.toggle_breakpoint()", desc = "Toggle [B]reakpoint", nowait = false, remap = false }, - { "dc", "lua require'dap'.continue()", desc = "[C]ontinue", nowait = false, remap = false }, - { "di", "lua require'dap'.step_into()", desc = "Step [I]nto", nowait = false, remap = false }, - { "do", "lua require'dap'.step_over()", desc = "Step [O]ver", nowait = false, remap = false }, - { "dq", "lua require'dap'.close()", desc = "[Q]uit", nowait = false, remap = false }, - { "du", "lua require'dap'.step_out()", desc = "[U] Step Out", nowait = false, remap = false }, - { "dx", "lua require'dap'.terminate()", desc = "[T]erminate", nowait = false, remap = false }, - } - - local opts = { - mode = "n", - prefix = "", - buffer = nil, - silent = true, - noremap = true, - nowait = false, - } - wk.add(keymap, opts) - end - end -} diff --git a/nvim/lua/juancwu/plugins/obsidian.lua b/nvim/lua/juancwu/plugins/obsidian.lua deleted file mode 100644 index 78e03dc..0000000 --- a/nvim/lua/juancwu/plugins/obsidian.lua +++ /dev/null @@ -1,57 +0,0 @@ -return { - "epwalsh/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit - lazy = true, - ft = "markdown", - enabled = true, - -- load plugin for eazy and fast creation of dailies - keys = { - { "od", "ObsidianToday", desc = "New obsidian daily note" }, - }, - -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: - -- event = { - -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. - -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/**.md" - -- "BufReadPre path/to/my-vault/**.md", - -- "BufNewFile path/to/my-vault/**.md", - -- }, - dependencies = { - -- Required. - "nvim-lua/plenary.nvim", - - -- see below for full list of optional dependencies 👇 - }, - opts = { - workspaces = { - { - name = "personal", - path = "~/Documents/Obsidian Vault", - }, - }, - follow_url_func = function(url) - vim.fn.jobstart({ "open", url }) - end, - note_id_func = function(title) - if title ~= nil then - print("create new obsidian note with given title: " .. title) - return title - end - local suffix = "" - for _ = 1, 4 do - suffix = suffix .. string.char(math.random(65, 90)) - end - return tostring(os.time()) .. "-" .. suffix - end, - daily_notes = { - date_format = "%d-%m-%Y", - }, - }, - mappings = { - [""] = { - action = function() - return require("obsidian").util.smart_action() - end, - opts = { noremap = false, expr = true, buffer = true }, - }, - }, -}