local is, when = require 'config.compose' () local map = require 'config.helpers.keymap' local n = map 'n' local nv = map { 'n', 'v' } ---@type LazySpec return { -- Theme { 'rebelot/kanagawa.nvim', enabled = is 'standalone', lazy = false, priority = math.huge, config = function() vim.cmd 'colorscheme kanagawa' end, }, -- Status line { 'nvim-lualine/lualine.nvim', enabled = is 'standalone', dependencies = { 'nvim-tree/nvim-web-devicons', }, config = true, }, -- Fuzzy search { 'nvim-telescope/telescope.nvim', enabled = is 'standalone', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim', when 'linux' { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' } }, config = function() local telescope = require 'telescope' local builtin = require 'telescope.builtin' local ext = telescope.extensions if is 'linux' then telescope.load_extension 'fzf' end if is 'standalone' then telescope.load_extension 'notify' end telescope.setup { extensions = { fzf = { fuzzy = true, override_generic_sorter = true, override_file_sorter = true, case_mode = 'smart_case', } } } n 'ff' (builtin.find_files) 'Telescope: files' n 'fb' (builtin.buffers) 'Telescope: buffers' n 'fg' (builtin.live_grep) 'Telescope: grep' n 'fh' (builtin.help_tags) 'Telescope: docs' n 'fk' (builtin.keymaps) 'Telescope: keymaps' if is 'standalone' then n 'fn' (ext.notify.notify) 'Telescope: notifications' end end, }, -- Treesitter { 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', dependencies = { 'nvim-treesitter/nvim-treesitter-textobjects' }, config = function() local configs = require 'nvim-treesitter.configs' configs.setup { modules = {}, auto_install = false, sync_install = false, ignore_install = {}, ensure_installed = { -- neovim 'vimdoc', 'lua', 'query', -- data 'json', 'xml', 'yaml', 'toml', -- markdown 'markdown', 'markdown_inline', -- latex 'latex', 'bibtex', -- git 'gitcommit', 'gitignore', 'diff', -- misc 'comment', 'dockerfile', 'regex', -- shell 'bash', -- python 'python', -- systems 'rust', 'c', -- webdev 'html', 'css', 'scss', 'javascript', 'jsdoc', 'typescript', 'tsx', 'astro', 'svelte', -- haskell 'haskell', }, highlight = { enable = true }, indent = { enable = true }, incremental_selection = { enable = true, keymaps = { node_incremental = 'v', node_decremental = 'V', }, }, textobjects = { select = { enable = true, keymaps = { ['af'] = '@function.outer', ['if'] = '@function.inner', ['a?'] = '@conditional.outer', ['i?'] = '@conditional.inner', } }, move = { enable = true, goto_next_start = { [']f'] = '@function.outer', }, goto_previous_start = { ['[f'] = '@function.outer', } } } } end, init = function() local lang = vim.treesitter.language lang.register('markdown', 'mdx') lang.register('markdown', 'lhaskell') end, }, -- Keymap hints { 'folke/which-key.nvim', enabled = is 'standalone', init = function() vim.o.timeout = true vim.o.timeoutlen = 300 end, config = true }, -- Notifications { 'rcarriga/nvim-notify', enabled = is 'standalone', config = function() vim.notify = require 'notify' end }, -- Comments { 'numToStr/Comment.nvim', config = true, }, -- Git - file hunks { 'lewis6991/gitsigns.nvim', enabled = is 'standalone', config = function() local gs = require 'gitsigns' gs.setup { on_attach = function() n 'hp' (gs.preview_hunk) 'Hunk: preview' n 'hs' (gs.stage_hunk) 'Hunk: stage' n 'hu' (gs.undo_stage_hunk) 'Hunk: unstage' n 'hr' (gs.reset_hunk) 'Hunk: reset' n 'hS' (gs.stage_buffer) 'Hunk: buffer stage' n 'hR' (gs.reset_buffer) 'Hunk: buffer reset' n 'hd' (gs.toggle_deleted) 'Hunk: show deleted' end } end, }, -- Git - project diff { 'sindrets/diffview.nvim', enabled = is 'standalone', dependencies = { 'nvim-lua/plenary.nvim', 'nvim-tree/nvim-web-devicons', }, config = function() local lib = require 'diffview.lib' local function toggle(name) return function() if not next(lib.views) then vim.cmd(name) else vim.cmd 'DiffviewClose' end end end n 'gd' (toggle 'DiffviewOpen') 'Git: Diff' n 'gh' (toggle 'DiffviewFileHistory') 'Git: History' end }, -- Color hints { 'NvChad/nvim-colorizer.lua', ft = { 'css', 'scss' }, config = true, }, -- { -- dir = '~/Desktop/disasm.nvim', -- ft = { 'c' }, -- config = function() -- local disasm = require 'disasm' -- -- n 'a' (disasm.disassemble) 'Disasm: Disassemble' -- n 'Af' (disasm.disassemble_full) 'Disasm: Disassemble full' -- n 'Ac' (disasm.reconfigure) 'Disasm: Configure' -- n 'AC' (disasm.save_config) 'Disasm: Save config' -- -- disasm.setup() -- end -- }, -- Snippet engine { 'L3MON4D3/LuaSnip', version = '2.*', }, -- Completion { 'hrsh7th/nvim-cmp', dependencies = { 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', 'hrsh7th/cmp-nvim-lsp', 'saadparwaiz1/cmp_luasnip', }, config = require 'config.plugins.nvim-cmp' }, -- LS configs { 'neovim/nvim-lspconfig', enabled = is { 'standalone', 'linux' }, }, -- Debugger adapter support { 'mfussenegger/nvim-dap', enabled = is { 'standalone', 'linux' }, dependencies = { 'rcarriga/nvim-dap-ui', }, config = function() local dap = require 'dap' local ui = require 'dapui' n '' (dap.continue) 'Debugger: continue' n '' (dap.step_over) 'Debugger: step over' n '' (dap.step_into) 'Debugger: step into' n '' (dap.step_out) 'Debugger: step out' n 'db' (dap.toggle_breakpoint) 'Debugger: toggle breakpoint' n 'du' (ui.toggle) 'Debugger: toggle UI' nv 'de' (ui.eval) 'Debugger: eval' -- vim.api.nvim_set_hl(0, 'DapBreakpoint', { ctermbg = 0, fg = '#993939', bg = '#31353f' }) -- vim.api.nvim_set_hl(0, 'DapLogPoint', { ctermbg = 0, fg = '#61afef', bg = '#31353f' }) -- vim.api.nvim_set_hl(0, 'DapStopped', { ctermbg = 0, fg = '#98c379', bg = '#31353f' }) -- -- vim.fn.sign_define('DapBreakpoint', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' }) -- vim.fn.sign_define('DapBreakpointCondition', { text='ﳁ', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl='DapBreakpoint' }) -- vim.fn.sign_define('DapBreakpointRejected', { text='', texthl='DapBreakpoint', linehl='DapBreakpoint', numhl= 'DapBreakpoint' }) -- vim.fn.sign_define('DapLogPoint', { text='', texthl='DapLogPoint', linehl='DapLogPoint', numhl= 'DapLogPoint' }) -- vim.fn.sign_define('DapStopped', { text='', texthl='DapStopped', linehl='DapStopped', numhl= 'DapStopped' }) ui.setup() dap.listeners.after.event_initialized["dapui_config"] = ui.open dap.listeners.after.event_terminated["dapui_config"] = ui.close dap.listeners.before.event_exited["dapui_config"] = ui.close end, }, -- Mason { 'williamboman/mason.nvim', enabled = is { 'standalone', 'linux' }, config = true, }, -- Automatic LSP server setup for Mason { 'williamboman/mason-lspconfig.nvim', enabled = is { 'standalone', 'linux' }, dependencies = { 'williamboman/mason.nvim', 'neovim/nvim-lspconfig', }, config = function() local config = require 'mason-lspconfig' local lsp = require 'lspconfig' local cmp = require 'cmp_nvim_lsp' local noop = function() end config.setup { automatic_installation = true, -- NOTE -- Haskell: Managed by GHCup ensure_installed = { 'lua_ls', -- Lua 'rust_analyzer', -- Rust 'clangd', -- C -- 'bashls', -- Bash 'html', -- HTML 'cssls', -- CSS / SCSS 'tsserver', -- TypeScript -- 'astro', -- Astro 'svelte', -- Svelte -- 'pyright', -- Python -- 'rnix', -- Nix -- 'purescriptls', -- Purescript -- 'ltex', -- Literate - LaTeX, Markdown, etc. }, } config.setup_handlers { function(name) lsp[name].setup { single_file_support = true, capabilities = cmp.default_capabilities(), } end, ['rust_analyzer'] = noop, } local signs = { Error = "", Warn = "", Hint = "", Info = "󰙎", } for sign, text in pairs(signs) do local name = 'DiagnosticSign' .. sign vim.fn.sign_define(name, { text = text, texthl = name }) end end, }, -- Automatic debugger install { 'jay-babu/mason-nvim-dap.nvim', enabled = is { 'standalone', 'linux' }, dependencies = { 'mfussenegger/nvim-dap', 'williamboman/mason.nvim', }, config = function() local config = require 'mason-nvim-dap' config.setup { automatic_installation = true, ensure_installed = { 'codelldb', --'js-debug-adapter', }, } end, }, -- Tools for Neovim { 'folke/neodev.nvim', enabled = is { 'standalone', 'linux' }, ft = 'lua', dependencies = { 'neovim/nvim-lspconfig', }, config = function() local neodev = require 'neodev' local lsp = require 'lspconfig' neodev.setup() lsp.lua_ls.setup { settings = { Lua = { completion = { callSnippet = 'Replace' } } } } end }, -- Tools for Rust { 'mrcjkb/rustaceanvim', enabled = is { 'standalone', 'linux' }, version = '^3', ft = { 'rust' }, init = function() require 'config.plugins.rustaceanvim' end }, -- Tools for Haskell { 'mrcjkb/haskell-tools.nvim', enabled = is { 'standalone', 'linux' }, version = '^3', ft = { 'haskell', 'lhaskell', 'cabal', 'cabalproject' }, dependencies = { 'nvim-lua/plenary.nvim', 'nvim-telescope/telescope.nvim', }, init = require 'config.plugins.haskell-tools' }, -- JS debugger { 'mxsdev/nvim-dap-vscode-js', dependencies = { 'microsoft/vscode-js-debug', version = '1.x', build = 'npm i && npm run compile vsDebugServerBundle && mv dist out', }, config = function() local dap = require 'dap' --local utils = require 'dap.utils' local dap_js = require 'dap-vscode-js' --local mason = require 'mason-registry' ---@diagnostic disable-next-line: missing-fields dap_js.setup { -- debugger_path = mason.get_package('js-debug-adapter'):get_install_path(), debugger_path = vim.fn.stdpath 'data' .. '/lazy/vscode-js-debug', adapters = { 'pwa-node', 'pwa-chrome', 'pwa-msedge', 'node-terminal', 'pwa-extensionHost' }, } local langs = { 'javascript', 'typescript', 'svelte', 'astro' } for _, lang in ipairs(langs) do dap.configurations[lang] = { { type = 'pwa-node', request = 'attach', name = 'Attach debugger to existing `node --inspect` process', cwd = '${workspaceFolder}', skipFiles = { '${workspaceFolder}/node_modules/**/*.js', '${workspaceFolder}/packages/**/node_modules/**/*.js', '${workspaceFolder}/packages/**/**/node_modules/**/*.js', '/**', 'node_modules/**', }, sourceMaps = true, resolveSourceMapLocations = { '${workspaceFolder}/**', '!**/node_modules/**', }, }, } end end, }, }