From 2ea3154977c3bd09fcd23793c5a51c16e207cd3b Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 09:28:44 +1100 Subject: [PATCH 01/51] feat: Documented and re-formatted modules.lua --- modules.lua | 94 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/modules.lua b/modules.lua index 237daa3..ad44776 100644 --- a/modules.lua +++ b/modules.lua @@ -7,65 +7,77 @@ return { features = { - "auto_session", - "autopairs", - "colorizer", - -- "dap", - "dashboard", - -- "doom_themes", - "editorconfig", - -- "explorer", - -- "firenvim", - -- "formatter", - "gitsigns", - "illuminate", - "indentlines", - "comment", - -- "lazygit", - "linter", - "lsp", - -- "minimap", - -- "neogit", - -- "neorg", - "range_highlight", - -- "ranger", - -- "restclient", - -- "show_registers", - "snippets", - "statusline", - "fidget", - "projects", - -- "suda", - -- "superman", - -- "symbols", - "auto_install", - "annotations", - "tabline", - "telescope", - -- "terminal", - "todo_comments", - "trouble", - "whichkey", - -- "zen", + -- Language features + "annotations", -- Code annotation generator + "auto_install", -- Auto install LSP providers + "autopairs", -- Automatically close character pairs + "comment", -- Adds keybinds to comment in any language + "linter", -- Linting and formatting for languages + "lsp", -- Code completion + "snippets", -- Code snippets for all languages + + -- Editor + "auto_session", -- Remember sessions between loads + "colorizer", -- Show colours in neovim + "editorconfig", -- Support editorconfig files + "gitsigns", -- Show git changes in sidebar + "illuminate", -- Highlight other copies of the word you're hovering on + "indentlines", -- Show indent lines with special characters + "range_highlight", -- Highlight selected range from commands + "todo_comments", -- Highlight TODO: comments + + -- UI + "fidget", -- Check status of LSP loading + "tabline", -- Tab bar buffer switcher + "dashboard", -- A pretty dashboard upon opening + "trouble", -- A pretty diagnostic viewer + "statusline", -- A pretty status line at the bottom of the buffer + -- "minimap", -- Shows current position in document + + -- Tools + -- "dap", -- Debug code through neovim + "explorer", -- An enhanced filetree explorer + -- "firenvim", -- Embed neovim in your browser + "telescope", -- Fuzzy searcher to find files, grep code and more + "neorg", -- Organise your life + "whichkey", -- An interactive sheet + "projects", -- Quickly switch between projects + + -- "doom_themes", -- Extra themes for doom + -- "lazygit", -- Lazy git integration + -- "neogit", -- A git client for neovim + -- "ranger", -- File explorer in neovim (TODO: Test) + -- "restclient", -- Test HTTP requests from neovim (TODO: Test) + -- "show_registers", -- Show and navigate between registers + -- "suda", -- Save using sudo when necessary + -- "superman", -- Read unix man pages in neovim + -- "symbols", -- Navigate between code symbols using telescope + -- "terminal", -- Integrated terminal in neovim + -- "zen", -- Distractionless coding }, langs = { + -- Scripts "lua", "python", "bash", - "config", + -- Web "javascript", "typescript", "css", "vue", "tailwindcss", + -- Compiled "rust", "cpp", + -- JIT "c_sharp", "kotlin", "java", + + "config", -- JSON, YAML, TOML } } From cfe8a789fdd449940a703b1f7fcf992f312ab791 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 09:29:24 +1100 Subject: [PATCH 02/51] temp: Added status line --- config.lua | 50 ++++++++++++++++++- .../modules/features/statusline2/init.lua | 44 ++++++++++++++++ 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 lua/doom/modules/features/statusline2/init.lua diff --git a/config.lua b/config.lua index adb595c..48c6f5c 100644 --- a/config.lua +++ b/config.lua @@ -8,6 +8,7 @@ -- Editor config doom.indent = 2 doom.escape_sequences = {} +doom.modules.telescope.settings.defaults.layout_config.prompt_position = "top" -- vim.lsp.set_log_level('trace') vim.diagnostic.config({ float = { @@ -15,11 +16,54 @@ vim.diagnostic.config({ }, }) +doom.modules.tabline.settings.options.numbers = nil; -- Hide buffer numbers +doom.modules.tabline.settings.options.diagnostics_indicator = function (_, _, diagnostics_dict, _) + local s = "" + for e, _ in pairs(diagnostics_dict) do + local sym = e == "error" and " " or (e == "warning" and " " or " ") + s = s .. sym + end + return s +end + -- Colourscheme table.insert(doom.packages, { 'sainnhe/sonokai' }) -doom.colorscheme = 'sonokai' +table.insert(doom.packages, { + 'EdenEast/nightfox.nvim', +}) +local options = { + dim_inactive = true, +} +local pallets = { +} +local specs = { +} +local groups = { + TelescopeNormal = { fg = 'fg0', bg = 'bg0' }, + TelescopePromptTitle = { fg = "bg0", bg = "pallet.green" }, + TelescopePromptBorder = { fg = "bg1", bg = "bg1" }, + TelescopePromptNormal = { fg = "fg1", bg = "bg1" }, + TelescopePromptPrefix = { fg = "fg1", bg = "bg1" }, + + TelescopeResultsTitle = { fg = "bg3", bg = "pallet.green" }, + TelescopeResultsBorder = { fg = 'bg3', bg = 'bg3' }, + TelescopeResultsNormal = { fg = 'fg1', bg = 'bg3' }, + + TelescopePreviewTitle = { fg = "bg1", bg = "pallet.green" }, + TelescopePreviewNormal = { bg = 'bg1' }, + TelescopePreviewBorder = { fg = "bg1", bg = "bg1" }, + TelescopeMatching = { fg = "error" }, + CursorLine = { bg = "bg2" }, +} +require('nightfox').setup({ + options = options, + pallets = pallets, + specs = specs, + groups = groups, +}) +doom.colorscheme = 'dawnfox' -- Extra packages table.insert(doom.packages, { @@ -32,5 +76,9 @@ table.insert(doom.packages, { 'tpope/vim-surround' }) +table.insert(doom.packages, { + 'dstein64/vim-startuptime' +}) +vim.opt.guifont = { 'Hack Nerd Font', 'h12' } -- vim: sw=2 sts=2 ts=2 expandtab diff --git a/lua/doom/modules/features/statusline2/init.lua b/lua/doom/modules/features/statusline2/init.lua new file mode 100644 index 0000000..5934628 --- /dev/null +++ b/lua/doom/modules/features/statusline2/init.lua @@ -0,0 +1,44 @@ +local statusline = {} + +statusline.settings = { +} + +statusline.packages = { + ["lualine.nvim"] = { + "nvim-lualine/lualine.nvim", + }, +} + +statusline.configure_functions = {} +statusline.configure_functions["lualine.nvim"] = function() + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'nightfox', + component_separators = { left = '', right = ''}, + section_separators = { left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} + } +end + +return statusline From 1614f94b3d1d7caa2e3d1e06176a073b7e8483b4 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 10:40:38 +1100 Subject: [PATCH 03/51] fix(gitsigns): Not showing in sidebar --- lua/doom/modules/features/gitsigns/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/doom/modules/features/gitsigns/init.lua b/lua/doom/modules/features/gitsigns/init.lua index 9f6fa78..bd849f5 100644 --- a/lua/doom/modules/features/gitsigns/init.lua +++ b/lua/doom/modules/features/gitsigns/init.lua @@ -72,6 +72,13 @@ gitsigns.settings = { }, } +gitsigns.packages = { + ["gitsigns.nvim"] = { + "lewis6991/gitsigns.nvim", + commit = "7de953329ff696408bd38d3218b0239839d285e0", + }, +} + gitsigns.configure_functions = {} gitsigns.configure_functions["gitsigns.nvim"] = function() require("gitsigns").setup(doom.modules.gitsigns.settings) From 2e37f46b9c9e2081dca606c90e1c556337fc4e09 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 10:52:33 +1100 Subject: [PATCH 04/51] fix(modules): Handle modules without config functions --- lua/doom/modules/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index eef9f63..ab4a3d4 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -55,7 +55,7 @@ for module_name, module in pairs(doom.modules) do if module.packages then for dependency_name, packer_spec in pairs(module.packages) do -- Set packer_spec to configure function - if module.configure_functions[dependency_name] then + if module.configure_functions and module.configure_functions[dependency_name] then packer_spec.config = module.configure_functions[dependency_name] end From 417a11c2b368a9344139bf05afa89d7114126958 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 10:53:00 +1100 Subject: [PATCH 05/51] feat(zen): Toggle using `tz` keybinding --- lua/doom/modules/features/zen/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/doom/modules/features/zen/init.lua b/lua/doom/modules/features/zen/init.lua index d1855f6..c1018e4 100644 --- a/lua/doom/modules/features/zen/init.lua +++ b/lua/doom/modules/features/zen/init.lua @@ -56,7 +56,7 @@ zen.packages = { event = "BufWinEnter", }, } - + zen.configure_functions = {} zen.configure_functions["TrueZen.nvim"] = function() @@ -65,6 +65,9 @@ end zen.binds = { { "", ":TZAtaraxis", name = "Enter Nirvana" }, + { "t", name = "+tweaks", { + { "z", ":TZAtaraxis", name = 'Toggle Zen' } + } } } return zen From 92c1c6e694ca3102073d6500cf37e2f661190a06 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Thu, 17 Mar 2022 10:59:42 +1100 Subject: [PATCH 06/51] fix(symbols): Changed keybinding to `os` for open symbols. --- lua/doom/modules/features/symbols/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/doom/modules/features/symbols/init.lua b/lua/doom/modules/features/symbols/init.lua index c515bd6..36bbc78 100644 --- a/lua/doom/modules/features/symbols/init.lua +++ b/lua/doom/modules/features/symbols/init.lua @@ -46,7 +46,7 @@ symbols.binds = { "o", name = "+open/close", { - { "c", "SymbolsOutline", name = "Symbol outline" }, + { "s", "SymbolsOutline", name = "Symbol outline" }, }, }, }, From 0022f6a9866252a3d1db9d8d24d79f67e08a9ea9 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Fri, 18 Mar 2022 08:20:41 +1100 Subject: [PATCH 07/51] temp: use nightfox colourscheme and enable lualine --- config.lua | 18 ++++++++++++------ modules.lua | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/config.lua b/config.lua index 48c6f5c..efed48d 100644 --- a/config.lua +++ b/config.lua @@ -37,25 +37,31 @@ local options = { dim_inactive = true, } local pallets = { + dawnfox = { + bg2 = '#F9EFEC', + bg3 = '#ECE3DE', + sel1 = '#EEF1F1', + sel2 = '#D8DDDD', + } } local specs = { } local groups = { TelescopeNormal = { fg = 'fg0', bg = 'bg0' }, - TelescopePromptTitle = { fg = "bg0", bg = "pallet.green" }, + TelescopePromptTitle = { fg = "pallet.green", bg = "bg1" }, TelescopePromptBorder = { fg = "bg1", bg = "bg1" }, TelescopePromptNormal = { fg = "fg1", bg = "bg1" }, TelescopePromptPrefix = { fg = "fg1", bg = "bg1" }, - TelescopeResultsTitle = { fg = "bg3", bg = "pallet.green" }, - TelescopeResultsBorder = { fg = 'bg3', bg = 'bg3' }, - TelescopeResultsNormal = { fg = 'fg1', bg = 'bg3' }, + TelescopeResultsTitle = { fg = "pallet.green", bg = "bg2" }, + TelescopeResultsBorder = { fg = 'bg2', bg = 'bg2' }, + TelescopeResultsNormal = { fg = 'fg1', bg = 'bg2' }, - TelescopePreviewTitle = { fg = "bg1", bg = "pallet.green" }, + TelescopePreviewTitle = { fg = "pallet.green", bg = "bg1" }, TelescopePreviewNormal = { bg = 'bg1' }, TelescopePreviewBorder = { fg = "bg1", bg = "bg1" }, TelescopeMatching = { fg = "error" }, - CursorLine = { bg = "bg2" }, + CursorLine = { bg = "sel1", link = "" }, } require('nightfox').setup({ options = options, diff --git a/modules.lua b/modules.lua index ad44776..b30e823 100644 --- a/modules.lua +++ b/modules.lua @@ -1,5 +1,5 @@ --- modules.lua - Doom nvim module selection -- +-- modules.lua - Doom nvim module selection -- modules.lua controls what Doom nvim plugins modules are enabled and -- what features are being used. -- @@ -31,7 +31,7 @@ return { "tabline", -- Tab bar buffer switcher "dashboard", -- A pretty dashboard upon opening "trouble", -- A pretty diagnostic viewer - "statusline", -- A pretty status line at the bottom of the buffer + "statusline2", -- A pretty status line at the bottom of the buffer -- "minimap", -- Shows current position in document -- Tools From 4640e7d961da87803a2c45e3aa8f367aa7814c09 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Fri, 18 Mar 2022 08:44:09 +1100 Subject: [PATCH 08/51] feat: Added `sr` to resume telescope search --- lua/doom/modules/features/telescope/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index 5d76471..fe9d54e 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -147,6 +147,7 @@ telescope.binds = function () "s", name = "+search", { + { "r", "Telescope resume", name = "Resume previous search" }, { "t", "Telescope live_grep", name = "Search text" }, { "b", "Telescope current_buffer_fuzzy_find", name = "Text in buffer" }, { "h", "Telescope command_history", name = "Recent commands" }, From 859c78ca0c5455c3ff82d236833f79c25db25be8 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Fri, 18 Mar 2022 11:03:34 +1100 Subject: [PATCH 09/51] feat: Overhauled `modules.md` documentation --- docs/modules.md | 348 ++++++++++++++++++++++++------------------------ 1 file changed, 173 insertions(+), 175 deletions(-) diff --git a/docs/modules.md b/docs/modules.md index 5cdc137..cffa280 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -6,180 +6,178 @@ Doom Nvim consists of around 40 plugins and growing. A Doom Nvim module is a bundle of packages, configurations, autocommands and binds, organized into a unit that can be toggled easily. -> **NOTE**: Doom Nvim uses [packer.nvim] as its plugins manager. - -## Toggling Doom Nvim Modules - -You can easily toggle Doom Nvim Modules by tweaking your `doom-nvim/modules.lua` file -(found in `~/.config/doom-nvim`). Return from this file a flat list of modules -you want. The `core` module is required and need not be listed. - -## List of modules - -First of all, we must know which modules are there and their plugins. - -> **NOTE:** all modules can be disabled, except `core`. Also, anything can be -overriden in `doom-nvim/config.lua`, from packer specs to vim options. - -### Essentials in core - -This is the one module you cannot disable. But why? - -That is because these plugins are the core of Doom, why would you want a -framework without these basic functionalies? These plugins are the following: - -- [packer.nvim] - - A use-package inspired plugin manager for Neovim. -- [nvim-treesitter and companions] - - An incremental parsing system for programming tools. -- [nest.nvim] - - A better way to set keybindings and create nvim-mapper structures. -- [nvim-mapper] - - A cheatsheet generator for your binds. - -### UI modules - -- [colorizer] - - Fastest colorizer for Neovim. -- [dashboard] - - Vim dashboard (start screen). -- [doom_themes] - - Additional doom emacs' colorschemes. -- [indentlines] - - Show indent lines. -- [range_highlight] - - Highlights ranges you have entered in commandline -- [statusline] - - Neovim statusline. -- [tabline] - - Tabline, shows your buffers list at top. -- [whichkey] - - Keybindings popup like Emacs' whichj-key. -- [zen] - - Distraction free environment. - - -### Lang modules - -- [neorg] - - Life Organization Tool. - -### Editor modules - -- [autopairs] - - Autopairs. -- [auto_session] - - A small automated session manager for Neovim. -- [editorconfig] - - EditorConfig support for Neovim, let other people argue about tabs vs spaces. -- [explorer] - - Tree explorer. -- [formatter] - - File formatting. -- [gitsigns] - - Git signs. -- [kommentary] - - Comments plugin. -- [lsp] - - Language Server Protocols ([cmp] + [lspconfig]). -- [minimap] - - Code minimap, requires [wfxr/code-minimap](https://github.com/wfxr/code-minimap). -- snippets - - Code snippets ([LuaSnip] + [friendly-snippets]). -- [symbols] - - LSP symbols and tags. -- [telescope] - - Highly extendable fuzzy finder over lists. -- [terminal] - - Terminal for Neovim. - -### Utilities modules - -- [lazygit] - - LazyGit integration for neovim, requires LazyGit. -- [neogit] - - Magit for Neovim. -- [suda] - - Write and read files without sudo permissions. -- [superman] - - Manage man files. -- [restclient] - - A fast Neovim http client. - -## Managing modules - -Configurations go in `doom-nvim/config.lua`. In this file, a `doom` global variable -is injected with defaults suh that you can override or insert to your liking. - -Common patterns: - -> **NOTE**: prefer setting the leaf keys, setting an entire table will override -> everything. - -- Install package/override existing if name is already there: - ```lua - -- Use fork. - doom.packages[name][1] = "myfork/name.nvim" - -- Add config to be run after module config. - doom.packages[name].config = function() - require("name.whatever").do_something({ - -- .. +Modules are grouped into 3 categories: +- `features` (optional, extend doom-nvim with extra capabilities) +- `langs` (optional, add support for a language) +- `core` (cannot be disabled, required for core functionality). + + You can enable or disable doom modules by commenting them out in the `modules.lua` file +(`Dm` or `~/.config/nvim/modules.lua`). + +## All modules + +### `core` modules + +- [`treesitter`](../lua/doom/modules/core/treesitter) An incremental parsing system for programming tools. +- [`nest`](../lua/doom/modules/core/nest) Used for keybind management, integrates with `whichkey` and `mapper`. + +### `features` modules + +- **Language related modules** + - [`annotations`](../lua/doom/modules/features/annotations) Code annotation generator + - [`auto_install`](../lua/doom/modules/features/auto_install) Auto install LSP providers + - [`autopairs`](../lua/doom/modules/features/autopairs) Automatically close character pairs + - [`comment`](../lua/doom/modules/features/comment) Generate comments in any language. + - [`linter`](../lua/doom/modules/features/linter) Format and lint your code + - [`snippets`](../lua/doom/modules/features/snippets) Code snippets for all languages + +- **Editor modules** + - [`auto_session`](../lua/doom/modules/features/auto_session) Return to previous sessions + - [`colorizer`](../lua/doom/modules/features/colorizer) Show colors in editor + - [`editorconfig`](../lua/doom/modules/features/editorconfig) .editorconfig file support + - [`gitsigns`](../lua/doom/modules/features/gitsigns) Show changes near linenumber + - [`illuminate`](../lua/doom/modules/features/illuminate) Highlight other occurances of the hovered word + - [`indentlines`](../lua/doom/modules/features/indentlines) Explicitly show indentation + - [`range_highlight`](../lua/doom/modules/features/range_highlight) Highlight selected range as you type commands + - [`todo_comments`](../lua/doom/modules/features/todo_comments) Highlights TODO: comments and more +- **UI modules** + - [`fidget`](../lua/doom/modules/features/fidget) Shows LSP loading status + - [`tabline`](../lua/doom/modules/features/tabline) Tabbed buffer switcher + - [`dashboard`](../lua/doom/modules/features/dashboard) A pretty dashboard upon opening doom-nvim. + - [`trouble`](../lua/doom/modules/features/trouble) A pretty diagnostics viewer + - [`minimap`](../lua/doom/modules/features/minimap) Shows current position in document + - [`whichkey`](../lua/doom/modules/features/whichkey) An interactive keybind cheatsheet +- **Tool modules** + - [`dap`](../lua/doom/modules/features/dap) Debug adapter protocol for neovim + - [`explorer`](../lua/doom/modules/features/explorer) File explorer in the sidebar + - [`neorg`](../lua/doom/modules/features/neorg) Organise your life + - [`telescope`](../lua/doom/modules/features/telescope) Search files, text, commands and more + - [`projects`](../lua/doom/modules/features/projects) Quick project switching + + + +### `langs` modules + +- [`lua`](../lua/doom/modules/langs/lua) Lua language support, we recommend keeping this enabled as it also provides LSP completion for all config options. +- [`python`](../lua/doom/modules/langs/python) +- [`bash`](../lua/doom/modules/langs/bash) +- [`javascript`](../lua/doom/modules/langs/javascript) +- [`typescript`](../lua/doom/modules/langs/typescript) +- [`css`](../lua/doom/modules/langs/css) +- [`vue`](../lua/doom/modules/langs/vue) +- [`tailwindcss`](../lua/doom/modules/langs/tailwindcss) +- [`rust`](../lua/doom/modules/langs/rust) +- [`cpp`](../lua/doom/modules/langs/cpp) +- [`c_sharp`](../lua/doom/modules/langs/c_sharp) +- [`kotlin`](../lua/doom/modules/langs/kotlin) +- [`java`](../lua/doom/modules/langs/java) +- [`config`](../lua/doom/modules/langs/config) Adds JSON, YAML, TOML support +- Missing a language? Submit a feature request issue. + +## Configuring modules + +### Quick Guide + +You can access, override and configure all modules by using the `config.lua` file (`Dc` or `~/.config/nvim/config.lua`). +This is done through the `doom.modules` global object. Here we'll use the [`comment`](../lua/doom/modules/features/comment) module as an example. +Compare the source file with the example overrides below. +```lua +--- config.lua + +-- Here `comment_module` is just a reference to `../lua/doom/modules/features/comment/init.lua` +local comment_module = doom.modules.comment +-- Override default settings (provided by doom-nvim) +comment_module.settings.padding = false +-- Override package source with a fork +comment_module.packages['Comment.nvim'] = { + 'my_fork/Comment.nvim', + module = "Comment" +} +-- If you need more customisability than overriding the settings, you can override the configure function +comment_module.configs["Comment.nvim"] = function () end +-- Replace keybinds +comment_module.binds = { + { "gc", "echo Do something", name = "Comment motion"} +} +``` + +> **NOTE:** If you have the `lua` language module and `lsp` feature module enabled, +all of these properties should be auto completeable. + +### Advanced + + +#### Limitations + +#### Module lifecycle +1. Modules are defined in `modules.lua`. +2. Doom loads the config for each module, saves it to `doom.modules`. +3. User can override the settings for a module in `config.lua` +4. Doom executes the module, loads and installs the dependencies, sets the keybinds and autocommands. + +#### Module spec + +These are the possible values a + +```lua +module.settings: table -- Table of settings that can be tweaked +module.packages: table> -- Table of packer specs +module.configs: table -- Table of plugin config functions relating to the packer specs +module.binds: table|function -> table -- Table of NestConfig or function that returns Table of NestConfig +module.autocmds: table|function -> table -- Table of AutoCmds (see below) or function that returns a table of AutoCmds +``` + +```lua +local module = {} + +module.settings = {...} -- Doom-nvim provided object to change settings + +-- Stores the packer.nvim config for all of the plugin dependencies +module.packages = { + ["example-plugin.nvim"] = { -- Use the repository name as the key + "GithubUser/example-plugin.nvim", + commit = "..." -- We like to pin plugins to commits to avoid issues upgrading. + } +} + +module.configs = { + ["example-plugin.nvim"] = function() -- key matches `module.packages` entry + require('example-plugin').setup( doom.modules.example.settings ) -- Consumes `module.settings` and uses it to config the plugin + end +} + +-- Keybinds are defined using a modified nest.nvim table syntax. +-- https://github.com/connorgmeehan/nest.nvim/tree/integrations-api +module.binds = { + { 'ff', ':Telescope find_files', name = 'Find files'} -- `name = "..."` For `whichkey` and `mapper` integrations + { 'cc', function() print('custom command') end, name = 'Find files' }, -- Can trigger either a `` string or a function +} + +-- If you need conditional keybinds it's recommended you use a function that returns a table instead. +module.binds = function() + local binds = { ... } + if doom.modules.other_module then + table.insert(binds, { + 'ff', function() print('this is a conditional keybind') end, name = 'My conditional keybind' }) end - ``` -- Add binds to your liking: - ```lua - table.insert(doom.binds, { - { "RnT", "RipAndTear", name = "Until it is done" }, - }) - ``` -- Add autocmds (`doom_` will be prefixed to the name): - ```lua - doom.autocmds[augroup_name] = { - { "BufReadPre", "*.lua", "setlocal sw=2", --[[once and nested are boolean keys here]] }, - { "InsertEnter", "*", function() print("Lua functions are valid!") end, once = true } - } - ``` - - - -[packer.nvim]: https://github.com/wbthomason/packer.nvim -[treesitter]: https://github.com/nvim-treesitter/nvim-treesitter - -[auto-session]: https://github.com/rmagatti/auto-session -[dashboard]: https://github.com/glepnir/dashboard-nvim -[explorer]: https://github.com/kyazdani42/nvim-tree.lua -[statusline]: https://github.com/glepnir/galaxyline.nvim -[tabline]: https://github.com/akinsho/nvim-bufferline.lua -[terminal]: https://github.com/akinsho/nvim-toggleterm.lua -[symbols]: https://github.com/simrat39/symbols-outline.nvim -[minimap]: https://github.com/wfxr/minimap.vim -[which-key]: https://github.com/folke/which-key.nvim -[zen]: https://github.com/kdav5758/TrueZen.nvim -[telescope]: https://github.com/nvim-telescope/telescope.nvim -[doom-themes]: https://github.com/GustavoPrietoP/doom-themes.nvim - -[gitsigns]: https://github.com/lewis6991/gitsigns.nvim -[lazygit]: https://github.com/kdheepak/lazygit.nvim -[neogit]: https://github.com/TimUntersberger/neogit -[neorg]: https://github.com/vhyrro/neorg - -[lsp]: https://github.com/neovim/nvim-lspconfig -[cmp]: https://github.com/hrsh7th/nvim-cmp -[lsp-installer]: https://github.com/williamboman/nvim-lsp-installer -[LuaSnip]: https://github.com/L3MON4D3/LuaSnip -[friendly-snippets]: https://github.com/rafamadriz/friendly-snippets - -[suda]: https://github.com/lambdalisue/suda.vim -[formatter]: https://github.com/lukas-reineke/format.nvim -[autopairs]: https://github.com/windwp/nvim-autopairs -[indentlines]: https://github.com/lukas-reineke/indent-blankline.nvim -[editorconfig]: https://github.com/editorconfig/editorconfig-vim -[kommentary]: https://github.com/b3nj5m1n/kommentary - -[restclient]: https://github.com/NTBBloodbath/rest.nvim -[colorizer]: https://github.com/norcalli/nvim-colorizer.lua -[range-highlight]: https://github.com/winston0410/range-highlight.nvim - -[runner]: ../lua/doom/modules/built-in/runner/README.md -[compiler]: ../lua/doom/modules/built-in/compiler/README.md + return binds +end + +-- Autocmds are defined as a table with the following syntax +-- { "event", "aupat", "command or function" } +-- Example +module.autocommands = { + { "FileType", "javascript", function() print("I'm in a javascript file now") end } +} +-- Similarly, autocmds can be conditional using a function +module.autocommands = function() + local autocmds = {} + if condition then + table.insert(autocmds, { "FileType", "javascript", function() print("I'm in a javascript file now") end }) + end + return autocmds +end +``` From 463ea35896410c287a7ca848f129615c91512dbd Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Fri, 18 Mar 2022 11:04:07 +1100 Subject: [PATCH 10/51] fix: Removed australian spelling in modules.lua --- modules.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules.lua b/modules.lua index b30e823..dd9c979 100644 --- a/modules.lua +++ b/modules.lua @@ -18,7 +18,7 @@ return { -- Editor "auto_session", -- Remember sessions between loads - "colorizer", -- Show colours in neovim + "colorizer", -- Show colors in neovim "editorconfig", -- Support editorconfig files "gitsigns", -- Show git changes in sidebar "illuminate", -- Highlight other copies of the word you're hovering on From ee463bbcc603bb8f76ad4f770cfbaacae0a1548b Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 13:51:30 +1100 Subject: [PATCH 11/51] feat: Added `doom.use` to add user-define packages --- lua/doom/core/config/init.lua | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 8c6b5a3..ef28880 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -200,6 +200,34 @@ config.load = function() doom.binds = {} -- Extra binds doom.modules = {} -- Modules + -- @type PackerSpec + -- @field 1 string Github `user/repositoryname` + -- @field opt boolean|nil Whether or not this package is optional (loaded manually or on startup) + -- @field commit string|nil Commit sha to pin this package to + + -- Add doom.use helper function + -- @param string|packer_spec PackerSpec + doom.use = function(...) + local arg = {...} + -- Get table of packages via git repository name + local packages_to_add = vim.tbl_map(function (t) + return type(t) == 'string' and t or t[1] + end, arg) + + -- Predicate returns false if the package needs to be overriden + local package_override_predicate = function(t) + return not vim.tbl_contains(packages_to_add, t[1]) + end + + -- Iterate over existing packages, removing all packages that are about to be overriden + doom.packages = vim.tbl_filter(package_override_predicate, doom.packages) + + for _, packer_spec in ipairs(arg) do + table.insert(doom.packages, type(packer_spec) == "string" and { packer_spec } or packer_spec) + end + end + --]] + -- Combine core modules with user-enabled modules local all_modules = vim.tbl_deep_extend('keep', { core = { @@ -208,13 +236,13 @@ config.load = function() 'treesitter', } }, enabled_modules) - + for section_name, section_modules in pairs(all_modules) do for _, module_name in pairs(section_modules) do local ok, result = xpcall(require, debug.traceback, ("doom.modules.%s.%s"):format(section_name, module_name)) if ok then doom.modules[module_name] = result - else + else print(vim.inspect(result)) end end From 7ca67e962b008dd3fb0c1dc6325ce92b13870ec1 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 17:30:29 +1100 Subject: [PATCH 12/51] feat(docs): WIP README.md overhaul --- README.md | 346 +++++++++++++++++++++------------------- docs/getting_started.md | 4 +- 2 files changed, 181 insertions(+), 169 deletions(-) diff --git a/README.md b/README.md index 1b8e931..97f6a42 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +
# Doom Nvim @@ -13,201 +14,212 @@ [![All Contributors](https://img.shields.io/badge/all_contributors-14-orange.svg?style=flat-square)](#contributors-) -[Features](#features) • [Install](#install) • [Documentation] • [Contribute](#contribute) - ![Doom Nvim demo](https://i.imgur.com/ejEnlEP.png)
--- -## Introduction - - - - - -Doom Nvim is a Neovim port of the [doom-emacs](https://github.com/hlissner/doom-emacs) framework -and adapted to Vim philosophy. - -Its goal is to give Neovim an initial configuration to start working in a stable and efficient -development environment without spending a lot of time configuring everything and without forgetting -that we don't all need the same environment. - -> As a vimmer, I know that it's difficult to configure Vim/Neovim when you are just starting to use it, -> how time consuming it's to customize it to your needs and that's why Doom Nvim exists -> _also because I love Doom_. - -Its design is guided by these mantras: - -- **Gotta go fast.** Startup and run-time performance are priorities. - That is why Doom Nvim uses Lua instead of Vimscript for its configurations - and lazy-loads _all_ the plugins. -- **Your system, your rules.** You know better than a third party what is - convenient for you. At least, Doom hopes so! It won't _automatically_ - install system dependencies nor plugins that have external dependencies - (and will force plugins not to do so either if they have any external dependencies). -- **What does not serve you, you throw away.** Doom Nvim is made up of a moderate number - of plugins (~40 plugins as of this writing). You more than anyone know what you need in - your environment and that's why Doom Nvim allows you to easily disable plugins and add new ones. - Also, Doom Nvim doesn't come with TreeSitter parsers or Language Server Protocols configured by default, - so **you can use _only_ what you need**. - -## Notices - -- **2021-07-12**: If you are facing issues related to `LuaSnip`, update Doom Nvim and follow - the instructions found in the issue [#38](https://github.com/NTBBloodbath/doom-nvim/issues/38). -- **2021-07-03**: The `doomrc` has been fragmented and it is not working anymore, - please see [Migrating to 3.0.0](./docs/getting_started.md#migrating-to-300) - for more information. -- **2021-05-01**: The `doomrc` is not using Vimscript anymore, please see the - new [doomrc](./doomrc) file structure for use it with Lua. - -## Features - -- Minimalistic good looks inspired by modern code editors. -- Works out of the box, just install and start editing. -- A modular organizational structure for separating concerns in your config. -- Extensible and customizable, everything can be easily modified. -- Curated and sane defaults for many plugins. -- Automatized, you don't have to care about manually managing plugins, installing - language servers or even TreeSitter syntax parsers, Doom Nvim will handle all - these things for you. -- A declarative and powerful [plugins management system](https://github.com/wbthomason/packer.nvim) - (powered by `packer.nvim`). -- Opt-in LSP integration for many languages by using the new - built-in LSP included on Neovim 0.5. -- An Emacs which-key like plugin to manage your `keybindings`, centered around leader - prefix key (SPC). -- Project search _and more_ utilities, powered by - [telescope.nvim]. - -## Prerequisites - -### Installation - -- Git 2.23+ - -### Runtime - -- Neovim 0.5.0 onwards - -- GNU `find` -- [ripgrep] 11.0+ or [fd] 7.3.0+ (optional but highly recommended, improves file indexing performance for some commands) -- `nodejs` and `npm` (optional, required to use some Language Server Protocols) -- `wget`, `unzip` (optional, required for auto installing LSPs) - -Doom is comprised of [~40 optional modules][modules], some of which may have -additional dependencies. [Please visit their documentation][modules]. +- [Doom Nvim](#doom-nvim) + * [What is Doom Nvim?](#what-is-doom-nvim-) + * [Install](#install) + * [Configuring](#configuring) + + [`modules.lua`](#-moduleslua-) + - [What is a module?](#what-is-a-module-) + - [Enabing/disabling modules](#enabing-disabling-modules) + - [All modules](#all-modules) + + [`config.lua`](#-configlua-) + - [Modifying neovim and doom options](#modifying-neovim-and-doom-options) + * [Adding plugins](#adding-plugins) + * [Adding Keybinds](#adding-keybinds) + * [Adding autocommands](#adding-autocommands) + - [Overriding module defaults](#overriding-module-defaults) + * [FAQ](#faq) + * [Contributing](#contributing) + * [Contributors](#contributors) + +--- + +## What is Doom Nvim? + +Doom Nvim is a Neovim interpretation of the [doom-emacs](https://github.com/hlissner/doom-emacs) framework, adapted to Vim philosophy. + +Its goal is to provide a configurable, extensible, performant and stable basis for any neovim configuration. +Some of the defining features that make this project unique are: + +- **Fast** Rapid startup time without defer_fn, packages are lazy loaded and languages are only configured when opening the file type. +- **Stable** Plugins are pinned to commit shas to avoid breaking between updates. +- **Configurable** All modules are 100% overridable and configurable, use a logical structure and have LSP completions. +- **Integrated** Desgined to handle and setup integrations between plugins for you. For example, whichkey will only show keybinds for + modules you have enabled (and will automatically handle your custom bindings). +- **Extensible** Take advantage of the modular architecture, enable only the features you need, customise or add your own modules. ## Install -> **IMPORTANT**: if you don't have a patched nerd font then you will need to -> install one in your system so you will be able to see icons in Neovim. +TODO: Add install docs here + +## Configuring + +Doom nvim is configured by enabling modules in the `modules.lua` file and then tweaking, overriding or adding new packages, keybinds and more within the `config.lua` module. + +### `modules.lua` -First you'll want to backup your current Neovim configuration if you have one. +#### What is a module? +A module is a collection of packages, autocommands, keybinds and functions that add new capabilities or functionality to Doom Nvim. +We organise modules into 3 categories: +- `features` extend the abilities of Doom Nvim by adding new functionality. +- `langs` add support for new languages. +- `user` (**optional**) You can create and enable your own modules without modifying the Doom Nvim source code (read more)[#TODO:]. -> **NOTES**: -> -> 1. Your current configuration will be backed up to `~/.config/nvim.bak` -> or where your `XDG_CONFIG_HOME` environment variable points to. +#### Enabing/disabling modules -```sh -[ -d ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ] && mv ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim.bak +You can enable or disable a module by going to `modules.lua` (`Dm`) and commenting or uncommenting the entry. +```lua +-- modules.lua +return { + features = { + 'lsp' + -- 'telescope' + }, + langs = { + 'lua', + -- 'rust', + } +} ``` +> Here the `lsp` module is enabled but the `telescope` module is disabled, similarly the `lua` language is enabled but the `rust` +> language module is disabled. + +#### All modules + +Doom-nvim currently has 39 `features` modules and 14 `langs` modules. Some standout features are: +- `lsp` Code completions provided by `nvim-cmp` +- `linter` Formatting and linting provided by `null-ls.nvim` +- `whichkey` Interactive cheatsheet that integrates with our keybind management to **only show keybinds for modules you have active** +- `fidget` Shows LSP loading/indexing progress status + +You can find a full list of modules (here)[#TODO: ]. -Now that you have backed up your current Neovim configuration you can proceed to install -`doom-nvim`. +### `config.lua` -```sh -git clone --depth 1 https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim +#### Modifying neovim and doom options + +Doom nvim provides a number of config options, including wrapping some of vim's own options. See all available config options (here)[TODO:]. + +```lua +-- config.lua +doom.freeze_dependencies = false -- Don't use pinned packer dependencies +doom.logging = 'trace' -- Debug doom internal issues +doom.indent = 2 -- Sets vim.opt.shiftwith, vim.opt.softtabstop, vim.opt.tabstop to 2 + +vim.opt.colorcolumn = 120 -- Regular vim options can also be set ``` -Or if you want to live in the bleeding-edge with the latest features: +> **NOTE:** If you have the `lua` language and `lsp` module enabled all of these options will be autocompleted. + +##### Adding plugins -```sh -git clone --depth 1 -b develop https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim +Additional packages can be imported with the `doom.use()` function. +This is a wrapper around `packer.use()` and provides the same API. [DOCS](https://github.com/wbthomason/packer.nvim#quickstart) + +```lua +-- Simple config +doom.use('sainnhe/sonokai', 'EdenEast/nightfox.nvim') + +-- Advanced config +doom.use({ + 'rafcamlet/nvim-luapad', + opt = true, + cmd = 'Luapad' +}) ``` ---- +##### Adding Keybinds -Then [read our Getting Started guide][getting-started] to be walked through -installing, configuring and maintaining Doom Nvim. +Additional keybinds can be defined with the `doom.bind()` function. +This is a wrapper around a custom `nest.nvim` implementation and provides the same API. [DOCS](https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide) -## Getting help +```lua +doom.bind({ + { 'u', name = '+user', { -- Names this group in whichkey "+user" + { 's', 'Telescope git_status', name = 'Git status' } -- Adds `us` keybind to trigger `Telescope git_status` + }}, +}) +``` + +> **NOTE:** By providing the `name` field your custom keybinds will show up in `whichkey` and `mapper` if you have those modules enabled. + +##### Adding autocommands -Although Neovim is not very difficult, you will occasionally run into problems -if you are not an advanced vimmer. When you do, here are some places you can look help: +Additional autocommands can be defined with the `doom.autocmd()` function. -- [Our documentation][documentation] covers many use cases. - - [The Configuration section][configuration] covers how to configure Doom Nvim and - its modules. - - [The Plugins Management section][plugins-management] covers how to install - and disable plugins. -- [Our troubleshooting wiki](https://github.com/NTBBloodbath/doom-nvim/wiki/Troubleshooting) -- Search the [Doom Nvim's issue tracker](https://github.com/NTBBloodbath/doom-nvim/issues) - before opening a new issue to see if your issue was already been reported and to - avoid duplicating issues. +```lua +doom.autcmd({ + -- { "", "", ""} + { "FileType", "javascript", function() print('Yuck!') end} +}) +``` + +#### Overriding module defaults + +The settings and config for all modules are also exposed inside of the `doom` global object. +Here you can override the plugin git sources, pre-defined settings, keybinds or autocmds. + + +```lua +-- modules.lua +return { + features = { + 'whichkey' -- Whichkey module is enabled + } +} + +-- config.lua +local whichkey = doom.modules.whichkey -- Get the whichkey module + +-- Some common settings are exposed in the `.settings` table. +whichkey.settings.window.height.max = 5 + +-- Inspect the existing config +print(vim.inspect(whichkey)) + +-- Add an additional keybind +table.insert(whichkey.binds, { 'u', name = '+user', { + { "wr", function() require("which-key").reset(), name = "Reset whichkey"} + } +}) +-- Replace all keybinds +whichkey.binds = { + { 'u', name = '+user', { + { "wr", function() require("which-key").reset(), name = "Reset whichkey"} + }} +} + +-- Add an additional autocommand +table.insert(whichkey.autcmds, { "event", "aupat", "cmd"}) +-- Replace all autocommands +whichkey.autocmds = { + { "event", "aupat", "cmd"} +} + +-- Modify the plugin source repo, plugins are indexed via the repository name. +whichkey.uses["which-key.nvim"] = { + "myfork/which-key.nvim" +} +-- Provide a different config function, the key has to match the entry in `whichkey.uses` +whichkey.configs["which-key.nvim"] = function () + local wk = require("which-key") +end +``` -## Acknowledgements +## FAQ -- [hlissner](https://github.com/hlissner) for making Doom Emacs :heart:. -- [romgrk](https://github.com/romgrk) for making a port of Doom One to Vim :heart:. -- [All our contributors](#contributors) per helping improve Doom :heart: +TODO: Add FAQ -## Contribute +## Contributing -- I really :heart: pull requests and bug reports (please see the [Contributing Guidelines][contribute] before contributing)! -- Don't hesitate to [tell me my Lua sucks](https://github.com/NTBBloodbath/doom-nvim/issues/new), - but please tell me why. +TODO: Add small info on contributing + overhaul contributing docs. ## Contributors -Special thanks to these amazing people for helping improve doom (see [emoji key](https://allcontributors.org/docs/en/emoji-key)): - - - - - - - - - - - - - - - - - - - - - - - -

John Irle

📖

Brian Ketelsen

💻 🐛

Samantha-uk

📖

rscircus

📖

bandithedoge

📖

vhyrro

💻

Ifeanyichukwu Sampson Ebenezer

🐛

Gustavo Prieto

💻

ZeusThundr

🐛

Leo Nistor

🐛

notusknot

📖

Bruce Dillahunty

📖 🐛

amxj9

🐛

Kyle Guerrero

📖
- - - - - - -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! - -## License - -Doom Nvim is licensed under [GPLv2](./LICENSE) license. - -[contribute]: docs/contributing.md -[documentation]: docs/README.md -[getting-started]: docs/getting_started.md -[install]: docs/getting_started.md#install -[configuration]: docs/getting_started.md#configuring-doom -[plugins-management]: docs/getting_started.md#plugins-management -[modules]: docs/modules.md -[editorconfig]: http://editorconfig.org/ -[fd]: https://github.com/sharkdp/fd -[ripgrep]: https://github.com/BurntSushi/ripgrep -[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim +TODO: Copy contributors from old README.md diff --git a/docs/getting_started.md b/docs/getting_started.md index 9aacf69..fd6ffa8 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -4,8 +4,8 @@ This is what you will have installed by the end of this section: -- Git 2.23+ -- Neovim 0.5.0+ (Neovim 0.4.x not supported, see [faq](./faq.md#why-does-doom-nvim-only-support-neovim-05) to know why) +- Git +- Neovim 0.6.0+ - GNU Find - **Optional**: ripgrep 11.0+ (highly recommended) - **Optional**: fd 7.3.0+ (known as `fd-find` on Debian, Ubuntu & derivates), From 208aeab016a6d49d4cb581e835fe1ccfd8653eaf Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 18:26:58 +1100 Subject: [PATCH 13/51] fix: Removed unused settings from lsp module --- lua/doom/modules/features/lsp/init.lua | 42 -------------------------- 1 file changed, 42 deletions(-) diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index 1ab67c1..a475ea6 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -21,48 +21,6 @@ lsp.settings = { shadow_blend = 36, -- if you using shadow as border use this set the opacity shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' }, - dont_install = {}, - servers = { - lua = { "sumneko_lua" }, - ansible = { "ansiblels" }, - angular = { "angularls" }, - bash = { "bashls" }, - c_sharp = { "omnisharp" }, - c = { "clangd" }, - cpp = { "clangd" }, - cmake = { "cmake" }, - css = { "cssls" }, - clojure = { "clojure_lsp" }, - dockerfile = { "dockerls" }, - dot = { "dotls" }, - elixer = { "elixerls" }, - elm = { "elmls" }, - ember = { "ember" }, - fortran = { "fortls" }, - go = { "gopls" }, - graphql = { "graphql" }, - groovy = { "groovyls" }, - html = { "html" }, - haskel = { "hls" }, - json = { "jsonls" }, - json5 = { "jsonls" }, - java = { "jdtls" }, - javascript = { "tsserver" }, - kotlin = { "kotlin_language_server" }, - latex = { "texlab" }, - ocaml = { "ocamells" }, - php = { "phpactor" }, - powershell = { "powershell_es" }, - python = { "pyright" }, - ruby = { "solargraph" }, - rust = { "rust_analyzer" }, - svelte = { "svelte" }, - typescript = { "tsserver" }, - vim = { "vimls" }, - vue = { "vuels" }, - xml = { "lemminx" }, - yaml = { "yamlls" }, - }, icons = { error = "", warn = "", From 285ce2accebc88bbd764a8504d57ff05b4df364b Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 18:41:49 +1100 Subject: [PATCH 14/51] clean: Unnecessary packer configs --- lua/doom/modules/features/neorg/init.lua | 2 ++ lua/doom/modules/features/whichkey/init.lua | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/doom/modules/features/neorg/init.lua b/lua/doom/modules/features/neorg/init.lua index c1ce943..249c14d 100644 --- a/lua/doom/modules/features/neorg/init.lua +++ b/lua/doom/modules/features/neorg/init.lua @@ -33,6 +33,8 @@ neorg.packages = { ["neorg"] = { "nvim-neorg/neorg", commit = "acfa3929971d488afac9c392fb34b80bac4f4c71", + opt = "true", + cmd = "NeorgStart" } } diff --git a/lua/doom/modules/features/whichkey/init.lua b/lua/doom/modules/features/whichkey/init.lua index d506c73..a46b0d6 100644 --- a/lua/doom/modules/features/whichkey/init.lua +++ b/lua/doom/modules/features/whichkey/init.lua @@ -65,8 +65,6 @@ whichkey.packages = { ["which-key.nvim"] = { "folke/which-key.nvim", commit = "28d2bd129575b5e9ebddd88506601290bb2bb221", - opt = false, - before = "nest.nvim", }, } From 3b6606768b59aa53c2405ca747c1b4f04d5f88ff Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 19:05:30 +1100 Subject: [PATCH 15/51] refact: Renamed module fields (uses, autocmds, binds) --- lua/doom/core/config/init.lua | 6 +++--- lua/doom/modules/core/core/init.lua | 8 ++++---- lua/doom/modules/core/nest/init.lua | 6 +++--- lua/doom/modules/core/treesitter/init.lua | 6 +++--- lua/doom/modules/features/annotations/init.lua | 6 +++--- .../modules/features/auto_install/init.lua | 8 ++++---- .../modules/features/auto_session/init.lua | 6 +++--- lua/doom/modules/features/autopairs/init.lua | 6 +++--- lua/doom/modules/features/colorizer/init.lua | 6 +++--- lua/doom/modules/features/comment/init.lua | 6 +++--- lua/doom/modules/features/dap/init.lua | 6 +++--- lua/doom/modules/features/dashboard/init.lua | 8 ++++---- .../modules/features/doom_reloader/init.lua | 6 +++--- lua/doom/modules/features/doom_themes/init.lua | 4 ++-- .../modules/features/editorconfig/init.lua | 4 ++-- lua/doom/modules/features/explorer/init.lua | 6 +++--- lua/doom/modules/features/fidget/init.lua | 6 +++--- lua/doom/modules/features/firenvim/init.lua | 6 +++--- lua/doom/modules/features/gitsigns/init.lua | 6 +++--- lua/doom/modules/features/illuminate/init.lua | 6 +++--- lua/doom/modules/features/indentlines/init.lua | 6 +++--- lua/doom/modules/features/lazygit/init.lua | 2 +- lua/doom/modules/features/linter/init.lua | 6 +++--- lua/doom/modules/features/lsp/init.lua | 10 +++++----- lua/doom/modules/features/minimap/init.lua | 4 ++-- lua/doom/modules/features/neogit/init.lua | 6 +++--- lua/doom/modules/features/neorg/init.lua | 6 +++--- lua/doom/modules/features/projects/init.lua | 6 +++--- .../modules/features/range_highlight/init.lua | 6 +++--- lua/doom/modules/features/ranger/init.lua | 4 ++-- lua/doom/modules/features/restclient/init.lua | 6 +++--- .../modules/features/show_registers/init.lua | 4 ++-- lua/doom/modules/features/snippets/init.lua | 6 +++--- lua/doom/modules/features/statusline/init.lua | 6 +++--- lua/doom/modules/features/statusline2/init.lua | 6 +++--- lua/doom/modules/features/suda/init.lua | 4 ++-- lua/doom/modules/features/superman/init.lua | 4 ++-- lua/doom/modules/features/symbols/init.lua | 6 +++--- lua/doom/modules/features/tabline/init.lua | 6 +++--- lua/doom/modules/features/telescope/init.lua | 8 ++++---- lua/doom/modules/features/terminal/init.lua | 6 +++--- .../modules/features/todo_comments/init.lua | 6 +++--- lua/doom/modules/features/trouble/init.lua | 6 +++--- lua/doom/modules/features/whichkey/init.lua | 6 +++--- lua/doom/modules/features/zen/init.lua | 6 +++--- lua/doom/modules/init.lua | 18 +++++++++--------- lua/doom/modules/langs/bash/init.lua | 2 +- lua/doom/modules/langs/c_sharp/init.lua | 2 +- lua/doom/modules/langs/config/init.lua | 8 ++++---- lua/doom/modules/langs/cpp/init.lua | 2 +- lua/doom/modules/langs/css/init.lua | 2 +- lua/doom/modules/langs/glsl/init.lua | 2 +- lua/doom/modules/langs/go/init.lua | 2 +- lua/doom/modules/langs/haskell/init.lua | 2 +- lua/doom/modules/langs/java/init.lua | 2 +- lua/doom/modules/langs/javascript/init.lua | 2 +- lua/doom/modules/langs/kotlin/init.lua | 2 +- lua/doom/modules/langs/lua/init.lua | 8 ++++---- lua/doom/modules/langs/python/init.lua | 2 +- lua/doom/modules/langs/rust/init.lua | 2 +- lua/doom/modules/langs/tailwindcss/init.lua | 2 +- lua/doom/modules/langs/terraform/init.lua | 2 +- lua/doom/modules/langs/typescript/init.lua | 2 +- lua/doom/modules/langs/vue/init.lua | 4 ++-- 64 files changed, 166 insertions(+), 166 deletions(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index ef28880..82f6d4a 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -195,7 +195,7 @@ config.load = function() vim.opt.foldenable = true vim.opt.foldtext = require("doom.core.functions").sugar_folds() doom = config.defaults - doom.packages = {} -- Extra packages + doom.uses = {} -- Extra packages doom.autocmds = {} -- Extra autocommands doom.binds = {} -- Extra binds doom.modules = {} -- Modules @@ -220,10 +220,10 @@ config.load = function() end -- Iterate over existing packages, removing all packages that are about to be overriden - doom.packages = vim.tbl_filter(package_override_predicate, doom.packages) + doom.uses = vim.tbl_filter(package_override_predicate, doom.uses) for _, packer_spec in ipairs(arg) do - table.insert(doom.packages, type(packer_spec) == "string" and { packer_spec } or packer_spec) + table.insert(doom.uses, type(packer_spec) == "string" and { packer_spec } or packer_spec) end end --]] diff --git a/lua/doom/modules/core/core/init.lua b/lua/doom/modules/core/core/init.lua index daa09e4..876b3f7 100644 --- a/lua/doom/modules/core/core/init.lua +++ b/lua/doom/modules/core/core/init.lua @@ -5,7 +5,7 @@ required.settings = { } local is_plugin_disabled = require("doom.utils").is_plugin_disabled -required.packages = { +required.uses = { ["packer.nvim"] = { "wbthomason/packer.nvim", }, @@ -36,8 +36,8 @@ required.packages = { } } -required.configure_functions = {} -required.configure_functions["nvim-mapper"] = function() +required.configs = {} +required.configs["nvim-mapper"] = function() require("nvim-mapper").setup(doom.modules.core.settings.mapper) end @@ -317,7 +317,7 @@ required.binds = function () return binds end -required.autocommands = function () +required.autocmds = function () local is_plugin_disabled = require("doom.utils").is_plugin_disabled local autocmds = {} diff --git a/lua/doom/modules/core/nest/init.lua b/lua/doom/modules/core/nest/init.lua index 0677d59..e721c25 100644 --- a/lua/doom/modules/core/nest/init.lua +++ b/lua/doom/modules/core/nest/init.lua @@ -3,7 +3,7 @@ local nest = {} nest.settings = { } -nest.packages = { +nest.uses = { ["nest.nvim"] = { "connorgmeehan/nest.nvim", branch = "integrations-api", @@ -11,8 +11,8 @@ nest.packages = { }, } -nest.configure_functions = {} -nest.configure_functions["nest.nvim"] = function() +nest.configs = {} +nest.configs["nest.nvim"] = function() local utils = require("doom.utils") local is_plugin_disabled = utils.is_plugin_disabled diff --git a/lua/doom/modules/core/treesitter/init.lua b/lua/doom/modules/core/treesitter/init.lua index 21a4ea0..2e7e202 100644 --- a/lua/doom/modules/core/treesitter/init.lua +++ b/lua/doom/modules/core/treesitter/init.lua @@ -39,7 +39,7 @@ treesitter.settings = { }, } -treesitter.packages = { +treesitter.uses = { ["nvim-treesitter"] = { "nvim-treesitter/nvim-treesitter", commit = "82389e52b6b50f712593079255ee088f1631b9cd", @@ -58,8 +58,8 @@ treesitter.packages = { }, } -treesitter.configure_functions = {} -treesitter.configure_functions["nvim-treesitter"] = function() +treesitter.configs = {} +treesitter.configs["nvim-treesitter"] = function() local is_plugin_disabled = require("doom.utils").is_plugin_disabled require("nvim-treesitter.configs").setup(vim.tbl_deep_extend("force", doom.modules.treesitter.settings.treesitter, { autopairs = { diff --git a/lua/doom/modules/features/annotations/init.lua b/lua/doom/modules/features/annotations/init.lua index 5d9e9cb..6eb63e9 100644 --- a/lua/doom/modules/features/annotations/init.lua +++ b/lua/doom/modules/features/annotations/init.lua @@ -11,7 +11,7 @@ annotations.settings = { }, } -annotations.packages = { +annotations.uses = { ["neogen"] = { "danymat/neogen", commit = "b7d2ce8c1d17a0b90f557e5f94372f42193291a5", @@ -19,8 +19,8 @@ annotations.packages = { }, } -annotations.configure_functions = {} -annotations.configure_functions["neogen"] = function() +annotations.configs = {} +annotations.configs["neogen"] = function() require("neogen").setup(doom.modules.annotations.settings) end diff --git a/lua/doom/modules/features/auto_install/init.lua b/lua/doom/modules/features/auto_install/init.lua index db75915..67cc556 100644 --- a/lua/doom/modules/features/auto_install/init.lua +++ b/lua/doom/modules/features/auto_install/init.lua @@ -7,7 +7,7 @@ auto_install.settings = { local is_plugin_disabled = require("doom.utils").is_plugin_disabled -auto_install.packages = { +auto_install.uses = { ["DAPInstall.nvim"] = { "Pocco81/DAPInstall.nvim", commit = "24923c3819a450a772bb8f675926d530e829665f", @@ -30,14 +30,14 @@ auto_install.packages = { }, } -auto_install.configure_functions = {} -auto_install.configure_functions["nvim-lsp-installer"] = function() +auto_install.configs = {} +auto_install.configs["nvim-lsp-installer"] = function() local lsp_installer = require("nvim-lsp-installer") lsp_installer.settings({ install_root_dir = doom.modules.auto_install.settings.lsp_dir, }) end -auto_install.configure_functions["DAPInstall.nvim"] = function() +auto_install.configs["DAPInstall.nvim"] = function() local dap_install = require("dap-install") dap_install.setup({ installation_path = doom.modules.auto_install.settings.dap_dir, diff --git a/lua/doom/modules/features/auto_session/init.lua b/lua/doom/modules/features/auto_session/init.lua index 3733f60..ec86588 100644 --- a/lua/doom/modules/features/auto_session/init.lua +++ b/lua/doom/modules/features/auto_session/init.lua @@ -4,7 +4,7 @@ auto_session.settings = { dir = vim.fn.stdpath("data") .. "/sessions/", } -auto_session.packages = { +auto_session.uses = { ["persistence.nvim"] = { "folke/persistence.nvim", commit = "77cf5a6ee162013b97237ff25450080401849f85", @@ -12,8 +12,8 @@ auto_session.packages = { }, } -auto_session.configure_functions = {} -auto_session.configure_functions["persistence.nvim"] = function() +auto_session.configs = {} +auto_session.configs["persistence.nvim"] = function() require("persistence").setup(doom.modules.auto_session.settings) end diff --git a/lua/doom/modules/features/autopairs/init.lua b/lua/doom/modules/features/autopairs/init.lua index f03fa55..8002eab 100644 --- a/lua/doom/modules/features/autopairs/init.lua +++ b/lua/doom/modules/features/autopairs/init.lua @@ -6,7 +6,7 @@ autopairs.settings = { enable_moveright = true, } -autopairs.packages = { +autopairs.uses = { ["nvim-autopairs"] = { "windwp/nvim-autopairs", commit = "771fda8d169384d345c8bbf2f871b75ba4a2dee5", @@ -14,8 +14,8 @@ autopairs.packages = { }, } -autopairs.configure_functions = {} -autopairs.configure_functions["nvim-autopairs"] = function() +autopairs.configs = {} +autopairs.configs["nvim-autopairs"] = function() require("nvim-autopairs").setup(vim.tbl_deep_extend("force", doom.modules.autopairs.settings, { check_ts = true })) end diff --git a/lua/doom/modules/features/colorizer/init.lua b/lua/doom/modules/features/colorizer/init.lua index a4e1426..2556329 100644 --- a/lua/doom/modules/features/colorizer/init.lua +++ b/lua/doom/modules/features/colorizer/init.lua @@ -6,7 +6,7 @@ colorizer.settings = { html = { names = false }, } -colorizer.packages = { +colorizer.uses = { ["nvim-colorizer.lua"] = { "norcalli/nvim-colorizer.lua", commit = "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6", @@ -14,8 +14,8 @@ colorizer.packages = { }, } -colorizer.configure_functions = {} -colorizer.configure_functions["nvim-colorizer.lua"] = function() +colorizer.configs = {} +colorizer.configs["nvim-colorizer.lua"] = function() require("colorizer").setup(doom.modules.colorizer.settings) end diff --git a/lua/doom/modules/features/comment/init.lua b/lua/doom/modules/features/comment/init.lua index cc43c3a..f702601 100644 --- a/lua/doom/modules/features/comment/init.lua +++ b/lua/doom/modules/features/comment/init.lua @@ -41,7 +41,7 @@ comment.settings = { end, } -comment.packages = { +comment.uses = { ["Comment.nvim"] = { "numToStr/Comment.nvim", commit = "18a8dc0bbdfc089d5f5a850e4640d8e75381c598", @@ -49,8 +49,8 @@ comment.packages = { }, } -comment.configure_functions = {} -comment.configure_functions["Comment.nvim"] = function() +comment.configs = {} +comment.configs["Comment.nvim"] = function() local config = vim.tbl_extend("force", doom.modules.comment.settings, { -- Disable mappings as we'll handle it in binds.lua mappings = { diff --git a/lua/doom/modules/features/dap/init.lua b/lua/doom/modules/features/dap/init.lua index f93d9da..af55791 100644 --- a/lua/doom/modules/features/dap/init.lua +++ b/lua/doom/modules/features/dap/init.lua @@ -35,7 +35,7 @@ dap.settings = { }, } -dap.packages = { +dap.uses = { ["nvim-dap"] = { "mfussenegger/nvim-dap", commit = "9fcff6e02e1a549d47a2c559a4b833798537c0bc", @@ -48,8 +48,8 @@ dap.packages = { }, } -dap.configure_functions = {} -dap.configure_functions["nvim-dap-ui"] = function() +dap.configs = {} +dap.configs["nvim-dap-ui"] = function() local dap_package = require("dap") local dapui = require("dapui") dap_package.listeners.after.event_initialized["dapui_config"] = function() diff --git a/lua/doom/modules/features/dashboard/init.lua b/lua/doom/modules/features/dashboard/init.lua index 72403f8..13aed4c 100644 --- a/lua/doom/modules/features/dashboard/init.lua +++ b/lua/doom/modules/features/dashboard/init.lua @@ -54,7 +54,7 @@ dashboard.settings = { }, } -dashboard.packages = { +dashboard.uses = { ["dashboard-nvim"] = { "glepnir/dashboard-nvim", commit = "ba98ab86487b8eda3b0934b5423759944b5f7ebd", @@ -64,8 +64,8 @@ dashboard.packages = { } -dashboard.configure_functions = {} -dashboard.configure_functions["dashboard-nvim"] = function() +dashboard.configs = {} +dashboard.configs["dashboard-nvim"] = function() local utils = require("doom.utils") local is_plugin_disabled = utils.is_plugin_disabled @@ -112,7 +112,7 @@ dashboard.binds = { }, } -dashboard.autocommands = { +dashboard.autocmds = { { "FileType", "dashboard", diff --git a/lua/doom/modules/features/doom_reloader/init.lua b/lua/doom/modules/features/doom_reloader/init.lua index 098a9cd..ad422bb 100644 --- a/lua/doom/modules/features/doom_reloader/init.lua +++ b/lua/doom/modules/features/doom_reloader/init.lua @@ -11,10 +11,10 @@ doom_reloader.settings = { }, } -doom_reloader.packages = {} -doom_reloader.configure_functions = {} +doom_reloader.uses = {} +doom_reloader.configs = {} -doom_reloader.autocommands = { +doom_reloader.autocmds = { { "BufWritePost", "*/doom/**/*.lua", function() require("doom.utils.reloader").full_reload() end }, { "BufWritePost", diff --git a/lua/doom/modules/features/doom_themes/init.lua b/lua/doom/modules/features/doom_themes/init.lua index 4a83fa4..fd82831 100644 --- a/lua/doom/modules/features/doom_themes/init.lua +++ b/lua/doom/modules/features/doom_themes/init.lua @@ -2,9 +2,9 @@ local doom_themes = {} doom_themes.settings = {} -doom_themes.configure_functions = {} +doom_themes.configs = {} -doom_themes.packages = { +doom_themes.uses = { ["doom-themes.nvim"] = { "GustavoPrietoP/doom-themes.nvim", commit = "03d417d3eab71c320744f8da22251715ba6cee53", diff --git a/lua/doom/modules/features/editorconfig/init.lua b/lua/doom/modules/features/editorconfig/init.lua index b16d2c4..d5336d6 100644 --- a/lua/doom/modules/features/editorconfig/init.lua +++ b/lua/doom/modules/features/editorconfig/init.lua @@ -2,13 +2,13 @@ local editorconfig = {} editorconfig.settings = {} -editorconfig.packages = { +editorconfig.uses = { ["editorconfig-vim"] = { "editorconfig/editorconfig-vim", commit = "a8e3e66deefb6122f476c27cee505aaae93f7109", }, } -editorconfig.configure_functions = {} +editorconfig.configs = {} return editorconfig diff --git a/lua/doom/modules/features/explorer/init.lua b/lua/doom/modules/features/explorer/init.lua index e1ce1f0..e93db50 100644 --- a/lua/doom/modules/features/explorer/init.lua +++ b/lua/doom/modules/features/explorer/init.lua @@ -74,7 +74,7 @@ explorer.settings = { }, } -explorer.packages = { +explorer.uses = { ["nvim-tree.lua"] = { "kyazdani42/nvim-tree.lua", commit = "9b03ab40e843e251f01bccec2eca5ea9dcdebc0d", @@ -90,8 +90,8 @@ explorer.packages = { } -explorer.configure_functions = {} -explorer.configure_functions["nvim-tree.lua"] = function() +explorer.configs = {} +explorer.configs["nvim-tree.lua"] = function() local utils = require("doom.utils") local is_plugin_disabled = utils.is_plugin_disabled diff --git a/lua/doom/modules/features/fidget/init.lua b/lua/doom/modules/features/fidget/init.lua index 6b0577a..ad05a9c 100644 --- a/lua/doom/modules/features/fidget/init.lua +++ b/lua/doom/modules/features/fidget/init.lua @@ -3,15 +3,15 @@ local fidget = {} fidget.settings = { } -fidget.packages = { +fidget.uses = { ["fidget.nvim"] = { "j-hui/fidget.nvim", commit = "cbe0db4f2adfddfd830310e5846f8735d4e068fa", }, } -fidget.configure_functions = {} -fidget.configure_functions["fidget.nvim"] = function() +fidget.configs = {} +fidget.configs["fidget.nvim"] = function() require("fidget").setup(doom.modules.fidget.settings) end diff --git a/lua/doom/modules/features/firenvim/init.lua b/lua/doom/modules/features/firenvim/init.lua index c4961d3..18db6aa 100644 --- a/lua/doom/modules/features/firenvim/init.lua +++ b/lua/doom/modules/features/firenvim/init.lua @@ -22,7 +22,7 @@ firenvim.settings = { }, } -firenvim.packages = { +firenvim.uses = { ["firenvim"] = { "glacambre/firenvim", commit = "668b350ce88cc9a2257644c67945c9abbdd36cb5", @@ -33,8 +33,8 @@ firenvim.packages = { }, } -firenvim.configure_functions = {} -firenvim.configure_functions["firenvim"] = function() +firenvim.configs = {} +firenvim.configs["firenvim"] = function() vim.g.firenvim_config = doom.modules.firenvim.settings for _, command in ipairs(doom.modules.firenvim.settings.autocmds) do diff --git a/lua/doom/modules/features/gitsigns/init.lua b/lua/doom/modules/features/gitsigns/init.lua index bd849f5..6bc59eb 100644 --- a/lua/doom/modules/features/gitsigns/init.lua +++ b/lua/doom/modules/features/gitsigns/init.lua @@ -72,15 +72,15 @@ gitsigns.settings = { }, } -gitsigns.packages = { +gitsigns.uses = { ["gitsigns.nvim"] = { "lewis6991/gitsigns.nvim", commit = "7de953329ff696408bd38d3218b0239839d285e0", }, } -gitsigns.configure_functions = {} -gitsigns.configure_functions["gitsigns.nvim"] = function() +gitsigns.configs = {} +gitsigns.configs["gitsigns.nvim"] = function() require("gitsigns").setup(doom.modules.gitsigns.settings) end diff --git a/lua/doom/modules/features/illuminate/init.lua b/lua/doom/modules/features/illuminate/init.lua index c404122..2c2c4bb 100644 --- a/lua/doom/modules/features/illuminate/init.lua +++ b/lua/doom/modules/features/illuminate/init.lua @@ -13,15 +13,15 @@ illuminate.settings = { }, } -illuminate.packages = { +illuminate.uses = { ["vim-illuminate"] = { "RRethy/vim-illuminate", commit = "db98338285574265a6ce54370b54d9f939e091bb", }, } -illuminate.configure_functions = {} -illuminate.configure_functions["vim-illuminate"] = function() +illuminate.configs = {} +illuminate.configs["vim-illuminate"] = function() vim.g.Illuminate_ftblacklist = doom.modules.illuminate.settings.blacklist end diff --git a/lua/doom/modules/features/indentlines/init.lua b/lua/doom/modules/features/indentlines/init.lua index 087389a..74940c1 100644 --- a/lua/doom/modules/features/indentlines/init.lua +++ b/lua/doom/modules/features/indentlines/init.lua @@ -8,7 +8,7 @@ indentlines.settings = { buftype_exclude = { "terminal" }, } -indentlines.packages = { +indentlines.uses = { ["indent-blankline.nvim"] = { "lukas-reineke/indent-blankline.nvim", commit = "2e35f7dcdc72f39b37c21e43cdb538d7a41c7e07", @@ -16,8 +16,8 @@ indentlines.packages = { }, } -indentlines.configure_functions = {} -indentlines.configure_functions["indent-blankline.nvim"] = function() +indentlines.configs = {} +indentlines.configs["indent-blankline.nvim"] = function() require("indent_blankline").setup(vim.tbl_deep_extend("force", doom.modules.indentlines.settings, { -- To remove indent lines, remove the module. Having the module and -- disabling it makes no sense. diff --git a/lua/doom/modules/features/lazygit/init.lua b/lua/doom/modules/features/lazygit/init.lua index 959c6ee..b4109af 100644 --- a/lua/doom/modules/features/lazygit/init.lua +++ b/lua/doom/modules/features/lazygit/init.lua @@ -2,7 +2,7 @@ local lazygit = {} lazygit.settings = {} -lazygit.packages = { +lazygit.uses = { ["lazygit.nvim"] = { "kdheepak/lazygit.nvim", commit = "9bceeab97668935cc6b91ab5190167d9771b5210", diff --git a/lua/doom/modules/features/linter/init.lua b/lua/doom/modules/features/linter/init.lua index 37252e1..9b7b3a5 100644 --- a/lua/doom/modules/features/linter/init.lua +++ b/lua/doom/modules/features/linter/init.lua @@ -4,7 +4,7 @@ linter.settings = { format_on_save = false, } -linter.packages = { +linter.uses = { ["null-ls.nvim"] = { "jose-elias-alvarez/null-ls.nvim", commit = "a1804de23ce354c982aa08c57d3ed89aad8a15a9", @@ -12,8 +12,8 @@ linter.packages = { }, } -linter.configure_functions = {} -linter.configure_functions["null-ls.nvim"] = function() +linter.configs = {} +linter.configs["null-ls.nvim"] = function() local null_ls = require("null-ls") null_ls.setup({ diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index a475ea6..1456321 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -78,7 +78,7 @@ lsp.settings = { } local is_plugin_disabled = require("doom.utils").is_plugin_disabled -lsp.packages = { +lsp.uses = { ["nvim-lspconfig"] = { "neovim/nvim-lspconfig", commit = "cdc2ec53e028d32f06c51ef8b2837ebb8460ef45", @@ -131,8 +131,8 @@ lsp.packages = { } -lsp.configure_functions = {} -lsp.configure_functions["nvim-lspconfig"] = function() +lsp.configs = {} +lsp.configs["nvim-lspconfig"] = function() -- Lsp Symbols local signs, hl if vim.fn.has("nvim-0.6.0") == 1 then @@ -195,7 +195,7 @@ lsp.configure_functions["nvim-lspconfig"] = function() end end end -lsp.configure_functions["nvim-cmp"] = function() +lsp.configs["nvim-cmp"] = function() local cmp = require("cmp") local luasnip = require("luasnip") local replace_termcodes = require("doom.utils").replace_termcodes @@ -280,7 +280,7 @@ lsp.configure_functions["nvim-cmp"] = function() end, })) end -lsp.configure_functions["lsp_signature.nvim"] = function() +lsp.configs["lsp_signature.nvim"] = function() -- Signature help require("lsp_signature").setup(vim.tbl_deep_extend("force", doom.modules.lsp.settings.signature, { handler_opts = { diff --git a/lua/doom/modules/features/minimap/init.lua b/lua/doom/modules/features/minimap/init.lua index a97987b..b158ec1 100644 --- a/lua/doom/modules/features/minimap/init.lua +++ b/lua/doom/modules/features/minimap/init.lua @@ -2,7 +2,7 @@ local minimap = {} minimap.settings = {} -minimap.packages = { +minimap.uses = { ["minimap.vim"] = { "wfxr/minimap.vim", commit = "c8ea2a5550b95b007631bc83908c48a3368eb57c", @@ -18,7 +18,7 @@ minimap.packages = { } -minimap.configure_functions = {} +minimap.configs = {} minimap.binds = { { "", ":MinimapToggle", name = "Toggle minimap" }, diff --git a/lua/doom/modules/features/neogit/init.lua b/lua/doom/modules/features/neogit/init.lua index f7d9a6a..ed08660 100644 --- a/lua/doom/modules/features/neogit/init.lua +++ b/lua/doom/modules/features/neogit/init.lua @@ -2,7 +2,7 @@ local neogit = {} neogit.settings = {} -neogit.packages = { +neogit.uses = { ["neogit"] = { "TimUntersberger/neogit", commit = "3bba2b63417cb679313e0ed0b7d9b7539c7f02b0", @@ -11,8 +11,8 @@ neogit.packages = { }, } -neogit.configure_functions = {} -neogit.configure_functions["neogit"] = function() +neogit.configs = {} +neogit.configs["neogit"] = function() require("neogit").setup(doom.modules.neogit.settings) end diff --git a/lua/doom/modules/features/neorg/init.lua b/lua/doom/modules/features/neorg/init.lua index 249c14d..f0427ec 100644 --- a/lua/doom/modules/features/neorg/init.lua +++ b/lua/doom/modules/features/neorg/init.lua @@ -29,7 +29,7 @@ neorg.settings = { }, } -neorg.packages = { +neorg.uses = { ["neorg"] = { "nvim-neorg/neorg", commit = "acfa3929971d488afac9c392fb34b80bac4f4c71", @@ -38,8 +38,8 @@ neorg.packages = { } } -neorg.configure_functions = {} -neorg.configure_functions["neorg"] = function() +neorg.configs = {} +neorg.configs["neorg"] = function() require("neorg").setup(doom.modules.neorg.settings) end diff --git a/lua/doom/modules/features/projects/init.lua b/lua/doom/modules/features/projects/init.lua index 174e567..451a2a2 100644 --- a/lua/doom/modules/features/projects/init.lua +++ b/lua/doom/modules/features/projects/init.lua @@ -35,7 +35,7 @@ projects.settings ={ datapath = vim.fn.stdpath("data"), } -projects.packages = { +projects.uses = { ["project.nvim"] = { "ahmedkhalf/project.nvim", commit = "cef52b8da07648b750d7f1e8fb93f12cb9482988", @@ -43,8 +43,8 @@ projects.packages = { }, } -projects.configure_functions = {} -projects.configure_functions["project.nvim"] = function() +projects.configs = {} +projects.configs["project.nvim"] = function() require("project_nvim").setup(doom.modules.projects.settings) table.insert(doom.modules.telescope.settings.extensions, 'projects') diff --git a/lua/doom/modules/features/range_highlight/init.lua b/lua/doom/modules/features/range_highlight/init.lua index 283e7f1..a3eaedc 100644 --- a/lua/doom/modules/features/range_highlight/init.lua +++ b/lua/doom/modules/features/range_highlight/init.lua @@ -2,7 +2,7 @@ local range_highlight = {} range_highlight.settings = {} -range_highlight.packages = { +range_highlight.uses = { ["range-highlight.nvim"] = { "winston0410/range-highlight.nvim", commit = "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9", @@ -13,8 +13,8 @@ range_highlight.packages = { }, } -range_highlight.configure_functions = {} -range_highlight.configure_functions["range-highlight.nvim"] = function() +range_highlight.configs = {} +range_highlight.configs["range-highlight.nvim"] = function() require("range-highlight").setup(doom.modules.range_highlight.settings) end diff --git a/lua/doom/modules/features/ranger/init.lua b/lua/doom/modules/features/ranger/init.lua index 5caf2a0..61e65c7 100644 --- a/lua/doom/modules/features/ranger/init.lua +++ b/lua/doom/modules/features/ranger/init.lua @@ -2,7 +2,7 @@ local ranger = {} ranger.settings = {} -ranger.packages = { +ranger.uses = { ["ranger.vim"] = { "francoiscabrol/ranger.vim", commit = "91e82debdf566dfaf47df3aef0a5fd823cedf41c", @@ -19,7 +19,7 @@ ranger.packages = { }, } -ranger.configure_functions = {} +ranger.configs = {} ranger.binds = { "", diff --git a/lua/doom/modules/features/restclient/init.lua b/lua/doom/modules/features/restclient/init.lua index 73cd0f6..23e9d4c 100644 --- a/lua/doom/modules/features/restclient/init.lua +++ b/lua/doom/modules/features/restclient/init.lua @@ -2,7 +2,7 @@ local restclient = {} restclient.settings = {} -restclient.packages = { +restclient.uses = { ["rest.nvim"] = { "NTBBloodbath/rest.nvim", commit = "2826f6960fbd9adb1da9ff0d008aa2819d2d06b3", @@ -15,8 +15,8 @@ restclient.packages = { } -restclient.configure_functions = {} -restclient.configure_functions["rest.nvim"] = function() +restclient.configs = {} +restclient.configs["rest.nvim"] = function() require("rest-nvim").setup(doom.modules.restclient.settings) end diff --git a/lua/doom/modules/features/show_registers/init.lua b/lua/doom/modules/features/show_registers/init.lua index a5567d2..1e07988 100644 --- a/lua/doom/modules/features/show_registers/init.lua +++ b/lua/doom/modules/features/show_registers/init.lua @@ -2,7 +2,7 @@ local show_registers = {} show_registers.settings = {} -show_registers.packages = { +show_registers.uses = { ["registers.nvim"] = { "tversteeg/registers.nvim", commit = "dd2bfa41b2c43d65f1f715e07acf1f1d34b37de8", @@ -10,6 +10,6 @@ show_registers.packages = { }, } -show_registers.configure_functions = {} +show_registers.configs = {} return show_registers diff --git a/lua/doom/modules/features/snippets/init.lua b/lua/doom/modules/features/snippets/init.lua index 42b7f15..7e60736 100644 --- a/lua/doom/modules/features/snippets/init.lua +++ b/lua/doom/modules/features/snippets/init.lua @@ -5,7 +5,7 @@ snippets.settings = { updateevents = "TextChanged,TextChangedI", } -snippets.packages = { +snippets.uses = { ["LuaSnip"] = { "L3MON4D3/LuaSnip", commit = "7c634ddf7ff99245ef993b5fa459c3b61e905075", @@ -14,8 +14,8 @@ snippets.packages = { }, } -snippets.configure_functions = {} -snippets.configure_functions["LuaSnip"] = function() +snippets.configs = {} +snippets.configs["LuaSnip"] = function() require("luasnip").config.set_config(doom.modules.snippets.settings) require("luasnip.loaders.from_vscode").load() end diff --git a/lua/doom/modules/features/statusline/init.lua b/lua/doom/modules/features/statusline/init.lua index 50f51d4..30f8a44 100644 --- a/lua/doom/modules/features/statusline/init.lua +++ b/lua/doom/modules/features/statusline/init.lua @@ -14,15 +14,15 @@ statusline.settings = { sections = {}, } -statusline.packages = { +statusline.uses = { ["galaxyline.nvim"] = { "NTBBloodbath/galaxyline.nvim", commit = "4d4f5fc8e20a10824117e5beea7ec6e445466a8f", }, } -statusline.configure_functions = {} -statusline.configure_functions["galaxyline.nvim"] = function() +statusline.configs = {} +statusline.configs["galaxyline.nvim"] = function() local utils = require("doom.utils") local is_plugin_disabled = utils.is_plugin_disabled diff --git a/lua/doom/modules/features/statusline2/init.lua b/lua/doom/modules/features/statusline2/init.lua index 5934628..ab284e6 100644 --- a/lua/doom/modules/features/statusline2/init.lua +++ b/lua/doom/modules/features/statusline2/init.lua @@ -3,14 +3,14 @@ local statusline = {} statusline.settings = { } -statusline.packages = { +statusline.uses = { ["lualine.nvim"] = { "nvim-lualine/lualine.nvim", }, } -statusline.configure_functions = {} -statusline.configure_functions["lualine.nvim"] = function() +statusline.configs = {} +statusline.configs["lualine.nvim"] = function() require('lualine').setup { options = { icons_enabled = true, diff --git a/lua/doom/modules/features/suda/init.lua b/lua/doom/modules/features/suda/init.lua index 4705752..4a1c306 100644 --- a/lua/doom/modules/features/suda/init.lua +++ b/lua/doom/modules/features/suda/init.lua @@ -2,7 +2,7 @@ local suda = {} suda.settings = {} -suda.packages = { +suda.uses = { ["suda.vim"] = { "lambdalisue/suda.vim", commit = "6bffe36862faa601d2de7e54f6e85c1435e832d0", @@ -11,7 +11,7 @@ suda.packages = { }, } -suda.configure_functions = {} +suda.configs = {} suda.binds = { "", diff --git a/lua/doom/modules/features/superman/init.lua b/lua/doom/modules/features/superman/init.lua index 8f4e52b..34bf86a 100644 --- a/lua/doom/modules/features/superman/init.lua +++ b/lua/doom/modules/features/superman/init.lua @@ -2,7 +2,7 @@ local superman = {} superman.settings = {} -superman.packages = { +superman.uses = { ["vim-superman"] = { "jez/vim-superman", commit = "19d307446576d9118625c5d9d3c7a4c9bec5571a", @@ -11,6 +11,6 @@ superman.packages = { }, } -superman.configure_functions = {} +superman.configs = {} return superman diff --git a/lua/doom/modules/features/symbols/init.lua b/lua/doom/modules/features/symbols/init.lua index 36bbc78..4da707a 100644 --- a/lua/doom/modules/features/symbols/init.lua +++ b/lua/doom/modules/features/symbols/init.lua @@ -16,7 +16,7 @@ symbols.settings = { width = 25, } -symbols.packages = { +symbols.uses = { ["symbols-outline.nvim"] = { "simrat39/symbols-outline.nvim", commit = "758944ebc6919c50557b6eb3a52bc41187041fe2", @@ -31,8 +31,8 @@ symbols.packages = { -symbols.configure_functions = {} -symbols.configure_functions["symbols_outline.nvim"] = function() +symbols.configs = {} +symbols.configs["symbols_outline.nvim"] = function() vim.g.symbols_outline = doom.modules.symbols.settings end diff --git a/lua/doom/modules/features/tabline/init.lua b/lua/doom/modules/features/tabline/init.lua index ef19ddd..8346150 100644 --- a/lua/doom/modules/features/tabline/init.lua +++ b/lua/doom/modules/features/tabline/init.lua @@ -139,7 +139,7 @@ tabline.settings = { }, } -tabline.packages = { +tabline.uses = { ["bufferline.nvim"] = { "akinsho/bufferline.nvim", commit = "871495d9e2dbe3314a421fd2d5e46f47de7ee537", @@ -148,8 +148,8 @@ tabline.packages = { } -tabline.configure_functions = {} -tabline.configure_functions["bufferline.nvim"] = function() +tabline.configs = {} +tabline.configs["bufferline.nvim"] = function() require("bufferline").setup(doom.modules.tabline.settings) end diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index fe9d54e..a732014 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -46,7 +46,7 @@ telescope.settings = { extensions = { "mapper" }, } -telescope.packages = { +telescope.uses = { ["telescope.nvim"] = { "nvim-telescope/telescope.nvim", commit = "567ec85b157f1606b500a0f755181f284810a28e", @@ -56,8 +56,8 @@ telescope.packages = { } -telescope.configure_functions = {} -telescope.configure_functions["telescope.nvim"] = function() +telescope.configs = {} +telescope.configs["telescope.nvim"] = function() local telescope_package = require("telescope") local actions = require("telescope.actions") @@ -187,7 +187,7 @@ telescope.binds = function () return binds end -telescope.autocommands = { +telescope.autocmds = { { "User", "TelescopePreviewerLoaded", "setlocal wrap" }, } diff --git a/lua/doom/modules/features/terminal/init.lua b/lua/doom/modules/features/terminal/init.lua index 7c147ba..bdd84cf 100644 --- a/lua/doom/modules/features/terminal/init.lua +++ b/lua/doom/modules/features/terminal/init.lua @@ -22,7 +22,7 @@ terminal.settings = { }, } -terminal.packages = { +terminal.uses = { ["toggleterm.nvim"] = { "akinsho/toggleterm.nvim", commit = "e97d0c1046512e975a9f3fa95afe98f312752b1c", @@ -31,8 +31,8 @@ terminal.packages = { }, } -terminal.configure_functions = {} -terminal.configure_functions["toggleterm.nvim"] = function() +terminal.configs = {} +terminal.configs["toggleterm.nvim"] = function() require("toggleterm").setup(doom.modules.terminal.settings) end diff --git a/lua/doom/modules/features/todo_comments/init.lua b/lua/doom/modules/features/todo_comments/init.lua index c50e1f5..435de2c 100644 --- a/lua/doom/modules/features/todo_comments/init.lua +++ b/lua/doom/modules/features/todo_comments/init.lua @@ -2,7 +2,7 @@ local todo_comments = {} todo_comments.settings = {} -todo_comments.packages = { +todo_comments.uses = { ["todo-comments.nvim"] = { "folke/todo-comments.nvim", commit = "98b1ebf198836bdc226c0562b9f906584e6c400e", @@ -12,8 +12,8 @@ todo_comments.packages = { -todo_comments.configure_functions = {} -todo_comments.configure_functions["todo-comments.nvim"] = function() +todo_comments.configs = {} +todo_comments.configs["todo-comments.nvim"] = function() require("todo-comments").setup(doom.modules.todo_comments.settings) end diff --git a/lua/doom/modules/features/trouble/init.lua b/lua/doom/modules/features/trouble/init.lua index 4f949ce..10e2de3 100644 --- a/lua/doom/modules/features/trouble/init.lua +++ b/lua/doom/modules/features/trouble/init.lua @@ -2,7 +2,7 @@ local trouble = {} trouble.settings = {} -trouble.packages = { +trouble.uses = { ["trouble.nvim"] = { "folke/trouble.nvim", commit = "20469be985143d024c460d95326ebeff9971d714", @@ -11,8 +11,8 @@ trouble.packages = { }, } -trouble.configure_functions = {} -trouble.configure_functions["trouble.nvim"] = function() +trouble.configs = {} +trouble.configs["trouble.nvim"] = function() require("trouble").setup(doom.modules.trouble.settings) end diff --git a/lua/doom/modules/features/whichkey/init.lua b/lua/doom/modules/features/whichkey/init.lua index a46b0d6..c4d56ce 100644 --- a/lua/doom/modules/features/whichkey/init.lua +++ b/lua/doom/modules/features/whichkey/init.lua @@ -61,7 +61,7 @@ whichkey.settings = { triggers = "auto", } -whichkey.packages = { +whichkey.uses = { ["which-key.nvim"] = { "folke/which-key.nvim", commit = "28d2bd129575b5e9ebddd88506601290bb2bb221", @@ -69,8 +69,8 @@ whichkey.packages = { } -whichkey.configure_functions = {} -whichkey.configure_functions["which-key.nvim"] = function() +whichkey.configs = {} +whichkey.configs["which-key.nvim"] = function() vim.g.mapleader = doom.modules.whichkey.settings.leader local wk = require("which-key") diff --git a/lua/doom/modules/features/zen/init.lua b/lua/doom/modules/features/zen/init.lua index c1018e4..5e3fd7f 100644 --- a/lua/doom/modules/features/zen/init.lua +++ b/lua/doom/modules/features/zen/init.lua @@ -48,7 +48,7 @@ zen.settings = { }, } -zen.packages = { +zen.uses = { ["TrueZen.nvim"] = { "Pocco81/TrueZen.nvim", commit = "508b977d71650da5c9243698614a9a1416f116d4", @@ -58,8 +58,8 @@ zen.packages = { } -zen.configure_functions = {} -zen.configure_functions["TrueZen.nvim"] = function() +zen.configs = {} +zen.configs["TrueZen.nvim"] = function() require("true-zen").setup(doom.modules.zen.settings) end diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index ab4a3d4..1759f99 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -51,12 +51,12 @@ packer.reset() -- Handle the Modules for module_name, module in pairs(doom.modules) do - -- Import dependencies with packer from module.packages - if module.packages then - for dependency_name, packer_spec in pairs(module.packages) do + -- Import dependencies with packer from module.uses + if module.uses then + for dependency_name, packer_spec in pairs(module.uses) do -- Set packer_spec to configure function - if module.configure_functions and module.configure_functions[dependency_name] then - packer_spec.config = module.configure_functions[dependency_name] + if module.configs and module.configs[dependency_name] then + packer_spec.config = module.configs[dependency_name] end -- Set/unset frozen packer dependencies @@ -67,13 +67,13 @@ for module_name, module in pairs(doom.modules) do end end -- Setup package autogroups - if module.autocommands then - local autocommands = type(module.autocommands) == 'function' and module.autocommands() or module.autocommands - utils.make_augroup(module_name, autocommands) + if module.autocmds then + local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds + utils.make_augroup(module_name, autocmds) end end -- Handle extra user modules -for _, packer_spec in ipairs(doom.packages) do +for _, packer_spec in ipairs(doom.uses) do use(packer_spec) end diff --git a/lua/doom/modules/langs/bash/init.lua b/lua/doom/modules/langs/bash/init.lua index 3f68ba7..ba4ec14 100644 --- a/lua/doom/modules/langs/bash/init.lua +++ b/lua/doom/modules/langs/bash/init.lua @@ -4,7 +4,7 @@ bash.settings = { language_server_name = 'bashls', } -bash.autocommands = { +bash.autocmds = { { "FileType", "sh", diff --git a/lua/doom/modules/langs/c_sharp/init.lua b/lua/doom/modules/langs/c_sharp/init.lua index 1ac5921..32fd00b 100644 --- a/lua/doom/modules/langs/c_sharp/init.lua +++ b/lua/doom/modules/langs/c_sharp/init.lua @@ -4,7 +4,7 @@ c_sharp.settings = { language_server_name = 'omnisharp', } -c_sharp.autocommands = { +c_sharp.autocmds = { { "FileType", "cs", diff --git a/lua/doom/modules/langs/config/init.lua b/lua/doom/modules/langs/config/init.lua index 046b566..929c3c7 100644 --- a/lua/doom/modules/langs/config/init.lua +++ b/lua/doom/modules/langs/config/init.lua @@ -14,15 +14,15 @@ config.settings = { -- yaml_language_server_name = 'yamlls', -- Currently broken } -config.packages = { +config.uses = { ["SchemaStore.nvim"] = { "b0o/SchemaStore.nvim", commit = "df5e98d3b3c93e9857908fce8a219360f81c5e32", ft = { "json", "yaml", "toml" } }, } -config.configure_functions = {} -config.configure_functions["SchemaStore.nvim"] = function() +config.configs = {} +config.configs["SchemaStore.nvim"] = function() local langs_utils = require('doom.modules.langs.utils') langs_utils.use_lsp(doom.modules.config.settings.json_language_server_name, { config = { @@ -37,7 +37,7 @@ config.configure_functions["SchemaStore.nvim"] = function() }) end -config.autocommands = { +config.autocmds = { { "FileType", "json,yaml,toml", diff --git a/lua/doom/modules/langs/cpp/init.lua b/lua/doom/modules/langs/cpp/init.lua index 7028ed6..afb5102 100644 --- a/lua/doom/modules/langs/cpp/init.lua +++ b/lua/doom/modules/langs/cpp/init.lua @@ -5,7 +5,7 @@ cpp.settings = { language_server_name = utils.get_sysname() == 'Darwin' and 'clangd' or 'ccls', } -cpp.autocommands = { +cpp.autocmds = { { "FileType", "cpp", diff --git a/lua/doom/modules/langs/css/init.lua b/lua/doom/modules/langs/css/init.lua index 2130f4f..bc951d5 100644 --- a/lua/doom/modules/langs/css/init.lua +++ b/lua/doom/modules/langs/css/init.lua @@ -4,7 +4,7 @@ css.settings = { language_server_name = 'cssls', } -css.autocommands = { +css.autocmds = { { "BufNewFile,BufRead", "*.css,*.scss,*.vue", diff --git a/lua/doom/modules/langs/glsl/init.lua b/lua/doom/modules/langs/glsl/init.lua index 7290456..cf31049 100644 --- a/lua/doom/modules/langs/glsl/init.lua +++ b/lua/doom/modules/langs/glsl/init.lua @@ -4,7 +4,7 @@ glsl.settings = { language_server_name = 'bashls', } -glsl.autocommands = { +glsl.autocmds = { { "FileType", "glsl,vs,fs,frag,vert", diff --git a/lua/doom/modules/langs/go/init.lua b/lua/doom/modules/langs/go/init.lua index d2f04e2..d752836 100644 --- a/lua/doom/modules/langs/go/init.lua +++ b/lua/doom/modules/langs/go/init.lua @@ -4,7 +4,7 @@ go.settings = { language_server_name = 'gopls', } -go.autocommands = { +go.autocmds = { { "FileType", "go", diff --git a/lua/doom/modules/langs/haskell/init.lua b/lua/doom/modules/langs/haskell/init.lua index 26de96c..dd093cb 100644 --- a/lua/doom/modules/langs/haskell/init.lua +++ b/lua/doom/modules/langs/haskell/init.lua @@ -4,7 +4,7 @@ haskell.settings = { language_server_name = 'hls', } -haskell.autocommands = { +haskell.autocmds = { { "FileType", "haskell", diff --git a/lua/doom/modules/langs/java/init.lua b/lua/doom/modules/langs/java/init.lua index 00f6f87..e32df31 100644 --- a/lua/doom/modules/langs/java/init.lua +++ b/lua/doom/modules/langs/java/init.lua @@ -4,7 +4,7 @@ java.settings = { language_server_name = 'jdtls', } -java.autocommands = { +java.autocmds = { { "FileType", "sh", diff --git a/lua/doom/modules/langs/javascript/init.lua b/lua/doom/modules/langs/javascript/init.lua index 0afe315..dab6c48 100644 --- a/lua/doom/modules/langs/javascript/init.lua +++ b/lua/doom/modules/langs/javascript/init.lua @@ -2,7 +2,7 @@ local javascript = {} javascript.settings = {} -javascript.autocommands = { +javascript.autocmds = { { "FileType", "javascript,javascriptreact", diff --git a/lua/doom/modules/langs/kotlin/init.lua b/lua/doom/modules/langs/kotlin/init.lua index 7b435bd..aa96539 100644 --- a/lua/doom/modules/langs/kotlin/init.lua +++ b/lua/doom/modules/langs/kotlin/init.lua @@ -4,7 +4,7 @@ kotlin.settings = { language_server_name = 'kotlin_language_server', } -kotlin.autocommands = { +kotlin.autocmds = { { "FileType", "kotlin", diff --git a/lua/doom/modules/langs/lua/init.lua b/lua/doom/modules/langs/lua/init.lua index 35d6e75..6f0f0ef 100644 --- a/lua/doom/modules/langs/lua/init.lua +++ b/lua/doom/modules/langs/lua/init.lua @@ -29,7 +29,7 @@ lua.settings = { }, } -lua.packages = { +lua.uses = { ["lua-dev.nvim"] = { "folke/lua-dev.nvim", commit = "a0ee77789d9948adce64d98700cc90cecaef88d5", @@ -37,12 +37,12 @@ lua.packages = { }, } -lua.configure_functions = {} -lua.configure_functions["lua-dev.nvim"] = function() +lua.configs = {} +lua.configs["lua-dev.nvim"] = function() require("lua-dev").setup(doom.modules.lua.settings.dev) end -lua.autocommands = { +lua.autocmds = { { "FileType", "lua", diff --git a/lua/doom/modules/langs/python/init.lua b/lua/doom/modules/langs/python/init.lua index c204dc5..0a3ce47 100644 --- a/lua/doom/modules/langs/python/init.lua +++ b/lua/doom/modules/langs/python/init.lua @@ -4,7 +4,7 @@ python.settings = { language_server_name = 'pyright', } -python.autocommands = { +python.autocmds = { { "FileType", "python", diff --git a/lua/doom/modules/langs/rust/init.lua b/lua/doom/modules/langs/rust/init.lua index 266d80e..33efc7a 100644 --- a/lua/doom/modules/langs/rust/init.lua +++ b/lua/doom/modules/langs/rust/init.lua @@ -3,7 +3,7 @@ local rust = {} rust.settings = { } -rust.autocommands = { +rust.autocmds = { { "FileType", "rust", diff --git a/lua/doom/modules/langs/tailwindcss/init.lua b/lua/doom/modules/langs/tailwindcss/init.lua index a56fa2d..c0689d1 100644 --- a/lua/doom/modules/langs/tailwindcss/init.lua +++ b/lua/doom/modules/langs/tailwindcss/init.lua @@ -3,7 +3,7 @@ local tailwindcss = {} tailwindcss.settings = { } -tailwindcss.autocommands = { +tailwindcss.autocmds = { { "FileType", "css,scss,vue,html", diff --git a/lua/doom/modules/langs/terraform/init.lua b/lua/doom/modules/langs/terraform/init.lua index 40bac28..1ae622e 100644 --- a/lua/doom/modules/langs/terraform/init.lua +++ b/lua/doom/modules/langs/terraform/init.lua @@ -3,7 +3,7 @@ local terraform = {} terraform.settings = { } -terraform.autocommands = { +terraform.autocmds = { { "FileType", "terraform", diff --git a/lua/doom/modules/langs/typescript/init.lua b/lua/doom/modules/langs/typescript/init.lua index d8dba58..b3940b4 100644 --- a/lua/doom/modules/langs/typescript/init.lua +++ b/lua/doom/modules/langs/typescript/init.lua @@ -3,7 +3,7 @@ local typescript = {} typescript.settings = { } -typescript.autocommands = { +typescript.autocmds = { { "FileType", "typescript,typescriptreact", diff --git a/lua/doom/modules/langs/vue/init.lua b/lua/doom/modules/langs/vue/init.lua index 4858f98..0847249 100644 --- a/lua/doom/modules/langs/vue/init.lua +++ b/lua/doom/modules/langs/vue/init.lua @@ -70,9 +70,9 @@ vue.settings = { } } -vue.configure_functions = {} +vue.configs = {} -vue.autocommands = { +vue.autocmds = { { "FileType", "vue", From a5b5927400c8b3130274c71a6f982dbda63b6b43 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 19:11:10 +1100 Subject: [PATCH 16/51] refact: Renamed `core/core` module to `core/doom` --- lua/doom/core/config/init.lua | 2 +- lua/doom/modules/core/{core => doom}/init.lua | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename lua/doom/modules/core/{core => doom}/init.lua (100%) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 82f6d4a..6a573e3 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -231,7 +231,7 @@ config.load = function() -- Combine core modules with user-enabled modules local all_modules = vim.tbl_deep_extend('keep', { core = { - 'core', + 'doom', 'nest', 'treesitter', } diff --git a/lua/doom/modules/core/core/init.lua b/lua/doom/modules/core/doom/init.lua similarity index 100% rename from lua/doom/modules/core/core/init.lua rename to lua/doom/modules/core/doom/init.lua From 256303dbd142c934aef5daa90991aefca742fdc2 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sat, 19 Mar 2022 19:11:35 +1100 Subject: [PATCH 17/51] refact: Updated `modules.md` docs to match changed fields --- docs/modules.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/modules.md b/docs/modules.md index cffa280..f9eb945 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -91,7 +91,7 @@ local comment_module = doom.modules.comment -- Override default settings (provided by doom-nvim) comment_module.settings.padding = false -- Override package source with a fork -comment_module.packages['Comment.nvim'] = { +comment_module.uses['Comment.nvim'] = { 'my_fork/Comment.nvim', module = "Comment" } @@ -123,7 +123,7 @@ These are the possible values a ```lua module.settings: table -- Table of settings that can be tweaked -module.packages: table> -- Table of packer specs +module.uses: table> -- Table of packer specs module.configs: table -- Table of plugin config functions relating to the packer specs module.binds: table|function -> table -- Table of NestConfig or function that returns Table of NestConfig module.autocmds: table|function -> table -- Table of AutoCmds (see below) or function that returns a table of AutoCmds @@ -135,7 +135,7 @@ local module = {} module.settings = {...} -- Doom-nvim provided object to change settings -- Stores the packer.nvim config for all of the plugin dependencies -module.packages = { +module.uses = { ["example-plugin.nvim"] = { -- Use the repository name as the key "GithubUser/example-plugin.nvim", commit = "..." -- We like to pin plugins to commits to avoid issues upgrading. @@ -143,7 +143,7 @@ module.packages = { } module.configs = { - ["example-plugin.nvim"] = function() -- key matches `module.packages` entry + ["example-plugin.nvim"] = function() -- key matches `module.uses` entry require('example-plugin').setup( doom.modules.example.settings ) -- Consumes `module.settings` and uses it to config the plugin end } @@ -169,11 +169,11 @@ end -- Autocmds are defined as a table with the following syntax -- { "event", "aupat", "command or function" } -- Example -module.autocommands = { +module.autocmds = { { "FileType", "javascript", function() print("I'm in a javascript file now") end } } -- Similarly, autocmds can be conditional using a function -module.autocommands = function() +module.autocmds = function() local autocmds = {} if condition then table.insert(autocmds, { "FileType", "javascript", function() print("I'm in a javascript file now") end }) From 5077cbdddbfdfa557e9f8f18e45efbe3e5564b38 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 13:36:31 +1100 Subject: [PATCH 18/51] feat: Finished module.md docs overhaul --- docs/modules.md | 470 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 463 insertions(+), 7 deletions(-) diff --git a/docs/modules.md b/docs/modules.md index f9eb945..0666fbb 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -1,5 +1,30 @@ # Doom Nvim Modules +- [Doom Nvim Modules](#doom-nvim-modules) + * [Introduction](#introduction) + * [All modules](#all-modules) + + [`core` modules](#-core--modules) + + [`features` modules](#-features--modules) + + [`langs` modules](#-langs--modules) + * [Configuring modules](#configuring-modules) + + [Quick Guide](#quick-guide) + + [Advanced guide](#advanced-guide) + - [Module lifecycle](#module-lifecycle) + - [Limitations](#limitations) + * [Direct plugin access](#direct-plugin-access) + * [Conditional keybinds and autocommands](#conditional-keybinds-and-autocommands) + - [Module spec](#module-spec) + * [Implementing your own doom module](#implementing-your-own-doom-module) + + [1. Setting up](#1-setting-up) + + [2. Adding autocommands](#2-adding-autocommands) + + [3. Enabling and testing your module](#3-enabling-and-testing-your-module) + + [4. Adding the character counter](#4-adding-the-character-counter) + + [5. Adding commands to get and reset the count](#5-adding-commands-to-get-and-reset-the-count) + + [6. Adding keybinds](#6-adding-keybinds) + + [7. Adding and lazyloading a plugin](#7-adding-and-lazyloading-a-plugin) + + [8. Exposing settings to the user](#8-exposing-settings-to-the-user) + + [9. You're done! Final output](#9-you-re-done---final-output) + ## Introduction Doom Nvim consists of around 40 plugins and growing. @@ -106,16 +131,50 @@ comment_module.binds = { > **NOTE:** If you have the `lua` language module and `lsp` feature module enabled, all of these properties should be auto completeable. -### Advanced +### Advanced guide +#### Module lifecycle +1. Doom nvim reads `modules.lua` to determine which modules to load. +2. Doom loads the config for each module, saves it to `doom.modules` global object. +3. User can override the settings for a module in `config.lua` using the `doom.modules` global object. +4. Doom executes the modules, installing plugins and setting keybinds/autocommands. + #### Limitations -#### Module lifecycle -1. Modules are defined in `modules.lua`. -2. Doom loads the config for each module, saves it to `doom.modules`. -3. User can override the settings for a module in `config.lua` -4. Doom executes the module, loads and installs the dependencies, sets the keybinds and autocommands. +##### Direct plugin access + +The main limitation is that plugins are not yet loaded when `config.lua` is executed meaning you +cant have direct access to plugins. We're working on a more concrete solution but for now you can +splice your own custom configure function with the default one. + +```lua +--- config.lua + +local lsp = doom.modules.lsp +local old_nvim_cmp_config_function = lsp.configs['nvim-cmp'] +lsp.configs['nvim-cmp'] = function() + old_nvim_cmp_config_function() -- Run the default config + local cmp = require("cmp") -- direct access to plugin +end +``` + +##### Conditional keybinds and autocommands + +Sometimes keybinds and autocommands will be conditionally added/disabled depending on if another module +is enabled or if a specific config option is set. In this case we use a function that returns a valid config +instead of a simple table. + +This is not ideal as it's harder to `vim.inspect` the defaults. As a workaround you can `vim.inspect` the returned value. + +```lua +-- config.lua + +print(type(doom.modules.lsp.binds)) -- "table" (not conditional) +print(vim.inspect(doom.modules.lsp.binds)) -- Shows config +print(type(doom.modules.telescope.binds)) -- "function" (adds extra keybinds if "lsp" module is enabled) +print(vim.inspect(doom.modules.telescope.binds())) -- You must execute the function to see the config. +``` #### Module spec @@ -123,7 +182,7 @@ These are the possible values a ```lua module.settings: table -- Table of settings that can be tweaked -module.uses: table> -- Table of packer specs +module.uses: table> -- Table of packer specs module.configs: table -- Table of plugin config functions relating to the packer specs module.binds: table|function -> table -- Table of NestConfig or function that returns Table of NestConfig module.autocmds: table|function -> table -- Table of AutoCmds (see below) or function that returns a table of AutoCmds @@ -181,3 +240,400 @@ module.autocmds = function() return autocmds end ``` + +## Implementing your own doom module + +I will use an example of implementing a module that counts the number of chars that you've typed. +This module will: + - Use autocommands to count the number of chars in a buffer when you enter insert mode vs when you leave insert mode + - Add it to an accumulated sum + - Provide keybinds + commands to restart or display total count + - Use a plugin to display the results in a popup window + - Include some settings to change the displayed output + +### 1. Setting up + +> Modules are loaded from the `lua/doom/modules/` folder. Within this folder there is a `features/`, `langs/` and `core/` directory. +> If you look at [`modules.lua`](../modules.lua) you'll see that this maps 1:1 with the returned data structure (except for `core` modules which can't be disabled). +> +> Because modules are implemented as folders with an `init.lua` inside, they must be named after valid folder names. +> Best practices are: +> - Seperate words with an underscore, this is so the plugin can be represented as a lua variable +> - Name the module after the functionality rather than the plugin it uses. +> +> If you're adding language support, add a new folder module to `lua/doom/modules/langs/`, else if +> it's a new feature add a directory to `lua/doom/module/features/`. + +For our example of adding char counting plugin I will add a folder called `lua/doom/modules/langs/char_counter/` and create a new `init.lua` +inside of it. +```lua +-- lua/doom/modules/features/char_counter/init.lua +local char_counter = {} + +return char_counter +``` + +### 2. Adding autocommands + +> Autocommands are set using the `module.autocmds` field. And follow the structure of +> ```lua +> module.autocmds = { +> { "{event}", "{aupat}", "command or function" } +> } +> ``` + +For our example we need to hook into the [InsertEnter](https://neovim.io/doc/user/autocmd.html#InsertEnter) +and [InsertLeave](https://neovim.io/doc/user/autocmd.html#InsertLeave) auto commands. + +```lua +-- lua/doom/modules/features/char_counter/init.lua +char_counter.autocmds = { + { "InsertEnter", "*", function () + print('Entered insert mode') + end}, + { "InsertLeave", "*", function () + print('Exited insert mode') + end}, +} +``` + +### 3. Enabling and testing your module + +Now you can enable the module in `modules.lua`! Once enabled, restart your doom-nvim instance and check +`:messages` to see if it's printing correctly. + +```lua +-- modules.lua +return { + features = { + "char_counter" -- Must match the name of the folder i.e. `lua/doom/modules/features/char_counter` + } +} +``` + +### 4. Adding the character counter + +Because modules are just tables, you can add any properties or functions that you need to the module table. +To implement the character counter we will add a few fields to the module table. Unless you want users to +access these fields we recommend prefixing them with an underscore. +1. A function that gets the character count of a buffer. +2. A field to store the character count when we enter insert mode. +3. A field to store the accumulated count when we exit insert mode. + +We will also check if the [`buftype`](https://neovim.io/doc/user/options.html#'buftype') is empty, this +means we wont count other interactive buffers like terminals, prompts or quick fix lists. + +```lua +-- lua/doom/modules/features/char_counter/init.lua + +local char_counter = {} + +char_counter._insert_enter_char_count = nil +char_counter._accumulated_difference = 0 +char_counter._get_current_buffer_char_count = function() + local lines = vim.api.nvim_buf_line_count(0) + local chars = 0 + for _, line in ipairs(vim.api.nvim_buf_get_lines(0, 0, lines, false)) do + chars = chars + #line + end + return chars +end + +char_counter.autocmds = { + { "InsertEnter", "*", function () + -- Only operate on normal file buffers + print(("buftype: %s"):format(vim.bo.buftype)) + if vim.bo.buftype == "" then + -- Store current char count + char_counter._insert_enter_char_count = char_counter._get_current_buffer_char_count() + end + end}, + { "InsertLeave", "*", function () + -- Only operate on normal file buffers + if vim.bo.buftype == "" and char_counter._insert_enter_char_count then + -- Find the amount of chars added or removed + local new_count = char_counter._get_current_buffer_char_count() + local diff = new_count - char_counter._insert_enter_char_count + print(new_count, diff) + -- Add the difference to the accumulated total + char_counter._accumulated_difference = char_counter._accumulated_difference + diff + print(('Accumulated difference %s'):format(char_counter._accumulated_difference)) + end + end}, +} + +return char_counter +``` + +### 5. Adding commands to get and reset the count + +Using the `module.cmds` property we can define and expose vim commands to the user. Here we will define a +`:CountPrint` and `:CountReset` command. + +```lua +-- lua/doom/modules/features/char_counter/init.lua + +char_counter.cmds = { + { "CountPrint", function () + local msg = ("char_counter: You have typed %s characters since I started counting."):format(char_counter._accumulated_difference) + vim.notify(msg, "info") + end}, + { "CountReset", function () + char_counter._accumulated_difference = 0 + vim.notify("char_counter: Reset count!", "info") + end} +} +``` +> **NOTE**: Instead of using a function you can also provide a string that will be executed using `vim.cmd` + +Now restart doom nvim and run `:CountPrint` and `:CountReset` to test it out. + +### 6. Adding keybinds + +Keybinds are provided using the `module.binds` field. We use a modified [nest.nvim]() config that integrates with whichkey and nvim-mapper. +You can read more about it [here](https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide) but generally you should +provide the `name` field for all entries so it displays in whichkey. + +```lua +-- lua/doom/modules/features/char_counter/init.lua + +char_counter.binds = { + { 'i', name = '+info', { -- Adds a new `whichkey` folder called `+info` + { 'c', ':CountPrint', name = 'Print new chars' }, -- Binds `:CountPrint` to `ic` + { 'r', ':CountReset', name = 'Reset char count' } -- Binds `:CountPrint` to `ic` + } } +} +``` +> **NOTE**: Instead of a cmd you can also provide a lua function that will be executed when the keybind is triggered. + +### 7. Adding and lazyloading a plugin + +Plugins are added using the `module.uses` field and are configured using the `module.configs` field. +We use the repository name as a key to connect the plugin to its config function. +The API for `module.uses` is passed to Packer nvim's use function. [DOCS](https://github.com/wbthomason/packer.nvim#specifying-plugins) + +In this example I will add [nui.nvim](https://github.com/MunifTanjim/nui.nvim) to display the results in a popup when +the user uses the `CountPrint` command. + +```lua +-- lua/doom/modules/features/char_counter/init.lua + +-- Add these two fields to `char_counter` at the top of the file. +char_counter.uses = { + ["nui.nvim"] = { + "MunifTanjim/nui.nvim", + cmd = { "CountPrint" } -- Here, nui.nvim wont be loaded until user does the `ic` or `:CountPrint` command. + } +} + +char_counter.configs = { + ["nui.nvim"] = function() + -- Log when nui loads so we can check that it's being lazy loaded correctly + vim.notify("char_counter: nui.nvim loaded", "info") + + -- If your plugin requires a `.setup({ ... config ... })` function, this is where you'd execute it. + + -- WARNING: Because of how Packer compiles plugin configs, this function does not have direct access to `char_counter` table. + -- Instead you must re-define it from the `doom` global object as `local char_counter` = doom.modules.char_counter + end +} + +-- Modify `char_counter.cmds` + +char_counter.cmds = { + { "CountPrint", function () + -- We can ensure that nui has loaded due to the `cmd = { "CountPrint" }` in the plugin's config + local Popup = require('nui.popup') + + local popup = Popup({ + position = '50%', + size = { + width = 80, + height = 40, + }, + border = { + padding = { + top = 2, + bottom = 2, + left = 3, + right = 3, + }, + }, + style = "rounded", + enter = true, + buf_options = { + modifiable = true, + readonly = true, + } + }) + popup:mount() + popup:map("n", "", function() popup:unmount() end) + + local msg = ("char_counter: You have typed %s characters since I started counting."):format(char_counter._accumulated_difference) + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, { msg }) + end}, + { "CountReset", function () + char_counter._accumulated_difference = 0 + vim.notify("char_counter: Reset count!", "info") + end} +} +``` + +### 8. Exposing settings to the user + +In order to keep doom-nvim flexible, it's best practice to expose settings for the module. A common practice is just to expose the entire config +object. This will allow users to tweak the config in their `config.lua` file without replacing and rewriting all of the logic for a small change. + + +```lua +-- lua/doom/modules/features/char_counter/init.lua + +-- Copy the settings that are passed to the `Popup` function, place them in `char_counter.settings.popup` +char_counter.settings = { + popup = { + position = '50%', + size = { + width = 80, + height = 40, + }, + border = { + padding = { + top = 2, + bottom = 2, + left = 3, + right = 3, + }, + }, + style = "rounded", + enter = true, + buf_options = { + modifiable = true, + readonly = true, + } + } +} + +-- Modify the Popup function +char_counter.cmds = { + { "CountPrint", function () + local Popup = require('nui.popup') + + local popup = Popup(char_counter.settings.popup) -- Configured via the `settings.popup` field. + + popup:mount() + popup:map("n", "", function() popup:unmount() end) + + local msg = ("char_counter: You have typed %s characters since I started counting."):format(char_counter._accumulated_difference) + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, { msg }) + end}, + { "CountReset", function () + char_counter._accumulated_difference = 0 + vim.notify("char_counter: Reset count!", "info") + end} +} +``` + +### 9. You're done! Final output + +If you'd just like to look at the end result, or if you're comparing why your implementation didn't work, here is the final working output. + +```lua +-- lua/doom/modules/features/char_counter/init.lua +local char_counter = {} + +char_counter.settings = { + popup = { + position = '50%', + size = { + width = 80, + height = 40, + }, + border = { + padding = { + top = 2, + bottom = 2, + left = 3, + right = 3, + }, + }, + style = "rounded", + enter = true, + buf_options = { + modifiable = true, + readonly = true, + } + } +} + +char_counter.uses = { + ["nui.nvim"] = { + "MunifTanjim/nui.nvim", + cmd = { "CountPrint" } + } +} + +char_counter.configs = { + ["nui.nvim"] = function() + vim.notify("char_counter: nui.nvim loaded", "info") + end +} + +char_counter._insert_enter_char_count = nil +char_counter._accumulated_difference = 0 +char_counter._get_current_buffer_char_count = function() + local lines = vim.api.nvim_buf_line_count(0) + local chars = 0 + for _, line in ipairs(vim.api.nvim_buf_get_lines(0, 0, lines, false)) do + chars = chars + #line + end + return chars +end + +char_counter.autocmds = { + { "InsertEnter", "*", function () + -- Only operate on normal file buffers + print(("buftype: %s"):format(vim.bo.buftype)) + if vim.bo.buftype == "" then + -- Store current char count + char_counter._insert_enter_char_count = char_counter._get_current_buffer_char_count() + end + end}, + { "InsertLeave", "*", function () + -- Only operate on normal file buffers + if vim.bo.buftype == "" and char_counter._insert_enter_char_count then + -- Find the amount of chars added or removed + local new_count = char_counter._get_current_buffer_char_count() + local diff = new_count - char_counter._insert_enter_char_count + print(new_count, diff) + -- Add the difference to the accumulated total + char_counter._accumulated_difference = char_counter._accumulated_difference + diff + print(('Accumulated difference %s'):format(char_counter._accumulated_difference)) + end + end}, +} + +char_counter.cmds = { + { "CountPrint", function () + local Popup = require('nui.popup') + local popup = Popup(char_counter.settings.popup) + popup:mount() + popup:map("n", "", function() popup:unmount() end) + + local msg = ("char_counter: You have typed %s characters since I started counting."):format(char_counter._accumulated_difference) + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, { msg }) + end}, + { "CountReset", function () + char_counter._accumulated_difference = 0 + vim.notify("char_counter: Reset count!", "info") + end} +} + +char_counter.binds = { + { 'i', name = '+info', { -- Adds a new `whichkey` folder called `+info` + { 'c', ':CountPrint', name = 'Print new chars' }, -- Binds `:CountPrint` to `ic` + { 'r', ':CountReset', name = 'Reset char count' } -- Binds `:CountPrint` to `ic` + } } +} + +return char_counter +``` From fa3cf8c0b2cb52ef63d27b8269a94cb2d65194a1 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 13:36:50 +1100 Subject: [PATCH 19/51] fix(core): Broken mapper-nvim settings --- lua/doom/modules/core/doom/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index 876b3f7..a985bc5 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -38,7 +38,7 @@ required.uses = { required.configs = {} required.configs["nvim-mapper"] = function() - require("nvim-mapper").setup(doom.modules.core.settings.mapper) + require("nvim-mapper").setup(doom.modules.doom.settings.mapper) end required.binds = function () From ba1bb4f1a0ad4cd1f83fa0515b8b620926522374 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 13:37:19 +1100 Subject: [PATCH 20/51] feat: Added `module.cmds` support --- lua/doom/modules/init.lua | 6 +++++ lua/doom/utils/init.lua | 44 +++++++++++++++++++++++++------------ lua/doom/utils/reloader.lua | 4 ++-- 3 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index 1759f99..fde08b5 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -71,6 +71,12 @@ for module_name, module in pairs(doom.modules) do local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds utils.make_augroup(module_name, autocmds) end + + if module.cmds then + for _, cmd_spec in ipairs(module.cmds) do + utils.make_cmd(cmd_spec[1], cmd_spec[2]) + end + end end -- Handle extra user modules diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index 938a69a..883a0b6 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -66,6 +66,33 @@ utils.load_modules = function(module_path, mods) end end +--- Stores a function in a global table, returns a string to execute the function +-- @param fn function +-- @return string +utils.commandify_function = function(fn) + if not _G._doom then + _G._doom = {} + end + if not _doom.cmd_funcs then + _doom.cmd_funcs = {} + end + -- Nobody is going to need more than a million of these, right? + local unique_number = utils.unique_index() + _doom.cmd_funcs[unique_number] = fn + return ("lua _doom.cmd_funcs[%d]()"):format(unique_number) +end + +--- Creates a new command that can be executed from the neovim command line +-- @param cmd_name string The name of the command, i.e. `:DoomReload` +-- @param action string|function The action to execute when the cmd is entered. +utils.make_cmd = function(cmd_name, action) + local cmd = "command! " .. cmd_name .. " " + cmd = type(action) == "function" + and cmd .. utils.commandify_function(action) + or cmd .. action + vim.cmd(cmd) +end + utils.make_autocmd = function(event, pattern, action, group, nested, once) local cmd = "autocmd " @@ -83,20 +110,9 @@ utils.make_autocmd = function(event, pattern, action, group, nested, once) cmd = cmd .. "++once " end - if type(action) == "function" then - if not _G._doom then - _G._doom = {} - end - if not _doom.autocmd_funcs then - _doom.autocmd_funcs = {} - end - -- Nobody is going to need more than a million of these, right? - local unique_number = utils.unique_index() - _doom.autocmd_funcs[unique_number] = action - cmd = cmd .. ("lua _doom.autocmd_funcs[%d]()"):format(unique_number) - else - cmd = cmd .. action - end + cmd = type(action) == "function" + and cmd .. utils.commandify_function(action) + or cmd .. action vim.cmd(cmd) end diff --git a/lua/doom/utils/reloader.lua b/lua/doom/utils/reloader.lua index 04f9cc2..daa5ec7 100644 --- a/lua/doom/utils/reloader.lua +++ b/lua/doom/utils/reloader.lua @@ -164,8 +164,8 @@ end reloader.reload_plugins_definitions = function() local old_plugins = vim.deepcopy(packer_plugins) - if _doom and _doom.autocmd_funcs then - _doom.autocmd_funcs = {} + if _doom and _doom.cmd_funcs then + _doom.cmd_funcs = {} end -- Silently reload plugins modules From 705350c36d3489dbd351a19000a1175d0c7b1bfc Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 13:37:41 +1100 Subject: [PATCH 21/51] temp: Fixed personal config --- config.lua | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/config.lua b/config.lua index efed48d..4bcceea 100644 --- a/config.lua +++ b/config.lua @@ -7,8 +7,8 @@ -- Editor config doom.indent = 2 +doom.autosave = false doom.escape_sequences = {} -doom.modules.telescope.settings.defaults.layout_config.prompt_position = "top" -- vim.lsp.set_log_level('trace') vim.diagnostic.config({ float = { @@ -27,12 +27,7 @@ doom.modules.tabline.settings.options.diagnostics_indicator = function (_, _, di end -- Colourscheme -table.insert(doom.packages, { - 'sainnhe/sonokai' -}) -table.insert(doom.packages, { - 'EdenEast/nightfox.nvim', -}) +doom.use('sainnhe/sonokai', 'EdenEast/nightfox.nvim') local options = { dim_inactive = true, } @@ -72,19 +67,12 @@ require('nightfox').setup({ doom.colorscheme = 'dawnfox' -- Extra packages -table.insert(doom.packages, { - 'rafcamlet/nvim-luapad' -}) -table.insert(doom.packages, { - 'nvim-treesitter/playground' -}) -table.insert(doom.packages, { - 'tpope/vim-surround' -}) - -table.insert(doom.packages, { +doom.use( + 'rafcamlet/nvim-luapad', + 'nvim-treesitter/playground', + 'tpope/vim-surround', 'dstein64/vim-startuptime' -}) +) vim.opt.guifont = { 'Hack Nerd Font', 'h12' } -- vim: sw=2 sts=2 ts=2 expandtab From 4868f2a2d8c9dc668f33e1c5d17509812f00a16d Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 13:38:56 +1100 Subject: [PATCH 22/51] feat: Added contributors to README.md --- README.md | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97f6a42..768ba47 100644 --- a/README.md +++ b/README.md @@ -218,8 +218,36 @@ TODO: Add FAQ ## Contributing -TODO: Add small info on contributing + overhaul contributing docs. +For for information please see our [contributing docs](./docs/contributing.md). ## Contributors -TODO: Copy contributors from old README.md +Special thanks to these amazing people for helping improve doom (see [emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + + + + + + + + + + + +

John Irle

📖

Brian Ketelsen

💻 🐛

Samantha-uk

📖

rscircus

📖

bandithedoge

📖

vhyrro

💻

Ifeanyichukwu Sampson Ebenezer

🐛

Gustavo Prieto

💻

ZeusThundr

🐛

Leo Nistor

🐛

notusknot

📖

Bruce Dillahunty

📖 🐛

amxj9

🐛

Kyle Guerrero

📖
+ + + + From ee712ce52d8e6d93153de57318a8fbfd672e273b Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:16:51 +1100 Subject: [PATCH 23/51] feat: Documented custom module tutorial + example. --- .gitignore | 3 + README.md | 39 ++++++----- docs/api.md | 3 + docs/modules.md | 67 +++++++++++------- lua/user/modules/char_counter/init.lua | 97 ++++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 43 deletions(-) create mode 100644 docs/api.md create mode 100644 lua/user/modules/char_counter/init.lua diff --git a/.gitignore b/.gitignore index a58273c..cbdc659 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,8 @@ tags contribute/doom-nvim-contrib contribute/local-share-nvim contribute/workspace + +# User modules +user/modules/* # Editor files .luarc.json diff --git a/README.md b/README.md index 768ba47..d62fab8 100644 --- a/README.md +++ b/README.md @@ -24,11 +24,11 @@ * [What is Doom Nvim?](#what-is-doom-nvim-) * [Install](#install) * [Configuring](#configuring) - + [`modules.lua`](#-moduleslua-) + + [Enabling features: `modules.lua`](#-moduleslua-) - [What is a module?](#what-is-a-module-) - [Enabing/disabling modules](#enabing-disabling-modules) - [All modules](#all-modules) - + [`config.lua`](#-configlua-) + + [Configuring and personalising: `config.lua`](#-configlua-) - [Modifying neovim and doom options](#modifying-neovim-and-doom-options) * [Adding plugins](#adding-plugins) * [Adding Keybinds](#adding-keybinds) @@ -44,15 +44,16 @@ Doom Nvim is a Neovim interpretation of the [doom-emacs](https://github.com/hlissner/doom-emacs) framework, adapted to Vim philosophy. -Its goal is to provide a configurable, extensible, performant and stable basis for any neovim configuration. +Our goal is to provide a configurable, extensible, performant and stable basis for any neovim configuration. Some of the defining features that make this project unique are: -- **Fast** Rapid startup time without defer_fn, packages are lazy loaded and languages are only configured when opening the file type. +- **Fast** Rapid startup time without defer_fn, packages are lazy loaded and languages are only configured when opening its relevent file type. - **Stable** Plugins are pinned to commit shas to avoid breaking between updates. +- **Scalable** Because of modular architecture you can disable any features you don't use. Your config is as simple or complex as you want it to be. - **Configurable** All modules are 100% overridable and configurable, use a logical structure and have LSP completions. +- **Extensible** With a simple api you can easily add, and or contribute, your own modules. - **Integrated** Desgined to handle and setup integrations between plugins for you. For example, whichkey will only show keybinds for modules you have enabled (and will automatically handle your custom bindings). -- **Extensible** Take advantage of the modular architecture, enable only the features you need, customise or add your own modules. ## Install @@ -62,7 +63,7 @@ TODO: Add install docs here Doom nvim is configured by enabling modules in the `modules.lua` file and then tweaking, overriding or adding new packages, keybinds and more within the `config.lua` module. -### `modules.lua` +### Enabling features: `modules.lua` #### What is a module? A module is a collection of packages, autocommands, keybinds and functions that add new capabilities or functionality to Doom Nvim. @@ -76,6 +77,7 @@ We organise modules into 3 categories: You can enable or disable a module by going to `modules.lua` (`Dm`) and commenting or uncommenting the entry. ```lua -- modules.lua + return { features = { 'lsp' @@ -92,22 +94,18 @@ return { #### All modules -Doom-nvim currently has 39 `features` modules and 14 `langs` modules. Some standout features are: -- `lsp` Code completions provided by `nvim-cmp` -- `linter` Formatting and linting provided by `null-ls.nvim` -- `whichkey` Interactive cheatsheet that integrates with our keybind management to **only show keybinds for modules you have active** -- `fidget` Shows LSP loading/indexing progress status - -You can find a full list of modules (here)[#TODO: ]. +Doom-nvim currently has 39 `features` modules and 14 `langs` modules. +You can find a full list of modules (here)[./docs/modules.md#all-modules] -### `config.lua` +### Configuring and personalising: `config.lua` #### Modifying neovim and doom options -Doom nvim provides a number of config options, including wrapping some of vim's own options. See all available config options (here)[TODO:]. +Doom nvim provides a number of config options, including wrapping some of vim's own options. See all available config options (in the API Reference)[./docs/api.md]. ```lua -- config.lua + doom.freeze_dependencies = false -- Don't use pinned packer dependencies doom.logging = 'trace' -- Debug doom internal issues doom.indent = 2 -- Sets vim.opt.shiftwith, vim.opt.softtabstop, vim.opt.tabstop to 2 @@ -123,6 +121,8 @@ Additional packages can be imported with the `doom.use()` function. This is a wrapper around `packer.use()` and provides the same API. [DOCS](https://github.com/wbthomason/packer.nvim#quickstart) ```lua +-- config.lua + -- Simple config doom.use('sainnhe/sonokai', 'EdenEast/nightfox.nvim') @@ -140,6 +140,8 @@ Additional keybinds can be defined with the `doom.bind()` function. This is a wrapper around a custom `nest.nvim` implementation and provides the same API. [DOCS](https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide) ```lua +-- config.lua + doom.bind({ { 'u', name = '+user', { -- Names this group in whichkey "+user" { 's', 'Telescope git_status', name = 'Git status' } -- Adds `us` keybind to trigger `Telescope git_status` @@ -154,6 +156,8 @@ doom.bind({ Additional autocommands can be defined with the `doom.autocmd()` function. ```lua +-- config.lua + doom.autcmd({ -- { "", "", ""} { "FileType", "javascript", function() print('Yuck!') end} @@ -168,6 +172,7 @@ Here you can override the plugin git sources, pre-defined settings, keybinds or ```lua -- modules.lua + return { features = { 'whichkey' -- Whichkey module is enabled @@ -212,10 +217,6 @@ whichkey.configs["which-key.nvim"] = function () end ``` -## FAQ - -TODO: Add FAQ - ## Contributing For for information please see our [contributing docs](./docs/contributing.md). diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 0000000..3ce854a --- /dev/null +++ b/docs/api.md @@ -0,0 +1,3 @@ +# Doom API Reference + +TODO: Autogenerate from config object. diff --git a/docs/modules.md b/docs/modules.md index 0666fbb..194c7c5 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -64,7 +64,7 @@ Modules are grouped into 3 categories: - [`illuminate`](../lua/doom/modules/features/illuminate) Highlight other occurances of the hovered word - [`indentlines`](../lua/doom/modules/features/indentlines) Explicitly show indentation - [`range_highlight`](../lua/doom/modules/features/range_highlight) Highlight selected range as you type commands - - [`todo_comments`](../lua/doom/modules/features/todo_comments) Highlights TODO: comments and more + - [`todo_comments`](../lua/doom/modules/features/todo_comments) Highlights TODO comments and more - **UI modules** - [`fidget`](../lua/doom/modules/features/fidget) Shows LSP loading status - [`tabline`](../lua/doom/modules/features/tabline) Tabbed buffer switcher @@ -241,7 +241,7 @@ module.autocmds = function() end ``` -## Implementing your own doom module +## Building your own module I will use an example of implementing a module that counts the number of chars that you've typed. This module will: @@ -253,21 +253,15 @@ This module will: ### 1. Setting up -> Modules are loaded from the `lua/doom/modules/` folder. Within this folder there is a `features/`, `langs/` and `core/` directory. -> If you look at [`modules.lua`](../modules.lua) you'll see that this maps 1:1 with the returned data structure (except for `core` modules which can't be disabled). -> > Because modules are implemented as folders with an `init.lua` inside, they must be named after valid folder names. > Best practices are: > - Seperate words with an underscore, this is so the plugin can be represented as a lua variable > - Name the module after the functionality rather than the plugin it uses. -> -> If you're adding language support, add a new folder module to `lua/doom/modules/langs/`, else if -> it's a new feature add a directory to `lua/doom/module/features/`. -For our example of adding char counting plugin I will add a folder called `lua/doom/modules/langs/char_counter/` and create a new `init.lua` -inside of it. +For our example of adding char counting plugin I will create a folder called `lua/user/modules/char_counter/` +and create a new `init.lua` inside of it. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua local char_counter = {} return char_counter @@ -286,7 +280,7 @@ For our example we need to hook into the [InsertEnter](https://neovim.io/doc/use and [InsertLeave](https://neovim.io/doc/user/autocmd.html#InsertLeave) auto commands. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua char_counter.autocmds = { { "InsertEnter", "*", function () print('Entered insert mode') @@ -299,6 +293,8 @@ char_counter.autocmds = { ### 3. Enabling and testing your module + + Now you can enable the module in `modules.lua`! Once enabled, restart your doom-nvim instance and check `:messages` to see if it's printing correctly. @@ -306,8 +302,15 @@ Now you can enable the module in `modules.lua`! Once enabled, restart your doom -- modules.lua return { features = { - "char_counter" -- Must match the name of the folder i.e. `lua/doom/modules/features/char_counter` - } + ... + }, + langs = { + ... + }, + -- user field is optional and will read from the `lua/user/modules` folder in your `.nvim/` folder. + user = { + "char_counter" -- Must match the name of the folder i.e. `lua/user/modules/char_counter/init.lua` + }, } ``` @@ -324,7 +327,7 @@ We will also check if the [`buftype`](https://neovim.io/doc/user/options.html#'b means we wont count other interactive buffers like terminals, prompts or quick fix lists. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua local char_counter = {} @@ -371,7 +374,7 @@ Using the `module.cmds` property we can define and expose vim commands to the us `:CountPrint` and `:CountReset` command. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua char_counter.cmds = { { "CountPrint", function () @@ -390,12 +393,10 @@ Now restart doom nvim and run `:CountPrint` and `:CountReset` to test it out. ### 6. Adding keybinds -Keybinds are provided using the `module.binds` field. We use a modified [nest.nvim]() config that integrates with whichkey and nvim-mapper. -You can read more about it [here](https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide) but generally you should -provide the `name` field for all entries so it displays in whichkey. +Keybinds are provided using the `module.binds` field. We use a modified [nest.nvim]() config that integrates with whichkey and nvim-mapper. You can read more about it [here](https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide) but generally you should provide the `name` field for all entries so it displays in whichkey. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua char_counter.binds = { { 'i', name = '+info', { -- Adds a new `whichkey` folder called `+info` @@ -416,7 +417,7 @@ In this example I will add [nui.nvim](https://github.com/MunifTanjim/nui.nvim) t the user uses the `CountPrint` command. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua -- Add these two fields to `char_counter` at the top of the file. char_counter.uses = { @@ -486,7 +487,7 @@ object. This will allow users to tweak the config in their `config.lua` file wi ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua -- Copy the settings that are passed to the `Popup` function, place them in `char_counter.settings.popup` char_counter.settings = { @@ -533,12 +534,30 @@ char_counter.cmds = { } ``` -### 9. You're done! Final output +### 9. Contributing your module upstream + +> Builtin modules are loaded from the `lua/doom/modules/` folder. Within this folder there is a `features/`, `langs/` and `core/` directory. +> If you look at [`modules.lua`](../modules.lua) you'll see that the table fields are used to lookup the subfolder. +```lua +return { + features = { + "lsp" -- Maps to `lua/doom/modules/features/lsp/`, + }, + langs = { + "lua" -- Maps to `lua/doom/modules/langs/lua/` + } +} +``` + +If you would like to contribute your module, just move it from `lua/user/modules/` to +`lua/user/modules//` and create a PR in accordance with our [Contributing Guidelines](./contributing.md). + +### 10. You're done! Final output If you'd just like to look at the end result, or if you're comparing why your implementation didn't work, here is the final working output. ```lua --- lua/doom/modules/features/char_counter/init.lua +-- lua/user/modules/char_counter/init.lua local char_counter = {} char_counter.settings = { diff --git a/lua/user/modules/char_counter/init.lua b/lua/user/modules/char_counter/init.lua new file mode 100644 index 0000000..9d9eebb --- /dev/null +++ b/lua/user/modules/char_counter/init.lua @@ -0,0 +1,97 @@ +local char_counter = {} + +char_counter.settings = { + popup = { + position = '50%', + size = { + width = 80, + height = 40, + }, + border = { + padding = { + top = 2, + bottom = 2, + left = 3, + right = 3, + }, + }, + style = "rounded", + enter = true, + buf_options = { + modifiable = true, + readonly = true, + } + } +} + +char_counter.uses = { + ["nui.nvim"] = { + "MunifTanjim/nui.nvim", + cmd = { "CountPrint" }, + } +} + +char_counter.configs = { + ["nui.nvim"] = function() + vim.notify("char_counter: nui.nvim loaded", "info") + end +} + +char_counter._insert_enter_char_count = nil +char_counter._accumulated_difference = 0 +char_counter._get_current_buffer_char_count = function() + local lines = vim.api.nvim_buf_line_count(0) + local chars = 0 + for _, line in ipairs(vim.api.nvim_buf_get_lines(0, 0, lines, false)) do + chars = chars + #line + end + return chars +end + +char_counter.autocmds = { + { "InsertEnter", "*", function () + -- Only operate on normal file buffers + print(("buftype: %s"):format(vim.bo.buftype)) + if vim.bo.buftype == "" then + -- Store current char count + char_counter._insert_enter_char_count = char_counter._get_current_buffer_char_count() + end + end}, + { "InsertLeave", "*", function () + -- Only operate on normal file buffers + if vim.bo.buftype == "" and char_counter._insert_enter_char_count then + -- Find the amount of chars added or removed + local new_count = char_counter._get_current_buffer_char_count() + local diff = new_count - char_counter._insert_enter_char_count + print(new_count, diff) + -- Add the difference to the accumulated total + char_counter._accumulated_difference = char_counter._accumulated_difference + diff + print(('Accumulated difference %s'):format(char_counter._accumulated_difference)) + end + end}, +} + +char_counter.cmds = { + { "CountPrint", function () + local Popup = require('nui.popup') + local popup = Popup(char_counter.settings.popup) + popup:mount() + popup:map("n", "", function() popup:unmount() end) + + local msg = ("char_counter: You have typed %s characters since I started counting."):format(char_counter._accumulated_difference) + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, { msg }) + end}, + { "CountReset", function () + char_counter._accumulated_difference = 0 + vim.notify("char_counter: Reset count!", "info") + end} +} + +char_counter.binds = { + { 'i', name = '+info', { -- Adds a new `whichkey` folder called `+info` + { 'c', ':CountPrint', name = 'Print new chars' }, -- Binds `:CountPrint` to `ic` + { 'r', ':CountReset', name = 'Reset char count' } -- Binds `:CountPrint` to `ic` + } } +} + +return char_counter From 114f0d3f92c5da4e11c4e288a2489de9cadba233 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:17:08 +1100 Subject: [PATCH 24/51] Fix on prev --- lua/doom/core/config/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 6a573e3..117a458 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -239,7 +239,12 @@ config.load = function() for section_name, section_modules in pairs(all_modules) do for _, module_name in pairs(section_modules) do - local ok, result = xpcall(require, debug.traceback, ("doom.modules.%s.%s"):format(section_name, module_name)) + -- Special case for user folder, resolves to `lua/user/modules` + local root_folder = section_name == "user" + and "user.modules" + or ("doom.modules.%s"):format(section_name) + + local ok, result = xpcall(require, debug.traceback, ("%s.%s"):format(root_folder, module_name)) if ok then doom.modules[module_name] = result else From f918c9baca4b49693dd893e0c5465346dea64045 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:17:50 +1100 Subject: [PATCH 25/51] fix: Removed `f` closing telescope --- lua/doom/modules/features/telescope/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index a732014..e8cd839 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -74,7 +74,6 @@ telescope.configs["telescope.nvim"] = function() [""] = actions.move_selection_next, [""] = actions.move_selection_previous, [""] = actions.smart_send_to_qflist + actions.open_qflist, - ["f"] = actions.close, -- works like a toggle, sometimes can be buggy [""] = actions.select_default + actions.center, }, n = { From 08f0c35072a15f4eaba93c99359e5adbeb435299 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:18:00 +1100 Subject: [PATCH 26/51] feat(modules): Added markdown language module. --- lua/doom/modules/langs/markdown/init.lua | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lua/doom/modules/langs/markdown/init.lua diff --git a/lua/doom/modules/langs/markdown/init.lua b/lua/doom/modules/langs/markdown/init.lua new file mode 100644 index 0000000..4de0b8b --- /dev/null +++ b/lua/doom/modules/langs/markdown/init.lua @@ -0,0 +1,32 @@ +local markdown = {} + +markdown.settings = { +} + +markdown.autocmds = { + { + "FileType", + "markdown", + function() + local langs_utils = require("doom.modules.langs.utils") + + langs_utils.use_lsp("remark_ls") + + vim.defer_fn(function() + require("nvim-treesitter.install").ensure_installed("markdown") + end, 0) + + -- Setup null-ls + if doom.modules.linter then + local null_ls = require("null-ls") + + langs_utils.use_null_ls_source({ + null_ls.builtins.diagnostics.markdownlint, + }) + end + end, + once = true, + }, +} + +return markdown From e5fd854e76f96e71aab8bf4a98d8b0462c0fe631 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:21:35 +1100 Subject: [PATCH 27/51] fix: Interdependency between `lsp` and `snippets` module. --- lua/doom/modules/features/lsp/init.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index 1456321..d791a93 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -94,7 +94,7 @@ lsp.uses = { ["nvim-cmp"] = { "hrsh7th/nvim-cmp", commit = "1001683bee3a52a7b7e07ba9d391472961739c7b", - after = is_plugin_disabled("snippets") or "LuaSnip", + after = not is_plugin_disabled("snippets") and "LuaSnip" or nil, }, ["cmp-nvim-lua"] = { "hrsh7th/cmp-nvim-lua", @@ -196,9 +196,12 @@ lsp.configs["nvim-lspconfig"] = function() end end lsp.configs["nvim-cmp"] = function() + local utils = require("doom.utils") + local snippets_enabled = not utils.is_plugin_disabled("snippets") + local cmp = require("cmp") - local luasnip = require("luasnip") - local replace_termcodes = require("doom.utils").replace_termcodes + local luasnip = snippets_enabled and require("luasnip") + local replace_termcodes = utils.replace_termcodes local source_map = { nvim_lsp = "[LSP]", @@ -248,7 +251,7 @@ lsp.configs["nvim-cmp"] = function() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then + elseif (snippets_enabled and luasnip.expand_or_jumpable()) then vim.fn.feedkeys(replace_termcodes("luasnip-expand-or-jump"), "") elseif check_backspace() then vim.fn.feedkeys(replace_termcodes(""), "n") @@ -262,7 +265,7 @@ lsp.configs["nvim-cmp"] = function() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable(-1) then + elseif snippets_enabled and luasnip.jumpable(-1) then vim.fn.feedkeys(replace_termcodes("luasnip-jump-prev"), "") else fallback() From 1b687c05369942ac3fb4d32a36b6552b2bde601e Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:22:27 +1100 Subject: [PATCH 28/51] refact: Returned to manually loading packer --- lua/doom/modules/core/doom/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index a985bc5..1187c87 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -8,6 +8,7 @@ local is_plugin_disabled = require("doom.utils").is_plugin_disabled required.uses = { ["packer.nvim"] = { "wbthomason/packer.nvim", + opt = true, }, -- Required by some treesitter modules ["aniseed"] = { From dc94ed427ee0af6d133ea8808b2dee972db1d23d Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:22:37 +1100 Subject: [PATCH 29/51] Fix on prev --- lua/doom/modules/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index fde08b5..ed9bd41 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -19,6 +19,7 @@ end -- Load packer local packer = require("packer") +vim.cmd [[packadd packer.nvim]] -- Change some defaults -- Of particular interest is compile_path: we use stdpath("data"), so as to not From 74438d24ce4519dd59c52e74a1a074222c42c404 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:23:48 +1100 Subject: [PATCH 30/51] refact: Renamed `fidget` module to `lsp_progress` --- lua/doom/modules/features/{fidget => lsp_progress}/init.lua | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/doom/modules/features/{fidget => lsp_progress}/init.lua (100%) diff --git a/lua/doom/modules/features/fidget/init.lua b/lua/doom/modules/features/lsp_progress/init.lua similarity index 100% rename from lua/doom/modules/features/fidget/init.lua rename to lua/doom/modules/features/lsp_progress/init.lua From a6e5dfc98b60a9c398da32dd6b58dfc54ef1afbb Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 19:40:14 +1100 Subject: [PATCH 31/51] fix: Possible for packer to uninstall self after certain errors. --- lua/doom/modules/core/doom/init.lua | 1 - lua/doom/modules/init.lua | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index 1187c87..a985bc5 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -8,7 +8,6 @@ local is_plugin_disabled = require("doom.utils").is_plugin_disabled required.uses = { ["packer.nvim"] = { "wbthomason/packer.nvim", - opt = true, }, -- Required by some treesitter modules ["aniseed"] = { diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index ed9bd41..19b279a 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -5,7 +5,7 @@ local system = require("doom.core.system") local enabled_modules = require("doom.core.config.modules").modules -- Packer Bootstrapping -local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" +local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim" if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then log.info("Bootstrapping packer.nvim, please wait ...") From 1ed143019c904762195c12858a6d8bd39effa63e Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 20:30:47 +1100 Subject: [PATCH 32/51] fix: Recover from errors in `config.lua` --- lua/doom/core/config/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 117a458..5bbd5f9 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -254,7 +254,11 @@ config.load = function() end end - dofile(config.source) + -- Execute user config + local ok, err = xpcall(dofile, debug.traceback, config.source) + if not ok then + print(vim.inspect(err)) + end -- Check plugins updates on start if enabled. if doom.check_updates then From 5ff14dce690618d83cdb14dbcdc4dc897884a555 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 20:31:20 +1100 Subject: [PATCH 33/51] fix(lsp_progress): Typo in config --- lua/doom/modules/features/lsp_progress/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/doom/modules/features/lsp_progress/init.lua b/lua/doom/modules/features/lsp_progress/init.lua index ad05a9c..d282907 100644 --- a/lua/doom/modules/features/lsp_progress/init.lua +++ b/lua/doom/modules/features/lsp_progress/init.lua @@ -12,7 +12,7 @@ fidget.uses = { fidget.configs = {} fidget.configs["fidget.nvim"] = function() - require("fidget").setup(doom.modules.fidget.settings) + require("fidget").setup(doom.modules.lsp_progress.settings) end return fidget From 2cdc8a655a2c01b46378498db003e4c7423d8ebd Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 20:31:55 +1100 Subject: [PATCH 34/51] fix: Language config errors when `lsp` module is disabled --- lua/doom/modules/langs/utils.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/doom/modules/langs/utils.lua b/lua/doom/modules/langs/utils.lua index aeb7b26..708811a 100644 --- a/lua/doom/modules/langs/utils.lua +++ b/lua/doom/modules/langs/utils.lua @@ -24,6 +24,9 @@ end module.use_lsp = function(lsp_name, _opts) local utils = require('doom.utils') + if utils.is_plugin_disabled("lsp") then + return + end local lsp = require('lspconfig') local lsp_configs = require("lspconfig.configs") From 78e65553365a411b95e7fdec3128575df194176a Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 22:08:50 +1100 Subject: [PATCH 35/51] fix: `` keybinds not working when whichkey disabled. --- lua/doom/modules/core/doom/init.lua | 290 ++++++++++++++-------------- 1 file changed, 143 insertions(+), 147 deletions(-) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index a985bc5..5f88d13 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -126,193 +126,189 @@ required.binds = function () if is_plugin_disabled("explorer") then table.insert(binds, { "", ":Lexplore%s", name = "Toggle explorer" }) - if not is_plugin_disabled("whichkey") then - table.insert(binds, { - "", - name = "+prefix", + table.insert(binds, { + "", + name = "+prefix", + { { + "o", + name = "+open/close", { - "o", - name = "+open/close", - { - { "e", ":Lexplore%s", name = "Explorer" }, - }, + { "e", ":Lexplore%s", name = "Explorer" }, }, }, - }) - end + }, + }) end - if not is_plugin_disabled("whichkey") then - local split_modes = { - vertical = "vert ", - horizontal = "", - [false] = "e", - } - local split_prefix = split_modes[doom.new_file_split] - table.insert(binds, { - "", - name = "+prefix", + local split_modes = { + vertical = "vert ", + horizontal = "", + [false] = "e", + } + local split_prefix = split_modes[doom.new_file_split] + table.insert(binds, { + "", + name = "+prefix", + { + { "m", "w", name = "Write" }, { - { "m", "w", name = "Write" }, + "b", + name = "+buffer", { - "b", - name = "+buffer", - { - { "b", "e #", name = "Jump to recent" }, - { "d", "bd", name = "Delete" }, - }, + { "b", "e #", name = "Jump to recent" }, + { "d", "bd", name = "Delete" }, }, + }, + { + "D", + name = "+doom", { - "D", - name = "+doom", { - { - "c", - ("e %s"):format(require("doom.core.config").source), - name = "Edit config", - }, - { - "m", - ("e %s"):format(require("doom.core.config.modules").source), - name = "Edit modules", - }, - { "l", "DoomConfigsReload", name = "Reload config" }, - { "r", "DoomRollback", name = "Rollback" }, - { "R", "DoomReport", name = "Report issue" }, - { "u", "DoomUpdate", name = "Update" }, - { "s", "PackerSync", name = "Sync packages" }, - { "I", "PackerInstall", name = "Install packages" }, - { "C", "PackerClean", name = "Clean packages" }, - { "b", "PackerCompile", name = "Build packages" }, - { "S", "PackerStatus", name = "Inform packages" }, - { "p", "PackerProfile", name = "Profile" }, + "c", + ("e %s"):format(require("doom.core.config").source), + name = "Edit config", }, + { + "m", + ("e %s"):format(require("doom.core.config.modules").source), + name = "Edit modules", + }, + { "l", "DoomConfigsReload", name = "Reload config" }, + { "r", "DoomRollback", name = "Rollback" }, + { "R", "DoomReport", name = "Report issue" }, + { "u", "DoomUpdate", name = "Update" }, + { "s", "PackerSync", name = "Sync packages" }, + { "I", "PackerInstall", name = "Install packages" }, + { "C", "PackerClean", name = "Clean packages" }, + { "b", "PackerCompile", name = "Build packages" }, + { "S", "PackerStatus", name = "Inform packages" }, + { "p", "PackerProfile", name = "Profile" }, }, + }, + { + "f", + name = "+file", { - "f", - name = "+file", + { "n", (":%snew"):format(split_prefix), name = "Create new" }, + { "w", "w", name = "Write" }, { - { "n", (":%snew"):format(split_prefix), name = "Create new" }, - { "w", "w", name = "Write" }, - { - "W", - function() - vim.fn.inputsave() - local new_name = vim.fn.input("New name: ") - vim.fn.inputrestore() - vim.cmd("w " .. new_name) - end, - name = "Write as", - }, - { "s", "w", name = "Save" }, - { - "S", - function() - vim.fn.inputsave() - local new_name = vim.fn.input("New name: ") - vim.fn.inputrestore() - vim.cmd("w " .. new_name) - end, - name = "Save as", - }, + "W", + function() + vim.fn.inputsave() + local new_name = vim.fn.input("New name: ") + vim.fn.inputrestore() + vim.cmd("w " .. new_name) + end, + name = "Write as", + }, + { "s", "w", name = "Save" }, + { + "S", + function() + vim.fn.inputsave() + local new_name = vim.fn.input("New name: ") + vim.fn.inputrestore() + vim.cmd("w " .. new_name) + end, + name = "Save as", }, }, + }, + { + "g", + name = "+git", { - "g", - name = "+git", + { "p", [[TermExec cmd="git pull"]], name = "Pull" }, + { "P", [[TermExec cmd="git push"]], name = "Push" }, { - { "p", [[TermExec cmd="git pull"]], name = "Pull" }, - { "P", [[TermExec cmd="git push"]], name = "Push" }, + "C", + name = "+commit", { - "C", - name = "+commit", - { - { "c", [[TermExec cmd="git commit"]], name = "commit" }, - { "a", [[TermExec cmd="git commit --ammend"]], name = "ammend" }, - }, + { "c", [[TermExec cmd="git commit"]], name = "commit" }, + { "a", [[TermExec cmd="git commit --ammend"]], name = "ammend" }, }, }, }, + }, + { + "h", + name = "+help", { - "h", - name = "+help", - { - { "h", "Man", name = "Manual pages", options = { silent = false } }, - { "D", "DoomManual", name = "Open Doom" }, - }, + { "h", "Man", name = "Manual pages", options = { silent = false } }, + { "D", "DoomManual", name = "Open Doom" }, }, + }, + { + "j", + name = "+jump", { - "j", - name = "+jump", - { - { "a", "", name = "Alternate file" }, - { "j", "", name = "Older file" }, - { "k", "", name = "Newer file" }, - { "p", "tag", name = "Push tag" }, - { "P", "pop", name = "Pop tag" }, - }, + { "a", "", name = "Alternate file" }, + { "j", "", name = "Older file" }, + { "k", "", name = "Newer file" }, + { "p", "tag", name = "Push tag" }, + { "P", "pop", name = "Pop tag" }, }, + }, + { + "q", + name = "+quit", { - "q", - name = "+quit", + { "q", require("doom.core.functions").quit_doom, name = "Exit and save" }, + { "w", require("doom.core.functions").quit_doom, name = "Exit and save" }, { - { "q", require("doom.core.functions").quit_doom, name = "Exit and save" }, - { "w", require("doom.core.functions").quit_doom, name = "Exit and save" }, - { - "d", - function() - require("doom.core.functions").quit_doom(true, true) - end, - name = "Exit and discard", - }, + "d", + function() + require("doom.core.functions").quit_doom(true, true) + end, + name = "Exit and discard", }, }, + }, + { + "t", + name = "+tweak", { - "t", - name = "+tweak", - { - { "b", require("doom.core.functions").toggle_background, name = "Toggle background" }, - { "s", require("doom.core.functions").toggle_signcolumn, name = "Toggle sigcolumn" }, - { "i", require("doom.core.functions").set_indent, name = "Set indent" }, - { "n", require("doom.core.functions").change_number, name = "Toggle number" }, - { "S", require("doom.core.functions").toggle_spell, name = "Toggle spelling" }, - { "x", require("doom.core.functions").change_syntax, name = "Toggle syntax" }, - }, + { "b", require("doom.core.functions").toggle_background, name = "Toggle background" }, + { "s", require("doom.core.functions").toggle_signcolumn, name = "Toggle sigcolumn" }, + { "i", require("doom.core.functions").set_indent, name = "Set indent" }, + { "n", require("doom.core.functions").change_number, name = "Toggle number" }, + { "S", require("doom.core.functions").toggle_spell, name = "Toggle spelling" }, + { "x", require("doom.core.functions").change_syntax, name = "Toggle syntax" }, }, + }, + { + "w", + name = "+window", { - "w", - name = "+window", + { "w", "p", name = "Jump to recent" }, + { "d", "c", name = "Delete window" }, + { "-", "s", name = "Split up/down" }, + { "|", "v", name = "Split left/right" }, + { "s", "s", name = "Split up/down" }, + { "v", "v", name = "Split left/right" }, + { "h", "h", name = "Jump left" }, + { "j", "j", name = "Jump down" }, + { "k", "k", name = "Jump up" }, + { "l", "l", name = "Jump right" }, + { "H", "H", name = "Move left" }, + { "J", "J", name = "Move down" }, + { "K", "K", name = "Move up" }, + { "L", "L", name = "Move right" }, + { "=", "=", name = "Move right" }, { - { "w", "p", name = "Jump to recent" }, - { "d", "c", name = "Delete window" }, - { "-", "s", name = "Split up/down" }, - { "|", "v", name = "Split left/right" }, - { "s", "s", name = "Split up/down" }, - { "v", "v", name = "Split left/right" }, - { "h", "h", name = "Jump left" }, - { "j", "j", name = "Jump down" }, - { "k", "k", name = "Jump up" }, - { "l", "l", name = "Jump right" }, - { "H", "H", name = "Move left" }, - { "J", "J", name = "Move down" }, - { "K", "K", name = "Move up" }, - { "L", "L", name = "Move right" }, - { "=", "=", name = "Move right" }, + "", "5<", name = "Expand left" }, - { "J>", "resize +5", name = "Expand down" }, - { "K>", "resize -5", name = "Expand up" }, - { "L>", "L", name = "Expand right" }, - }, + { "H>", "5<", name = "Expand left" }, + { "J>", "resize +5", name = "Expand down" }, + { "K>", "resize -5", name = "Expand up" }, + { "L>", "L", name = "Expand right" }, }, }, }, }, - }) - end + }, + }) return binds end From 67e7bfb090e64bf338984ece563ee5f43694e69a Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 22:11:59 +1100 Subject: [PATCH 36/51] feat(lsp_progress): Lazyload `lsp_progress` module --- lua/doom/modules/features/lsp_progress/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/doom/modules/features/lsp_progress/init.lua b/lua/doom/modules/features/lsp_progress/init.lua index d282907..b9f8500 100644 --- a/lua/doom/modules/features/lsp_progress/init.lua +++ b/lua/doom/modules/features/lsp_progress/init.lua @@ -7,6 +7,7 @@ fidget.uses = { ["fidget.nvim"] = { "j-hui/fidget.nvim", commit = "cbe0db4f2adfddfd830310e5846f8735d4e068fa", + after = "nvim-lspconfig", }, } From 0bc644880a84aee9d59b9180ddef6eb305a42be8 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 22:12:43 +1100 Subject: [PATCH 37/51] feat(core): packer bootstrap, make clone --depth 1 --- lua/doom/modules/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index 19b279a..f545a53 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -12,6 +12,8 @@ if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then vim.fn.system({ "git", "clone", + "--depth", + "1", "https://github.com/wbthomason/packer.nvim", packer_path, }) @@ -19,7 +21,6 @@ end -- Load packer local packer = require("packer") -vim.cmd [[packadd packer.nvim]] -- Change some defaults -- Of particular interest is compile_path: we use stdpath("data"), so as to not From 9b22e0e60c89b1d0fd8a6638b59c3ffd0609135c Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 22:13:54 +1100 Subject: [PATCH 38/51] refact: Do not defer loading modules. --- init.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index 6fe3473..b1f6bab 100644 --- a/init.lua +++ b/init.lua @@ -12,13 +12,12 @@ require("doom.core.config"):load() -- Load Doom core and UI related stuff (colorscheme, background). local utils = require("doom.utils") utils.load_modules("doom", { "core" }) +-- Load Doom modules. +utils.load_modules("doom", { "modules" }) -- Defer and schedule loading of modules until the Neovim API functions are -- safe to call to avoid weird errors with plugins stuff. vim.defer_fn(function() - -- Load Doom modules. - utils.load_modules("doom", { "modules" }) - -- Start dashboard if it is enabled and an empty buffer is opened initially. if not require("doom.utils").is_plugin_disabled("dashboard") From e3f28a6e960dec48b622a45a093e62782e290f12 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Sun, 20 Mar 2022 22:14:18 +1100 Subject: [PATCH 39/51] feat(core): Log errors in `config.lua`. --- lua/doom/core/config/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 5bbd5f9..f38e991 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -254,10 +254,11 @@ config.load = function() end end - -- Execute user config + -- Execute user config, log errors if any occur local ok, err = xpcall(dofile, debug.traceback, config.source) - if not ok then - print(vim.inspect(err)) + local log = require("doom.utils.logging") + if not ok and err then + log.error("Error while running `config.lua. Traceback:\n" .. err) end -- Check plugins updates on start if enabled. From 71e0edb5282aa7b97df4e06625c2867d3c60a443 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Tue, 22 Mar 2022 22:35:14 +1100 Subject: [PATCH 40/51] refact: Switched `is_plugin_disabled` to `is_module_enabled` --- init.lua | 2 +- lua/doom/core/functions.lua | 6 ++--- lua/doom/core/init.lua | 4 ++-- lua/doom/modules/core/doom/init.lua | 10 ++++---- lua/doom/modules/core/nest/init.lua | 24 +++++++++++++++---- lua/doom/modules/core/treesitter/init.lua | 4 ++-- .../modules/features/auto_install/init.lua | 6 ++--- lua/doom/modules/features/dashboard/init.lua | 8 +++---- lua/doom/modules/features/explorer/init.lua | 6 ++--- lua/doom/modules/features/lsp/init.lua | 9 ++++--- lua/doom/modules/features/statusline/init.lua | 6 ++--- lua/doom/modules/features/telescope/init.lua | 4 ++-- lua/doom/modules/langs/utils.lua | 6 ++--- lua/doom/utils/init.lua | 2 +- modules.lua | 2 +- 15 files changed, 55 insertions(+), 44 deletions(-) diff --git a/init.lua b/init.lua index b1f6bab..a635372 100644 --- a/init.lua +++ b/init.lua @@ -20,7 +20,7 @@ utils.load_modules("doom", { "modules" }) vim.defer_fn(function() -- Start dashboard if it is enabled and an empty buffer is opened initially. if - not require("doom.utils").is_plugin_disabled("dashboard") + require("doom.utils").is_module_enabled("dashboard") and (vim.api.nvim_buf_get_number(0) > 1 or vim.api.nvim_buf_get_lines(0, 0, 1, false)[1]:len() == 0) and vim.api.nvim_buf_get_name(0):len() == 0 -- Empty buffer name diff --git a/lua/doom/core/functions.lua b/lua/doom/core/functions.lua index 3de5af7..9960bab 100644 --- a/lua/doom/core/functions.lua +++ b/lua/doom/core/functions.lua @@ -4,7 +4,7 @@ local utils = require("doom.utils") local fs = require("doom.utils.fs") local system = require("doom.core.system") local async = require("doom.utils.async") -local is_plugin_disabled = utils.is_plugin_disabled +local is_module_enabled = utils.is_module_enabled local functions = {} @@ -383,7 +383,7 @@ functions.toggle_background = function() end -- Only define if lsp enabled, it only makes sense there. -if not is_plugin_disabled("lsp") then +if is_module_enabled("lsp") then -- Toggle completion (by running cmp setup again). functions.toggle_completion = function() _doom.cmp_enable = not _doom.cmp_enable @@ -440,7 +440,7 @@ functions.change_number = function() end -- Toggle autopairs. -if not is_plugin_disabled("autopairs") then +if is_module_enabled("autopairs") then functions.toggle_autopairs = function() local autopairs = require("nvim-autopairs") if autopairs.state.disabled then diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua index 17d95ac..b9423f0 100644 --- a/lua/doom/core/init.lua +++ b/lua/doom/core/init.lua @@ -3,13 +3,13 @@ --- (ui, options, doomrc, etc) local utils = require("doom.utils") -local is_plugin_disabled = utils.is_plugin_disabled +local is_module_enabled = utils.is_module_enabled -- Required setup modules. local core_modules = { "commands", "ui" } -- If the explorer is disabled, the user probably wants a better netrw. -- Otherwise, don't bother configuring it. -if is_plugin_disabled("explorer") then +if is_module_enabled("explorer") then table.insert(core_modules, "netrw") end utils.load_modules("doom.core", core_modules) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index 5f88d13..46beb07 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -3,7 +3,6 @@ local required = {} required.settings = { mapper = {}, } -local is_plugin_disabled = require("doom.utils").is_plugin_disabled required.uses = { ["packer.nvim"] = { @@ -27,7 +26,6 @@ required.uses = { }, ["nvim-mapper"] = { "lazytanuki/nvim-mapper", - before = is_plugin_disabled("telescope") or "telescope.nvim", }, ['nvim-web-devicons'] = { 'kyazdani42/nvim-web-devicons', @@ -43,7 +41,7 @@ end required.binds = function () local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled local binds = { { "ZZ", require("doom.core.functions").quit_doom, name = "Fast exit" }, @@ -124,7 +122,7 @@ required.binds = function () table.insert(binds, { esc_seq, "", mode = "i" }) end - if is_plugin_disabled("explorer") then + if is_module_enabled("explorer") then table.insert(binds, { "", ":Lexplore%s", name = "Toggle explorer" }) table.insert(binds, { "", @@ -314,7 +312,7 @@ required.binds = function () end required.autocmds = function () - local is_plugin_disabled = require("doom.utils").is_plugin_disabled + local is_module_enabled = require("doom.utils").is_module_enabled local autocmds = {} @@ -340,7 +338,7 @@ required.autocmds = function () }) end - if is_plugin_disabled("explorer") then + if is_module_enabled("explorer") then table.insert(autocmds, { "FileType", "netrw", diff --git a/lua/doom/modules/core/nest/init.lua b/lua/doom/modules/core/nest/init.lua index e721c25..705cd2df 100644 --- a/lua/doom/modules/core/nest/init.lua +++ b/lua/doom/modules/core/nest/init.lua @@ -14,20 +14,34 @@ nest.uses = { nest.configs = {} nest.configs["nest.nvim"] = function() local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled local nest_package = require("nest") nest_package.enable(require("nest.integrations.mapper")) - if not is_plugin_disabled("whichkey") then + if is_module_enabled("whichkey") then local whichkey_integration = require("nest.integrations.whichkey") nest_package.enable(whichkey_integration) end - for _, module in pairs(doom.modules) do - if module.binds then - nest_package.applyKeymaps(type(module.binds) == 'function' and module.binds() or module.binds) + local last_module = ''; + local ok, err = xpcall(function() + for module_name, module in pairs(doom.modules) do + last_module = module_name + if module.binds then + nest_package.applyKeymaps(type(module.binds) == 'function' and module.binds() or module.binds) + end end + end, debug.traceback) + if not ok and err then + local log = require("doom.utils.logging") + log.error( + string.format( + "There was an error setting keymaps for module '%s'. Traceback:\n%s", + last_module, + err + ) + ) end end diff --git a/lua/doom/modules/core/treesitter/init.lua b/lua/doom/modules/core/treesitter/init.lua index 2e7e202..fca87a1 100644 --- a/lua/doom/modules/core/treesitter/init.lua +++ b/lua/doom/modules/core/treesitter/init.lua @@ -60,10 +60,10 @@ treesitter.uses = { treesitter.configs = {} treesitter.configs["nvim-treesitter"] = function() - local is_plugin_disabled = require("doom.utils").is_plugin_disabled + local is_module_enabled = require("doom.utils").is_module_enabled require("nvim-treesitter.configs").setup(vim.tbl_deep_extend("force", doom.modules.treesitter.settings.treesitter, { autopairs = { - enable = not is_plugin_disabled("autopairs"), + enable = is_module_enabled("autopairs"), }, })) diff --git a/lua/doom/modules/features/auto_install/init.lua b/lua/doom/modules/features/auto_install/init.lua index 67cc556..be3b74f 100644 --- a/lua/doom/modules/features/auto_install/init.lua +++ b/lua/doom/modules/features/auto_install/init.lua @@ -5,7 +5,7 @@ auto_install.settings = { dap_dir = vim.fn.stdpath("data") .. "/dap-install", } -local is_plugin_disabled = require("doom.utils").is_plugin_disabled +local is_module_enabled = require("doom.utils").is_module_enabled auto_install.uses = { ["DAPInstall.nvim"] = { @@ -17,7 +17,7 @@ auto_install.uses = { "DIList", "DIUninstall", }, - disabled = is_plugin_disabled("dap"), + disabled = not is_module_enabled("dap"), module = "dap-install", disable = true, }, @@ -25,7 +25,7 @@ auto_install.uses = { "williamboman/nvim-lsp-installer", commit = "29154c2fe1147c8eed5d54a419841e5637a8c3b2", opt = true, - disabled = is_plugin_disabled("lsp"), + disabled = not is_module_enabled("lsp"), module = "nvim-lsp-install", }, } diff --git a/lua/doom/modules/features/dashboard/init.lua b/lua/doom/modules/features/dashboard/init.lua index 13aed4c..2ffc078 100644 --- a/lua/doom/modules/features/dashboard/init.lua +++ b/lua/doom/modules/features/dashboard/init.lua @@ -67,15 +67,15 @@ dashboard.uses = { dashboard.configs = {} dashboard.configs["dashboard-nvim"] = function() local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled - if not is_plugin_disabled("auto_session") then + if is_module_enabled("auto_session") then vim.g.dashboard_session_directory = doom.modules.auto_session.settings.dir end - if not is_plugin_disabled("telescope") then + if is_module_enabled("telescope") then vim.g.dashboard_default_executive = "telescope" end - if not is_plugin_disabled("auto_session") then + if is_module_enabled("auto_session") then doom.modules.dashboard.settings.entries.a = { description = { " Load Last Session SPC s r" }, command = [[lua require("persistence").load({ last = true })]], diff --git a/lua/doom/modules/features/explorer/init.lua b/lua/doom/modules/features/explorer/init.lua index e93db50..f7f6bee 100644 --- a/lua/doom/modules/features/explorer/init.lua +++ b/lua/doom/modules/features/explorer/init.lua @@ -93,7 +93,7 @@ explorer.uses = { explorer.configs = {} explorer.configs["nvim-tree.lua"] = function() local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled local tree_cb = require("nvim-tree.config").nvim_tree_callback @@ -132,7 +132,7 @@ explorer.configs["nvim-tree.lua"] = function() vim.g.nvim_tree_show_icons = show_icons local override_icons = {} - if not is_plugin_disabled("lsp") then + if is_module_enabled("lsp") then override_icons = { lsp = { hint = doom.modules.lsp.settings.icons.hint, @@ -149,7 +149,7 @@ explorer.configs["nvim-tree.lua"] = function() enable = false, }, } - if not is_plugin_disabled("lsp") then + if is_module_enabled("lsp") then override_table = { diagnostics = { enable = true, diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index d791a93..5dd533a 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -77,7 +77,7 @@ lsp.settings = { }, } -local is_plugin_disabled = require("doom.utils").is_plugin_disabled +local is_module_enabled = require("doom.utils").is_module_enabled lsp.uses = { ["nvim-lspconfig"] = { "neovim/nvim-lspconfig", @@ -94,7 +94,7 @@ lsp.uses = { ["nvim-cmp"] = { "hrsh7th/nvim-cmp", commit = "1001683bee3a52a7b7e07ba9d391472961739c7b", - after = not is_plugin_disabled("snippets") and "LuaSnip" or nil, + after = is_module_enabled("snippets") and "LuaSnip" or nil, }, ["cmp-nvim-lua"] = { "hrsh7th/cmp-nvim-lua", @@ -120,13 +120,12 @@ lsp.uses = { "saadparwaiz1/cmp_luasnip", commit = "d6f837f4e8fe48eeae288e638691b91b97d1737f", after = "nvim-cmp", - disabled = is_plugin_disabled("snippets"), + disabled = not is_module_enabled("snippets"), }, ["lsp_signature.nvim"] = { "ray-x/lsp_signature.nvim", commit = "f7c308e99697317ea572c6d6bafe6d4be91ee164", after = "nvim-lspconfig", - opt = true, }, } @@ -197,7 +196,7 @@ lsp.configs["nvim-lspconfig"] = function() end lsp.configs["nvim-cmp"] = function() local utils = require("doom.utils") - local snippets_enabled = not utils.is_plugin_disabled("snippets") + local snippets_enabled = utils.is_module_enabled("snippets") local cmp = require("cmp") local luasnip = snippets_enabled and require("luasnip") diff --git a/lua/doom/modules/features/statusline/init.lua b/lua/doom/modules/features/statusline/init.lua index 30f8a44..6b8b437 100644 --- a/lua/doom/modules/features/statusline/init.lua +++ b/lua/doom/modules/features/statusline/init.lua @@ -24,7 +24,7 @@ statusline.uses = { statusline.configs = {} statusline.configs["galaxyline.nvim"] = function() local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled local gl = require("galaxyline") local colors = require("galaxyline.themes.colors").get_color @@ -45,7 +45,7 @@ statusline.configs["galaxyline.nvim"] = function() gl.short_line_list = doom.modules.statusline.settings.short_line_list - if not is_plugin_disabled("dashboard") and not doom.modules.statusline.settings.on_dashboard then + if is_module_enabled("dashboard") and not doom.modules.statusline.settings.on_dashboard then table.insert(gl.exclude_filetypes, "dashboard") end @@ -297,7 +297,7 @@ statusline.configs["galaxyline.nvim"] = function() }, } - if not is_plugin_disabled("lsp") then + if is_module_enabled("lsp") then table.insert(default_sections.left, { DiagnosticError = { provider = "DiagnosticError", diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index e8cd839..8ad8da9 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -92,7 +92,7 @@ end telescope.binds = function () local utils = require("doom.utils") - local is_plugin_disabled = utils.is_plugin_disabled + local is_module_enabled = utils.is_module_enabled local binds = { "", @@ -168,7 +168,7 @@ telescope.binds = function () }, }, } - if not is_plugin_disabled("lsp") then + if is_module_enabled("lsp") then table.insert(binds, { "", name = "+prefix", diff --git a/lua/doom/modules/langs/utils.lua b/lua/doom/modules/langs/utils.lua index 708811a..7bcd0f1 100644 --- a/lua/doom/modules/langs/utils.lua +++ b/lua/doom/modules/langs/utils.lua @@ -24,7 +24,7 @@ end module.use_lsp = function(lsp_name, _opts) local utils = require('doom.utils') - if utils.is_plugin_disabled("lsp") then + if utils.is_module_enabled("lsp") then return end local lsp = require('lspconfig') @@ -40,7 +40,7 @@ module.use_lsp = function(lsp_name, _opts) -- Combine default on_attach with provided on_attach local on_attach_functions = {} - if not utils.is_plugin_disabled("illuminate") then + if utils.is_module_enabled("illuminate") then table.insert(on_attach_functions, utils.illuminate_attach) end if (opts.config and opts.config.on_attach) then @@ -74,7 +74,7 @@ module.use_lsp = function(lsp_name, _opts) end -- Auto install if possible - if not utils.is_plugin_disabled('auto_install') and not opts.no_installer then + if utils.is_module_enabled('auto_install') and not opts.no_installer then local lsp_installer = require("nvim-lsp-installer.servers") local server_available, server = lsp_installer.get_server(lsp_name) if server_available then diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index 883a0b6..c9b6efd 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -211,7 +211,7 @@ end --- Check if the given plugin is disabled in doom-nvim/modules.lua --- @param plugin string The plugin identifier, e.g. statusline --- @return boolean -utils.is_plugin_disabled = function(plugin) +utils.is_module_enabled = function(plugin) local modules = require("doom.core.config.modules").modules -- Iterate over all modules sections (e.g. ui) and their plugins diff --git a/modules.lua b/modules.lua index dd9c979..bc34dcc 100644 --- a/modules.lua +++ b/modules.lua @@ -27,7 +27,7 @@ return { "todo_comments", -- Highlight TODO: comments -- UI - "fidget", -- Check status of LSP loading + "lsp_progress", -- Check status of LSP loading "tabline", -- Tab bar buffer switcher "dashboard", -- A pretty dashboard upon opening "trouble", -- A pretty diagnostic viewer From e4ba1e3e5464264096b5fe8f21f690fec8e6d974 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Tue, 22 Mar 2022 22:35:45 +1100 Subject: [PATCH 41/51] fix: Fixed race condition with lsp plugins --- lua/doom/modules/features/auto_install/init.lua | 1 - lua/doom/modules/features/autopairs/init.lua | 11 +++-------- lua/doom/modules/features/lsp/init.lua | 7 ------- 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/lua/doom/modules/features/auto_install/init.lua b/lua/doom/modules/features/auto_install/init.lua index be3b74f..ded5734 100644 --- a/lua/doom/modules/features/auto_install/init.lua +++ b/lua/doom/modules/features/auto_install/init.lua @@ -24,7 +24,6 @@ auto_install.uses = { ["nvim-lsp-installer"] = { "williamboman/nvim-lsp-installer", commit = "29154c2fe1147c8eed5d54a419841e5637a8c3b2", - opt = true, disabled = not is_module_enabled("lsp"), module = "nvim-lsp-install", }, diff --git a/lua/doom/modules/features/autopairs/init.lua b/lua/doom/modules/features/autopairs/init.lua index 8002eab..a9fc476 100644 --- a/lua/doom/modules/features/autopairs/init.lua +++ b/lua/doom/modules/features/autopairs/init.lua @@ -20,14 +20,9 @@ autopairs.configs["nvim-autopairs"] = function() end autopairs.binds = { - "", - name = "+prefix", - { - { - "t", - name = "+tweak", - { - { "p", require("doom.core.functions").toggle_autopairs, name = "Toggle autopairs" }, + "", name = "+prefix", { + { "t", name = "+tweak", { + { "p", function() require("doom.core.functions").toggle_autopairs() end, name = "Toggle autopairs" }, }, }, }, diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index 5dd533a..efe9bd1 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -82,13 +82,6 @@ lsp.uses = { ["nvim-lspconfig"] = { "neovim/nvim-lspconfig", commit = "cdc2ec53e028d32f06c51ef8b2837ebb8460ef45", - opt = true, - cmd = { - "LspInfo", - "LspStart", - "LspRestart", - "LspStop", - }, module = "lspconfig", }, ["nvim-cmp"] = { From 7ff116014374b9093c58885bdc905189f11a2406 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Tue, 22 Mar 2022 22:36:35 +1100 Subject: [PATCH 42/51] fix: Racecondition loading neovim modules --- init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index a635372..7531135 100644 --- a/init.lua +++ b/init.lua @@ -12,12 +12,12 @@ require("doom.core.config"):load() -- Load Doom core and UI related stuff (colorscheme, background). local utils = require("doom.utils") utils.load_modules("doom", { "core" }) --- Load Doom modules. -utils.load_modules("doom", { "modules" }) -- Defer and schedule loading of modules until the Neovim API functions are -- safe to call to avoid weird errors with plugins stuff. vim.defer_fn(function() + -- Load Doom modules. + utils.load_modules("doom", { "modules" }) -- Start dashboard if it is enabled and an empty buffer is opened initially. if require("doom.utils").is_module_enabled("dashboard") From bdd8f7bc50c448fedc152ea9ad44f65ba6a5b5bc Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Tue, 22 Mar 2022 22:38:39 +1100 Subject: [PATCH 43/51] fix: Use correct code annotations in typescript --- lua/doom/modules/features/annotations/init.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/doom/modules/features/annotations/init.lua b/lua/doom/modules/features/annotations/init.lua index 6eb63e9..4240065 100644 --- a/lua/doom/modules/features/annotations/init.lua +++ b/lua/doom/modules/features/annotations/init.lua @@ -5,7 +5,12 @@ annotations.settings = { languages = { lua = { template = { - annotation_convention = "ldoc", + annotation_convention = "emmylua", + }, + }, + typescript = { + template = { + annotation_convention = "tsdoc", }, }, }, From e82cd3aee9c846768ec8795a4de9465ce7be2368 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 07:58:54 +1100 Subject: [PATCH 44/51] feat: Refacted `use` to `use_package`, added `use_cmd` and `use_autocmd` --- lua/doom/core/config/init.lua | 34 ++++++++++++++++++++++++++++++++-- lua/doom/modules/init.lua | 15 +++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index f38e991..0b74e31 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -196,6 +196,7 @@ config.load = function() vim.opt.foldtext = require("doom.core.functions").sugar_folds() doom = config.defaults doom.uses = {} -- Extra packages + doom.cmds = {} -- Extra commands doom.autocmds = {} -- Extra autocommands doom.binds = {} -- Extra binds doom.modules = {} -- Modules @@ -207,7 +208,7 @@ config.load = function() -- Add doom.use helper function -- @param string|packer_spec PackerSpec - doom.use = function(...) + doom.use_package = function(...) local arg = {...} -- Get table of packages via git repository name local packages_to_add = vim.tbl_map(function (t) @@ -226,7 +227,36 @@ config.load = function() table.insert(doom.uses, type(packer_spec) == "string" and { packer_spec } or packer_spec) end end - --]] + + doom.use_keybind = function(...) + local arg = {...} + for _, bind in ipairs(arg) do + table.insert(doom.binds, bind) + end + end + + doom.use_cmd = function(...) + local arg = {...} + for _, cmd in ipairs(arg) do + if type(cmd[1] == "string") then + doom.cmds[cmd[1]] = cmd; + elseif cmd ~= nil then + doom.use_cmd(unpack(cmd)) + end + end + end + + doom.use_autocmd = function(...) + local arg = {...} + for _, autocmd in ipairs(arg) do + if type(autocmd[1]) == 'string' and type(autocmd[2]) == 'string' then + local key = string.format('%s-%s', autocmd[1], autocmd[2]) + doom.autocmds[key] = autocmd + elseif autocmd ~= nil then + doom.use_autocmd(unpack(autocmd)) + end + end + end -- Combine core modules with user-enabled modules local all_modules = vim.tbl_deep_extend('keep', { diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index f545a53..94410b3 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -85,3 +85,18 @@ end for _, packer_spec in ipairs(doom.uses) do use(packer_spec) end + +-- Handle extra user cmds +for _, cmd_spec in pairs(doom.cmds) do + print(cmd_spec[1]) + utils.make_cmd(cmd_spec[1], cmd_spec[2]) +end + +-- Handle extra user autocmds +local autocmds = {} +for _, cmd_spec in pairs(doom.autocmds) do + table.insert(autocmds, cmd_spec) +end +utils.make_augroup('user', autocmds) + +-- User keybinds handled in `nest` module From 83a8c4265df389d69f656fd9fa66952c8ceac97d Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 08:10:34 +1100 Subject: [PATCH 45/51] fix: Fixed logging output when error loading module. --- lua/doom/core/config/init.lua | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 0b74e31..27344c1 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -278,7 +278,15 @@ config.load = function() if ok then doom.modules[module_name] = result else - print(vim.inspect(result)) + local log = require("doom.utils.logging") + log.error( + string.format( + "There was an error loading module '%s.%s'. Traceback:\n%s", + section_name, + module_name, + result + ) + ) end end end From 39e25dc02663c78d0e8b039d504f9d899338f04a Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 08:11:10 +1100 Subject: [PATCH 46/51] temp: Custom config changes + noting packer sequencing time --- config.lua | 28 +++++++++++++++++++--------- modules.lua | 18 +++++++++++------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/config.lua b/config.lua index 4bcceea..892fe43 100644 --- a/config.lua +++ b/config.lua @@ -16,18 +16,20 @@ vim.diagnostic.config({ }, }) -doom.modules.tabline.settings.options.numbers = nil; -- Hide buffer numbers -doom.modules.tabline.settings.options.diagnostics_indicator = function (_, _, diagnostics_dict, _) - local s = "" - for e, _ in pairs(diagnostics_dict) do - local sym = e == "error" and " " or (e == "warning" and " " or " ") - s = s .. sym +if doom.modules.tabline then + doom.modules.tabline.settings.options.diagnostics_indicator = function (_, _, diagnostics_dict, _) + doom.modules.tabline.settings.options.numbers = nil; -- Hide buffer numbers + local s = "" + for e, _ in pairs(diagnostics_dict) do + local sym = e == "error" and " " or (e == "warning" and " " or " ") + s = s .. sym + end + return s end - return s end -- Colourscheme -doom.use('sainnhe/sonokai', 'EdenEast/nightfox.nvim') +doom.use_package('sainnhe/sonokai', 'EdenEast/nightfox.nvim') local options = { dim_inactive = true, } @@ -67,12 +69,20 @@ require('nightfox').setup({ doom.colorscheme = 'dawnfox' -- Extra packages -doom.use( +doom.use_package( 'rafcamlet/nvim-luapad', 'nvim-treesitter/playground', 'tpope/vim-surround', 'dstein64/vim-startuptime' ) + +doom.use_cmd({ + 'Test', function() print('test') end +}) + +doom.use_autocmd({ + {"FileType", "lua", function() print('lua') end } +}) vim.opt.guifont = { 'Hack Nerd Font', 'h12' } -- vim: sw=2 sts=2 ts=2 expandtab diff --git a/modules.lua b/modules.lua index bc34dcc..5a96668 100644 --- a/modules.lua +++ b/modules.lua @@ -7,7 +7,7 @@ return { features = { - -- Language features + -- Language features (33ms) "annotations", -- Code annotation generator "auto_install", -- Auto install LSP providers "autopairs", -- Automatically close character pairs @@ -16,7 +16,7 @@ return { "lsp", -- Code completion "snippets", -- Code snippets for all languages - -- Editor + -- Editor (34ms, 1ms) "auto_session", -- Remember sessions between loads "colorizer", -- Show colors in neovim "editorconfig", -- Support editorconfig files @@ -26,18 +26,18 @@ return { "range_highlight", -- Highlight selected range from commands "todo_comments", -- Highlight TODO: comments - -- UI + -- UI (44ms, 10ms) "lsp_progress", -- Check status of LSP loading "tabline", -- Tab bar buffer switcher "dashboard", -- A pretty dashboard upon opening "trouble", -- A pretty diagnostic viewer "statusline2", -- A pretty status line at the bottom of the buffer - -- "minimap", -- Shows current position in document + "minimap", -- Shows current position in document - -- Tools - -- "dap", -- Debug code through neovim + -- Tools (188ms, 144ms) + "dap", -- Debug code through neovim "explorer", -- An enhanced filetree explorer - -- "firenvim", -- Embed neovim in your browser + -- "firenvim", -- Embed neovim in your browser "telescope", -- Fuzzy searcher to find files, grep code and more "neorg", -- Organise your life "whichkey", -- An interactive sheet @@ -78,6 +78,10 @@ return { "java", "config", -- JSON, YAML, TOML + "markdown", + }, + user = { + -- 'char_counter', } } From 7d591830726a4130c33d067a56de4af208bdb949 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 08:24:48 +1100 Subject: [PATCH 47/51] fix: `is_module_enabled` utility incorrect result --- lua/doom/utils/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index c9b6efd..d3b3bab 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -217,11 +217,11 @@ utils.is_module_enabled = function(plugin) -- Iterate over all modules sections (e.g. ui) and their plugins for _, section in pairs(modules) do if vim.tbl_contains(section, plugin) then - return false + return true end end - return true + return false end --- Rounds a number, optionally to the nearest decimal place From 3126a8082318dcfc0a3cd8521b517bb3e7f98e81 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 08:24:55 +1100 Subject: [PATCH 48/51] chore: Update pinned packer dependencies --- lua/doom/modules/core/doom/init.lua | 4 ++-- lua/doom/modules/core/treesitter/init.lua | 6 ++--- .../modules/features/annotations/init.lua | 2 +- .../modules/features/auto_install/init.lua | 6 ++--- lua/doom/modules/features/autopairs/init.lua | 2 +- lua/doom/modules/features/comment/init.lua | 2 +- lua/doom/modules/features/dap/init.lua | 4 ++-- lua/doom/modules/features/explorer/init.lua | 2 +- lua/doom/modules/features/gitsigns/init.lua | 2 +- lua/doom/modules/features/illuminate/init.lua | 2 +- .../modules/features/indentlines/init.lua | 2 +- lua/doom/modules/features/lazygit/init.lua | 2 +- lua/doom/modules/features/linter/init.lua | 2 +- lua/doom/modules/features/lsp/init.lua | 6 ++--- .../modules/features/lsp_progress/init.lua | 2 +- lua/doom/modules/features/neogit/init.lua | 2 +- lua/doom/modules/features/neorg/init.lua | 2 +- .../modules/features/show_registers/init.lua | 2 +- lua/doom/modules/features/snippets/init.lua | 2 +- lua/doom/modules/features/symbols/init.lua | 2 +- lua/doom/modules/features/tabline/init.lua | 2 +- lua/doom/modules/features/telescope/init.lua | 2 +- lua/doom/modules/features/terminal/init.lua | 2 +- lua/doom/modules/features/trouble/init.lua | 2 +- lua/doom/modules/features/whichkey/init.lua | 2 +- lua/doom/modules/init.lua | 22 +++++++++---------- lua/doom/modules/langs/config/init.lua | 2 +- lua/doom/modules/langs/utils.lua | 2 +- 28 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index 46beb07..fdeb40e 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -11,12 +11,12 @@ required.uses = { -- Required by some treesitter modules ["aniseed"] = { "Olical/aniseed", - commit = "a955096c566843302a0a509680b92ab276488add", + commit = "bd79727af8a21037222a08ec9bcaf1c85488aaa4", module_pattern = "aniseed", }, ["plenary.nvim"] = { "nvim-lua/plenary.nvim", - commit = "2a278c8a12a399e25b78a43ebcd4f3996cd4e4b6", + commit = "0d660152000a40d52158c155625865da2aa7aa1b", module = "plenary", }, ["popup.nvim"] = { diff --git a/lua/doom/modules/core/treesitter/init.lua b/lua/doom/modules/core/treesitter/init.lua index fca87a1..fc32349 100644 --- a/lua/doom/modules/core/treesitter/init.lua +++ b/lua/doom/modules/core/treesitter/init.lua @@ -42,18 +42,18 @@ treesitter.settings = { treesitter.uses = { ["nvim-treesitter"] = { "nvim-treesitter/nvim-treesitter", - commit = "82389e52b6b50f712593079255ee088f1631b9cd", + commit = "3e2ac54e1638da214dab58f9edf01ad93f57261d", run = ":TSUpdate", branch = "master", }, ["nvim-ts-context-commentstring"] = { "JoosepAlviste/nvim-ts-context-commentstring", - commit = "097df33c9ef5bbd3828105e4bee99965b758dc3f", + commit = "7810f1fe706092290dd338f40e5e857bac4a03cf", after = "nvim-treesitter", }, ["nvim-ts-autotag"] = { "windwp/nvim-ts-autotag", - commit = "887fcd9e45ff112c4f39d2a8ba2594d04b99752a", + commit = "57035b5814f343bc6110676c9ae2eacfcd5340c2", after = "nvim-treesitter", }, } diff --git a/lua/doom/modules/features/annotations/init.lua b/lua/doom/modules/features/annotations/init.lua index 4240065..98cd06c 100644 --- a/lua/doom/modules/features/annotations/init.lua +++ b/lua/doom/modules/features/annotations/init.lua @@ -19,7 +19,7 @@ annotations.settings = { annotations.uses = { ["neogen"] = { "danymat/neogen", - commit = "b7d2ce8c1d17a0b90f557e5f94372f42193291a5", + commit = "778a8537865a2c692ba4909b72e1b14ea98999c6", after = "nvim-treesitter", }, } diff --git a/lua/doom/modules/features/auto_install/init.lua b/lua/doom/modules/features/auto_install/init.lua index ded5734..43bd2fa 100644 --- a/lua/doom/modules/features/auto_install/init.lua +++ b/lua/doom/modules/features/auto_install/init.lua @@ -23,9 +23,9 @@ auto_install.uses = { }, ["nvim-lsp-installer"] = { "williamboman/nvim-lsp-installer", - commit = "29154c2fe1147c8eed5d54a419841e5637a8c3b2", - disabled = not is_module_enabled("lsp"), - module = "nvim-lsp-install", + commit = "56b7cf4e55ec51580ecd4285ba3cf848b3e1ece6", + -- disabled = not is_module_enabled("lsp"), + module = "nvim-lsp-installer", }, } diff --git a/lua/doom/modules/features/autopairs/init.lua b/lua/doom/modules/features/autopairs/init.lua index a9fc476..3319e8f 100644 --- a/lua/doom/modules/features/autopairs/init.lua +++ b/lua/doom/modules/features/autopairs/init.lua @@ -9,7 +9,7 @@ autopairs.settings = { autopairs.uses = { ["nvim-autopairs"] = { "windwp/nvim-autopairs", - commit = "771fda8d169384d345c8bbf2f871b75ba4a2dee5", + commit = "6617498bea01c9c628406d7e23030da57f2f8718", event = "BufReadPost", }, } diff --git a/lua/doom/modules/features/comment/init.lua b/lua/doom/modules/features/comment/init.lua index f702601..306679c 100644 --- a/lua/doom/modules/features/comment/init.lua +++ b/lua/doom/modules/features/comment/init.lua @@ -44,7 +44,7 @@ comment.settings = { comment.uses = { ["Comment.nvim"] = { "numToStr/Comment.nvim", - commit = "18a8dc0bbdfc089d5f5a850e4640d8e75381c598", + commit = "8a2b2f3b302e3a35184b1107dfb3781aa76e442a", module = "Comment", }, } diff --git a/lua/doom/modules/features/dap/init.lua b/lua/doom/modules/features/dap/init.lua index af55791..b0a2408 100644 --- a/lua/doom/modules/features/dap/init.lua +++ b/lua/doom/modules/features/dap/init.lua @@ -38,12 +38,12 @@ dap.settings = { dap.uses = { ["nvim-dap"] = { "mfussenegger/nvim-dap", - commit = "9fcff6e02e1a549d47a2c559a4b833798537c0bc", + commit = "3d0575a777610b364fea745b85ad497d56b8009a", module = "dap", }, ["nvim-dap-ui"] = { "rcarriga/nvim-dap-ui", - commit = "22e94f2303c8d8d72b541799d7733c5ded0733c5", + commit = "45805d69273f1ca0753a096abd419e89af8e5f8a", after = { "nvim-dap", "nest.nvim" }, }, } diff --git a/lua/doom/modules/features/explorer/init.lua b/lua/doom/modules/features/explorer/init.lua index f7f6bee..d71f6a9 100644 --- a/lua/doom/modules/features/explorer/init.lua +++ b/lua/doom/modules/features/explorer/init.lua @@ -77,7 +77,7 @@ explorer.settings = { explorer.uses = { ["nvim-tree.lua"] = { "kyazdani42/nvim-tree.lua", - commit = "9b03ab40e843e251f01bccec2eca5ea9dcdebc0d", + commit = "7b0ebf8b17d85abecccfd1c924090a28d5935b88", cmd = { "NvimTreeClipboard", "NvimTreeClose", diff --git a/lua/doom/modules/features/gitsigns/init.lua b/lua/doom/modules/features/gitsigns/init.lua index 6bc59eb..ff4e873 100644 --- a/lua/doom/modules/features/gitsigns/init.lua +++ b/lua/doom/modules/features/gitsigns/init.lua @@ -75,7 +75,7 @@ gitsigns.settings = { gitsigns.uses = { ["gitsigns.nvim"] = { "lewis6991/gitsigns.nvim", - commit = "7de953329ff696408bd38d3218b0239839d285e0", + commit = "3791dfa1ee356a3250e0b74f63bad90e27455f60", }, } diff --git a/lua/doom/modules/features/illuminate/init.lua b/lua/doom/modules/features/illuminate/init.lua index 2c2c4bb..2b09847 100644 --- a/lua/doom/modules/features/illuminate/init.lua +++ b/lua/doom/modules/features/illuminate/init.lua @@ -16,7 +16,7 @@ illuminate.settings = { illuminate.uses = { ["vim-illuminate"] = { "RRethy/vim-illuminate", - commit = "db98338285574265a6ce54370b54d9f939e091bb", + commit = "487563de7ed6195fd46da178cb38dc1ff110c1ce", }, } diff --git a/lua/doom/modules/features/indentlines/init.lua b/lua/doom/modules/features/indentlines/init.lua index 74940c1..1de2ed6 100644 --- a/lua/doom/modules/features/indentlines/init.lua +++ b/lua/doom/modules/features/indentlines/init.lua @@ -11,7 +11,7 @@ indentlines.settings = { indentlines.uses = { ["indent-blankline.nvim"] = { "lukas-reineke/indent-blankline.nvim", - commit = "2e35f7dcdc72f39b37c21e43cdb538d7a41c7e07", + commit = "9915d46ba9361784c70036bb7259c436249e5b0c", event = "ColorScheme", }, } diff --git a/lua/doom/modules/features/lazygit/init.lua b/lua/doom/modules/features/lazygit/init.lua index b4109af..46154fc 100644 --- a/lua/doom/modules/features/lazygit/init.lua +++ b/lua/doom/modules/features/lazygit/init.lua @@ -5,7 +5,7 @@ lazygit.settings = {} lazygit.uses = { ["lazygit.nvim"] = { "kdheepak/lazygit.nvim", - commit = "9bceeab97668935cc6b91ab5190167d9771b5210", + commit = "ca8ea75e5a1d838635fd2fcc5c3467a5bb33c4ec", cmd = { "LazyGit", "LazyGitConfig" }, opt = true, }, diff --git a/lua/doom/modules/features/linter/init.lua b/lua/doom/modules/features/linter/init.lua index 9b7b3a5..6494d4f 100644 --- a/lua/doom/modules/features/linter/init.lua +++ b/lua/doom/modules/features/linter/init.lua @@ -7,7 +7,7 @@ linter.settings = { linter.uses = { ["null-ls.nvim"] = { "jose-elias-alvarez/null-ls.nvim", - commit = "a1804de23ce354c982aa08c57d3ed89aad8a15a9", + commit = "71bb21da7faa6676629ebac5e8818b701da46f80", after = "nvim-lspconfig", }, } diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index efe9bd1..71226f5 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -81,12 +81,12 @@ local is_module_enabled = require("doom.utils").is_module_enabled lsp.uses = { ["nvim-lspconfig"] = { "neovim/nvim-lspconfig", - commit = "cdc2ec53e028d32f06c51ef8b2837ebb8460ef45", + commit = "63efd6ed156ae578c7e23278ec0a82776802106b", module = "lspconfig", }, ["nvim-cmp"] = { "hrsh7th/nvim-cmp", - commit = "1001683bee3a52a7b7e07ba9d391472961739c7b", + commit = "272cbdca3e327bf43e8df85c6f4f00921656c4e4", after = is_module_enabled("snippets") and "LuaSnip" or nil, }, ["cmp-nvim-lua"] = { @@ -117,7 +117,7 @@ lsp.uses = { }, ["lsp_signature.nvim"] = { "ray-x/lsp_signature.nvim", - commit = "f7c308e99697317ea572c6d6bafe6d4be91ee164", + commit = "e4f7dad45a1a3bb390977b4e69a528993bcefeac", after = "nvim-lspconfig", }, } diff --git a/lua/doom/modules/features/lsp_progress/init.lua b/lua/doom/modules/features/lsp_progress/init.lua index b9f8500..bbb251e 100644 --- a/lua/doom/modules/features/lsp_progress/init.lua +++ b/lua/doom/modules/features/lsp_progress/init.lua @@ -6,7 +6,7 @@ fidget.settings = { fidget.uses = { ["fidget.nvim"] = { "j-hui/fidget.nvim", - commit = "cbe0db4f2adfddfd830310e5846f8735d4e068fa", + commit = "d47f2bbf7d984f69dc53bf2d37f9292e3e99ae8a", after = "nvim-lspconfig", }, } diff --git a/lua/doom/modules/features/neogit/init.lua b/lua/doom/modules/features/neogit/init.lua index ed08660..28bc80e 100644 --- a/lua/doom/modules/features/neogit/init.lua +++ b/lua/doom/modules/features/neogit/init.lua @@ -5,7 +5,7 @@ neogit.settings = {} neogit.uses = { ["neogit"] = { "TimUntersberger/neogit", - commit = "3bba2b63417cb679313e0ed0b7d9b7539c7f02b0", + commit = "9987421e0724ce704d0035f50a7080c677a85d71", cmd = "Neogit", opt = true, }, diff --git a/lua/doom/modules/features/neorg/init.lua b/lua/doom/modules/features/neorg/init.lua index f0427ec..9079baf 100644 --- a/lua/doom/modules/features/neorg/init.lua +++ b/lua/doom/modules/features/neorg/init.lua @@ -32,7 +32,7 @@ neorg.settings = { neorg.uses = { ["neorg"] = { "nvim-neorg/neorg", - commit = "acfa3929971d488afac9c392fb34b80bac4f4c71", + commit = "9aeaf79c5ad01930705a0534a35adbdba9eb5f13", opt = "true", cmd = "NeorgStart" } diff --git a/lua/doom/modules/features/show_registers/init.lua b/lua/doom/modules/features/show_registers/init.lua index 1e07988..873dc26 100644 --- a/lua/doom/modules/features/show_registers/init.lua +++ b/lua/doom/modules/features/show_registers/init.lua @@ -5,7 +5,7 @@ show_registers.settings = {} show_registers.uses = { ["registers.nvim"] = { "tversteeg/registers.nvim", - commit = "dd2bfa41b2c43d65f1f715e07acf1f1d34b37de8", + commit = "c66458fe5f83b57d40b678058a8eeb6340f9275c", opt = true, }, } diff --git a/lua/doom/modules/features/snippets/init.lua b/lua/doom/modules/features/snippets/init.lua index 7e60736..2edfb35 100644 --- a/lua/doom/modules/features/snippets/init.lua +++ b/lua/doom/modules/features/snippets/init.lua @@ -8,7 +8,7 @@ snippets.settings = { snippets.uses = { ["LuaSnip"] = { "L3MON4D3/LuaSnip", - commit = "7c634ddf7ff99245ef993b5fa459c3b61e905075", + commit = "80e68242cf8127844653060fbada32dca15579fc", requires = { "rafamadriz/friendly-snippets", opt = true }, event = "InsertEnter", }, diff --git a/lua/doom/modules/features/symbols/init.lua b/lua/doom/modules/features/symbols/init.lua index 4da707a..85f2dc4 100644 --- a/lua/doom/modules/features/symbols/init.lua +++ b/lua/doom/modules/features/symbols/init.lua @@ -19,7 +19,7 @@ symbols.settings = { symbols.uses = { ["symbols-outline.nvim"] = { "simrat39/symbols-outline.nvim", - commit = "758944ebc6919c50557b6eb3a52bc41187041fe2", + commit = "1361738c47892c3cee0d0b7a3b3bc7a8b48139c2", cmd = { "SymbolsOutline", "SymbolsOutlineOpen", diff --git a/lua/doom/modules/features/tabline/init.lua b/lua/doom/modules/features/tabline/init.lua index 8346150..b68a0e1 100644 --- a/lua/doom/modules/features/tabline/init.lua +++ b/lua/doom/modules/features/tabline/init.lua @@ -142,7 +142,7 @@ tabline.settings = { tabline.uses = { ["bufferline.nvim"] = { "akinsho/bufferline.nvim", - commit = "871495d9e2dbe3314a421fd2d5e46f47de7ee537", + commit = "e1202c6569353d03ef0cb3da11b839dba26854dd", event = "BufAdd", }, } diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index 8ad8da9..a5a83b0 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -49,7 +49,7 @@ telescope.settings = { telescope.uses = { ["telescope.nvim"] = { "nvim-telescope/telescope.nvim", - commit = "567ec85b157f1606b500a0f755181f284810a28e", + commit = "1a72a92b641e1dab42036c07e2571b43c55bfaa1", cmd = "Telescope", opt = true, }, diff --git a/lua/doom/modules/features/terminal/init.lua b/lua/doom/modules/features/terminal/init.lua index bdd84cf..b828c50 100644 --- a/lua/doom/modules/features/terminal/init.lua +++ b/lua/doom/modules/features/terminal/init.lua @@ -25,7 +25,7 @@ terminal.settings = { terminal.uses = { ["toggleterm.nvim"] = { "akinsho/toggleterm.nvim", - commit = "e97d0c1046512e975a9f3fa95afe98f312752b1c", + commit = "36704ddf3883842f3354e11da968d4c1201f0831", cmd = { "ToggleTerm", "TermExec" }, opt = true, }, diff --git a/lua/doom/modules/features/trouble/init.lua b/lua/doom/modules/features/trouble/init.lua index 10e2de3..d2ee81d 100644 --- a/lua/doom/modules/features/trouble/init.lua +++ b/lua/doom/modules/features/trouble/init.lua @@ -5,7 +5,7 @@ trouble.settings = {} trouble.uses = { ["trouble.nvim"] = { "folke/trouble.nvim", - commit = "20469be985143d024c460d95326ebeff9971d714", + commit = "691d490cc4eadc430d226fa7d77aaa84e2e0a125", cmd = { "Trouble", "TroubleClose", "TroubleRefresh", "TroubleToggle" }, opt = true, }, diff --git a/lua/doom/modules/features/whichkey/init.lua b/lua/doom/modules/features/whichkey/init.lua index c4d56ce..e3231bb 100644 --- a/lua/doom/modules/features/whichkey/init.lua +++ b/lua/doom/modules/features/whichkey/init.lua @@ -64,7 +64,7 @@ whichkey.settings = { whichkey.uses = { ["which-key.nvim"] = { "folke/which-key.nvim", - commit = "28d2bd129575b5e9ebddd88506601290bb2bb221", + commit = "a3c19ec5754debb7bf38a8404e36a9287b282430", }, } diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index 94410b3..4f9535c 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -53,6 +53,17 @@ packer.reset() -- Handle the Modules for module_name, module in pairs(doom.modules) do + -- Setup package autogroups + if module.autocmds then + local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds + utils.make_augroup(module_name, autocmds) + end + + if module.cmds then + for _, cmd_spec in ipairs(module.cmds) do + utils.make_cmd(cmd_spec[1], cmd_spec[2]) + end + end -- Import dependencies with packer from module.uses if module.uses then for dependency_name, packer_spec in pairs(module.uses) do @@ -68,17 +79,6 @@ for module_name, module in pairs(doom.modules) do use(packer_spec) end end - -- Setup package autogroups - if module.autocmds then - local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds - utils.make_augroup(module_name, autocmds) - end - - if module.cmds then - for _, cmd_spec in ipairs(module.cmds) do - utils.make_cmd(cmd_spec[1], cmd_spec[2]) - end - end end -- Handle extra user modules diff --git a/lua/doom/modules/langs/config/init.lua b/lua/doom/modules/langs/config/init.lua index 929c3c7..9a3cf41 100644 --- a/lua/doom/modules/langs/config/init.lua +++ b/lua/doom/modules/langs/config/init.lua @@ -17,7 +17,7 @@ config.settings = { config.uses = { ["SchemaStore.nvim"] = { "b0o/SchemaStore.nvim", - commit = "df5e98d3b3c93e9857908fce8a219360f81c5e32", + commit = "0a3f765335acde2bdf33504a62fe944a5d6d907e", ft = { "json", "yaml", "toml" } }, } diff --git a/lua/doom/modules/langs/utils.lua b/lua/doom/modules/langs/utils.lua index 7bcd0f1..ed03a5c 100644 --- a/lua/doom/modules/langs/utils.lua +++ b/lua/doom/modules/langs/utils.lua @@ -24,7 +24,7 @@ end module.use_lsp = function(lsp_name, _opts) local utils = require('doom.utils') - if utils.is_module_enabled("lsp") then + if not utils.is_module_enabled("lsp") then return end local lsp = require('lspconfig') From b8d8e8876272b0650a019db5e7cff3be18ceca0f Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 08:29:19 +1100 Subject: [PATCH 49/51] fix(lsp,typescript): Breaking when switching between tsx and ts files --- lua/doom/modules/langs/typescript/init.lua | 7 +++++-- lua/doom/utils/init.lua | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lua/doom/modules/langs/typescript/init.lua b/lua/doom/modules/langs/typescript/init.lua index b3940b4..9fb111e 100644 --- a/lua/doom/modules/langs/typescript/init.lua +++ b/lua/doom/modules/langs/typescript/init.lua @@ -1,3 +1,5 @@ +local utils = require('doom.utils'); + local typescript = {} typescript.settings = { @@ -7,7 +9,8 @@ typescript.autocmds = { { "FileType", "typescript,typescriptreact", - function() + utils.make_run_once_function(function() + print('Configuring typescript') local langs_utils = require('doom.modules.langs.utils') langs_utils.use_lsp('tsserver') @@ -26,7 +29,7 @@ typescript.autocmds = { null_ls.builtins.diagnostics.eslint_d, }) end - end, + end), once = true, }, } diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index d3b3bab..b8a7052 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -224,6 +224,19 @@ utils.is_module_enabled = function(plugin) return false end +--- Returns a function that can only be run once +---@param fn function +---@return function +utils.make_run_once_function = function(fn) + local has_run = false + return function(...) + if not has_run then + fn(...) + has_run = true + end + end +end + --- Rounds a number, optionally to the nearest decimal place --- @param num number - Value to round --- @param decimalplace number|nil - Number of decimal places From b5ad85300aa3c41802919cafb48727230b07941f Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 16:59:34 +1100 Subject: [PATCH 50/51] fix(langs,vue): Volar language server not starting --- lua/doom/modules/langs/vue/init.lua | 95 ++++++++++++++++++----------- 1 file changed, 58 insertions(+), 37 deletions(-) diff --git a/lua/doom/modules/langs/vue/init.lua b/lua/doom/modules/langs/vue/init.lua index 0847249..4c50fa4 100644 --- a/lua/doom/modules/langs/vue/init.lua +++ b/lua/doom/modules/langs/vue/init.lua @@ -4,7 +4,7 @@ vue.settings = { -- Volar API lspconfig options volar_api = { default_config = { - filetypes = { 'vue' }, + filetypes = { "vue" }, -- If you want to use Volar's Take Over Mode (if you know, you know) --filetypes = { 'vue', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' }, init_options = { @@ -20,37 +20,37 @@ vue.settings = { codeAction = true, workspaceSymbol = true, completion = { - defaultTagNameCase = 'both', - defaultAttrNameCase = 'kebabCase', + defaultTagNameCase = "both", + defaultAttrNameCase = "kebabCase", getDocumentNameCasesRequest = false, getDocumentSelectionRequest = false, }, - } + }, }, - } + }, }, -- Volar Document lspconfig options volar_doc = { default_config = { - filetypes = { 'vue' }, + filetypes = { "vue" }, -- If you want to use Volar's Take Over Mode (if you know, you know): --filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue', 'json' }, init_options = { languageFeatures = { documentHighlight = true, documentLink = true, - codeLens = { showReferencesNotification = true}, + codeLens = { showReferencesNotification = true }, -- not supported - https://github.com/neovim/neovim/pull/14122 semanticTokens = false, diagnostics = true, schemaRequestService = true, - } + }, }, - } + }, }, volar_html = { default_config = { - filetypes = { 'vue' }, + filetypes = { "vue" }, -- If you want to use Volar's Take Over Mode (if you know, you know), intentionally no 'json': --filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, init_options = { @@ -64,10 +64,10 @@ vue.settings = { documentFormatting = { defaultPrintWidth = 100, }, - } + }, }, - } - } + }, + }, } vue.configs = {} @@ -79,8 +79,8 @@ vue.autocmds = { function() local lspconfig = require("lspconfig") local lspconfig_util = require("lspconfig/util") - local langs_utils = require('doom.modules.langs.utils') - + local langs_utils = require("doom.modules.langs.utils") + -- volar needs works with typescript server, needs to get the typescript server from the project's node_modules local volar = lspconfig.volar -- Get the volar config to set the `cmd` local function on_new_config(new_config, new_root_dir) @@ -96,7 +96,7 @@ vue.autocmds = { )) or "" end - + if new_config.init_options and new_config.init_options.typescript @@ -106,11 +106,12 @@ vue.autocmds = { end end local volar_root_dir = lspconfig_util.root_pattern("package.json") - + -- Contains base configuration necessary for volar to start local base_config = { default_config = { - cmd = volar.document_config.default_config.cmd, + cmd = { 'vue-language-server', '--stdio' }, + -- cmd = volar.document_config.default_config.cmd, root_dir = volar_root_dir, on_new_config = on_new_config, init_options = { @@ -120,37 +121,57 @@ vue.autocmds = { }, }, } - - - local volar_api_config = vim.tbl_deep_extend('force', {}, doom.modules.vue.settings.volar_api, base_config) - langs_utils.use_lsp('volar', { - name = 'volar_api', + + local volar_api_config = vim.tbl_deep_extend( + "force", + {}, + doom.modules.vue.settings.volar_api, + base_config + ) + langs_utils.use_lsp("volar", { + name = "volar_api", config = volar_api_config, }) - - local volar_doc_config = vim.tbl_deep_extend('force', {}, doom.modules.vue.settings.volar_doc, base_config) - langs_utils.use_lsp('volar', { - name = 'volar_doc', + + local volar_doc_config = vim.tbl_deep_extend( + "force", + {}, + doom.modules.vue.settings.volar_doc, + base_config + ) + langs_utils.use_lsp("volar", { + name = "volar_doc", config = volar_doc_config, }) - - local volar_html_config = vim.tbl_deep_extend('force', {}, doom.modules.vue.settings.volar_html, base_config) - langs_utils.use_lsp('volar', { - name = 'volar_html', + + local volar_html_config = vim.tbl_deep_extend( + "force", + {}, + doom.modules.vue.settings.volar_html, + base_config + ) + langs_utils.use_lsp("volar", { + name = "volar_html", config = volar_html_config, }) - - - + vim.defer_fn(function() local ts_install = require("nvim-treesitter.install") - ts_install.ensure_installed("vue", "css", "scss", "html", "scss", "javascript", "typescript") + ts_install.ensure_installed( + "vue", + "css", + "scss", + "html", + "scss", + "javascript", + "typescript" + ) end, 0) - + -- Setup null-ls if doom.modules.linter then local null_ls = require("null-ls") - + langs_utils.use_null_ls_source({ null_ls.builtins.formatting.eslint_d, null_ls.builtins.code_actions.eslint_d, From 9a03bad25986f44a82dc71360be0d4531e5daa31 Mon Sep 17 00:00:00 2001 From: connorgmeean Date: Wed, 23 Mar 2022 17:00:16 +1100 Subject: [PATCH 51/51] fix(core): Autocmds triggered before plugins setup --- lua/doom/modules/init.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index 4f9535c..9bba4cb 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -53,17 +53,6 @@ packer.reset() -- Handle the Modules for module_name, module in pairs(doom.modules) do - -- Setup package autogroups - if module.autocmds then - local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds - utils.make_augroup(module_name, autocmds) - end - - if module.cmds then - for _, cmd_spec in ipairs(module.cmds) do - utils.make_cmd(cmd_spec[1], cmd_spec[2]) - end - end -- Import dependencies with packer from module.uses if module.uses then for dependency_name, packer_spec in pairs(module.uses) do @@ -79,6 +68,18 @@ for module_name, module in pairs(doom.modules) do use(packer_spec) end end + + -- Setup package autogroups + if module.autocmds then + local autocmds = type(module.autocmds) == 'function' and module.autocmds() or module.autocmds + utils.make_augroup(module_name, autocmds) + end + + if module.cmds then + for _, cmd_spec in ipairs(module.cmds) do + utils.make_cmd(cmd_spec[1], cmd_spec[2]) + end + end end -- Handle extra user modules