From ff3c6e551bf940b67d7e418234e59ba7fd9ba0ea Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sun, 16 Jul 2023 12:47:49 +0800 Subject: [PATCH 1/7] feat: pde --- lua/pde/rust.lua | 2 +- lua/pde/typescript.lua | 104 ++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/lua/pde/rust.lua b/lua/pde/rust.lua index d0f0a98..b0277be 100644 --- a/lua/pde/rust.lua +++ b/lua/pde/rust.lua @@ -54,9 +54,9 @@ return { }, }, }, + taplo = {}, }, setup = { - taplo = {}, rust_analyzer = function(_, opts) local codelldb_path, liblldb_path = get_codelldb() local lsp_utils = require "base.lsp.utils" diff --git a/lua/pde/typescript.lua b/lua/pde/typescript.lua index 9ba5035..664e397 100644 --- a/lua/pde/typescript.lua +++ b/lua/pde/typescript.lua @@ -9,40 +9,32 @@ return { vim.list_extend(opts.ensure_installed, { "javascript", "typescript", "tsx" }) end, }, - -- { - -- "williamboman/mason.nvim", - -- opts = function(_, opts) - -- table.insert(opts.ensure_installed, "js-debug-adapter") - -- end, - -- }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { "typescript-language-server", "js-debug-adapter" }) + end, + }, + { + "pmizio/typescript-tools.nvim", + dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, + opts = {}, + config = function(_, opts) + require("base.lsp.utils").on_attach(function(client, bufnr) + if client.name == "tsserver" then + vim.keymap.set("n", "lo", "TSToolsOrganizeImports", { buffer = bufnr, desc = "Organize Imports" }) + vim.keymap.set("n", "lF", "TSToolsFixAll", { desc = "Fix All", buffer = bufnr }) + end + end) + require("typescript-tools").setup(opts) + end, + }, { "neovim/nvim-lspconfig", dependencies = { "jose-elias-alvarez/typescript.nvim" }, opts = { -- make sure mason installs the server servers = { - ---Typescript - tsserver = { - settings = { - typescript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - }, - javascript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - }, - completions = { - completeFunctionCalls = true, - }, - }, - }, -- ESLint eslint = { settings = { @@ -52,18 +44,6 @@ return { }, }, setup = { - tsserver = function(_, opts) - require("base.lsp.utils").on_attach(function(client, bufnr) - if client.name == "tsserver" then - -- stylua: ignore - vim.keymap.set("n", "lo", "TypescriptOrganizeImports", { buffer = bufnr, desc = "Organize Imports" }) - -- stylua: ignore - vim.keymap.set("n", "lR", "TypescriptRenameFile", { desc = "Rename File", buffer = bufnr }) - end - end) - require("typescript").setup { server = opts } - return true - end, eslint = function() vim.api.nvim_create_autocmd("BufWritePre", { callback = function(event) @@ -89,25 +69,45 @@ return { { "mfussenegger/nvim-dap", dependencies = { - { "mxsdev/nvim-dap-vscode-js" }, - { - "microsoft/vscode-js-debug", - build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", - }, + -- { "mxsdev/nvim-dap-vscode-js" }, + -- { + -- "microsoft/vscode-js-debug", + -- build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", + -- }, }, opts = { setup = { vscode_js_debug = function() + -- local function get_js_debug() + -- local path = vim.fn.stdpath "data" + -- return path .. "/lazy/vscode-js-debug" + -- end + + -- require("dap-vscode-js").setup { + -- node_path = "node", + -- debugger_path = get_js_debug(), + -- adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, + -- } + local function get_js_debug() - local path = vim.fn.stdpath "data" - return path .. "/lazy/vscode-js-debug" + local install_path = require("mason-registry").get_package("js-debug-adapter"):get_install_path() + return install_path .. "/js-debug/src/dapDebugServer.js" end - require("dap-vscode-js").setup { - node_path = "node", - debugger_path = get_js_debug(), - adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, - } + for _, adapter in ipairs { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" } do + require("dap").adapters[adapter] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "node", + args = { + get_js_debug(), + "${port}", + }, + }, + } + end for _, language in ipairs { "typescript", "javascript" } do require("dap").configurations[language] = { From c6e6cc8420519bf29f3345bcd1d22393fd40ade4 Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sun, 16 Jul 2023 13:10:37 +0800 Subject: [PATCH 2/7] refactor: typescript pde --- lua/pde/typescript.lua | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/lua/pde/typescript.lua b/lua/pde/typescript.lua index 664e397..5c63387 100644 --- a/lua/pde/typescript.lua +++ b/lua/pde/typescript.lua @@ -23,7 +23,10 @@ return { require("base.lsp.utils").on_attach(function(client, bufnr) if client.name == "tsserver" then vim.keymap.set("n", "lo", "TSToolsOrganizeImports", { buffer = bufnr, desc = "Organize Imports" }) - vim.keymap.set("n", "lF", "TSToolsFixAll", { desc = "Fix All", buffer = bufnr }) + vim.keymap.set("n", "lO", "TSToolsSortImports", { buffer = bufnr, desc = "Sort Imports" }) + vim.keymap.set("n", "lR", "TSToolsRemoveUnusedImports", { buffer = bufnr, desc = "Removed Unused Imports" }) + vim.keymap.set("n", "lF", "TSToolsFixAll", { buffer = bufnr, desc = "Fix All" }) + vim.keymap.set("n", "lA", "TSToolsAddMissingImports", { buffer = bufnr, desc = "Add Missing Imports" }) end end) require("typescript-tools").setup(opts) @@ -31,7 +34,7 @@ return { }, { "neovim/nvim-lspconfig", - dependencies = { "jose-elias-alvarez/typescript.nvim" }, + dependencies = { "pmizio/typescript-tools.nvim" }, opts = { -- make sure mason installs the server servers = { @@ -60,35 +63,11 @@ return { }, }, }, - { - "jose-elias-alvarez/null-ls.nvim", - opts = function(_, opts) - table.insert(opts.sources, require "typescript.extensions.null-ls.code-actions") - end, - }, { "mfussenegger/nvim-dap", - dependencies = { - -- { "mxsdev/nvim-dap-vscode-js" }, - -- { - -- "microsoft/vscode-js-debug", - -- build = "npm install --legacy-peer-deps && npx gulp vsDebugServerBundle && mv dist out", - -- }, - }, opts = { setup = { vscode_js_debug = function() - -- local function get_js_debug() - -- local path = vim.fn.stdpath "data" - -- return path .. "/lazy/vscode-js-debug" - -- end - - -- require("dap-vscode-js").setup { - -- node_path = "node", - -- debugger_path = get_js_debug(), - -- adapters = { "pwa-node", "pwa-chrome", "pwa-msedge", "node-terminal", "pwa-extensionHost" }, - -- } - local function get_js_debug() local install_path = require("mason-registry").get_package("js-debug-adapter"):get_install_path() return install_path .. "/js-debug/src/dapDebugServer.js" From 21457fdb7f0b174dcd567cbaf8fe09050128956f Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sun, 16 Jul 2023 16:24:08 +0800 Subject: [PATCH 3/7] chore: fix --- lua/base/editor.lua | 9 +++++++++ lua/pde/jupyter.lua | 32 +++++--------------------------- 2 files changed, 14 insertions(+), 27 deletions(-) diff --git a/lua/base/editor.lua b/lua/base/editor.lua index af52d20..d3d893a 100644 --- a/lua/base/editor.lua +++ b/lua/base/editor.lua @@ -88,4 +88,13 @@ return { end end, }, + { + "folke/edgy.nvim", + event = "VeryLazy", + opts = { + bottom = { + { ft = "qf", title = "QuickFix" }, + }, + }, + }, } diff --git a/lua/pde/jupyter.lua b/lua/pde/jupyter.lua index 568ae30..ddd197d 100644 --- a/lua/pde/jupyter.lua +++ b/lua/pde/jupyter.lua @@ -162,32 +162,10 @@ local function repl_menu() local cmd = require("hydra.keymap-util").cmd local hint = [[ - ^ - _a_: Insert Cell After - _b_: Insert Cell Before - _e_: Execute Cell - _j_: Next Cell - _k_: Previous Cell - _m_: Insert Markdown Cell - _x_: Delete Cell - ^ - _s_: Send Motion - _l_: Send Line - _t_: Send Until Cursor - _f_: Send File - ^ - _R_: Show REPL - _C_: Close REPL - _S_: Restart REPL - _F_: Focus - _H_: Hide - ^ - _c_: Clear - _L_: Clear Highlight - __: ENTER - _I_: Interrupt - ^ - ^ ^ _q_: Quit + ^^ _a_: Insert Cell After ^ _b_: Insert Cell Before ^ _e_: Execute Cell ^ _j_: Next Cell ^ _k_: Previous Cell ^ _m_: Insert Markdown Cell ^ _x_: Delete Cell + ^^ _s_: Send Motion ^ _l_: Send Line ^ _t_: Send Until Cursor ^ _f_: Send File _R_: Show REPL ^ _C_: Close REPL ^ _S_: Restart REPL ^ _F_: Focus _H_: Hide + ^^ _c_: Clear ^ _L_: Clear Highlight ^ __: ENTER ^ _I_: Interrupt + ^ ^ ^ _q_: Quit ]] return { @@ -198,7 +176,7 @@ local function repl_menu() invoke_on_body = true, hint = { border = "rounded", - position = "top-middle", + position = "bottom-middle", }, }, mode = "n", From ade78cec11f9455135bd1e40624ac412f1547174 Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sun, 16 Jul 2023 18:18:39 +0800 Subject: [PATCH 4/7] feat: typescript pde --- lua/pde/typescript.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/pde/typescript.lua b/lua/pde/typescript.lua index 5c63387..c4f2c23 100644 --- a/lua/pde/typescript.lua +++ b/lua/pde/typescript.lua @@ -17,7 +17,6 @@ return { }, { "pmizio/typescript-tools.nvim", - dependencies = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" }, opts = {}, config = function(_, opts) require("base.lsp.utils").on_attach(function(client, bufnr) From e4405c16cea3e04c8a6ab8f3bcee998686b067e8 Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Fri, 21 Jul 2023 14:45:12 +0800 Subject: [PATCH 5/7] fix: minor changes --- lua/base/lsp/keymaps.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/base/lsp/keymaps.lua b/lua/base/lsp/keymaps.lua index 14c0f4d..ebb3983 100644 --- a/lua/base/lsp/keymaps.lua +++ b/lua/base/lsp/keymaps.lua @@ -3,10 +3,13 @@ local M = {} function M.on_attach(client, buffer) local self = M.new(client, buffer) - self:map("gd", "Telescope lsp_definitions", { desc = "Goto Definition" }) + -- stylua: ignore + self:map("gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, { desc = "Goto Definition" }) self:map("gr", "Telescope lsp_references", { desc = "References" }) - self:map("gI", "Telescope lsp_implementations", { desc = "Goto Implementation" }) - self:map("gb", "Telescope lsp_type_definitions", { desc = "Goto Type Definition" }) + -- stylua: ignore + self:map("gI", function() require("telescope.builtin").lsp_implementations({ reuse_win = true }) end, { desc = "Goto Implementation" }) + -- stylua: ignore + self:map("gy", function() require("telescope.builtin").lsp_type_definitions({ reuse_win = true }) end, { desc = "Goto Type Definition" }) self:map("K", vim.lsp.buf.hover, { desc = "Hover" }) self:map("gK", vim.lsp.buf.signature_help, { desc = "Signature Help", has = "signatureHelp" }) self:map("]d", M.diagnostic_goto(true), { desc = "Next Diagnostic" }) From c3d40c50144ea04649d05ed17fe2bce0352dfdaa Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sat, 22 Jul 2023 20:51:05 +0800 Subject: [PATCH 6/7] chore: minor changes --- lua/base/editor.lua | 4 ++-- lua/pde/typescript.lua | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/base/editor.lua b/lua/base/editor.lua index d3d893a..3150b5f 100644 --- a/lua/base/editor.lua +++ b/lua/base/editor.lua @@ -92,8 +92,8 @@ return { "folke/edgy.nvim", event = "VeryLazy", opts = { - bottom = { - { ft = "qf", title = "QuickFix" }, + left = { + { ft = "hydra_hint", title = "Hydra", size = { height = 0.5 }, pinned = false }, }, }, }, diff --git a/lua/pde/typescript.lua b/lua/pde/typescript.lua index c4f2c23..2ad6fce 100644 --- a/lua/pde/typescript.lua +++ b/lua/pde/typescript.lua @@ -23,6 +23,8 @@ return { if client.name == "tsserver" then vim.keymap.set("n", "lo", "TSToolsOrganizeImports", { buffer = bufnr, desc = "Organize Imports" }) vim.keymap.set("n", "lO", "TSToolsSortImports", { buffer = bufnr, desc = "Sort Imports" }) + vim.keymap.set("n", "lu", "TSToolsRemoveUnused", { buffer = bufnr, desc = "Removed Unused" }) + vim.keymap.set("n", "lz", "TSToolsGoToSourceDefinition", { buffer = bufnr, desc = "Go To Source Definition" }) vim.keymap.set("n", "lR", "TSToolsRemoveUnusedImports", { buffer = bufnr, desc = "Removed Unused Imports" }) vim.keymap.set("n", "lF", "TSToolsFixAll", { buffer = bufnr, desc = "Fix All" }) vim.keymap.set("n", "lA", "TSToolsAddMissingImports", { buffer = bufnr, desc = "Add Missing Imports" }) From 53c610db58a18418e9f44bd7435389af7eaf2aad Mon Sep 17 00:00:00 2001 From: alpha2phi Date: Sat, 22 Jul 2023 23:17:54 +0800 Subject: [PATCH 7/7] feat: configuration recipes --- lua/base/editor.lua | 2 +- lua/pde/jupyter.lua | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lua/base/editor.lua b/lua/base/editor.lua index 3150b5f..3414bf7 100644 --- a/lua/base/editor.lua +++ b/lua/base/editor.lua @@ -93,7 +93,7 @@ return { event = "VeryLazy", opts = { left = { - { ft = "hydra_hint", title = "Hydra", size = { height = 0.5 }, pinned = false }, + { ft = "hydra_hint", title = "Hydra", size = { height = 0.5 }, pinned = true }, }, }, }, diff --git a/lua/pde/jupyter.lua b/lua/pde/jupyter.lua index ddd197d..ea560e5 100644 --- a/lua/pde/jupyter.lua +++ b/lua/pde/jupyter.lua @@ -162,10 +162,32 @@ local function repl_menu() local cmd = require("hydra.keymap-util").cmd local hint = [[ - ^^ _a_: Insert Cell After ^ _b_: Insert Cell Before ^ _e_: Execute Cell ^ _j_: Next Cell ^ _k_: Previous Cell ^ _m_: Insert Markdown Cell ^ _x_: Delete Cell - ^^ _s_: Send Motion ^ _l_: Send Line ^ _t_: Send Until Cursor ^ _f_: Send File _R_: Show REPL ^ _C_: Close REPL ^ _S_: Restart REPL ^ _F_: Focus _H_: Hide - ^^ _c_: Clear ^ _L_: Clear Highlight ^ __: ENTER ^ _I_: Interrupt - ^ ^ ^ _q_: Quit + ^ + _a_: Insert Cell After + _b_: Insert Cell Before + _e_: Execute Cell + _j_: Next Cell + _k_: Previous Cell + _m_: Insert Markdown Cell + _x_: Delete Cell + ^ + _s_: Send Motion + _l_: Send Line + _t_: Send Until Cursor + _f_: Send File + ^ + _R_: Show REPL + _C_: Close REPL + _S_: Restart REPL + _F_: Focus + _H_: Hide + ^ + _c_: Clear + _L_: Clear Highlight + __: ENTER + _I_: Interrupt + ^ + ^ ^ _q_: Quit ]] return {