(nvim) finalize improved nvim config
This commit is contained in:
parent
09bed20099
commit
f3d0de71c1
12 changed files with 288 additions and 396 deletions
|
|
@ -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" },
|
||||
|
|
|
|||
|
|
@ -73,5 +73,8 @@
|
|||
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
|
||||
"/home/jc/ghq/juancwu/dotfiles/nvim/lua",
|
||||
"${3rd}/luv/library"
|
||||
],
|
||||
"diagnostics.globals": [
|
||||
"vim"
|
||||
]
|
||||
}
|
||||
93
nvim/lua/juancwu/plugins/autocomplete.lua
Normal file
93
nvim/lua/juancwu/plugins/autocomplete.lua
Normal file
|
|
@ -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
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
-- Select the [p]revious item
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
|
||||
-- Scroll the documentation window [b]ack / [f]orward
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = 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.
|
||||
["<CR>"] = 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.
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
|
||||
-- <c-l> will move you to the right of each of the expansion locations.
|
||||
-- <c-h> is similar, except moving you backwards.
|
||||
["<C-l>"] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-h>"] = 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,
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
return {
|
||||
"windwp/nvim-autopairs",
|
||||
event = "InsertEnter",
|
||||
opts = {
|
||||
disable_filetype = { "TelescopePrompt", "vim" }
|
||||
},
|
||||
}
|
||||
50
nvim/lua/juancwu/plugins/conform.lua
Normal file
50
nvim/lua/juancwu/plugins/conform.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
return {
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>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,
|
||||
}
|
||||
|
|
@ -1,118 +1,123 @@
|
|||
return {
|
||||
-- lspconfig
|
||||
{
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
branch = "v2.x",
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
-- LSP Support
|
||||
{ "neovim/nvim-lspconfig" }, -- Required
|
||||
{
|
||||
-- Optional
|
||||
"williamboman/mason.nvim",
|
||||
build = function()
|
||||
pcall(vim.cmd, "MasonUpdate")
|
||||
end,
|
||||
},
|
||||
{ "williamboman/mason-lspconfig.nvim" }, -- Optional
|
||||
|
||||
-- Autocompletion
|
||||
{ "hrsh7th/nvim-cmp" }, -- Required
|
||||
{ "williamboman/mason.nvim", opts = {} },
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"WhoIsSethDaniel/mason-tool-installer.nvim",
|
||||
|
||||
-- status updates for LSP
|
||||
{ "j-hui/fidget.nvim", opts = {} },
|
||||
|
||||
{ "hrsh7th/cmp-nvim-lsp" }, -- Required
|
||||
{ "L3MON4D3/LuaSnip" }, -- Required
|
||||
|
||||
-- Neovim Plugin Development Completions
|
||||
{
|
||||
"folke/neodev.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
|
||||
-- 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
|
||||
|
||||
-- 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 <C-t>.
|
||||
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
|
||||
|
||||
-- Find references for the word under your cursor.
|
||||
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
|
||||
|
||||
-- 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")
|
||||
|
||||
-- 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("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
|
||||
|
||||
-- Fuzzy find all the symbols in your current document.
|
||||
-- Symbols are things like variables, functions, types, etc.
|
||||
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
|
||||
|
||||
-- Fuzzy find all the symbols in your current workspace.
|
||||
-- Similar to document symbols, except searches over your entire project.
|
||||
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
|
||||
|
||||
-- Rename the variable under your cursor.
|
||||
-- Most Language Servers support renaming across files, etc.
|
||||
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
|
||||
|
||||
-- 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("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
|
||||
|
||||
-- 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")
|
||||
|
||||
-- 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,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
|
||||
buffer = event.buf,
|
||||
group = highlight_augroup,
|
||||
callback = vim.lsp.buf.clear_references,
|
||||
})
|
||||
|
||||
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
|
||||
return { timeout_ms = 500, lsp_fallback = true }
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_user_command("FormatDisable", function()
|
||||
vim.g.disable_autoformat = true
|
||||
end, {
|
||||
desc = "Disable autoformat on save",
|
||||
})
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
|
||||
|
||||
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({})
|
||||
|
||||
local lspzero = require("lsp-zero")
|
||||
|
||||
lspzero.preset({})
|
||||
|
||||
lspzero.on_attach(function(_, bufnr)
|
||||
lspzero.default_keymaps({
|
||||
buffer = bufnr,
|
||||
omit = {
|
||||
"gr",
|
||||
vim.filetype.add({
|
||||
extension = {
|
||||
templ = "templ",
|
||||
},
|
||||
})
|
||||
|
||||
local function nmap(key, action, desc)
|
||||
vim.keymap.set("n", key, action, {
|
||||
desc = "LSP: " .. desc,
|
||||
})
|
||||
end
|
||||
|
||||
local function format()
|
||||
require("conform").format({ bufnr = bufnr })
|
||||
end
|
||||
|
||||
nmap("[d", "<cmd>lua vim.diagnostic.goto_prev()<CR>", "Goto Prev Diagnostic")
|
||||
nmap("]d", "<cmd>lua vim.diagnostic.goto_next()<CR>", "Goto Next Diagnostic")
|
||||
|
||||
-- local current_dir = vim.fn.expand("%:p:h")
|
||||
|
||||
-- vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references<cr>', { buffer = true })
|
||||
|
||||
-- format with space + f
|
||||
-- vim.keymap.set("n", "<leader>fb", "<cmd>lua vim.lsp.buf.format()<CR>",
|
||||
-- { desc = "[F]ormat [B]uffer" })
|
||||
nmap("<leader>fb", format, "[F]ormat [B]uffer")
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_)
|
||||
format()
|
||||
end, { desc = "Format current buffer with LSP" })
|
||||
end)
|
||||
|
||||
local status, lspconfig = pcall(require, "lspconfig")
|
||||
|
||||
if status then
|
||||
lspconfig.ts_ls.setup({})
|
||||
lspconfig.tailwindcss.setup({
|
||||
local servers = {
|
||||
ts_ls = {},
|
||||
gopls = {},
|
||||
zls = {},
|
||||
rust_analyzer = {},
|
||||
templ = {
|
||||
filetypes = { "templ" },
|
||||
},
|
||||
intelephense = {},
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
tailwindcss = {
|
||||
filetypes = {
|
||||
"templ",
|
||||
"html",
|
||||
|
|
@ -126,41 +131,21 @@ return {
|
|||
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
|
||||
}
|
||||
|
||||
lspzero.setup()
|
||||
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 })
|
||||
|
||||
local cmp
|
||||
status, cmp = pcall(require, "cmp")
|
||||
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
mapping = {
|
||||
-- press 'enter' to confirm completion/suggestion
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
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,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
return {
|
||||
"echasnovski/mini.icons",
|
||||
opts = {
|
||||
version = false,
|
||||
},
|
||||
}
|
||||
|
|
@ -5,11 +5,6 @@ return {
|
|||
},
|
||||
config = function()
|
||||
local null_ls = require("null-ls")
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
null_ls.builtins.formatting.prettierd,
|
||||
-- null_ls.builtins.diagnostics.eslint,
|
||||
},
|
||||
})
|
||||
null_ls.setup({})
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
@ -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",
|
||||
"<leader>d" .. key,
|
||||
action,
|
||||
{
|
||||
desc = "[D]AP: " .. desc,
|
||||
noremap = true,
|
||||
nowait = false,
|
||||
silent = true
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
nmap("c", "<cmd>lua require'dap'.continue()<CR>", "[C]ontinue")
|
||||
nmap("b", "<cmd>lua require'dap'.toggle_breakpoint()<CR>", "Toggle [B]reakpoint")
|
||||
nmap("i", "<cmd>lua require'dap'.step_into()<CR>", "Step [I]nto")
|
||||
nmap("o", "<cmd>lua require'dap'.step_over()<CR>", "Step [O]ver")
|
||||
nmap("u", "<cmd>lua require'dap'.step_out()<CR>", "[U] Step Out")
|
||||
nmap("x", "<cmd>lua require'dap'.terminate()<CR>", "[T]erminate")
|
||||
nmap("q", "<cmd>lua require'dap'.close()<CR>", "[Q]uit")
|
||||
else
|
||||
local keymap = {
|
||||
{ "<leader>d", group = "DAP", nowait = false, remap = false },
|
||||
{ "<leader>db", "<cmd>lua require'dap'.toggle_breakpoint()<CR>", desc = "Toggle [B]reakpoint", nowait = false, remap = false },
|
||||
{ "<leader>dc", "<cmd>lua require'dap'.continue()<CR>", desc = "[C]ontinue", nowait = false, remap = false },
|
||||
{ "<leader>di", "<cmd>lua require'dap'.step_into()<CR>", desc = "Step [I]nto", nowait = false, remap = false },
|
||||
{ "<leader>do", "<cmd>lua require'dap'.step_over()<CR>", desc = "Step [O]ver", nowait = false, remap = false },
|
||||
{ "<leader>dq", "<cmd>lua require'dap'.close()<CR>", desc = "[Q]uit", nowait = false, remap = false },
|
||||
{ "<leader>du", "<cmd>lua require'dap'.step_out()<CR>", desc = "[U] Step Out", nowait = false, remap = false },
|
||||
{ "<leader>dx", "<cmd>lua require'dap'.terminate()<CR>", desc = "[T]erminate", nowait = false, remap = false },
|
||||
}
|
||||
|
||||
local opts = {
|
||||
mode = "n",
|
||||
prefix = "<leader>",
|
||||
buffer = nil,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
nowait = false,
|
||||
}
|
||||
wk.add(keymap, opts)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
@ -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 = {
|
||||
{ "<leader>od", "<cmd>ObsidianToday<cr>", 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 = {
|
||||
["<CR>"] = {
|
||||
action = function()
|
||||
return require("obsidian").util.smart_action()
|
||||
end,
|
||||
opts = { noremap = false, expr = true, buffer = true },
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue