From 4952447714b01da5f89c95956e3e98a96ae09873 Mon Sep 17 00:00:00 2001 From: Gilad Sher Date: Sun, 17 Dec 2023 18:24:28 -0500 Subject: [PATCH] bring up to date with remote --- after/plugin/filetype.lua | 6 + after/plugin/harpoon.lua | 8 + after/plugin/init.lua | 12 ++ after/plugin/prettier.lua | 6 + init.lua | 222 +++++++++++---------- lazy-lock.json | 16 +- lua/custom/plugins/autobrackets.lua | 6 + lua/custom/plugins/autopairs.lua | 6 + lua/custom/plugins/colorizer.lua | 6 + lua/custom/plugins/copilot.lua | 3 + lua/custom/plugins/filetree.lua | 15 ++ lua/custom/plugins/harpoon.lua | 3 + lua/custom/plugins/prettier.lua | 3 + lua/custom/plugins/tree-sitter-context.lua | 6 + lua/kickstart/plugins/debug.lua | 41 +++- 15 files changed, 253 insertions(+), 106 deletions(-) create mode 100644 after/plugin/filetype.lua create mode 100644 after/plugin/harpoon.lua create mode 100644 after/plugin/init.lua create mode 100644 after/plugin/prettier.lua create mode 100644 lua/custom/plugins/autobrackets.lua create mode 100644 lua/custom/plugins/autopairs.lua create mode 100644 lua/custom/plugins/colorizer.lua create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/filetree.lua create mode 100644 lua/custom/plugins/harpoon.lua create mode 100644 lua/custom/plugins/prettier.lua create mode 100644 lua/custom/plugins/tree-sitter-context.lua diff --git a/after/plugin/filetype.lua b/after/plugin/filetype.lua new file mode 100644 index 00000000..45f67020 --- /dev/null +++ b/after/plugin/filetype.lua @@ -0,0 +1,6 @@ +vim.cmd([[ + augroup filetypedetect + autocmd! BufRead,BufNewFile .swcrc setfiletype json + autocmd! BufRead,BufNewFile .prettierrc setfiletype json + augroup END +]]) diff --git a/after/plugin/harpoon.lua b/after/plugin/harpoon.lua new file mode 100644 index 00000000..018bb93c --- /dev/null +++ b/after/plugin/harpoon.lua @@ -0,0 +1,8 @@ +-- local mark = require("harpoon.mark") +-- local ui = require("harpoon.ui") +-- vim.keymap.set("n", "ah", mark.add_file) +-- vim.keymap.set("n", "", ui.toggle_quick_menu) +-- vim.keymap.set("n", "", function() ui.nav_file(1) end) +-- vim.keymap.set("n", "", function() ui.nav_file(2) end) +-- vim.keymap.set("n", "", function() ui.nav_file(3) end) +-- vim.keymap.set("n", "", function() ui.nav_file(4) end) diff --git a/after/plugin/init.lua b/after/plugin/init.lua new file mode 100644 index 00000000..86fdcbcf --- /dev/null +++ b/after/plugin/init.lua @@ -0,0 +1,12 @@ +vim.opt.relativenumber = true +vim.keymap.set("n", "pv", "Ex") +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.smartindent = true +vim.opt.tabstop = 2 +vim.keymap.set("n", "y", '"+y') +vim.keymap.set("n", "gs", ':Git') +vim.keymap.set("n", "gp", ':Git pull') +vim.keymap.set("n", "gpsh", ':Git push') +vim.keymap.set("n", "gh", 'diffget //2') +vim.keymap.set("n", "gl", 'diffget //3') diff --git a/after/plugin/prettier.lua b/after/plugin/prettier.lua new file mode 100644 index 00000000..e5ef0962 --- /dev/null +++ b/after/plugin/prettier.lua @@ -0,0 +1,6 @@ +vim.cmd([[ + augroup FormatAutogroup + autocmd! + autocmd BufWritePre *.js,*.jsx,*.ts,*.tsx,*.cjs,*.mjs,*.cts,*.mts Prettier + augroup END +]]) diff --git a/init.lua b/init.lua index cf4a3790..19d069c6 100644 --- a/init.lua +++ b/init.lua @@ -95,6 +95,8 @@ require('lazy').setup({ }, }, + { 'b0o/schemastore.nvim', dependencies = { "neovim/nvim-lspconfig" } }, + { -- Autocompletion 'hrsh7th/nvim-cmp', @@ -222,7 +224,7 @@ require('lazy').setup({ }, -- "gc" to comment visual regions/lines - { 'numToStr/Comment.nvim', opts = {} }, + { 'numToStr/Comment.nvim', opts = {} }, -- Fuzzy Finder (files, lsp, etc) { @@ -257,8 +259,8 @@ require('lazy').setup({ -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart -- These are some example plugins that I've included in the kickstart repository. -- Uncomment any of the lines below to enable them. - -- require 'kickstart.plugins.autoformat', - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.autoformat', + require 'kickstart.plugins.debug', -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping @@ -266,7 +268,7 @@ require('lazy').setup({ -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, {}) -- [[ Setting options ]] @@ -320,12 +322,6 @@ vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) --- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) -vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) - -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) @@ -347,12 +343,21 @@ require('telescope').setup { [''] = false, }, }, + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden' + } }, } -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') - -- Telescope live_grep in git root -- Function to find the git root directory based on the current buffer's path local function find_git_root() @@ -419,72 +424,75 @@ vim.keymap.set('n', 'sr', require('telescope.builtin').resume, { desc = -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` --- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' -vim.defer_fn(function() - require('nvim-treesitter.configs').setup { - -- Add languages to be installed here that you want installed for treesitter - ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim', 'bash' }, +require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim', 'css', 'scss' }, - -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) - auto_install = false, + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + scope_incremental = '', + node_decremental = '', + }, + }, + textobjects = { + select = { enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim keymaps = { - init_selection = '', - node_incremental = '', - scope_incremental = '', - node_decremental = '', + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', }, }, - textobjects = { - select = { - enable = true, - lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ['aa'] = '@parameter.outer', - ['ia'] = '@parameter.inner', - ['af'] = '@function.outer', - ['if'] = '@function.inner', - ['ac'] = '@class.outer', - ['ic'] = '@class.inner', - }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - [']m'] = '@function.outer', - [']]'] = '@class.outer', - }, - goto_next_end = { - [']M'] = '@function.outer', - [']['] = '@class.outer', - }, - goto_previous_start = { - ['[m'] = '@function.outer', - ['[['] = '@class.outer', - }, - goto_previous_end = { - ['[M'] = '@function.outer', - ['[]'] = '@class.outer', - }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', }, - swap = { - enable = true, - swap_next = { - ['a'] = '@parameter.inner', - }, - swap_previous = { - ['A'] = '@parameter.inner', - }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', }, }, - } -end, 0) + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, +} + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. @@ -506,10 +514,10 @@ local on_attach = function(_, bufnr) nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') - nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') + nmap('gI', vim.lsp.buf.implementation, '[G]oto [I]mplementation') + nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') @@ -531,29 +539,6 @@ local on_attach = function(_, bufnr) end, { desc = 'Format current buffer with LSP' }) end --- document existing key chains -require('which-key').register { - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['t'] = { name = '[T]oggle', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, -} --- register which-key VISUAL mode --- required for visual hs (hunk stage) to work -require('which-key').register({ - [''] = { name = 'VISUAL ' }, - ['h'] = { 'Git [H]unk' }, -}, { mode = 'v' }) - --- mason-lspconfig requires that these setup functions are called in this order --- before setting up the servers. -require('mason').setup() -require('mason-lspconfig').setup() - -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- @@ -564,18 +549,20 @@ require('mason-lspconfig').setup() -- define the property 'filetypes' to the map in question. local servers = { -- clangd = {}, - -- gopls = {}, + gopls = {}, -- pyright = {}, - -- rust_analyzer = {}, - -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + rust_analyzer = {}, + tsserver = {}, lua_ls = { Lua = { - workspace = { checkThirdParty = false }, + workspace = { checkThirdParty = false, library = vim.api.nvim_get_runtime_file("", true) }, telemetry = { enable = false }, - -- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings - -- diagnostics = { disable = { 'missing-fields' } }, + diagnostics = { + globals = { + 'vim', 'require' + } + } }, }, } @@ -585,15 +572,42 @@ require('neodev').setup() -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + -- Ensure the servers above are installed local mason_lspconfig = require 'mason-lspconfig' +require('mason').setup() mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), } +require('lspconfig').jsonls.setup { + settings = { + json = { + schemas = require('schemastore').json.schemas(), + validate = { enable = true }, + }, + yaml = { + schemas = require('schemastore').yaml.schemas(), + }, + } +} + +require('lspconfig').ltex.setup { + settings = { + ltex = { + language = "en-US", + diagnosticsSeverity = "information", + additionalRules = { + motherTongue = "en-US" + } + } + } +} + mason_lspconfig.setup_handlers { function(server_name) require('lspconfig')[server_name].setup { @@ -602,7 +616,7 @@ mason_lspconfig.setup_handlers { settings = servers[server_name], filetypes = (servers[server_name] or {}).filetypes, } - end, + end } -- [[ Configure nvim-cmp ]] @@ -626,12 +640,12 @@ cmp.setup { [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.complete {}, [''] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then @@ -640,7 +654,7 @@ cmp.setup { fallback() end end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) + [''] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.locally_jumpable(-1) then diff --git a/lazy-lock.json b/lazy-lock.json index b2372cfc..5c8dc506 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -2,26 +2,40 @@ "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "57c9f5c31b3d712376c704673eac8e948c82e9c1" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot.vim": { "branch": "release", "commit": "5b19fb001d7f31c4c7c5556d7a97b243bd29f45f" }, "fidget.nvim": { "branch": "main", "commit": "7b9c383438a2e490e37d57b07ddeae3ab4f4cf69" }, "friendly-snippets": { "branch": "main", "commit": "53d3df271d031c405255e99410628c26a8f0d2b0" }, "gitsigns.nvim": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, + "harpoon": { "branch": "master", "commit": "867e212ac153e793f95b316d1731f3ca1894625e" }, "indent-blankline.nvim": { "branch": "master", "commit": "d4c718467d35bc93714425a7102d82e7e5065280" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9453e3d6cd2ca45d96e20f343e8f1b927364b630" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "5b4db7c0d6873436b42bcda0ba7cd4efa9206745" }, "mason.nvim": { "branch": "main", "commit": "41e75af1f578e55ba050c863587cffde3556ffa6" }, + "neo-tree.nvim": { "branch": "main", "commit": "230ff118613fa07138ba579b89d13ec2201530b9" }, "neodev.nvim": { "branch": "main", "commit": "be6bf4f5d2d3b173c9291f074130a3d29e1af78a" }, + "nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, + "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, "nvim-cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, + "nvim-dap": { "branch": "master", "commit": "e64ebf3309154b578a03c76229ebf51c37898118" }, + "nvim-dap-go": { "branch": "main", "commit": "a5cc8dcad43f0732585d4793deb02a25c4afb766" }, + "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, "nvim-lspconfig": { "branch": "master", "commit": "e50a8fcd6267cb9b2d2a880dcf3a8ac113b75abc" }, "nvim-treesitter": { "branch": "master", "commit": "25ddfde8d7167d7d81403d6809242439037d2b68" }, + "nvim-treesitter-context": { "branch": "master", "commit": "c9f2b429a1d63023f7a33b5404616f4cd2a109c5" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" }, + "nvim-ts-autotag": { "branch": "main", "commit": "8515e48a277a2f4947d91004d9aa92c29fdc5e18" }, + "nvim-web-devicons": { "branch": "master", "commit": "a1425903ab52a0a0460622519e827f224e5b4fee" }, "onedark.nvim": { "branch": "master", "commit": "c5476a091b0f1b4e853db91c91ff941f848a1cdd" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, + "schemastore.nvim": { "branch": "main", "commit": "de7a5763edab2075e1925869af827ca38109ebfa" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope.nvim": { "branch": "0.1.x", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, "vim-fugitive": { "branch": "master", "commit": "59659093581aad2afacedc81f009ed6a4bfad275" }, + "vim-prettier": { "branch": "master", "commit": "7dbdbb12c50a9f4ba72390cce2846248e4368fd0" }, "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } diff --git a/lua/custom/plugins/autobrackets.lua b/lua/custom/plugins/autobrackets.lua new file mode 100644 index 00000000..bf695bfe --- /dev/null +++ b/lua/custom/plugins/autobrackets.lua @@ -0,0 +1,6 @@ +return { + 'windwp/nvim-ts-autotag', + config = function() + require('nvim-ts-autotag').setup() + end +} diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua new file mode 100644 index 00000000..4082bd88 --- /dev/null +++ b/lua/custom/plugins/autopairs.lua @@ -0,0 +1,6 @@ +return { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup {} + end, +} diff --git a/lua/custom/plugins/colorizer.lua b/lua/custom/plugins/colorizer.lua new file mode 100644 index 00000000..090dddb4 --- /dev/null +++ b/lua/custom/plugins/colorizer.lua @@ -0,0 +1,6 @@ +return { + 'norcalli/nvim-colorizer.lua', + config = function () + require('colorizer').setup() + end +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000..7a6f681b --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,3 @@ +return { + 'github/copilot.vim' +} diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua new file mode 100644 index 00000000..4c9f2399 --- /dev/null +++ b/lua/custom/plugins/filetree.lua @@ -0,0 +1,15 @@ +-- Unless you are still migrating, remove the deprecated commands from v1.x +vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) + +return { + "nvim-neo-tree/neo-tree.nvim", + version = "*", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + config = function() + require('neo-tree').setup {} + end, +} diff --git a/lua/custom/plugins/harpoon.lua b/lua/custom/plugins/harpoon.lua new file mode 100644 index 00000000..8653cffe --- /dev/null +++ b/lua/custom/plugins/harpoon.lua @@ -0,0 +1,3 @@ +return { + "ThePrimeagen/harpoon" +} diff --git a/lua/custom/plugins/prettier.lua b/lua/custom/plugins/prettier.lua new file mode 100644 index 00000000..0890fba4 --- /dev/null +++ b/lua/custom/plugins/prettier.lua @@ -0,0 +1,3 @@ +return { + 'prettier/vim-prettier' +} diff --git a/lua/custom/plugins/tree-sitter-context.lua b/lua/custom/plugins/tree-sitter-context.lua new file mode 100644 index 00000000..20381f7e --- /dev/null +++ b/lua/custom/plugins/tree-sitter-context.lua @@ -0,0 +1,6 @@ +return { + 'nvim-treesitter/nvim-treesitter-context', + config = function () + require('treesitter-context').setup() + end +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 7fc783fa..46e51888 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -38,7 +38,8 @@ return { -- online, please don't ask me how to install them :) ensure_installed = { -- Update this to ensure that you have the debuggers for the langs you want - 'delve', + -- 'delve', + 'chrome-debug-adapter' }, } @@ -51,6 +52,7 @@ return { vim.keymap.set('n', 'B', function() dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ') end, { desc = 'Debug: Set Breakpoint' }) + vim.keymap.set('n', 'dr', function() dap.repl.open() end, { desc = 'Debug: Open Repl' }) -- Dap UI setup -- For more information, see |:help nvim-dap-ui| @@ -83,5 +85,42 @@ return { -- Install golang specific config require('dap-go').setup() + + dap.adapters.chrome = { + type = "executable", + command = "node", + args = { "/Users/giladsher/.local/share/nvim/lazy/vscode-chrome-debug/out/src/chromeDebug.js" } -- TODO adjust + } + + + for _, language in ipairs({ "typescript", "javascript" }) do + require("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}", + }, + { + name = 'Chrome', + type = "chrome", + request = "attach", + program = "${file}", + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = "inspector", + port = 9222, + webRoot = "${workspaceFolder}" + } + } + end end, }