diff --git a/.gitignore b/.gitignore index 005b535b606..34477f08fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ test.sh nvim spell/ -lazy-lock.json +# lazy-lock.json diff --git a/init.lua b/init.lua index 776c6873ff6..8ebe5c8d34c 100644 --- a/init.lua +++ b/init.lua @@ -1,87 +1,8 @@ --[[ - -===================================================================== -==================== READ THIS BEFORE CONTINUING ==================== -===================================================================== -======== .-----. ======== -======== .----------------------. | === | ======== -======== |.-""""""""""""""""""-.| |-----| ======== -======== || || | === | ======== -======== || KICKSTART.NVIM || |-----| ======== -======== || || | === | ======== -======== || || |-----| ======== -======== ||:Tutor || |:::::| ======== -======== |'-..................-'| |____o| ======== -======== `"")----------------(""` ___________ ======== -======== /::::::::::| |::::::::::\ \ no mouse \ ======== -======== /:::========| |==hjkl==:::\ \ required \ ======== -======== '""""""""""""' '""""""""""""' '""""""""""' ======== -======== ======== -===================================================================== -===================================================================== - -What is Kickstart? - - Kickstart.nvim is *not* a distribution. - - Kickstart.nvim is a starting point for your own configuration. - The goal is that you can read every line of code, top-to-bottom, understand - what your configuration is doing, and modify it to suit your needs. - - Once you've done that, you can start exploring, configuring and tinkering to - make Neovim your own! That might mean leaving Kickstart just the way it is for a while - or immediately breaking it into modular pieces. It's up to you! - - If you don't know anything about Lua, I recommend taking some time to read through - a guide. One possible example which will only take 10-15 minutes: - - https://learnxinyminutes.com/docs/lua/ - - After understanding a bit more about Lua, you can use `:help lua-guide` as a - reference for how Neovim integrates Lua. + - Lua 15 mins guide - https://learnxinyminutes.com/docs/lua/ - :help lua-guide - - (or HTML version): https://neovim.io/doc/user/lua-guide.html - -Kickstart Guide: - - TODO: The very first thing you should do is to run the command `:Tutor` in Neovim. - - If you don't know what this means, type the following: - - - - : - - Tutor - - - - (If you already know the Neovim basics, you can skip this step.) - - Once you've completed that, you can continue working through **AND READING** the rest - of the kickstart init.lua. - - Next, run AND READ `:help`. - This will open up a help window with some basic information - about reading, navigating and searching the builtin help documentation. - - This should be the first place you go to look when you're stuck or confused - with something. It's one of my favorite Neovim features. - - MOST IMPORTANTLY, we provide a keymap "sh" to [s]earch the [h]elp documentation, - which is very useful when you're not exactly sure of what you're looking for. - - I have left several `:help X` comments throughout the init.lua - These are hints about where to find more information about the relevant settings, - plugins or Neovim features used in Kickstart. - - NOTE: Look for lines like this - - Throughout the file. These are for you, the reader, to help you understand what is happening. - Feel free to delete them once you know what you're doing, but they should serve as a guide - for when you are first encountering a few different constructs in your Neovim config. - -If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. -I hope you enjoy your Neovim journey, -- TJ - -P.S. You can delete this when you're done too. It's your config now! :) + If you experience any errors while trying to install kickstart, run `:checkhealth` for more info. --]] -- Set as the leader key @@ -91,7 +12,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -101,8 +22,7 @@ vim.g.have_nerd_font = false -- Make line numbers default vim.opt.number = true -- You can also add relative line numbers, to help with jumping. --- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -163,6 +83,7 @@ vim.opt.confirm = true -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` +vim.keymap.set('n', 'Q', 'qa', { desc = 'Quit All' }) -- Clear highlights on search when pressing in normal mode -- See `:help hlsearch` @@ -200,6 +121,10 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the upper win -- vim.keymap.set("n", "", "J", { desc = "Move window to the lower" }) -- vim.keymap.set("n", "", "K", { desc = "Move window to the upper" }) +-- Lazy keymaps +vim.keymap.set('n', 'ml', 'Lazy', { desc = 'Lazy' }) +vim.keymap.set('n', 'mr', 'LspRestart', { desc = 'Restart LSP' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -226,16 +151,8 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end ---@diagnostic disable-next-line: undefined-field vim.opt.rtp:prepend(lazypath) --- [[ Configure and install plugins ]] --- --- To check the current status of your plugins, run -- :Lazy --- --- You can press `?` in this menu for help. Use `:q` to close the window --- --- To update plugins you can run -- :Lazy update --- -- NOTE: Here is where you install your plugins. require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). @@ -296,7 +213,7 @@ require('lazy').setup({ opts = { -- delay between pressing a key and opening which-key (milliseconds) -- this setting is independent of vim.opt.timeoutlen - delay = 0, + delay = 500, icons = { -- set icon mappings to true if you have a Nerd Font mappings = vim.g.have_nerd_font, @@ -336,9 +253,13 @@ require('lazy').setup({ -- Document existing key chains spec = { - { 's', group = '[S]earch' }, + { 'd', group = '[D]ebug/Document' }, + { 'g', group = '[G]it' }, + { 's', group = '[S]earch', mode = { 'n', 'v' } }, { 't', group = '[T]oggle' }, { 'h', group = 'Git [H]unk', mode = { 'n', 'v' } }, + { 'm', group = '[M]isc' }, + { 'u', group = '[U]I' }, }, }, }, @@ -399,11 +320,16 @@ require('lazy').setup({ -- You can put your default mappings / updates / etc. in here -- All the info you're looking for is in `:help telescope.setup()` -- - -- defaults = { - -- mappings = { - -- i = { [''] = 'to_fuzzy_refine' }, - -- }, - -- }, + defaults = { + -- mappings = { + -- i = { [''] = 'to_fuzzy_refine' }, + -- }, + path_display = { + filename_first = { + reverse_directories = true, + }, + }, + }, -- pickers = {} extensions = { ['ui-select'] = { @@ -423,10 +349,13 @@ require('lazy').setup({ vim.keymap.set('n', 'sf', builtin.find_files, { desc = '[S]earch [F]iles' }) vim.keymap.set('n', 'ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' }) vim.keymap.set('n', 'sw', builtin.grep_string, { desc = '[S]earch current [W]ord' }) + vim.keymap.set('v', 'sv', builtin.grep_string, { desc = '[S]earch current [V]isual selection' }) vim.keymap.set('n', 'sg', builtin.live_grep, { desc = '[S]earch by [G]rep' }) vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' }) vim.keymap.set('n', 'sr', builtin.resume, { desc = '[S]earch [R]esume' }) - vim.keymap.set('n', 's.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' }) + vim.keymap.set('n', 's.', function() + builtin.oldfiles { only_cwd = true } + end, { desc = '[S]earch Recent Files ("." for repeat)' }) vim.keymap.set('n', '', builtin.buffers, { desc = '[ ] Find existing buffers' }) -- Slightly advanced example of overriding default behavior and theme @@ -553,6 +482,7 @@ require('lazy').setup({ -- Fuzzy find all the symbols in your current document. -- Symbols are things like variables, functions, types, etc. + map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') -- Fuzzy find all the symbols in your current workspace. @@ -624,6 +554,9 @@ require('lazy').setup({ severity_sort = true, float = { border = 'rounded', source = 'if_many' }, underline = { severity = vim.diagnostic.severity.ERROR }, + virtual_lines = { + current_line = true, + }, signs = vim.g.have_nerd_font and { text = { [vim.diagnostic.severity.ERROR] = '󰅚 ', @@ -690,6 +623,85 @@ require('lazy').setup({ }, }, }, + + -- NOTE: Dont forget to `npm i -g @vtsls/language-server` + vtsls = { + settings = { + typescript = { + preferences = { + importModuleSpecifier = 'project-relative', + importModuleSpecifierPreference = 'relative', + importModuleSpecifierEnding = 'minimal', + }, + inlayHints = { + parameterNames = { enabled = 'all' }, + parameterTypes = { enabled = true }, + variableTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + enumMemberValues = { enabled = true }, + }, + }, + }, + }, + + -- NOTE: Dont forget to `npm i -g @angular/language-server` + angularls = { + capabilities = lsp_capabilities, + filetypes = { 'typescript', 'html', 'angular', 'htmlangular' }, + root_dir = function(fname) + return require('lspconfig.util').root_pattern('angular.json', 'workspace.json', 'nx.json', 'package.json', 'tsconfig.base.json', 'project.json')( + fname + ) + end, + on_new_config = function(new_config, new_root_dir) + new_config.cmd = { + 'ngserver', + '--stdio', + '--tsProbeLocations', + new_root_dir, + '--ngProbeLocations', + new_root_dir, + } + end, + }, + + -- NOTE: Dont forget to `npm i -g vscode-langservers-extracted` + cssls = { + capabilities = lsp_capabilities, + cmd = { 'vscode-css-language-server', '--stdio' }, + filetypes = { 'css', 'scss' }, + init_options = { provideFormatter = true }, + -- TODO: Maybe I should use same patter for root finding as for "angularls" server? + root_dir = require('lspconfig.util').root_pattern('package.json', '.git'), + single_file_support = true, + settings = { + css = { validate = true }, + scss = { validate = true }, + }, + }, + + -- TODO: Add emmet abbreviation + -- NOTE: Dont forget to `npm i -g vscode-langservers-extracted` + html = { + capabilities = lsp_capabilities, + cmd = { 'vscode-html-language-server', '--stdio' }, + filetypes = { 'html', 'htmlangular' }, + init_options = { + { + configurationSection = { 'html', 'css', 'javascript', 'htmlangular' }, + embeddedLanguages = { + css = true, + javascript = true, + }, + provideFormatter = true, + }, + }, + -- TODO: Maybe I should use same patter for root finding as for "angularls" server? + root_dir = require('lspconfig.util').root_pattern('package.json', '.git'), + single_file_support = true, + settings = {}, + }, } -- Ensure the servers and tools above are installed @@ -760,6 +772,9 @@ require('lazy').setup({ end, formatters_by_ft = { lua = { 'stylua' }, + htmlangular = { 'prettier' }, + angular = { 'prettier' }, + typescript = { 'prettier', 'eslint_d' }, -- Conform can also run multiple formatters sequentially -- python = { "isort", "black" }, -- @@ -806,6 +821,7 @@ require('lazy').setup({ --- @type blink.cmp.Config opts = { keymap = { + -- TODO: Add "Enter as way to apply suggestion" -- 'default' (recommended) for mappings similar to built-in completions -- to accept ([y]es) the completion. -- This will auto-import if your LSP supports it. @@ -827,7 +843,7 @@ require('lazy').setup({ -- : Toggle signature help -- -- See :h blink-cmp-config-keymap for defining your own keymap - preset = 'default', + preset = 'enter', -- For more advanced Luasnip keymaps (e.g. selecting choice nodes, expansion) see: -- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps @@ -873,20 +889,20 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + 'neanias/everforest-nvim', + lazy = false, + priority = 1000, -- Make sure to load this before all the other start plugins. config = function() - ---@diagnostic disable-next-line: missing-fields - require('tokyonight').setup { - styles = { - comments = { italic = false }, -- Disable italics in comments - }, + require('everforest').setup { + background = 'soft', + ui_contrast = 'high', } -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + vim.cmd.colorscheme 'everforest' end, }, @@ -930,6 +946,34 @@ require('lazy').setup({ -- Check out: https://github.com/echasnovski/mini.nvim end, }, + + { -- LazyGit + 'kdheepak/lazygit.nvim', + lazy = false, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + config = function() + vim.keymap.set('n', 'gg', 'LazyGit', { desc = 'LazyGit' }) + + require('telescope').load_extension 'lazygit' + end, + }, + + { + 'FabijanZulj/blame.nvim', + lazy = false, + config = function() + require('blame').setup {} + + vim.keymap.set('n', 'gb', 'BlameToggle', { desc = 'Toggle blame' }) + end, + }, + { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', @@ -956,6 +1000,122 @@ require('lazy').setup({ -- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects }, + { + 'ggandor/leap.nvim', + enabled = true, + keys = { + { 's', mode = { 'n', 'x', 'o' }, desc = 'Leap Forward to' }, + { 'S', mode = { 'n', 'x', 'o' }, desc = 'Leap Backward to' }, + { 'gs', mode = { 'n', 'x', 'o' }, desc = 'Leap from Windows' }, + }, + config = function(_, opts) + local leap = require 'leap' + for k, v in pairs(opts) do + leap.opts[k] = v + end + leap.add_default_mappings(true) + vim.keymap.del({ 'x', 'o' }, 'x') + vim.keymap.del({ 'x', 'o' }, 'X') + end, + }, + + { + 'folke/trouble.nvim', + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = 'Trouble', + keys = { + { + 'xx', + 'Trouble diagnostics toggle', + desc = 'Diagnostics (Trouble)', + }, + { + 'xX', + 'Trouble diagnostics toggle filter.buf=0', + desc = 'Buffer Diagnostics (Trouble)', + }, + { + 'cs', + 'Trouble symbols toggle focus=false', + desc = 'Symbols (Trouble)', + }, + { + 'cl', + 'Trouble lsp toggle focus=false win.position=right', + desc = 'LSP Definitions / references / ... (Trouble)', + }, + { + 'xL', + 'Trouble loclist toggle', + desc = 'Location List (Trouble)', + }, + { + 'xQ', + 'Trouble qflist toggle', + desc = 'Quickfix List (Trouble)', + }, + }, + }, + + { -- Oil + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + opts = {}, + keys = { + { '-', 'Oil --float', desc = 'Oil' }, + }, + -- Optional dependencies + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons + -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. + lazy = false, + }, + + { -- Hardtime + 'm4xshen/hardtime.nvim', + lazy = false, + dependencies = { 'MunifTanjim/nui.nvim' }, + opts = {}, + }, + + { -- nvim-notify + 'rcarriga/nvim-notify', + lazy = false, + opts = {}, + }, + + { + 'tris203/precognition.nvim', + --event = "VeryLazy", + opts = { + -- startVisible = true, + -- showBlankVirtLine = true, + -- highlightColor = { link = "Comment" }, + -- hints = { + -- Caret = { text = "^", prio = 2 }, + -- Dollar = { text = "$", prio = 1 }, + -- MatchingPair = { text = "%", prio = 5 }, + -- Zero = { text = "0", prio = 1 }, + -- w = { text = "w", prio = 10 }, + -- b = { text = "b", prio = 9 }, + -- e = { text = "e", prio = 8 }, + -- W = { text = "W", prio = 7 }, + -- B = { text = "B", prio = 6 }, + -- E = { text = "E", prio = 5 }, + -- }, + -- gutterHints = { + -- G = { text = "G", prio = 10 }, + -- gg = { text = "gg", prio = 9 }, + -- PrevParagraph = { text = "{", prio = 8 }, + -- NextParagraph = { text = "}", prio = 8 }, + -- }, + -- disabled_fts = { + -- "startify", + -- }, + }, + }, + -- The following comments only work if you have downloaded the kickstart repo, not just copy pasted the -- init.lua. If you want these files, they are in the repository, so you can just download them and -- place them in the correct locations. @@ -965,11 +1125,11 @@ require('lazy').setup({ -- Here are some example plugins that I've included in the Kickstart repository. -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- - -- require 'kickstart.plugins.debug', + require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` @@ -1004,5 +1164,7 @@ require('lazy').setup({ }, }) +vim.notify = require 'notify' + -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..1b551d11dcd --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,41 @@ +{ + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, + "blame.nvim": { "branch": "main", "commit": "b87b8c820e4cec06fbbd2f946b7b35c45906ee0c" }, + "blink.cmp": { "branch": "main", "commit": "4f38ce99a472932d5776337f08f7a8180f1f571a" }, + "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" }, + "everforest-nvim": { "branch": "main", "commit": "2eb7c348f880ba93de4d98cae049c9441f5d4d49" }, + "fidget.nvim": { "branch": "main", "commit": "d9ba6b7bfe29b3119a610892af67602641da778e" }, + "gitsigns.nvim": { "branch": "main", "commit": "43b0c856ae5f32a195d83f4a27fe21d63e6c966c" }, + "hardtime.nvim": { "branch": "main", "commit": "1a3648a53002c2911ccb88e9c9f876cdc6c43ad6" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" }, + "lazygit.nvim": { "branch": "main", "commit": "b9eae3badab982e71abab96d3ee1d258f0c07961" }, + "leap.nvim": { "branch": "main", "commit": "2b68ddc0802bd295e64c9e2e75f18f755e50dbcc" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "d39a75bbce4b8aad5d627191ea915179c77c100f" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "aafae207d5a2a28c59c9d478d8581c2739135d09" }, + "mason.nvim": { "branch": "main", "commit": "7c7318e8bae7e3536ef6b9e86b9e38e74f2e125e" }, + "mini.icons": { "branch": "main", "commit": "397ed3807e96b59709ef3292f0a3e253d5c1dc0a" }, + "mini.nvim": { "branch": "main", "commit": "6105b69d79fef0afed5ed576081b1997ef2b4be1" }, + "neo-tree.nvim": { "branch": "main", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, + "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, + "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, + "nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" }, + "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, + "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" }, + "nvim-lspconfig": { "branch": "master", "commit": "4bc481b6f0c0cf3671fc894debd0e00347089a4e" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-notify": { "branch": "master", "commit": "b5825cf9ee881dd8e43309c93374ed5b87b7a896" }, + "nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" }, + "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "oil.nvim": { "branch": "master", "commit": "685cdb4ffa74473d75a1b97451f8654ceeab0f4a" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "precognition.nvim": { "branch": "main", "commit": "80ac0a99064eba71894dd164e891cc5d7e05827e" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "1f08ed60cafc8f6168b72b80be2b2ea149813e55" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, + "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "trouble.nvim": { "branch": "main", "commit": "85bedb7eb7fa331a2ccbecb9202d8abba64d37b3" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lua/kickstart/plugins/debug.lua b/lua/kickstart/plugins/debug.lua index 753cb0cedd3..55f2f45a205 100644 --- a/lua/kickstart/plugins/debug.lua +++ b/lua/kickstart/plugins/debug.lua @@ -23,59 +23,147 @@ return { -- Add your own debuggers here 'leoluz/nvim-dap-go', + + -- Web + { + 'microsoft/vscode-js-debug', + -- TODO: check wheter vscode-js-debug has some "build dap server script in package.json" + build = 'npm i && npx gulp dapDebugServer', + }, }, keys = { - -- Basic debugging keymaps, feel free to change to your liking! + { -- NOTE: Temporary solution to open chrome - until I'll figure out how to run it automatically + 'dd', + ':!open -a "Google Chrome" --args --remote-debugging-port=9222', + }, + -- TODO: change lua formatter to keep such entries in one line + { + 'dB', + function() + require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + end, + desc = 'Breakpoint Condition', + }, { - '', + 'db', + function() + require('dap').toggle_breakpoint() + end, + desc = 'Toggle Breakpoint', + }, + { + 'dc', function() require('dap').continue() end, - desc = 'Debug: Start/Continue', + desc = 'Run/Continue', + }, + { + 'da', + function() + require('dap').continue { before = get_args } + end, + desc = 'Run with Args', }, { - '', + 'dC', + function() + require('dap').run_to_cursor() + end, + desc = 'Run to Cursor', + }, + { + 'dg', + function() + require('dap').goto_() + end, + desc = 'Go to Line (No Execute)', + }, + { + 'di', function() require('dap').step_into() end, - desc = 'Debug: Step Into', + desc = 'Step Into', }, { - '', + 'dj', function() - require('dap').step_over() + require('dap').down() + end, + desc = 'Down', + }, + { + 'dk', + function() + require('dap').up() + end, + desc = 'Up', + }, + { + 'dl', + function() + require('dap').run_last() end, - desc = 'Debug: Step Over', + desc = 'Run Last', }, { - '', + 'do', function() require('dap').step_out() end, - desc = 'Debug: Step Out', + desc = 'Step Out', }, { - 'b', + 'dO', function() - require('dap').toggle_breakpoint() + require('dap').step_over() end, - desc = 'Debug: Toggle Breakpoint', + desc = 'Step Over', }, { - 'B', + 'dP', function() - require('dap').set_breakpoint(vim.fn.input 'Breakpoint condition: ') + require('dap').pause() end, - desc = 'Debug: Set Breakpoint', + desc = 'Pause', }, -- Toggle to see last session result. Without this, you can't see session output in case of unhandled exception. { - '', + 'dl', function() require('dapui').toggle() end, desc = 'Debug: See last session result.', }, + { + 'dr', + function() + require('dap').repl.toggle() + end, + desc = 'Toggle REPL', + }, + { + 'ds', + function() + require('dap').session() + end, + desc = 'Session', + }, + { + 'dt', + function() + require('dap').terminate() + end, + desc = 'Terminate', + }, + { + 'dw', + function() + require('dap.ui.widgets').hover() + end, + desc = 'Widgets', + }, }, config = function() local dap = require 'dap' @@ -136,6 +224,114 @@ return { dap.listeners.before.event_terminated['dapui_config'] = dapui.close dap.listeners.before.event_exited['dapui_config'] = dapui.close + for _, adapterType in ipairs { 'node', 'chrome', 'msedge' } do + local pwaType = 'pwa-' .. adapterType + + dap.adapters[pwaType] = { + type = 'server', + host = 'localhost', + port = '${port}', + executable = { + command = 'node', + args = { + vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug/dist/src/dapDebugServer.js', + '${port}', + }, + }, + } + + -- this allow us to handle launch.json configurations + -- which specify type as "node" or "chrome" or "msedge" + dap.adapters[adapterType] = function(cb, config) + local nativeAdapter = dap.adapters[pwaType] + + config.type = pwaType + + if type(nativeAdapter) == 'function' then + nativeAdapter(cb, config) + else + cb(nativeAdapter) + end + end + end + + local enter_launch_url = function() + local co = coroutine.running() + return coroutine.create(function() + vim.ui.input({ prompt = 'Enter URL: ', default = 'http://localhost:4201' }, function(url) + if url == nil or url == '' then + return + else + coroutine.resume(co, url) + end + end) + end) + end + + for _, language in ipairs { 'typescript', 'javascript', 'typescriptreact', 'javascriptreact', 'vue' } do + dap.configurations[language] = { + -- NOTE: Tested configs + -- NOTE: inspired by https://github.com/StevanFreeborn/nvim-config/blob/main/lua/plugins/debugging.lua + -- NOTE: If debug launch suggests strange entries which are not provided by setup (like I had "Launch Chrome Debugger") - check ".vscode" folder of project; launch.config from there is automatically added + { + -- TODO: Figure out how to launch chrome automatically + -- now I have to do "open -a "Google Chrome" --args --remote-debugging-port=9222" + -- url = enter_launch_url, + name = 'Attach to Chrome', + type = 'pwa-chrome', + request = 'attach', + program = '${file}', + cwd = vim.fn.getcwd(), + sourceMaps = true, + protocol = 'inspector', + port = 9222, + webRoot = '${workspaceFolder}', + }, + { + -- TODO: This config launches chrome, breapoints are working, but it's very slow for some reason + type = 'pwa-chrome', + request = 'launch', + name = 'Launch Chrome (nvim-dap)', + url = enter_launch_url, + webRoot = '${workspaceFolder}', + sourceMaps = true, + }, + + -- NOTE: Untested configs + { + type = 'pwa-node', + request = 'launch', + name = 'Launch file using Node.js (nvim-dap)', + program = '${file}', + cwd = '${workspaceFolder}', + }, + { + type = 'pwa-node', + request = 'attach', + name = 'Attach to process using Node.js (nvim-dap)', + processId = require('dap.utils').pick_process, + cwd = '${workspaceFolder}', + }, + -- requires ts-node to be installed globally or locally + { + type = 'pwa-node', + request = 'launch', + name = 'Launch file using Node.js with ts-node/register (nvim-dap)', + program = '${file}', + cwd = '${workspaceFolder}', + runtimeArgs = { '-r', 'ts-node/register' }, + }, + { + type = 'pwa-msedge', + request = 'launch', + name = 'Launch Edge (nvim-dap)', + url = enter_launch_url, + webRoot = '${workspaceFolder}', + sourceMaps = true, + }, + } + end + -- Install golang specific config require('dap-go').setup { delve = { diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index bd4422695aa..13fa6607cef 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -14,6 +14,11 @@ return { { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, }, opts = { + default_component_configs = { + indent = { + indent_size = 1, + }, + }, filesystem = { window = { mappings = {