diff --git a/.gitignore b/.gitignore index cbdc659da..f7305f88d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,9 +10,9 @@ tags # OS files .DS_Store # Doom Nvim Contrib files -contribute/doom-nvim-contrib -contribute/local-share-nvim -contribute/workspace +tools/doom-nvim-contrib +tools/local-share-nvim +tools/workspace # User modules user/modules/* diff --git a/CHANGELOG.md b/CHANGELOG.md index e9ceedd30..3e3beaa6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,34 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [4.0.0] + +- `doom_modules.lua` renamed to `modules.lua` +- `doom_config.lua` renamed to `config.lua` +- `doom_userplugins.lua` replaced by the `doom.use_package(...)` helper function. +- refact!: `+lsp` flags for languages are now redundant, all langs have LSP enabled by default. +- refact!: Rewrote doom-nvim internals to simplify code + improve modularity and integrations between modules. + - `modules.lua` now only has two sections: `features` and `langs` + - Modules defined in `lua/doom/modules/SECTION_NAME/MODULE_NAME` + - Each module contains all plugins, config, keybinds, autocommands for a feature or a language. + - Users can override or add new modules by creating a folder in `lua/user/modules/SECTION_NAME/MODULE_NAME` ([implementing custom modules](https://github.com/NTBBloodbath/doom-nvim/docs/modules.md#building-your-own-module)). +- refact!: `config.lua` to define your config programatically / imperatively using new [helper functions](https://github.com/NTBBloodbath/doom-nvim#configuring-and-personalising-configlua). +- feat: Added an install script (clones doom-nvim, checks out a new branch `my-config`). +- feat: Added `repl` module (run code in neovim using [iron.nvim](https://github.com/hkupty/iron.nvim)). +- feat: Added `annotations` module (generate code documentation using [neogen](https://github.com/danymat/neogen)) to replace broken `nvim-tree-docs` plugin. +- feat: Added `projects` module (quickly switch between projects using [project.nvim](https://github.com/ahmedkhalf/project.nvim)). +- feat: Added `lsp_progress` module (shows lsp startup and loading using [fidget.nvim](https://github.com/j-hui/fidget.nvim)) +- refact!: `linter` and `formatter` module merged into one (`linter`). +- refact!: `linter` module to use [null-ls.nvim](https://github.com/jose-elias-alvarez/null-ls.nvim). +- refact: Renamed `kommentary` module to `comment` module, switched to [Comment.nvim](https://github.com/numToStr/Comment.nvim) and fixed keybinds. +- feat: Implemented a `nest.nvim` inspired keymap syntax that integrates with `whichkey` and `nvim-mapper`. +- feat: Added optional [impatient.nvim](lewis6991/impatient.nvim) (`doom.impatient_enabled = true` in `config.lua`). + - WARN: This can create bugs when modifying your config and you'll probably have to run `:LuaCacheClear`. +- refact: Removed `develop` branch, doom-nvim will now use rolling releases with tagged stable versions. +- refact: Auto updating logic moved into core module + - Now requires user to use a custom config branch + - Updating will merge the latest tagged stable version with your custom config branch. +- tweak: Various startup time improvements. ## [3.3.0] - Removed support for Neovim 0.5 diff --git a/README.md b/README.md index 8004a1780..2ff90c246 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ ![License](https://img.shields.io/github/license/NTBBloodbath/doom-nvim?style=for-the-badge) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge)](http://makeapullrequest.com) ![Latest Release](https://img.shields.io/github/v/release/NTBBloodbath/doom-nvim?include_prereleases&style=for-the-badge&color=red) -![GitHub last commit (branch)](https://img.shields.io/github/last-commit/NTBBloodbath/doom-nvim/develop?style=for-the-badge) -![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=for-the-badge&logo=neovim) +![GitHub last commit (branch)](https://img.shields.io/github/last-commit/NTBBloodbath/doom-nvim/main?style=for-the-badge) +![Neovim version](https://img.shields.io/badge/Neovim-0.7-57A143?style=for-the-badge&logo=neovim) [![Discord](https://img.shields.io/badge/discord-join-7289da?style=for-the-badge&logo=discord)](https://discord.gg/xhvBM45zBf) @@ -18,28 +18,10 @@ ---- - -- [Doom Nvim](#doom-nvim) - * [What is Doom Nvim?](#what-is-doom-nvim-) - * [Install](#install) - * [Configuring](#configuring) - + [Enabling features: `modules.lua`](#-moduleslua-) - - [What is a module?](#what-is-a-module-) - - [Enabing/disabling modules](#enabing-disabling-modules) - - [All modules](#all-modules) - + [Configuring and personalising: `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) - * [Adding commands](#adding-commands) - - [Overriding module defaults](#overriding-module-defaults) - * [FAQ](#faq) - * [Contributing](#contributing) - * [Contributors](#contributors) - ---- +> Note: Doom nvim v4.0.0 has just been released (29th July 2022). +> This release introduces many changes so feel free to ask questions on the +> discord or in the github discussions page or create an issue ticket and I'll +> solve it as soon as possible. ## What is Doom Nvim? @@ -58,51 +40,97 @@ Some of the defining features that make this project unique are: ## Install -TODO: Add install docs here +### Mac OS / Linux + +```bash +bash <(curl -s https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/tools/install.sh) +``` + +### Manual (Mac OS / Linux) + +1. Clone doom-nvim to ~/.config/nvim + - `git clone https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim` +2. (optional) Checkout the latest stable version in a new branch called `my-config` so the auto-updater works. + - `git checkout tags/$(git tag -l --sort -version:refname | head -n 1) -b my-config` + - ℹ️ The auto-updater will be broken without this step but you're free to check updates using the `:DoomCheckUpdates` command and manage updates manually. + +--- + +- [Configuring](#configuring) +- [Enabling features: `modules.lua`](#enabling-features-moduleslua) + - [What is a module?](#what-is-a-module) + - [Enabing/disabling modules](#enabingdisabling-modules) + - [All modules](#all-modules) +- [Configuring and personalising: `config.lua`](#configuring-and-personalising-configlua) + - [Modifying neovim and doom options](#modifying-neovim-and-doom-options) + * [Adding plugins](#adding-plugins) + * [Adding keybinds](#adding-keybinds) + * [Adding autocommands](#adding-autocommands) + * [Adding commands](#adding-commands) + - [Overriding module defaults](#overriding-module-defaults) +- [FAQ](#faq) +- [Contributing](#contributing) +- [Contributors](#contributors) +- [Uninstall](#uninstalling) + +--- ## 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. +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. + +> We recommend creating a custom config branch (the auto install script will +> do this for you) and committing your changes to this branch. The auto updater +> will merge new releases into your config branch for you. ### 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. -We organise modules into 3 categories: + +A module is a collection of packages, autocommands, keybinds and functions that +add new capabilities or functionality to Doom Nvim. See what's avaliable in +`modules.lua` and enable the modules that you think you would like. Then restart +`doom-nvim`, run `:PackerSync` and then restart `doom-nvim` again. + +We organise modules into 2 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:]. #### Enabing/disabling modules -You can enable or disable a module by going to `modules.lua` (`Dm`) and commenting or uncommenting the entry. +You can enable or disable a module by going to `modules.lua` (`Dm`) and +commenting or uncommenting the entry. + ```lua -- modules.lua return { + -- `lsp` module is enabled, `telescope is disabled` features = { 'lsp' -- 'telescope' }, + -- `lua` language is enabled, `rust is disabled` 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 35+ `features` modules and 20+ `langs` modules. -You can find a full list of modules (here)[./docs/modules.md#all-modules] +You can find a full list of modules [here](./docs/modules.md#all-modules) ### 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 (in the API Reference)[./docs/api.md]. +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 @@ -114,7 +142,8 @@ doom.settings.indent = 2 -- Sets vim.opt.shiftwith, vim.opt.so vim.opt.colorcolumn = 120 -- Regular vim options can also be set ``` -> **NOTE:** If you have the `lua` language and `lsp` module enabled all of these options will be autocompleted. +> **NOTE:** If you have the `lua` language and `lsp` module enabled all of these +> options will be autocompleted. ##### Adding plugins @@ -138,7 +167,8 @@ doom.use_package({ ##### Adding Keybinds Additional keybinds can be defined with the `doom.use_keybind()` 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) +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 @@ -150,7 +180,8 @@ doom.use_keybind({ }) ``` -> **NOTE:** By providing the `name` field your custom keybinds will show up in `whichkey` and `mapper` if you have those modules enabled. +> **NOTE:** By providing the `name` field your custom keybinds will show up +> in `whichkey` and `mapper` if you have those modules enabled. ##### Adding autocommands @@ -275,15 +306,23 @@ return { The majors changes between v3 and v4 are the following. - `doom_config.lua` renamed to `config.lua` -- Adding custom commands, keybinds and autocommands done using new [`doom.use_*`](#-configlua-) helper functions. -- Adding extra plugins done using new [`doom.use_package`](#adding-plugins) helper function. +- Adding custom commands, keybinds and autocommands done using new [`doom.use_*`](#-configlua-) + helper functions. +- Adding extra plugins done using new [`doom.use_package`](#adding-plugins) helper + function. - `doom_modules.lua` renamed to `modules.lua` -- Many of the modules categories have been combined, there are now only `features` (modifying capabilities of doom-nvim) and `languages` (add support for a language) +- Many of the modules categories have been combined, there are now only `features` + (modifying capabilities of doom-nvim) and `languages` (add support for a language) - Languages `+lsp`, `+formatting`, etc flags are no longer necessary > Because of the durastic changes to the way you configure doom-nvim we recommend > starting a new branch and porting your changes across. +## Uninstalling + +To uninstall doom-nvim delete the `.nvim` folder from `$XDG_CONFIG_HOME/nvim` (`rm -r ~/.config/nvim`) +You will also need to delete `packer_compiled.lua` from `$XDG_DATA_HOME/nvim/plugin/packer_compiled` (`rm ~/.local/share/nvim/plugin/packer_compiled.lua`) + ## Contributing For for information please see our [contributing docs](./docs/contributing.md). @@ -316,6 +355,7 @@ Special thanks to these amazing people for helping improve doom (see [emoji key] + diff --git a/config.lua b/config.lua index 4dc904f81..67c7158f3 100644 --- a/config.lua +++ b/config.lua @@ -834,8 +834,8 @@ doom.use_cmd({ -- vim.opt.guifont = { 'Hack Nerd Font', 'h12' } -- Editor config -doom.border_style = { "", "", "", "", "", "", "", "" } -doom.impatient_enabled = true +-- doom.border_style = { "", "", "", "", "", "", "", "" } +-- doom.impatient_enabled = true -- vim.lsp.set_log_level('trace') vim.diagnostic.config({ diff --git a/doc/doom_nvim.norg b/doc/doom_nvim.norg index ad52a3d61..b1cea0630 100644 --- a/doc/doom_nvim.norg +++ b/doc/doom_nvim.norg @@ -10,626 +10,227 @@ = TOC Table of Contents * Table of Contents - -> [Introduction](#Introduction) - -> [Using Doom Nvim as your daily setup](#Using Doom Nvim as your daily setup) - --> [Moving around](#Moving around) - --> [Configuration](#Configuration) - ---> [Modules](#Modules) - ----> [Tweaking modules](#Tweaking modules) - ---> [Custom plugins](#Custom plugins) - ---> [Language Server Protocols](#Language Server Protocols) - --> [Autocompletion](#Autocompletion) - --> [Colorscheme](#Colorscheme) - --> [Layout](#Layout) - ---> [File Explorer](#File Explorer) - ---> [Main Buffer](#Main Buffer) - ---> [Terminal](#Terminal) - ---> [Minimap](#Minimap) - ---> [Outline](#Outline) - --> [Commands](#Commands) - --> [Keybindings](#Keybindings) - --> [Hacking Doom Nvim](#Hacking Doom Nvim) - -> [Known issues](#Known issues) - -> [FAQ](#FAQ) - --> [General](#General) - ---> [Who is Doom Nvim intended for?](#Who is Doom Nvim intended for?) - --> [Workaround](#Workaround) - ---> [Missing nvim help documentation](#Missing nvim help documentation) - -> [Acknowledgements](#Acknowledgements) - -> [Contributing](#Contributing) - -> [License](#License) + -> {# Introduction} + -> {# Configuring doom-nvim} + --> {# Modules} + ---> {# Enabling / disabling modules} + ---> {# Custom plugins} + ---> {# Customising the behaviour of modules} + --> {# Config} + ---> {# Adding Plugins} + ---> {# Adding keybinds} + ---> {# Adding commands} + ---> {# Configuring modules} + ---> {# Overriding modules or adding custom modules} + -> {# Contributing} + -> {# License} * Introduction - Doom Nvim is a Neovim port of the [Doom Emacs](https://github.com/hlissner/doom-emacs) configuration framework, adapted for the Neovim user - that wants less framework in their framework and the performance of a hand-made configuration. - You can use it as your own setup or as a learning resource on how to achieve a great Neovim configuration. - - Doom Nvim features an opinionated collection of reasonable and optional defaults, with a focus on - runtime and startup performance, and a clean, readable and very robust code base. - -* Using Doom Nvim as your daily setup - You can start Doom Nvim by typing `nvim` in a terminal emulator or by executing your preferred - Neovim GUI client. - - By default, if no files were opened, Doom Nvim will show the start menu ([dashboard-nvim](https://github.com/glepnir/dashboard-nvim)) where you - can select files to edit or if you have a saved session in the current workspace, Doom Nvim will load - it automatically if you want to. - - ** Moving around - Doom Nvim uses the default Neovim keybindings to move around: `k, j, k, l` and the cursor keys. - If you are in the insert mode, you must type `Esc`-key first to change into the normal mode. - Use `h` to go left, `j` to go down, `k` to go up and `l` to go right. - - See `:Tutor` to know how to use Neovim and its keybindings. - - To move around buffers press `SPC - b` to select the `Buffers` section of keybindings and then press - the key `g` to select a buffer or press `TAB` to cycle buffers. - - ** Configuration - Doom Nvim offers easy access to the dynamic reconfiguration of some key editor featurs, such as - console background to be dark or light, auto-completion to be on or off, autopairs to be on or - off, indentation step width, line number display style, spell checker to be on or off, and more. - For these, press `SPC - t` and select the desired configuration item by another key stroke. - - The Doom Nvim configuration files resides under the `$HOME/.config/nvim` directory by default. - See [Hacking Doom Nvim](**Hacking Doom Nvim) for more information. - - *** Modules - Doom Nvim consists of around `6` modules. A Doom Nvim module is a bundle of plugins, - configurations and commands, organized into a unit that can be toggled easily. - - To give a quick summary, the modules are as follows: - - UI, everything related to Neovim UI. - - Doom, neorg and built-in plugins. - - Editor, everything related to editing, e.g. tree explorer, git signs, lsp, debugging. - - Langs, languages support for Doom, languages servers and debuggers. - - Utilities, some utility plugins like `neogit`. - - Web, web development related plugins like `rest.nvim`. - - You can see in a more detailed view the modules and its plugins at [modules.md](https://github.com/NTBBloodbath/doom-nvim/blob/main/docs/modules.md). - - **** Tweaking modules - For persistently tweaking a module (enable / disable its plugins) you will only need to - comment or uncomment the desired plugin, e.g. for disabling the tree explorer you will only - need to comment it. - -@code lua - -- Right now the Tree explorer is enabled - "explorer", - - -- Now the Tree Explorer is disabled - -- "explorer", -@end - - *NOTE*: after doing changes to your modules you will only need to restart Neovim - and Doom Nvim will automatically handle your changes on here. - - *** Custom plugins - To use your own plugins in Doom Nvim you can use the `doom_userplugins.lua` file located - in the Doom Nvim root directory (`$HOME/.config/nvim` by default). - - To add plugins without extra configurations (e.g. if a plugin does not depends on other plugins), - you can simply set it as follow: - -@code lua - M.plugins = { - "andweeb/presence.nvim", - } -@end - - Otherwise, if your plugin depends on other or you do not want to enable it then you can - do it as follow: - -@code lua - M.plugins = { - { - "andweeb/presence.nvim", - -- Plugin dependencies - requires = { - "JohnDoe/foo" +Doom Nvim is a Neovim interpretation of the {https://github.com/hlissner/doom-emacs}[doom-emacs] framework, adapted to Vim philosophy. + +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 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). +* Configuring doom-nvim +** Modules + A module is a collection of packages, autocommands, keybinds and functions + that add new capabilities or functionality to Doom Nvim. We organise modules + into 2 categories: + - `features` extend the abilities of Doom Nvim by adding new functionality. + - `langs` add support for new languages. + +*** Enabling / disabling modules + You can enable or disable a module by going to `modules.lua` (`Dm`) + and commenting or uncommenting the entry. + + @code lua + -- modules.lua + return { + features = { + 'lsp' + -- 'telescope' }, - -- Disable plugin - disable = true, - }, - } -@end - - *NOTE*: if you are familiar with [packer.nvim](https://github.com/wbthomason/packer.nvim) then you can see that the `doom_userplugins.lua` file - is just a wrapper for it. - - *** Language Server Protocols - To easily install language servers and without having to do it system-wide or having to manually - configure servers, Doom Nvim makes use of [nvim-lspinstall](https://github.com/kabouzeid/nvim-lspinstall). - - To enable the language server for a certain programming language and automatically install it, - just append a `+lsp` flag at the end of the language field in your `doom_modules.lua`, - e.g. for enabling Rust support in Doom Nvim and install `rust-analyzer`: - -@code lua - M.modules = { - langs = { - "rust +lsp", -- Let's get rusty! - }, - } -@end - - *NOTE*: You can see a list of currently supported languages at [bundled installers](https://github.com/kabouzeid/nvim-lspinstall#bundled-installers). + langs = { + 'lua', + -- 'rust', + } + } + @end - ** Autocompletion - Doom Nvim uses the [built-in LSP](https://neovim.io/doc/user/lsp.html) plus [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) plugin as completion engine. + *NOTE*: after doing changes to your modules you will only need to restart Neovim + and Doom Nvim will automatically handle your changes on here. - Use `` to select the next suggestion and `` to select the current one. - - Autocompletion for parenthesis can be disabled by disabling the [nvim-autopairs](https://github.com/windwp/nvim-autopairs) - plugin (see [Tweaking modules](***Tweaking modules) for more information). - - ** Colorscheme - The colorscheme of Doom Nvim. Default is `doom-one`. There are some additional - doom emacs' colorschemes port for Neovim that can be enabled by uncommenting - the `doom-themes` entry in your `doom_modules.lua`. - - You can switch between colorschemes by doing `SPC - d - s` and then type the name - of the colorscheme you want to use. You can also edit the `doom_config.lua` - file located at `$HOME/.config/nvim` (see [Hacking Doom Nvim](**Hacking Doom Nvim)). - - *NOTE*: If you exit Neovim and you changed the colorscheme then Doom Nvim will automatically - update the `doom_config.lua` file to use the new colorscheme on next launch. - - ** Layout - Excluding the statusline and the tabline, Doom Nvim will mostly have the - following layout: - - ┌─────┬────────────────────┬────┬──────┐ - │ │ │ │ │ - │ │ │ │ │ - │ │ │ │ │ - │ A* │ B │ D* │ E* │ - │ │ │ │ │ - │ │ │ │ │ - │ │ │ │ │ - │ ├────────────────────┤ │ │ - │ │ C* │ │ │ - └─────┴────────────────────┴────┴──────┘ +*** Custom plugins + See the documentatition in {| Adding plugins} - Where: - - 'A' is the file explorer (plugin: [nvim-tree.lua](https://github.com/kyazdani42/nvim-tree.lua)) - - 'B' is the main buffer - - 'C' is the terminal (plugin: [toggleterm.nvim](https://github.com/akinsho/toggleterm.nvim)) - - 'D' is the minimap (plugin: [minimap.vim](https://github.com/wfxr/minimap.vim)) - - 'E' is the symbol outline (plugin: [symbols-outline.nvim](https://github.com/simrat39/symbols-outline.nvim)) - - *NOTE*: Sections with `*` are not opened by default but can be toggled. - See [Commands](**Commands) for more information. - - *** File Explorer - Doom Nvim uses the `nvim-tree.lua` plugin as a file explorer. It can be toggled by - running the following keybinds: - - `SPC - o - e` - - `` - - To create a new file within the file explorer, press `a` and type the name of the - file. Append a `/` at the end if you want to create a directory. - - Check [nvim-tree.lua repository](https://github.com/kyazdani42/nvim-tree.lua) for more information. - - *** Main Buffer - The main buffer is the buffer where the code is opened. - - To split the main buffer, do `SPC - w` and then select the split method you - want to use horizontally (`s`), or vertically (`v`). - - *** Terminal - The terminal is placed like in others editors, e.g. Visual Studio Code. The - buffer of the terminal is automatically set to `INSERT` mode. - - The only way to close it is to enter `exit` to close the shell session, or if you - just want to toggle it, you can use the following keybinds: - - `SPC - o - t` (only `NORMAL` mode!) - - `` - - Check [toggleterm.nvim repository](https://github.com/akinsho/toggleterm.nvim) for more information. - - *** Minimap - Doom Nvim uses `wfxr/minimap.vim` plugin as its minimap. It can be toggled by - performing the following keybinds: - - `SPC - o - m` - - `` - - Check [minimap.vim repository](https://github.com/wfxr/minimap.vim) for more information. - - *** Outline - `Symbols-Outline` is a plugin that can show the tags and structure of the opened - file, ordered by its scope. - - For this function, Doom Nvim makes use of `simrat39/symbols-outline.nvim`. - It can be toggled by performing the following keybinds: - - `SPC - o - s` - - `` - - Check [symbols-outline.nvim repository](https://github.com/simrat39/symbols-outline.nvim) for more information. - - ** Commands - Doom Nvim has its own commands, to make your life easier when developing on it. - - ┌──────────────────┬────────────────────────────────────────────────┐ - │Command │ Description │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomUpdate │ Update Doom Nvim if there are updates │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomRollback │ Rollback Doom Nvim to a previous version │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomManual │ Open Doom Nvim User Manual │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomConfigs │ Open a selection menu to edit Doom configs │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomConfigsReload │ Reload user-defined keybindings, etc │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomReload │ Reload Doom Nvim and simulate a new Neovim run │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomReport │ Create a Doom Nvim markdown crash report │ - ├──────────────────┼────────────────────────────────────────────────┤ - │DoomInfo │ Open Doom Nivm information dashboard │ - └──────────────────┴────────────────────────────────────────────────┘ - - Doom Nvim also uses [which-key.nvim](https://github.com/folke/which-key.nvim) as a commands manager, inspired by emacs' guide-key. - To open it, press `SPC` and wait for the popup to show, it should not take much time. - Each section has a label and is mnemonic, e.g. - - `Open Terminal` > `SPC - o - t` - - There are multiple sections for Doom Nvim commands. Those sections create a path in the - decision tree that identifies any command. - - Let's say you want to go to the next buffer you are working on. You will need to perform - the following keystrokes: - - `SPC - b` - - In order to open the `Buffers` section. There we want to go to the next buffer. - - `SPC - b - n` - - Finally, we changed our current buffer to the next one in our workspace. You can see more - keybindings in [Keybindings](**Keybindings). - - ** Keybindings - In Doom Nvim, we make use of the `SPC` keystroke as the map leader. - - This is the list of all Doom Nvim leader mappings, `SPC` is omitted here to avoid redundancy. - - ┌─────────────────────┬────────────────────────────────────────────────────┐ - │ Keybind │ Description │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ , │ Switch buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ . │ Browse files │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ / │ Search │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ : │ Command history │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ ` │ Find file │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ h │ Man pages │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ m │ Save │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ v │ Save │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - [ │ Previous buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - ] │ Next Buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - b │ Switch to other buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - c │ Close current buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - f │ Format buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - g │ Goto buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - n │ Next buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ b - p │ Previous buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - b │ Compile project │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - c │ Compile and run project │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - d │ +debug │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - d - e │ Evaluate word under cursor │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - d - s │ Evaluate selection │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - h │ Run rest client on the line that the cursor is │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - i │ Start a REPL │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - r │ Run current file │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l │ +lsp │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l - a │ Code actions │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l - d │ Show type definition │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l - i │ Lsp info │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l - L │ Diagnostics into location list │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ c - l - l │ Show line diagnostics │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - c │ Edit your Doom Nvim configurations │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - d │ Open Doom Nvim documentation │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - i │ Open Doom Nivm information dashboard │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - R │ Create crash reports, useful for debugging issues │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - r │ Rollback Doom Nvim version │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - s │ Change colorscheme │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ d - u │ Update Doom Nvim │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - c │ Edit Neovim configurations │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - f │ Find files │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - n │ New unnamed buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - R │ Re-open an unreadable file with sudo permissions │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - r │ Recently opened files │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - t │ Help tags │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ f - w │ Write an unwritable file with sudo permissions │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - B │ Branches │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - b │ Blame line │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - c │ Commits │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - h │ Preview hunk │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - R │ Reset buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - r │ Reset hunk │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - o │ Open LazyGit │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - l │ Pull │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - p │ Push │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - S │ Stage hunk │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - s │ Status │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - u │ Undo stage hunk │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - a │ Alternate file │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - j │ Jump back │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - k │ Jump forward │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - p │ Pop tag stack │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - t │ Jump to tag │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ o - d │ Start screen │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ o - e │ Tree Explorer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ o - m │ Minimap │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ o - s │ LSP Symbols │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ o - t │ Terminal │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - C │ Compile your plugins changes │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - c │ Clean unused plugins │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - i │ Install missing plugins │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - p │ Profile the time taken loading your plugins │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - S │ Sync plugins (runs Clean and Update) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ p - s │ Plugins status │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ q - q │ Quit Neovim │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ q - r │ Restore previously saved session │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ q - w │ Save and quit Neovim │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ s - b │ Buffer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ s - g │ Grep │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ s - h │ Command history │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ s - m │ Jump to mark │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ s - s │ Goto symbol │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - - │ Tweak Neovim behavior │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - b │ Toggle background light/dark │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - c │ Turn on and off completion if available │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - g │ Turn on and off signcolumn for gitsigns, ... │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - i │ Set tabstop and indent steps to any integer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - n │ Change line number display (4 types) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - p │ Turn on and off autopairs if available │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - s │ Spell check on/off │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ t - x │ Syntax/treesetter on/off │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - - │ Split window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - = │ Balance windows size │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - | │ Split window right │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - 2 │ Layout double columns │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - d │ Delete window │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - H │ Expand window left │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - h │ Window left │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - J │ Expand window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - j │ Window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - K │ Expand window up │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - k │ Window up │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - L │ Expand window right │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - l │ Window right │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - s │ Split window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - v │ Split window right │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ w - w │ Other window │ - └─────────────────────┴────────────────────────────────────────────────────┘ - - But there is still more, Doom Nvim knows that you love to use the keyboard but you do not - like to be typing so much so it has more keybindings that will make your life easier! - - | The following keybindings does not use the leader key. - - ┌─────────────────────┬────────────────────────────────────────────────────┐ - │ Keybind │ Description │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ TAB │ Cycle buffers (next buffer) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Shift - TAB │ Cycle buffers (prev buffer) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ ESC │ Search highlighting off │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F2 │ Toggle Symbols-Outline │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F3 │ Toggle Tree Explorer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F4 │ Toggle Terminal │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F5 │ Toggle Minimap │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F6 │ Toggle Zen mode │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ F7 │ Run rest client on current cursor position │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Z - Z │ Toggle Symbols-Outline │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ j - k │ Toggle Tree Explorer │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - c - c │ Comment current line (NORMAL mode) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ g - c │ Comment selected block (VISUAL mode) │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + h │ Select window left │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + j │ Select window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + k │ Select window up │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + l │ Select window right │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + Up │ Resize window up │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + Down │ Resize window below │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + Left │ Resize window left │ - ├─────────────────────┼────────────────────────────────────────────────────┤ - │ Control + Right │ Resize window right │ - └─────────────────────┴────────────────────────────────────────────────────┘ - - You can modify the default keybindings by modifying the following files: - - General keybindings: `lua/doom/extras/keybindings/init.lua` - - Plugins keybindings: `lua/doom/modules/config` - - which-key keybindings: `lua/doom/modules/config/doom-whichkey.lua` - - *NOTE*: You can also make your own keybindings or override the default ones - by editing your `doom_config.lua` file. If you override, you need to update which-key - keybindings to make it work properly. This is known issue. - - ** Hacking Doom Nvim - Doom Nvim aims to be hackable to suit everyone's needs. Therefore this is the structure of Doom Nvim: - -@code - . -> Doom Nvim root - ├── colors -> Pre-installed colorschemes directory - │ └── doom-one.lua -> doom-one colorscheme ported to Nvim (default one) - ├── doc -> Docs to be used inside Nvim - │ └── doom_nvim.norg -> Doom Nvim User Manual - ├── docs -> Docs meant to be read on GitHub - ├── doom_modules.lua -> Doom modules configurations file - ├── doom_config.lua -> Doom main configurations file - ├── doom_userplugins.lua -> User defined plugins - ├── init.lua -> Init file - ├── LICENSE -> License - └── lua -> Location of Doom Nvim Lua files - ├── doom -> Doom Nvim core - │ ├── core -> Doom Nvim core functionality - │ │ ├── config -> Doom Nvim configuration files - │ │ ├── settings -> Doom Nvim Neovim settings - │ │ ├── functions -> Doom Nvim functions - │ │ └── system -> Doom Nvim system utilities - │ ├── extras -> Doom Nvim extra functionalities - │ │ ├── autocmds -> Doom Nvim autocommands - │ │ ├── keybindings -> Doom Nvim keybindings - │ │ └── logging -> Doom Nvim logging system - │ └── utils -> Doom Nvim utilities - └── modules -> Location of Doom Nvim plugins - ├── configs -> Plugins configurations - ├── built-in -> Doom Nvim built-in plugins - └── init.lua -> packer.nvim setup -@end - -* Known issues - Nothing here but chickens ... - - *NOTE*: If you are facing an undocummented issue, feel free to [open an issue](https://github.com/NTBBloodbath/doom-nvim/issues/new) at Doom Nvim repository on - GitHub and we will try to fix it together! - -* FAQ - ** General - *** Who is Doom Nvim intended for? - Doom Nvim is intended for anyone who wants a stable and efficient - development environment that just works without spending a lot of time setting everything up. - - ** Workaround - *** Missing nvim help documentation - Since Doom Nvim extensively uses delayed loading of packages, their help documentation may not - show up under `LOCAL ADDITIONS:`. If this happens and you still wish to see them, you need to - make copies or symlinks of the help documentation of the affected packages in `doc/` of Doom - Nvim and update help tags file manually with `:helptags ALL` . - -* Acknowledgements - Doom Nvim would not have been possible had it not been for - - hlissner, creator of Doom Emacs - - All our contributors +*** Customising the behaviour of modules + Sometimes you'll want to edit the default behaviour of the modules, please + see {| Configuring modules}. + +** Config + Doom-nvim provides a number of config options, including easier to use versions of vim's own options. See all available config options in the {| Config API Reference }. + + @code 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 + + @end + + > **NOTE:** If you have the `lua` language and `lsp` module enabled all of these options will be autocompleted. + +*** Adding Plugins + Additional packages can be imported with the `doom.use_package()` function. + This is a wrapper around `packer.use()` and provides the same API. {https://github.com/wbthomason/packer.nvim#quickstart}[DOCS] + @code lua + -- config.lua + + -- Simple config + doom.use_package('sainnhe/sonokai', 'EdenEast/nightfox.nvim') + + -- Advanced config + doom.use_package({ + 'rafcamlet/nvim-luapad', + opt = true, + cmd = 'Luapad' + }) + @end + +*** Adding keybinds + Additional keybinds can be defined with the `doom.use_keybind()` function. + This is a wrapper around a custom `nest.nvim` implementation and provides + the same API. {https://github.com/connorgmeehan/nest.nvim/tree/integrations-api#quickstart-guide}[DOCS] + + @code lua + -- config.lua + + doom.use_keybind({ + { 'u', name = '+user', { -- Names this group in whichkey "+user" + { 's', 'Telescope git_status', name = 'Git status' } -- Adds `us` keybind to trigger `Telescope git_status` + }}, + }) + @end + > **NOTE:** By providing the `name` field your custom keybinds will show up in `whichkey` and `mapper` if you have those modules enabled. + + +*** Adding commands + Additional commands can be define with the `doom.use_cmd()` function. + + @code lua + -- config.lua + + -- Bind single + doom.use_cmd( { 'Test', function() print('test') end } ) + + -- Bind multiple + doom.use_cmd({ + { 'Test1', function() print('test1') end }, + { 'Test2', function() print('test2') end }, + }) + @end + + +*** Configuring modules + 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. + + Make sure that the module that you want to configure/override is enabled in `modules.lua` + @code lua + -- modules.lua + return { + features = { + 'whichkey' -- Whichkey module is enabled + } + } + @end + + The same module with be avaliable in your `config.lua` in the `doom.features.module_name` field. + The settings should have autocomplete from sumneko lua lsp. + @code lua + -- config.lua + local whichkey = doom.features.whichkey -- Get the whichkey module + -- You can also access it as `doom.modules.features.whichkey` + + -- 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.autocmds, { "event", "aupat", "cmd"}) + -- Replace all autocommands + whichkey.autocmds = { + { "event", "aupat", "cmd"} + } + + -- Modify the plugin source repo, plugins are indexed via the repository name. + whichkey.packages["which-key.nvim"] = { + "myfork/which-key.nvim" + } + -- Provide a different config function, the key has to match the entry in `whichkey.packages` + whichkey.configs["which-key.nvim"] = function () + local wk = require("which-key") + end + + -- Another example with a language module + local lua = doom.langs.lua + + -- Disable lua-dev loading library definitions + lua.settings.dev.library.plugins = false + @end + + +*** Overriding modules or adding custom modules + + It's possible to add your own doom modules or completely replace builtin doom + modules without editing the original files. Doom will first check the `lua/user/modules` + directory if a module exists before loading the default from `lua/doom/modules`. + + As an example, if we wanted to replace the `lua` module in the `langs` section we + would create a new file at `lua/user/modules/langs/lua/init.lua`. + + Alternatively if we wanted to add support for a new language (lets use julia as + an example) we would create a new file at `lua/user/modules/langs/julia/init.lua`. + You would then enable the module in `modules.lua` + + @code lua + --- modules.lua + return { + langs = { + 'julia', + } + } + @end + + > For more info, read the {:./doom_nvim_modules:# Building your own module} docs. * Contributing - I really love pull requests and bug reports, please see the [Contributing Guidelines](https://github.com/NTBBloodbath/doom-nvim/blob/main/docs/contributing.md) on GitHub + I really love pull requests and bug reports, please see the {https://github.com/NTBBloodbath/doom-nvim/blob/main/docs/contributing.md}[Contributing Guidelines] on GitHub before contributing. Don't hesitate to tell me my Lua coding style sucks, but please tell me why. @@ -637,6 +238,4 @@ * License Doom Nvim is distributed under GPLv2 license. - -$comment vim:sw=2:ts=2:cole=3:cocu=n:tw=100:norl: diff --git a/doc/doom_nvim_modules.norg b/doc/doom_nvim_modules.norg new file mode 100644 index 000000000..fe93d08b2 --- /dev/null +++ b/doc/doom_nvim_modules.norg @@ -0,0 +1,653 @@ +@document.meta +title: doom_nvim_modules +description: +authors: connormeehan +categories: +created: 2022-07-29 +version: 0.0.11 +@end + += TOC Table of Contents + +* Table of Contents +-> {# Introduction} +-> {# All modules} +-> {# `core` modules} +---> {# `features` modules} +---> {# `langs` modules} +-> {# Configuring modules} +---> {# Quick Guide} +---> {# Advanced guide} +----> {# Module lifecycle} +----> {# Limitations} +-----> {# Direct plugin access} +-----> {# Conditional keybinds and autocommands} +----> {# Module spec} + -> {# Building your own module} +---> {# 1. Setting up} +---> {# 2. Adding autocommands} +---> {# 3. Enabling and testing your module} +---> {# 4. Adding the character counter} +---> {# 5. Adding commands to get and reset the count} +---> {# 6. Adding keybinds} +---> {# 7. Adding and lazyloading a plugin} +---> {# 8. Exposing settings to the user} +---> {# 9. Contributing your module upstream} +---> {# 10. You're done! Final output} +* Introduction + + Doom Nvim consists of around 40 modules and growing. + A Doom Nvim module is a bundle of packages, configurations, autocommands and + binds, organized into a unit that can be toggled easily. + + 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\* + -- {@ ../lua/doom/modules/features/annotations/init.lua}[annotations] Add code documents/annotations + -- {@ ../lua/doom/modules/features/auto_install/init.lua}[auto_install] Auto install LSP providers + -- {@ ../lua/doom/modules/features/autopairs/init.lua}[autopairs] Automatically close character pairs + -- {@ ../lua/doom/modules/features/comment/init.lua}[comment] Generate comments in any language. + -- {@ ../lua/doom/modules/features/linter/init.lua}[linter] Format and lint your code + -- {@ ../lua/doom/modules/features/snippets/init.lua}[snippets] Code snippets for all languages + + - **Editor modules** + -- {@ ../lua/doom/modules/features/auto_session/init.lua}[`auto_session`] Return to previous sessions + -- {@ ../lua/doom/modules/features/colorizer/init.lua}[`colorizer`] Show colors in editor + -- {@ ../lua/doom/modules/features/editorconfig/init.lua}[`editorconfig`] .editorconfig file support + -- {@ ../lua/doom/modules/features/gitsigns/init.lua}[`gitsigns`] Show changes near linenumber + -- {@ ../lua/doom/modules/features/illuminate/init.lua}[`illuminate`] Highlight other occurances of the hovered word + -- {@ ../lua/doom/modules/features/indentlines/init.lua}[`indentlines`] Explicitly show indentation + -- {@ ../lua/doom/modules/features/range_highlight/init.lua}[`range_highlight`] Highlight selected range as you type commands + -- {@ ../lua/doom/modules/features/todo_comments/init.lua}[`todo_comments`] Highlights TODO comments and more + - **UI modules** + -- {@ ../lua/doom/modules/features/fidget/init.lua}[`fidget`] Shows LSP loading status + -- {@ ../lua/doom/modules/features/tabline/init.lua}[`tabline`] Tabbed buffer switcher + -- {@ ../lua/doom/modules/features/dashboard/init.lua}[`dashboard`] A pretty dashboard upon opening doom--nvim. + -- {@ ../lua/doom/modules/features/trouble/init.lua}[`trouble`] A pretty diagnostics viewer + -- {@ ../lua/doom/modules/features/minimap/init.lua}[`minimap`] Shows current position in document + -- {@ ../lua/doom/modules/features/whichkey/init.lua}[`whichkey`] An interactive keybind cheatsheet + -- **Tool modules** + -- {@ ../lua/doom/modules/features/dap/init.lua}[`dap`] Debug adapter protocol for neovim + -- {@ ../lua/doom/modules/features/explorer/init.lua}[`explorer`] File explorer in the sidebar + -- {@ ../lua/doom/modules/features/neorg/init.lua}[`neorg`] Organise your life + -- {@ ../lua/doom/modules/features/netrw/init.lua}[`netrw`] Native file explorer in the sidebar + -- {@ ../lua/doom/modules/features/telescope/init.lua}[`telescope`] Search files, text, commands and more + -- {@ ../lua/doom/modules/features/projects/init.lua}[`projects`] Quick project switching + +*** `langs` modules + + - {@ ../lua/doom/modules/langs/lua/init.lua}[`lua`] Lua language support, we recommend keeping this enabled as it also provides LSP completion for all config options. + - {@ ../lua/doom/modules/langs/python/init.lua}[`python`] + - {@ ../lua/doom/modules/langs/bash/init.lua}[`bash`] + - {@ ../lua/doom/modules/langs/javascript/init.lua}[`javascript`] + - {@ ../lua/doom/modules/langs/typescript/init.lua}[`typescript`] + - {@ ../lua/doom/modules/langs/css/init.lua}[`css`] + - {@ ../lua/doom/modules/langs/vue/init.lua}[`vue`] + - {@ ../lua/doom/modules/langs/tailwindcss/init.lua}[`tailwindcss`] + - {@ ../lua/doom/modules/langs/svelte/init.lua}[`svelte`] + - {@ ../lua/doom/modules/langs/rust/init.lua}[`rust`] + - {@ ../lua/doom/modules/langs/cpp/init.lua}[`cpp`] + - {@ ../lua/doom/modules/langs/c_sharp/init.lua}[`c_sharp`] + - {@ ../lua/doom/modules/langs/kotlin/init.lua}[`kotlin`] + - {@ ../lua/doom/modules/langs/java/init.lua}[`java`] + - {@ ../lua/doom/modules/langs/go/init.lua}[`go`] + - {@ ../lua/doom/modules/langs/config/init.lua}[`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.features` 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. + + @code lua + --- config.lua + + -- Here `comment_module` is just a reference to `../lua/doom/modules/features/comment/init.lua` + local comment_module = doom.features.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"} + } + @end + + > **NOTE:** If you have the `lua` language module and `lsp` feature module enabled, + all of these properties should be auto completeable. + +*** 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.features|doom.langs|doom.core` 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 + +***** 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. + + @code lua + --- config.lua + + local lsp = doom.langs.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 + @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. + + @code lua + -- config.lua + + print(type(doom.features.lsp.binds)) -- "table" (not conditional) + print(vim.inspect(doom.features.lsp.binds)) -- Shows config + print(type(doom.features.telescope.binds)) -- "function" (adds extra keybinds if "lsp" module is enabled) + print(vim.inspect(doom.features.telescope.binds())) -- You must execute the function to see the config. + @end + +**** Module spec + + These are the possible fields a module might have. + + @code 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 + @end + + @code lua + local example = {} + + example.settings = {...} -- Doom-nvim provided object to change settings + + -- Stores the packer.nvim config for all of the plugin dependencies + example.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. + } + } + + example.configs = { + ["example-plugin.nvim"] = function() -- key matches `example.packages` entry + require('example-plugin').setup( doom.features.example.settings ) -- Consumes `example.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 + example.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. + example.binds = function() + local binds = { ... } + if doom.features.other_module then + table.insert(binds, { + 'ff', function() print('this is a conditional keybind') end, name = 'My conditional keybind' + }) + end + return binds + end + + -- Autocmds are defined as a table with the following syntax + -- { "event", "aupat", "command or function" } + -- Example + example.autocmds = { + { "BufWinEnter", "*.js", function() print("I'm in a javascript file now") end } + } + -- Similarly, autocmds can be conditional using a function + example.autocmds = function() + local autocmds = {} + if condition then + table.insert(autocmds, { "BufWinEnter", "*.js", function() print("I'm in a javascript file now") end }) + end + return autocmds + end + @end + +* 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: + - 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 + + > 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. + + For our example of adding char counting plugin I will create a folder called `lua/user/modules/features/char_counter/` + and create a new `init.lua` inside of it. + @code lua + -- lua/user/modules/features/char_counter/init.lua + local char_counter = {} + + return char_counter + @end + +*** 2. Adding autocommands + + Autocommands are set using the `module_name.autocmds` field. And follow the structure of + @code lua + module_name.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. + + @code lua + -- lua/user/modules/features/char_counter/init.lua + char_counter.autocmds = { + { "InsertEnter", "*", function () + print('Entered insert mode') + end}, + { "InsertLeave", "*", function () + print('Exited insert mode') + end}, + } + @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. + + @code lua + -- modules.lua + return { + features = { + 'char_counter', + }, + } + @end + +*** 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. + + @code lua + -- lua/user/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 + @end + +*** 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. + + @code lua + -- lua/user/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} + } + @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. + + @code lua + -- lua/user/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` + } } + } + @end + > **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.packages` 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.packages` 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. + + @code lua + -- lua/user/modules/features/char_counter/init.lua + + -- Add these two fields to `char_counter` at the top of the file. + char_counter.packages = { + ["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. + -- The only way to access the `char_counter` object is via `doom.features.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} + } + @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. + + + @code lua + -- lua/user/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} + } + @end + +*** 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. + @code lua + return { + features = { + "lsp" -- Maps to `lua/doom/modules/features/lsp/`, + }, + langs = { + "lua" -- Maps to `lua/doom/modules/langs/lua/` + } + } + @end + + 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. + + @code lua + -- lua/user/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.packages = { + ["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 + @end diff --git a/docs/README.md b/docs/README.md index a30c3373b..eb59c93fb 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,35 +1,17 @@ # Doom Nvim Documentation -Doom Nvim is a port to Neovim of the [Doom Emacs](https://github.com/hlissner/doom-emacs) -configuration framework for [GNU Emacs](https://www.gnu.org/software/emacs/) adapted -for all vimmer who want less framework in their framework and the performance of -a handmade configuration (or better). It can be a base for your own setup or a -resource for Neovim enthusiasts to learn more about our favorite editor and how to -do X things on it by using Lua. - -Doom Nvim is an opinionated collection of reasonable (and optional) defaults with -a focus on performance (both runtime and startup) and on abstraction-light, readable -code design, so that there is less between you and Neovim. - > The documentation is designed to be viewed within Doom Nvim. Access it by pressing > `:h doom_nvim`. ## Documentation -### Getting Started - -- [Install](./getting_started.md#install) -- [Update & Rollback](./getting_started.md#update--rollback) -- [Configuration](./getting_started.md#configuration) - -### Modules - -- [Introduction](./modules.md#introduction) -- [Tweaking Doom Nvim Modules](./modules.md#tweaking-doom-nvim-modules) +- [All Modules](./modules.md#all-modules) +- [Configuring modules](./modules.md#quick-guide) +- [Buidling/contributing your own modules](./modules.md#building-your-own-module) +- [API Reference](./api.md) :warning: Not yet implemented. Refer to comments in [doom_global.lua](../lua/doom/core/doom_global.lua) ### Contributing -- [Where can I help?](./contributing.md#where-can-i-help) - [Reporting issues](./contributing.md#reporting-issues) - [Suggesting features, keybinds and enhancements](./contributing.md#suggesting-features-keybinds-and-enhancements) - [Contributing code](./contributing.md#contributing-code) @@ -39,7 +21,3 @@ code design, so that there is less between you and Neovim. ### Asking for help - [Our issues tracker](https://github.com/NTBBloodbath/doom-nvim/issues) - -### Projects - -- [Projects](https://github.com/NTBBloodbath/doom-nvim/projects) diff --git a/docs/contributing.md b/docs/contributing.md index 6f025a9f4..e3d721dd4 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -32,7 +32,7 @@ will have less settings and plugins than you personal branch and therefore it wi not work as expected otherwise. Eg. you will see 'Dashboard' text on vim load instead of 'Doom'. -> Alternatively you can setup an isolated dev environment for contributing using our docker image [here](../contribute/README.md#doom-contrib-docker-image-start_dockersh). +> Alternatively you can setup an isolated dev environment for contributing using our docker image [here](../tools/README.md#doom-contrib-docker-image-start_dockersh). ## Reporting issues @@ -100,9 +100,7 @@ quote_style = "AutoPreferDouble" #### Commits & PRs -- Target `develop` instead of `main`. - The only exception are hotfixes (plugins breaking changes, Doom bugs) - and documentation improvements! +- Target the `main` branch. #### Keybind conventions @@ -121,10 +119,10 @@ your pull request :) ### Tools -A range of tools for contributors are currently housed in the `contribute/` folder. -Read the detailed [documentation](../contribute/README.md). +A range of tools for contributors are currently housed in the `tools/` folder. +Read the detailed [documentation](../tools/README.md). #### Notable Tools - - [`contribute/start_docker.sh`](../contribute/README.md#doom-contrib-docker-image-start_dockersh) Sets up a dev environment for contributing to doom-nvim. Creates a git worktree to make changes and a docker image to test them within. + - [`tools/start_docker.sh`](../tools/README.md#doom-contrib-docker-image-start_dockersh) Sets up a dev environment for contributing to doom-nvim. Creates a git worktree to make changes and a docker image to test them within. diff --git a/docs/faq.md b/docs/faq.md deleted file mode 100644 index 17203bc81..000000000 --- a/docs/faq.md +++ /dev/null @@ -1,20 +0,0 @@ -# Frequently Asked Questions - -## General - -### What type of vimmer is Doom Nvim intended for? - -Doom Nvim is intended for all types of Vimmers who want a stable and efficient -development environment without spending a lot of time setting everything up. - -### Why does Doom Nvim only support Neovim 0.5+? - -Doom Nvim doesn't support Neovim versions lower than the current stable (0.5) -due big plugin incompatibilities and performance differences, which would make -the experience not worth it. - -### How to version control Doom Nvim? - -Doom Nvim makes use of an internal variable called `doom_configs_root` that points -to `/home/user/.config/doom-nvim` path by default. This allows you to move your -configuration files to this path so you can version control your doom setup too. diff --git a/docs/getting_started.md b/docs/getting_started.md deleted file mode 100644 index fd6ffa894..000000000 --- a/docs/getting_started.md +++ /dev/null @@ -1,375 +0,0 @@ -# Getting Started - -## Install - -This is what you will have installed by the end of this section: - -- 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), - improves performance for many file indexing commands -- **Optional**: node & npm, required to use some Language Server Protocols (LSP) and packages using LSP, like the symbols-outline plugin. - -These packages should to be available through the package managers of your OS; -i.e. pacman/aptitude/rpm/etc on the various Linux distributions. - -### Neovim & dependencies - -#### On Linux - -Neovim 0.5.0 was recently released as a stable version. -You can check what version your repository has by looking at [this site.](https://repology.org/project/neovim/versions) -If Neovim 0.5.0 is still not available in your repository, you can install it by doing one of the following: - -1. Using extra repositories according to your distribution (PPA/COPR/AUR/etc). - -2. Using a Neovim version manager like [nvenv](https://github.com/NTBBloodbath/nvenv). - -##### Ubuntu - -You can get nightly builds of git master from the -[Neovim Unstable PPA](https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable). - -```sh -add-apt-repository ppa:neovim-ppa/unstable -apt-get update -``` - -##### Fedora - -Nightly builds can be installed by using the -[agriffis/neovim-nightly](https://copr.fedorainfracloud.org/coprs/agriffis/neovim-nightly/) -COPR repository. - -```sh -dnf copr enable agriffis/neovim-nightly -dnf update -``` - -##### Arch - -Neovim Nightly builds can be installed using the PKGBUILD -[`neovim-nightly-bin`](https://aur.archlinux.org/packages/neovim-nightly-bin), -available on the [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository). - -#### On MacOS - -You can download a prebuilt binary from the [Neovim](https://github.com/neovim/neovim/releases/tag/nightly) releases page. - -1. Download: `curl -LO https://github.com/neovim/neovim/releases/download/v0.5.0/nvim-macos.tar.gz` -2. Extract: `tar xzvf nvim-macos.tar.gz` -3. Run: `./nvim-osx64/bin/nvim` - -You may wish to add it to your PATH using something like: -`export PATH="$HOME/nvim-osx64/bin:$PATH"` - -Neovim nightly can also be downloaded with [homebrew](https://brew.sh/): - -`brew install --HEAD neovim` will download the source and build it locally on your machine. - -If you already have Neovim v0.4 installed you may need to unlink it. - -``` -brew unlink neovim -brew install neovim --HEAD -nvim --version -``` - -MacPorts currently only has Neovim v0.4.4 - -#### On Windows - -> **NOTE**: new module architecture is pending tests on Windows. - -##### [Chocolatey](https://community.chocolatey.org/) - -``` -choco install neovim --pre -``` - -##### [Scoop](https://scoop.sh/) - -``` -scoop bucket add versions -scoop install neovim-nightly -``` - -##### Manual - -1. Download a prebuilt binary from the [Neovim](https://github.com/neovim/neovim/releases) releases page. -2. Unpack the binary -3. Move and symlink to somewhere in your path - -```sh -# unpack the binary -tar xzvf nvim-linux64.tar.gz - -# create a directory to store the unpacked folder -sudo mkdir /opt/nvim - -# move the unpacked binary -sudo mv nvim-linux64 /opt/nvim - -# add the neovim executable to somewhere in your path -# ex: /usr/bin OR $HOME/.local/bin -sudo ln -s /opt/nvim/nvim-linux64/bin/nvim /usr/bin/nvim - -# should print /usr/bin/nvim -which nvim - -# should print NVIM 0.5 -nvim --version -``` - -``` -# unpack the binary -tar xzvf nvim-linux64.tar.gz - -# create a directory to store the unpacked folder -sudo mkdir /opt/nvim - -# move the unpacked binary -sudo mv nvim-linux64 /opt/nvim - -# add the neovim executable to somewhere in your path -# ex: /usr/bin OR $HOME/.local/bin -sudo ln -s /opt/nvim/nvim-linux64/bin/nvim /usr/bin/nvim - -# should print /usr/bin/nvim -which nvim - -# should print NVIM 0.5 -nvim --version -``` -### External dependencies - -#### On Linux - -##### Ubuntu - -```sh -# Required dependencies -apt-get install git ripgrep - -# (Optional) Improves performance for many file indexing commands -apt-get install fd-find - -# (Optional) Required by some Language Server Protocols -apt-get install nodejs npm -``` - -##### Fedora - -```sh -# Required dependencies -dnf install git ripgrep - -# (Optional) Improves performance for many file indexing commands -dnf install fd-find # is 'fd' in Fedora <28 - -# (Optional) Required by some Language Server Protocols -dnf install nodejs -``` - -##### Arch - -```sh -# Required dependencies -pacman -S git ripgrep - -# (Optional) Improves performance for many file indexing commands -pacman -S fd - -# (Optional) Required by some Language Server Protocols -pacman -S nodejs npm -``` - -#### On MacOS - -Dependencies can be installed using [homebrew](https://brew.sh/) - -```sh -# Required dependencies -# git is already installed as part of MacOS -brew install ripgrep ctags - -# (Optional) Required by Language Server Protocols -brew install node -``` - -#### On Windows - -If you use Windows, please help by posting the steps to install the external -dependencies here! - -### Doom Nvim - -With Neovim v0.5.0 and Doom's dependencies installed, next is to install -Doom Nvim itself. - -> **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. - -First you'll want to backup your current Neovim configuration if you have one. - -> **NOTES**: -> -> 1. Your current configuration will be backed up to `~/.config/nvim.bak` -> or where your `XDG_CONFIG_HOME` environment variable points to. -> -> 2. If you're a cheovim user you can skip this step and go directly to -> [Using cheovim](#using-cheovim). - -```sh -[ -d ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ] && mv ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim.bak -``` - -Now that you have backed up your current Neovim configuration you can proceed to install -`doom-nvim`. - -```sh -git clone --depth 1 https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim -``` - -Or if you want to live in the bleeding-edge with the latest features: - -```sh -git clone --depth 1 -b develop https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim -``` - -## Update & Rollback - -### Update Doom Nvim - -To update Doom Nvim, you have two options, run `:DoomUpdate` or SPC d u -inside Neovim or alternatively run `git pull` in doom-nvim directory (**not recommended, see why below**). - -#### Why use the built-in doom command for updating instead of running git pull manually? - -> **TODO**: These commands are pending testing in the new module architecture. - -> **tl;dr**: The `:DoomUpdate` command creates an additional local database of the doom-nvim -> releases so in case something breaks you can easily rollback to a previous doom-nvim version - -The reason is that `doom-nvim` also brings a functionality for rolling back to a previous version -or a previous state (e.g. a previous commit) and doing it manually can be a bit tedious (looking -for the previous release tag or the previous commit hash if there were too much commits). -Our `:DoomUpdate` command creates a local database into the `doom-nvim` directory depending on -what branch are you using because if you are using the development branch you will not want to -rollback to a previous version, isn't it? - -So, if you are using the main a.k.a stable branch of doom-nvim, the `:DoomUpdate` command will -create a local database of doom-nvim's releases. Otherwise, if you're using the development branch -it will create a local file with the commit hash that you were using before updating. - -### Rollback - -#### Previous Configurations - -To uninstall Doom Nvim and go back to your previous setup, simply remove the `~/.config/nvim` -directory if it's where you have `doom-nvim` installed and move your backup. - -```sh -rm -rf ${XDG_CONFIG_HOME:-$HOME/.config}/nvim \ - && mv ${XDG_CONFIG_HOME:-$HOME/.config}/nvim.bak ${XDG_CONFIG_HOME:-$HOME/.config}/nvim -``` - -#### Rolling Back Doom - -Did the update screw up your setup because of a bug or a breaking change and you want to rollback? -Then you're lucky. Just run `:DoomRollback` in Neovim and Doom will rollback itself to -a previous release (for main branch) or a previous commit (for development branch). - -> **IMPORTANT**: remember to report the issues before just rolling back. In that -> way we can work on fixing them and make doom better! - -## Configuration - -You can configure Doom Nvim by tweaking the `config.lua` and -`modules.lua` files located in your Doom Nvim root directory -(`$HOME/.config/doom-nvim/` by default). - -### modules.lua - -This file handles all the Doom Nvim modules, copy the one in the root of this -repo for a template. - -> **NOTE**: for more information please refer to [modules]. - -### config.lua - -This file handles all the Doom Nvim configurations, including the ability to easily -create new custom mappings and global Neovim variables. - -It has no proper structure, but revolves around the `doom` global variable. -See each module's documentation for options. - -> **NOTE**: all your used-defined configurations here will be live-reloaded, e.g. -> mappings, autocommands, etc. - -### Plugin Management - -Doom Nvim uses a declarative and use-package inspired package manager called -[packer.nvim](https://github.com/wbthomason/packer.nvim). - -Each Doom module has a folder inside `lua/doom/modules/`, with the following -files: - -- `init.lua`: has default options and packer `config` functions. -- `packages.lua`: has packer specs, except for the config key. -- `binds.lua` (optional): has bindings for the module. -- `autocmds.lua` (optional): has autocmds. - -> **WARNING:** Do not change modules directly in Doom source code. Instead, -> use your `modules.lua` and `config.lua` files to modify them. - -### Configuring Doom - -#### Configuring settings - -You can change Doom's default settings by tweaking your `config.lua` file, -please see [modules] to know how. - -## Migrating to 4.0.0 - -As this is a major version, there are many improvements and breaking changes. -This section is made to help you migrate to this version without having to -respawn. - -### Changes for end users - -- Make modules more granular and configurable, allowing everything to be - overriden. -- Completely change the structure of `config.lua` to revolve around a - single settings store. -- Remove the category groupings in modules. -- Remove the need to return the filepath from each config file. -- Fully move all data file to stdpath("data"). -- Fix bugs. - -### Changes for contributors - -- Restructured source code. The Doom Nvim source code is now cleaner and - easier to understand. Many things have been flattened, no module is special - anymore, some things were removed in favor of later implementations - out-of-source. -- Adding modules is simpler, it only requires creating a new module folder - and adding its configuration. -- Care should be taken with order of execution, since you only have config - accesible after the doom global is created. You can't, for instance, - use the global do define defaults in `lua/doom/core/config/init.lua`. - This is rarely a problem, but worth mentioning. - -We recomend doing a fresh install, backing up your current -`~/.config/doom-nvim` for reference. Sadly, it cannot be used as is, and there's -no migration script yet. - -#### New configurations - - -[packer.nvim]: https://github.com/wbthomason/packer.nvim -[vhyrro]: https://github.com/vhyrro -[modules]: ./modules.md -[report them]: https://github.com/NTBBloodbath/doom-nvim/issues/new diff --git a/docs/modules.md b/docs/modules.md index fe3ff7386..98dbb694e 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -43,11 +43,13 @@ Modules are grouped into 3 categories: ### `core` modules +- [`core`](../lua/doom/modules/core/doom) Contains most of the doom default keybinds, autocommands, etc. - [`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`. +- [`updater`](../lua/doom/modules/core/updater) Checks updates and can automatically pull latest changes. +- [`reloader`](../lua/doom/modules/core/reloader) Allows you to reload and update your config without exiting doom-nvim. ### `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 diff --git a/init.lua b/init.lua index 346afe517..6c939ac9b 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,9 @@ if vim.fn.has("nvim-0.6.0") ~= 1 then return end +-- Makes sure ~/.local/share/nvim exists, to prevent problems with logging +vim.fn.mkdir(vim.fn.stdpath("data"), "p") + -- Add ~/.local/share to runtimepath early, such that -- neovim autoloads plugin/packer_compiled.lua along with vimscript, -- before we start using the plugins it lazy-loads. @@ -14,3 +17,10 @@ vim.opt.runtimepath:append(vim.fn.stdpath("data")) -- Load the doom-nvim framework require("doom.core") + +vim.defer_fn(function() + -- Check for updates + if doom.check_updates and doom.core.updater then + doom.core.updater.check_updates(true) + end +end, 0) diff --git a/lua/doom/core/config.lua b/lua/doom/core/config.lua index eb9c1e65f..e0b1f658a 100644 --- a/lua/doom/core/config.lua +++ b/lua/doom/core/config.lua @@ -11,7 +11,6 @@ local filename = "config.lua" config.source = nil - --- Entry point to bootstrap doom-nvim. config.load = function() -- Set vim defaults on first load. To override these, the user can just @@ -32,7 +31,6 @@ config.load = function() vim.opt.path = "**" vim.opt.signcolumn = "auto:2-3" vim.opt.foldcolumn = "auto:9" - vim.opt.colorcolumn = "80" vim.opt.formatoptions:append("j") vim.opt.fillchars = { vert = "▕", @@ -47,7 +45,6 @@ config.load = function() vim.opt.smartindent = true vim.opt.copyindent = true vim.opt.preserveindent = true - vim.opt.clipboard = "unnamedplus" vim.opt.cursorline = true vim.opt.splitright = false vim.opt.splitbelow = true @@ -56,8 +53,6 @@ config.load = function() vim.opt.mouse = "a" vim.opt.wrap = false vim.opt.swapfile = false - vim.opt.number = true - vim.opt.relativenumber = true vim.opt.expandtab = true vim.opt.conceallevel = 0 vim.opt.foldenable = true @@ -69,18 +64,17 @@ config.load = function() -- Iterate over each module and save it to the doom global object for section_name, section_modules in pairs(enabled_modules) do for _, module_name in pairs(section_modules) do - -- If the section is `user` resolves from `lua/user/modules` local search_paths = { ("user.modules.%s.%s"):format(section_name, module_name), - ("doom.modules.%s.%s"):format(section_name, module_name) + ("doom.modules.%s.%s"):format(section_name, module_name), } local ok, result for _, path in ipairs(search_paths) do ok, result = xpcall(require, debug.traceback, path) if ok then - break; + break end end if ok then @@ -132,13 +126,33 @@ config.load = function() vim.opt.undofile = false vim.opt.undodir = nil end + +-- vim.g.mapleader = doom.settings.leader_key +-- end + + if doom.settings.global_statusline then + vim.opt.laststatus = 3 + end + + -- Use system clipboard + if doom.settings.clipboard then + vim.opt.clipboard = "unnamedplus" + end + + -- Color column + vim.opt.colorcolumn = type(doom.settings.max_columns) == "number" and tostring(doom.settings.max_columns) or "" + + -- Number column + vim.opt.number = not doom.settings.disable_numbering + vim.opt.relativenumber = not doom.settings.disable_numbering and doom.settings.relative_num + vim.g.mapleader = doom.settings.leader_key end - -- Path cases: -- 1. stdpath('config')/../doom-nvim/config.lua -- 2. stdpath('config')/config.lua -- 3. /doom-nvim/config.lua config.source = utils.find_config(filename) + return config diff --git a/lua/doom/core/doom_global.lua b/lua/doom/core/doom_global.lua index e79fa2312..80ba69456 100644 --- a/lua/doom/core/doom_global.lua +++ b/lua/doom/core/doom_global.lua @@ -168,7 +168,6 @@ doom = { end end, - -- TODO: USE GLOB PATH TO DYNAMICALLY COLLECT MODULE PATHS -- This is where modules are stored. -- The entire data structure will be stored in modules[module_name] = {} -- The key (`user` vs `modules` vs `langs`) cooresponds with the section in diff --git a/lua/doom/core/functions.lua b/lua/doom/core/functions.lua index ad6064cbc..caba396bb 100644 --- a/lua/doom/core/functions.lua +++ b/lua/doom/core/functions.lua @@ -39,7 +39,7 @@ functions.open_docs = function() vim.cmd(string.format("split %s", docs_path)) -- Move cursor to table of contents section vim.api.nvim_buf_call(vim.fn.bufnr("doom_nvim.norg"), function() - vim.fn.cursor({12, 1}) + vim.fn.cursor({ 12, 1 }) end) -- Set local documentation options vim.opt_local.modified = false @@ -178,9 +178,8 @@ end -- Set the indent and tab related numbers. -- Negative numbers mean tabstop -- Really though? Tabs? functions.set_indent = function() - local indent = tonumber( - vim.fn.input("Set indent (>0 uses spaces, <0 uses tabs, 0 uses vim defaults): ") - ) + local indent = + tonumber(vim.fn.input("Set indent (>0 uses spaces, <0 uses tabs, 0 uses vim defaults): ")) if not indent then indent = -8 end @@ -209,7 +208,11 @@ functions.change_number = function() vim.opt.number = false vim.opt.relativenumber = false end - print("number=%s, relativenumber=%s", utils.bool2str(vim.opt.number), utils.bool2str(vim.opt.relativenumber)) + print( + "number=%s, relativenumber=%s", + utils.bool2str(vim.opt.number), + utils.bool2str(vim.opt.relativenumber) + ) end -- Toggle spell. diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua index 9a85f59c1..3a0756025 100644 --- a/lua/doom/core/init.lua +++ b/lua/doom/core/init.lua @@ -25,18 +25,11 @@ g.loaded_matchparen = 1 g.loaded_logiPat = 1 g.loaded_rrhelper = 1 -g.loaded_netrw = 1 -g.loaded_netrwPlugin = 1 -g.loaded_netrwSettings = 1 -g.loaded_netrwFileHandlers = 1 - -local utils = require("doom.utils") -- Sets the `doom` global object require("doom.core.doom_global") --- Load user settings -doom[ "settings" ] = dofile(utils.find_config("settings.lua")) +local utils = require("doom.utils") -- Load user settings doom[ "settings" ] = dofile(utils.find_config("settings.lua")) @@ -44,6 +37,12 @@ doom[ "settings" ] = dofile(utils.find_config("settings.lua")) -- Boostraps the doom-nvim framework, runs the user's `config.lua` file. local config = utils.safe_require("doom.core.config") config.load() +if not utils.is_module_enabled("features", "netrw") then + g.loaded_netrw = 1 + g.loaded_netrwPlugin = 1 + g.loaded_netrwSettings = 1 + g.loaded_netrwFileHandlers = 1 +end -- Load the colourscheme utils.safe_require("doom.core.ui") @@ -51,7 +50,6 @@ utils.safe_require("doom.core.ui") -- Set some extra commands utils.safe_require("doom.core.commands") - -- Load Doom modules. local modules = utils.safe_require("doom.core.modules") modules.start() @@ -59,4 +57,9 @@ modules.load_modules() modules.handle_user_config() modules.try_sync() +-- Execute autocommand for user to hook custom config into +vim.api.nvim_exec_autocmds("User", { + pattern = "DoomStarted", +}) + -- vim: fdm=marker diff --git a/lua/doom/core/modules.lua b/lua/doom/core/modules.lua index 3c473ab34..b70991715 100644 --- a/lua/doom/core/modules.lua +++ b/lua/doom/core/modules.lua @@ -19,13 +19,14 @@ modules.source = utils.find_config(filename) -- Merge core modules (can't be disabled) with user enabled modules local core_modules = { core = { - 'doom', - 'nest', - 'treesitter', - 'reloader', - } + "doom", + "nest", + "treesitter", + "reloader", + "updater", + }, } -modules.enabled_modules = vim.tbl_deep_extend('keep', core_modules, dofile(modules.source)) +modules.enabled_modules = vim.tbl_deep_extend("keep", core_modules, dofile(modules.source)) local system = require("doom.core.system") @@ -113,7 +114,7 @@ local keymaps_service = require("doom.services.keymaps") modules.load_modules = function() local use = require("packer").use -- Handle the Modules - for section_name, _ in pairs(doom.modules) do + for section_name, _ in pairs(doom.modules) do for module_name, module in pairs(doom[section_name]) do -- Import dependencies with packer from module.packages -- print(module_name, module) diff --git a/lua/doom/modules/core/doom/init.lua b/lua/doom/modules/core/doom/init.lua index 336d5a5d6..daa647b9a 100644 --- a/lua/doom/modules/core/doom/init.lua +++ b/lua/doom/modules/core/doom/init.lua @@ -16,7 +16,7 @@ required.packages = { }, ["plenary.nvim"] = { "nvim-lua/plenary.nvim", - commit = "9c3239bc5f99b85be1123107f7290d16a68f8e64", + commit = "986ad71ae930c7d96e812734540511b4ca838aa2", module = "plenary", }, ["popup.nvim"] = { @@ -26,7 +26,7 @@ required.packages = { }, ["nvim-web-devicons"] = { "kyazdani42/nvim-web-devicons", - commit = "8d2c5337f0a2d0a17de8e751876eeb192b32310e", + commit = "2d02a56189e2bde11edd4712fea16f08a6656944", module = "nvim-web-devicons", }, -- Must include impatient.nvim here, even though it's bootstrapped in @@ -332,7 +332,7 @@ required.autocmds = function() table.insert(autocmds, { "BufReadPost", "*", - [[if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]], + [[if &ft !~# 'commit\|rebase' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]], }) end return autocmds diff --git a/lua/doom/modules/core/nest/init.lua b/lua/doom/modules/core/nest/init.lua index 03d460964..56757dff1 100644 --- a/lua/doom/modules/core/nest/init.lua +++ b/lua/doom/modules/core/nest/init.lua @@ -108,8 +108,6 @@ mapper.configs["nvim-mapper"] = function() if id ~= nil then local rhs = type(node.rhs) == "function" and "" or node.rhs if node_settings.buffer then - local bufnr = type(node_settings.buffer) == "number" and node_settings.buffer - or vim.api.nvim_get_current_buf() Mapper.map_buf_virtual( sanitizedMode, node.lhs, diff --git a/lua/doom/modules/core/reloader/init.lua b/lua/doom/modules/core/reloader/init.lua index ac860263e..27b141633 100644 --- a/lua/doom/modules/core/reloader/init.lua +++ b/lua/doom/modules/core/reloader/init.lua @@ -1,3 +1,6 @@ +-- Store state that persists between reloads here. +_G._doom_reloader = _G._doom_reloader ~= nil and _G._doom_reloader or {} + local reloader = {} --- Only show error reloading message once per session @@ -127,9 +130,12 @@ reloader._reload_doom = function() local needs_install = vim.deep_equal(modules, old_modules) and vim.deep_equal(packages, old_packages) if needs_install then - log.warn( - "reloader: If you made changes to the config of a plugin, run `:PackerCompile` to execute these changes." - ) + if not _G._doom_reloader._has_shown_packer_compile_message then + log.warn( + "reloader: You will have to run `:PackerCompile` before changes to plugin configs take effect." + ) + _G._doom_reloader._has_shown_packer_compile_message = true + end else log.warn("reloader: Run `:PackerSync` to install and configure new plugins.") end @@ -176,10 +182,7 @@ reloader.autocmds = function() -- RELOAD DOOM ON SAVE if reloader.settings.reload_on_save then - table.insert( - autocmds, - { "BufWritePost", "*/doom/**/*.lua,*/user/**/*.lua", reloader.reload } - ) + table.insert(autocmds, { "BufWritePost", "*/doom/**/*.lua,*/user/**/*.lua", reloader.reload }) table.insert(autocmds, { "BufWritePost", "*/modules.lua,*/config.lua,*/settings.lua", @@ -196,4 +199,3 @@ reloader.autocmds = function() end return reloader - diff --git a/lua/doom/modules/core/treesitter/init.lua b/lua/doom/modules/core/treesitter/init.lua index 62b2158e2..11797376c 100644 --- a/lua/doom/modules/core/treesitter/init.lua +++ b/lua/doom/modules/core/treesitter/init.lua @@ -42,7 +42,7 @@ treesitter.settings = { treesitter.packages = { ["nvim-treesitter"] = { "nvim-treesitter/nvim-treesitter", - commit = "9e8df1b3ca576eeaca4e8d48e3d67119b32adb99", + commit = "6289410c7a4715d6e7743c4d81cf5d262e90951e", run = ":TSUpdate", branch = "master", }, @@ -61,11 +61,13 @@ treesitter.packages = { treesitter.configs = {} treesitter.configs["nvim-treesitter"] = function() local is_module_enabled = require("doom.utils").is_module_enabled - require("nvim-treesitter.configs").setup(vim.tbl_deep_extend("force", doom.core.treesitter.settings.treesitter, { - autopairs = { - enable = is_module_enabled("features", "autopairs"), - }, - })) + require("nvim-treesitter.configs").setup( + vim.tbl_deep_extend("force", doom.core.treesitter.settings.treesitter, { + autopairs = { + enable = is_module_enabled("features", "autopairs"), + }, + }) + ) -- Check if user is using clang and notify that it has poor compatibility with treesitter -- WARN: 19/11/2021 | issues: #222, #246 clang compatibility could improve in future diff --git a/lua/doom/modules/core/updater/init.lua b/lua/doom/modules/core/updater/init.lua index 94b2349ae..1965c360c 100644 --- a/lua/doom/modules/core/updater/init.lua +++ b/lua/doom/modules/core/updater/init.lua @@ -24,159 +24,322 @@ local updater = {} updater.packages = { ["plenary.nvim"] = { "nvim-lua/plenary.nvim", - commit = "9c3239bc5f99b85be1123107f7290d16a68f8e64", + commit = "986ad71ae930c7d96e812734540511b4ca838aa2", module = "plenary", }, } +updater.settings = { + unstable = false, +} + updater._cwd = vim.fn.stdpath("config") --- Using git and plenary jobs gets a list of all available versions to update to ---@param callback function Handler to receive the list of versions -updater._fetch_versions = function(callback) - local versions = {} +updater._pull_tags = function(callback) local Job = require("plenary.job") - local job = Job:new({ + Job:new({ command = "git", args = { "fetch", "--tags", "--all" }, cwd = updater._cwd, - }) + on_exit = function(j, exit_code) + if exit_code ~= 0 then + callback(nil, "Error pulling tags... \n\n " .. vim.inspect(j.result())) + end + callback(j:result()) + end, + }):start() +end + +--- Gets the current commit sha or error +---@param callback function(commit_sha, error_string) +updater._get_commit_sha = function(callback) + local Job = require("plenary.job") - job:and_then(Job:new({ + Job:new({ command = "git", - args = { "log", "--no-walk", "--tags", '--pretty="%d %s"' }, - cwd = updater._cwd, - on_exit = function(j, err_code) - if err_code ~= 0 then - callback(nil, "Git error when fetching tags" .. j:result()) + args = { "rev-parse", "HEAD" }, + on_exit = function(j, exit_code) + if exit_code ~= 0 then + callback(nil, "Error getting current commit... \n\n" .. vim.inspect(j:result())) return end - - local result = "" - for _, l in ipairs(j:result()) do - result = result .. l .. "\n" - local tag = l:match("%((.-)[%),]") - local v = tag:gsub("%a", ""):gsub("[:%c%s]", "") - local major, minor, patch = unpack(vim.split(v, "%.")) - - table.insert(versions, { - message = l, - major = tonumber(major), - minor = tonumber(minor), - patch = tonumber(patch), - }) + local result = j:result() + if #result == 1 then + callback(result[1]) + else + callback(nil, "Error getting current commit... No output.") end - callback(versions) end, - })) - job:start() + }):start() end ---- Gets the latest version from a list of versions ----@param versions DoomVersion[] List of versions from _fetch_versions ----@return DoomVersion the latest version from the list -updater._get_latest_from_versions = function(versions) - local latest = nil - for _, v in ipairs(versions) do - if latest == nil then - latest = v - elseif updater._is_version_newer(latest, v) then - latest = v - end - end - return latest +--- Given a version string, checks if it's an alpha/beta version +---@param version string +---@return boolean +local is_version_unstable = function(version) + return version:match("alpha") ~= nil or version:match("beta") ~= nil end ---- Check if alternate version is newer than another version ----@param curr DoomVersion The base/current version ----@param alternate DoomVersion The alternate version to compare ----@return boolean True if alternate is newer than curr -updater._is_version_newer = function(curr, alternate) - return curr.major < alternate.major - or (curr.major == alternate.major and curr.minor < alternate.minor) - or (curr.major == alternate.major and curr.minor == alternate.minor and curr.patch < alternate.patch) +--- Gets all version tags as a table of strings +---@param callback function(all_versions, error_string) +updater._get_all_versions = function(callback) + local Job = require("plenary.job") + Job + :new({ + command = "git", + args = { "tag", "-l", "--sort", "-version:refname" }, + cwd = updater._cwd, + on_exit = function(j) + ---@param version string + local filter_predicate = function(version) + local is_unsupported = version:match("^1") or version:match("v2") or version:match("v3") + if is_unsupported or (not updater.settings.unstable and is_version_unstable(version)) then + return false + end + return true + end + local result = vim.tbl_filter(filter_predicate, j:result()) + callback(result) + end, + }) + :start() end ---- Checks for updates and notifys user if a new version is available -updater._check_updates = function() - print("Check updates") - updater._fetch_versions(function(versions, err) - print(vim.inspect(versions)) - local log = require("doom.utils.logging") - print("Handling check updates with versions") - if err then - log.error(("reloader: Failed to check for updates: %s."):format(err)) +--- Using a commit sha, finds the first version tag in commit history +---@param commit_sha string +---@param callback function(version_tag, error_string) +updater._get_last_version_for_commit = function(commit_sha, callback) + local Job = require("plenary.job") + Job:new({ + command = "git", + args = { "tag", "-l", "--sort", "-version:refname", "--merged", commit_sha }, + cwd = updater._cwd, + on_exit = function(j, exit_code) + if exit_code ~= 0 then + callback(nil, "Error getting current version... \n\n " .. vim.inspect(j:result())) + return + end + local result = j:result() + if #result > 0 then + callback(result[1]) + else + callback(nil, "Error getting current version... No output.") + end + end, + }):start() +end + +--- Gets the current version and the latest upstream version +---@param callback function(current_version, latest_version, error_string) +updater._fetch_current_and_latest_version = function(callback) + updater._pull_tags(function(_, pull_tags_error) + if pull_tags_error then + callback(nil, nil, pull_tags_error) return end - local utils = require("doom.utils") - local latest = updater._get_latest_from_versions(versions) - if updater._is_version_newer(utils.version, latest) then - local s = ( - "updater: New version of doom-nvim available(v%d.%d.%d). Run `:DoomUpdate` to update." - ):format(latest.major, latest.minor, latest.patch) - log.warn(s) - else - log.warn("updater: No new version detected, up to date.") - end + updater._get_commit_sha(function(commit_sha, commit_sha_error) + if commit_sha_error then + callback(nil, nil, commit_sha_error) + return + end + + local cur_version, all_versions = nil, nil + local try_compare_updates = function() + if cur_version and all_versions then + -- Find How many versions behind we are + if #all_versions > 0 then + callback(cur_version, all_versions[1]) + return + else + callback(nil, nil, "Error getting latest version. The versions list is empty!") + end + end + end + + updater._get_last_version_for_commit(commit_sha, function(version) + cur_version = version + try_compare_updates() + end) + + updater._get_all_versions(function(all) + all_versions = all + try_compare_updates() + end) + end) end) end ---- Checks for updates and updates if a new version is available. -updater._update = function() - updater._fetch_versions(function(versions, err) - if err then - local log = require("doom.utils.logging") - log.error(("reloader: Failed to check for updates: %s."):format(err)) - return - end - local utils = require("doom.utils") - local latest = updater._get_latest_from_versions(versions) - if updater._is_version_newer(utils.version, latest) then - updater._checkout_version(latest) - end +--- Entry point for `:DoomCheckUpdates`, fetches new tags, compares with current version and notifies results +---@param quiet boolean When enabled, disable all but error / needs update messages +updater.check_updates = function(quiet) + local log = require("doom.utils.logging") + if not quiet then + vim.notify("updater: Checking updates...") + end + + updater._fetch_current_and_latest_version(function(current_version, latest_version, error) + vim.defer_fn(function() + if error then + log.error(("updater: Error checking updates... %s"):format(error)) + return + end + + if current_version == latest_version then + if not quiet then + vim.notify(("updater: You are up to date! (%s)"):format(current_version)) + end + else + vim.notify( + ( + "updater: There is a new version (%s). You are currently on %s. Run `:DoomUpdate` to update." + ):format(latest_version, current_version) + ) + end + end, 0) end) end ---- Checks out doom-nvim to a specific version, used by update but can also be used to rollback. ----@param version DoomVersion -updater._checkout_version = function(version) - local version_string = ("%d.%d.%d"):format(version.major, version.minor, version.patch) - local tag_string = "tags/v" .. version_string +--- Attempts to merge a version into the current branch, fails if working tree is dirty +---@param target_version string +---@param callback function(error_string) +updater._try_merge_version = function(target_version, callback) + local Job = require("plenary.job") + + local merge_job = Job:new({ + command = "git", + args = { "merge", target_version }, + cwd = updater._cwd, + on_exit = function(j, exit_code) + if exit_code ~= 0 then + callback( + "Error merging " + .. target_version + .. ". You may have to resolve the merge conflict manually... \n\n " + .. vim.inspect(table.concat(j:result(), "\n")) + ) + return + end + callback(nil) + end, + }) - local log = require("doom.utils.logging") - log.info("Attempting to checkout " .. tag_string) + Job + :new({ + command = "git", + args = { "diff", "--quiet" }, + cwd = updater._cwd, + on_exit = function(_, exit_code) + if exit_code ~= 0 then + callback( + ( + "Tried to update to new version %s but could not due to uncommitted changes. Please commit or stash your changes before trying again." + ):format(target_version) + ) + else + merge_job:start() + end + end, + }) + :start() +end +--- Gets the name of the current working branch +---@param callback function(branch_name, error) +updater._get_branch_name = function(callback) local Job = require("plenary.job") Job:new({ command = "git", - args = { "merge", tag_string }, + args = { "symbolic-ref", "--short", "-q", "HEAD" }, cwd = updater._cwd, - on_exit = function(j, return_val) - print(vim.inspect(j:result()) .. vim.inspect(return_val)) - log.info(( "updater: Updated to v%s."):format(version_string)) + on_exit = function(j, exit_code) + if exit_code ~= 0 then + callback(nil, "Error getting branch name... \n\n " .. vim.inspect(j:result())) + return + end + local result = j:result() + if #result > 0 then + callback(result[1]) + else + callback(nil, "Error getting branch name... No output.") + end end, }):start() end --- recursive check that user settings mirror `core/doom_global.lua` --- with the new defaults. don't modify any user settings. only --- add. -updater.sync_user_settings = function() -end +--- Entry point for `:DoomUpdate`, fetches new tags, compares with current version and attempts to merge new tags into current branch +updater._try_update = function() + local log = require("doom.utils.logging") + vim.notify("updater: Attempting to update...") + + updater._get_branch_name(function(branch_name, error) + -- Ensure user is not in main/next branch + local error_message = nil + if error then + error_message = error + elseif branch_name == "next" or branch_name == "main" then + error_message = + "You cannot use `:DoomUpdate` from within the `main` branch. Please make a new branch for your custom config (`git checkout -b my-config`)." + end + + if error_message then + vim.defer_fn(function() + log.error(("updater: %s"):format(error_message)) + end, 0) + return + end + + updater._fetch_current_and_latest_version( + function(current_version, latest_version, get_version_error) + vim.defer_fn(function() + if get_version_error then + log.error(("updater: Error checking updates... %s"):format(get_version_error)) + return + end + if current_version == latest_version then + vim.notify( + ("updater: You are already using the latest version! (%s)"):format(current_version) + ) + else + -- Attempt to merge new version into user's custom config branch + updater._try_merge_version(latest_version, function(merge_error) + vim.defer_fn(function() + if merge_error then + log.error(("updater: Error updating... %s"):format(merge_error)) + else + local message = ("updater: Updated to version %s!"):format(latest_version) + -- Only print changelog info if it's a stable release + if not is_version_unstable(latest_version) then + message = message + .. ( + " Check the changelog at https://github.com/NTBBloodbath/doom-nvim/releases/tag/%s" + ):format(latest_version) + end + vim.notify(message) + end + end, 0) + end) + end + end, 0) + end + ) + end) +end updater.cmds = { - -- { - -- "DoomUpdate", - -- function() - -- updater._update() - -- end, - -- }, - -- { - -- "DoomCheckUpdates", - -- function() - -- updater._check_updates() - -- end, - -- }, + { + "DoomUpdate", + function() + updater._try_update() + end, + }, + { + "DoomCheckUpdates", + function() + updater.check_updates(false) + end, + }, } return updater diff --git a/lua/doom/modules/features/annotations/init.lua b/lua/doom/modules/features/annotations/init.lua index e90ee432c..2684bd40f 100644 --- a/lua/doom/modules/features/annotations/init.lua +++ b/lua/doom/modules/features/annotations/init.lua @@ -19,7 +19,7 @@ annotations.settings = { annotations.packages = { ["neogen"] = { "danymat/neogen", - commit = "a4b2fd5ba5ec3cdd9c3c7a5f6868b6c52eea0313", + commit = "c5a0c39753808faa41dea009d41dd686732c6774", after = "nvim-treesitter", }, } @@ -30,9 +30,19 @@ annotations.configs["neogen"] = function() end annotations.binds = { - { 'c', name = '+code', { - { 'g', function() require('neogen').generate() end, name = 'Generate annotations'} - }} + { + "c", + name = "+code", + { + { + "g", + function() + require("neogen").generate() + end, + name = "Generate annotations", + }, + }, + }, } return annotations diff --git a/lua/doom/modules/features/auto_install/init.lua b/lua/doom/modules/features/auto_install/init.lua index dc4db9227..f71591c7e 100644 --- a/lua/doom/modules/features/auto_install/init.lua +++ b/lua/doom/modules/features/auto_install/init.lua @@ -23,7 +23,7 @@ auto_install.packages = { }, ["nvim-lsp-installer"] = { "williamboman/nvim-lsp-installer", - commit = "effafae44012a6ad3091968ad358531c62925a45", + commit = "b8c168ccb30529a11404e5f71525502ec6288ccf", -- disabled = not is_module_enabled("features", "lsp"), }, } diff --git a/lua/doom/modules/features/auto_session/init.lua b/lua/doom/modules/features/auto_session/init.lua index d97ce26a9..96f3b1263 100644 --- a/lua/doom/modules/features/auto_session/init.lua +++ b/lua/doom/modules/features/auto_session/init.lua @@ -8,7 +8,7 @@ auto_session.packages = { ["persistence.nvim"] = { "folke/persistence.nvim", commit = "77cf5a6ee162013b97237ff25450080401849f85", - module = 'persistence', + module = "persistence", }, -- -- https://github.com/Shatur/neovim-session-manager -- https://github.com/jedrzejboczar/possession.nvim diff --git a/lua/doom/modules/features/autopairs/init.lua b/lua/doom/modules/features/autopairs/init.lua index 84a272a7b..0af83847e 100644 --- a/lua/doom/modules/features/autopairs/init.lua +++ b/lua/doom/modules/features/autopairs/init.lua @@ -9,27 +9,38 @@ autopairs.settings = { autopairs.packages = { ["nvim-autopairs"] = { "windwp/nvim-autopairs", - commit = "84cde3547e9a8b16db0bfe523e98e19b7be5148b", + commit = "972a7977e759733dd6721af7bcda7a67e40c010e", event = "BufReadPost", }, } autopairs.configs = {} autopairs.configs["nvim-autopairs"] = function() - require("nvim-autopairs").setup(vim.tbl_deep_extend("force", doom.features.autopairs.settings, { check_ts = true })) + require("nvim-autopairs").setup( + vim.tbl_deep_extend("force", doom.features.autopairs.settings, { check_ts = true }) + ) end autopairs.binds = { - "", name = "+prefix", { - { "t", name = "+tweak", { - { "p", function() - local autopairs_plugin = require('nvim-autopairs') - if autopairs_plugin.state.disabled then - autopairs_plugin.enable() - else - autopairs_plugin.disable() - end - end, name = "Toggle autopairs" }, + "", + name = "+prefix", + { + { + "t", + name = "+tweak", + { + { + "p", + function() + local autopairs_plugin = require("nvim-autopairs") + if autopairs_plugin.state.disabled then + autopairs_plugin.enable() + else + autopairs_plugin.disable() + end + end, + name = "Toggle autopairs", + }, }, }, }, diff --git a/lua/doom/modules/features/comment/init.lua b/lua/doom/modules/features/comment/init.lua index 77dc1d54f..68e23f4e6 100644 --- a/lua/doom/modules/features/comment/init.lua +++ b/lua/doom/modules/features/comment/init.lua @@ -44,7 +44,7 @@ comment.settings = { comment.packages = { ["Comment.nvim"] = { "numToStr/Comment.nvim", - commit = "3c69bab36569d5d0321351ec956fc43a8d409fb0", + commit = "78ab4e9785b6da9b7a539df3bd6f70300dc9482b", module = "Comment", }, } diff --git a/lua/doom/modules/features/dap/init.lua b/lua/doom/modules/features/dap/init.lua index 0406b4d1c..92960c09b 100644 --- a/lua/doom/modules/features/dap/init.lua +++ b/lua/doom/modules/features/dap/init.lua @@ -38,12 +38,12 @@ dap.settings = { dap.packages = { ["nvim-dap"] = { "mfussenegger/nvim-dap", - commit = "014ebd53612cfd42ac8c131e6cec7c194572f21d", + commit = "a13d6cb9ea8f7bbf8dd9c5de9ca2cbee64d2e258", module = "dap", }, ["nvim-dap-ui"] = { "rcarriga/nvim-dap-ui", - commit = "d76d6594374fb54abf2d94d6a320f3fd6e9bb2f7", + commit = "b7b71444128f5aa90e4aee8dbfa36b14afddfb7a", after = { "nvim-dap" }, }, } @@ -65,105 +65,105 @@ dap.configs["nvim-dap-ui"] = function() end dap.binds = { - "", - name = "+prefix", + "", + name = "+prefix", + { { + "d", + name = "+debug", { - "d", - name = "+debug", { + "c", + function() + require("dap").continue() + end, + name = "Continue/Start", + }, + { + "d", + function() + require("dap").disconnect() + end, + name = "Disconnect", + }, + { + "e", + function() + require("dapui").eval() + end, + name = "Evaluate", + }, + { + mode = "v", { - "c", - function() - require("dap").continue() - end, - name = "Continue/Start", - }, - { - "d", - function() - require("dap").disconnect() - end, - name = "Disconnect", - }, - { - "e", - function() - require("dapui").eval() - end, - name = "Evaluate", - }, - { - mode = "v", { - { - "e", - function() - require("dapui").eval() - end, - name = "Evaluate", - }, + "e", + function() + require("dapui").eval() + end, + name = "Evaluate", }, }, + }, + { + "b", + name = "+breakpoint", { - "b", - name = "+breakpoint", { - { - "b", - function() - require("dap").toggle_breakpoint() - end, - name = "Toggle breakpoint", - }, - { - "c", - function() - vim.fn.inputsave() - local condition = vim.fn.input("Condition: ") - vim.fn.inputrestore() - require("dap").toggle_breakpoint(condition) - end, - name = "Toggle", - }, - { - "h", - function() - vim.fn.inputsave() - local number = vim.fn.input("Hit number: ") - vim.fn.inputrestore() - require("dap").toggle_breakpoint(nil, number) - end, - name = "Hit number", - }, - { - "l", - function() - vim.fn.inputsave() - local msg = vim.fn.input("Message: ") - vim.fn.inputrestore() - require("dap").toggle_breakpoint(nil, nil, msg) - end, - name = "Log", - }, + "b", + function() + require("dap").toggle_breakpoint() + end, + name = "Toggle breakpoint", + }, + { + "c", + function() + vim.fn.inputsave() + local condition = vim.fn.input("Condition: ") + vim.fn.inputrestore() + require("dap").toggle_breakpoint(condition) + end, + name = "Toggle", + }, + { + "h", + function() + vim.fn.inputsave() + local number = vim.fn.input("Hit number: ") + vim.fn.inputrestore() + require("dap").toggle_breakpoint(nil, number) + end, + name = "Hit number", + }, + { + "l", + function() + vim.fn.inputsave() + local msg = vim.fn.input("Message: ") + vim.fn.inputrestore() + require("dap").toggle_breakpoint(nil, nil, msg) + end, + name = "Log", }, }, }, }, + }, + { + "o", + name = "+open", { - "o", - name = "+open", { - { - "d", - function() - require("dapui").toggle() - end, - name = "Debugger", - }, + "d", + function() + require("dapui").toggle() + end, + name = "Debugger", }, }, }, - } + }, +} return dap diff --git a/lua/doom/modules/features/dashboard/init.lua b/lua/doom/modules/features/dashboard/init.lua index c4bbd0e65..1e6752805 100644 --- a/lua/doom/modules/features/dashboard/init.lua +++ b/lua/doom/modules/features/dashboard/init.lua @@ -6,31 +6,31 @@ dashboard.settings = { icon = " ", desc = "Recently Opened Files ", shortcut = "SPC f r", - action = "Telescope oldfiles" + action = "Telescope oldfiles", }, { icon = " ", desc = "Jump to Bookmark ", shortcut = "SPC s m", - action = "Telescope marks" + action = "Telescope marks", }, { icon = " ", desc = "Open Configuration ", shortcut = "SPC D c", - action = "e " .. require("doom.core.config").source + action = "e " .. require("doom.core.config").source, }, { icon = " ", desc = "Open Modules ", shortcut = "SPC D m", - action = "e " .. require("doom.core.modules").source + action = "e " .. require("doom.core.modules").source, }, { icon = " ", desc = "Open Documentation ", shortcut = "SPC D d", - action = "lua require('doom.core.functions').open_docs()" + action = "lua require('doom.core.functions').open_docs()", }, }, header = { @@ -67,7 +67,7 @@ dashboard.settings = { dashboard.packages = { ["dashboard-nvim"] = { "glepnir/dashboard-nvim", - commit = "883c7953d3e0a45ed0dd0fa05f9d029efdbf3c8a", + commit = "94585fab23f17a9450b85cc04d71f98251579e37", cmd = "Dashboard", opt = true, }, @@ -90,7 +90,7 @@ dashboard.configs["dashboard-nvim"] = function() icon = " ", desc = "Load Last Session ", shortcut = "SPC s r", - action = "lua require('persistence').load({ last = true })" + action = "lua require('persistence').load({ last = true })", } end diff --git a/lua/doom/modules/features/editorconfig/init.lua b/lua/doom/modules/features/editorconfig/init.lua index 3feaf20ab..0693a3304 100644 --- a/lua/doom/modules/features/editorconfig/init.lua +++ b/lua/doom/modules/features/editorconfig/init.lua @@ -5,7 +5,7 @@ editorconfig.settings = {} editorconfig.packages = { ["editorconfig-vim"] = { "editorconfig/editorconfig-vim", - commit = "a8e3e66deefb6122f476c27cee505aaae93f7109", + commit = "d354117b72b3b43b75a29b8e816c0f91af10efe9", }, } diff --git a/lua/doom/modules/features/explorer/init.lua b/lua/doom/modules/features/explorer/init.lua index 96a9b6a6d..307ebf86c 100644 --- a/lua/doom/modules/features/explorer/init.lua +++ b/lua/doom/modules/features/explorer/init.lua @@ -17,7 +17,6 @@ explorer.settings = { view = { width = 35, side = "left", - auto_resize = true, mappings = { custom_only = false, }, @@ -72,6 +71,7 @@ explorer.settings = { }, actions = { open_file = { + resize_window = true, -- previously view.auto_resize window_picker = { exclude = { filetype = { @@ -94,7 +94,8 @@ explorer.settings = { explorer.packages = { ["nvim-tree.lua"] = { "kyazdani42/nvim-tree.lua", - commit = "bdb6d4a25410da35bbf7ce0dbdaa8d60432bc243", + commit = "7fcb48c852b9d58709169a4dc1ec634fa9ea56f9", + module = "nvim-tree.api", cmd = { "NvimTreeClipboard", "NvimTreeClose", @@ -184,4 +185,17 @@ explorer.binds = { }, } +explorer.autocmds = { + { + "BufEnter", + "*", + function() + local name = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()) + if vim.fn.isdirectory(name) == 1 then + require("nvim-tree.api").tree.change_root(name) + end + end, + }, +} + return explorer diff --git a/lua/doom/modules/features/extra_snippets/init.lua b/lua/doom/modules/features/extra_snippets/init.lua new file mode 100644 index 000000000..5ba6bac6a --- /dev/null +++ b/lua/doom/modules/features/extra_snippets/init.lua @@ -0,0 +1,17 @@ +local extra_snippets = {} + +extra_snippets.settings = {} + +extra_snippets.packages = { + ["friendly-snippets"] = { + "rafamadriz/friendly-snippets", + after = "LuaSnip", + }, +} + +extra_snippets.configs = {} +extra_snippets.configs["friendly-snippets"] = function() + require("luasnip.loaders.from_vscode").lazy_load() +end + +return extra_snippets diff --git a/lua/doom/modules/features/firenvim/init.lua b/lua/doom/modules/features/firenvim/init.lua index 6bf9ad2db..d2552e3d5 100644 --- a/lua/doom/modules/features/firenvim/init.lua +++ b/lua/doom/modules/features/firenvim/init.lua @@ -25,7 +25,7 @@ firenvim.settings = { firenvim.packages = { ["firenvim"] = { "glacambre/firenvim", - commit = "e90f87872b313df15a06119ddbb84cdf1599657c", + commit = "f679455c294c62eddee86959cfc9f1b1f79fe97d", run = function() vim.fn["firenvim#install"](0) end, diff --git a/lua/doom/modules/features/gitsigns/init.lua b/lua/doom/modules/features/gitsigns/init.lua index 197acd821..9cf983798 100644 --- a/lua/doom/modules/features/gitsigns/init.lua +++ b/lua/doom/modules/features/gitsigns/init.lua @@ -75,7 +75,7 @@ gitsigns.settings = { gitsigns.packages = { ["gitsigns.nvim"] = { "lewis6991/gitsigns.nvim", - commit = "c18e016864c92ecf9775abea1baaa161c28082c3", + commit = "8b817e76b6399634f3f49e682d6e409844241858", }, } diff --git a/lua/doom/modules/features/illuminate/init.lua b/lua/doom/modules/features/illuminate/init.lua index 5c1d6f889..40839005a 100644 --- a/lua/doom/modules/features/illuminate/init.lua +++ b/lua/doom/modules/features/illuminate/init.lua @@ -16,7 +16,7 @@ illuminate.settings = { illuminate.packages = { ["vim-illuminate"] = { "RRethy/vim-illuminate", - commit = "c82e6d04f27a41d7fdcad9be0bce5bb59fcb78e5", + commit = "6bfa5dc069bd4aa8513a3640d0b73392094749be", }, } diff --git a/lua/doom/modules/features/indentlines/init.lua b/lua/doom/modules/features/indentlines/init.lua index 90e6a3324..40b75287d 100644 --- a/lua/doom/modules/features/indentlines/init.lua +++ b/lua/doom/modules/features/indentlines/init.lua @@ -11,18 +11,20 @@ indentlines.settings = { indentlines.packages = { ["indent-blankline.nvim"] = { "lukas-reineke/indent-blankline.nvim", - commit = "6177a59552e35dfb69e1493fd68194e673dc3ee2", + commit = "c15bbe9f23d88b5c0b4ca45a446e01a0a3913707", event = "ColorScheme", }, } indentlines.configs = {} indentlines.configs["indent-blankline.nvim"] = function() - require("indent_blankline").setup(vim.tbl_deep_extend("force", doom.features.indentlines.settings, { - -- To remove indent lines, remove the module. Having the module and - -- disabling it makes no sense. - enabled = true, - })) + require("indent_blankline").setup( + vim.tbl_deep_extend("force", doom.features.indentlines.settings, { + -- To remove indent lines, remove the module. Having the module and + -- disabling it makes no sense. + enabled = true, + }) + ) end return indentlines diff --git a/lua/doom/modules/features/lazygit/init.lua b/lua/doom/modules/features/lazygit/init.lua index 245592a2a..262ec26a5 100644 --- a/lua/doom/modules/features/lazygit/init.lua +++ b/lua/doom/modules/features/lazygit/init.lua @@ -7,7 +7,7 @@ lazygit.settings = {} lazygit.packages = { ["lazygit.nvim"] = { "kdheepak/lazygit.nvim", - commit = "1f9f372b9fc137b8123d12a78c22a26c0fa78f0a", + commit = "9c73fd69a4c1cb3b3fc35b741ac968e331642600", cmd = { "LazyGit", "LazyGitConfig" }, opt = true, }, diff --git a/lua/doom/modules/features/linter/init.lua b/lua/doom/modules/features/linter/init.lua index 57636db95..306388933 100644 --- a/lua/doom/modules/features/linter/init.lua +++ b/lua/doom/modules/features/linter/init.lua @@ -2,12 +2,15 @@ local linter = {} linter.settings = { format_on_save = false, + null_ls_settings = { + default_timeout = 2000, + }, } linter.packages = { ["null-ls.nvim"] = { "jose-elias-alvarez/null-ls.nvim", - commit = "dfdd5fab3c53c30f83c78ea351b9a8f65715a5b7", + commit = "47c04991af80b6acdf08a5db057908b52f4d0699", after = "nvim-lspconfig", }, } @@ -16,7 +19,8 @@ linter.configs = {} linter.configs["null-ls.nvim"] = function() local null_ls = require("null-ls") - null_ls.setup({ + local null_ls_settings = doom.features.linter.settings.null_ls_settings + null_ls.setup(vim.tbl_deep_extend("force", null_ls_settings, { on_attach = function(client) if client.server_capabilities.documentFormattingProvider @@ -30,17 +34,20 @@ linter.configs["null-ls.nvim"] = function() ]]) end end, - }) + })) end linter.binds = { { "cf", function() + local null_ls_settings = doom.features.linter.settings.null_ls_settings if type(vim.lsp.buf.format) == "function" then - vim.lsp.buf.format() + vim.lsp.buf.format({ + timeout_ms = null_ls_settings.default_timeout, + }) else - vim.lsp.buf.formatting_sync() + vim.lsp.buf.formatting_sync(nil, null_ls_settings.default_timeout) end end, name = "Format/Fix", diff --git a/lua/doom/modules/features/lsp/init.lua b/lua/doom/modules/features/lsp/init.lua index 835dc04b2..8cd31c354 100644 --- a/lua/doom/modules/features/lsp/init.lua +++ b/lua/doom/modules/features/lsp/init.lua @@ -5,6 +5,10 @@ local lsp = {} lsp.__completions_enabled = true lsp.settings = { + snippets = { + history = true, + updateevents = "TextChanged,TextChangedI", + }, signature = { bind = true, doc_lines = 10, @@ -31,7 +35,6 @@ lsp.settings = { hint = "", info = "", }, - virtual_text = false, severity_sort = true, completion = { kinds = { @@ -61,6 +64,9 @@ lsp.settings = { Operator = " ", TypeParameter = " ", }, + experimental = { + ghost_text = true, + }, completeopt = "menu,menuone,preview,noinsert", window = { documentation = { @@ -88,20 +94,23 @@ lsp.settings = { "sort_text", "length", "order", - } + }, } -local is_module_enabled = require("doom.utils").is_module_enabled lsp.packages = { ["nvim-lspconfig"] = { "neovim/nvim-lspconfig", - commit = "4eac16e87f24ad26738e632446e29766e87141ae", + commit = "60f2993b9661d9844cee3bebdbd1b5860577eb3c", module = "lspconfig", }, ["nvim-cmp"] = { "hrsh7th/nvim-cmp", - commit = "15c7bf7c0dfb7c75eb526c53f9574633c13dc22d", - after = is_module_enabled("features", "snippets") and "LuaSnip" or nil, + commit = "706371f1300e7c0acb98b346f80dad2dd9b5f679", + requires = { + "L3MON4D3/LuaSnip", + commit = "53e812a6f51c9d567c98215733100f0169bcc20a", + module = "luasnip", + }, }, ["cmp-nvim-lua"] = { "hrsh7th/cmp-nvim-lua", @@ -115,23 +124,22 @@ lsp.packages = { }, ["cmp-path"] = { "hrsh7th/cmp-path", - commit = "466b6b8270f7ba89abd59f402c73f63c7331ff6e", + commit = "447c87cdd6e6d6a1d2488b1d43108bfa217f56e1", after = "nvim-cmp", }, ["cmp-buffer"] = { "hrsh7th/cmp-buffer", - commit = "12463cfcd9b14052f9effccbf1d84caa7a2d57f0", + commit = "62fc67a2b0205136bc3e312664624ba2ab4a9323", after = "nvim-cmp", }, ["cmp_luasnip"] = { "saadparwaiz1/cmp_luasnip", commit = "a9de941bcbda508d0a45d28ae366bb3f08db2e36", after = "nvim-cmp", - disabled = not is_module_enabled("features", "snippets"), }, ["lsp_signature.nvim"] = { "ray-x/lsp_signature.nvim", - commit = "9ccee20602a10843e3ea3ebc2536dfdcc6cee9a3", + commit = "aea1e060d465fcb565bc1178e4189fc79524ba61", after = "nvim-lspconfig", }, } @@ -193,10 +201,14 @@ lsp.configs["nvim-lspconfig"] = function() end lsp.configs["nvim-cmp"] = function() local utils = require("doom.utils") - local snippets_enabled = utils.is_module_enabled("features", "snippets") - local cmp = require("cmp") - local luasnip = snippets_enabled and require("luasnip") + local cmp_ok, cmp = pcall(require, "cmp") + local luasnip_ok, luasnip = pcall(require, "luasnip") + if not cmp_ok or not luasnip_ok then + return + end + luasnip.config.set_config(doom.features.lsp.settings.snippets) + local replace_termcodes = utils.replace_termcodes local source_map = { @@ -221,7 +233,7 @@ lsp.configs["nvim-cmp"] = function() -- Fetch the comparators from cmp local comparators = require("cmp.config.compare") - doom.features.lsp.settings.sorting = vim.tbl_map(function (comparator) + doom.features.lsp.settings.sorting = vim.tbl_map(function(comparator) return comparators[comparator] end, doom.features.lsp.settings.sorting) @@ -232,11 +244,8 @@ lsp.configs["nvim-cmp"] = function() }, formatting = { format = function(entry, item) - item.kind = string.format( - "%s %s", - doom.features.lsp.settings.completion.kinds[item.kind], - item.kind - ) + item.kind = + string.format("%s %s", doom.features.lsp.settings.completion.kinds[item.kind], item.kind) item.menu = source_map[entry.source.name] item.dup = vim.tbl_contains({ "path", "buffer" }, entry.source.name) return item @@ -257,7 +266,7 @@ lsp.configs["nvim-cmp"] = function() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() - elseif snippets_enabled and luasnip.expand_or_jumpable() then + elseif luasnip.expand_or_jumpable() then vim.fn.feedkeys(replace_termcodes("luasnip-expand-or-jump"), "") elseif check_backspace() then vim.fn.feedkeys(replace_termcodes(""), "n") @@ -271,7 +280,7 @@ lsp.configs["nvim-cmp"] = function() [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif snippets_enabled and luasnip.jumpable(-1) then + elseif luasnip.jumpable(-1) then vim.fn.feedkeys(replace_termcodes("luasnip-jump-prev"), "") else fallback() @@ -364,7 +373,7 @@ lsp.binds = { end, name = "Line", }, - { "l", vim.lsp.diagnostic.set_loclist, name = "Loclist" }, + { "l", vim.diagnostic.setloclist, name = "Loclist" }, }, }, }, diff --git a/lua/doom/modules/features/lsp_progress/init.lua b/lua/doom/modules/features/lsp_progress/init.lua index 26f97468b..cc59feb7c 100644 --- a/lua/doom/modules/features/lsp_progress/init.lua +++ b/lua/doom/modules/features/lsp_progress/init.lua @@ -1,12 +1,11 @@ local fidget = {} -fidget.settings = { -} +fidget.settings = {} fidget.packages = { ["fidget.nvim"] = { "j-hui/fidget.nvim", - commit = "37d536bbbee47222ddfeca0e8186e8ee6884f9a2", + commit = "492492e7d50452a9ace8346d31f6d6da40439f0e", after = "nvim-lspconfig", }, } diff --git a/lua/doom/modules/features/minimap/init.lua b/lua/doom/modules/features/minimap/init.lua index d9908ef0f..6f3d3841f 100644 --- a/lua/doom/modules/features/minimap/init.lua +++ b/lua/doom/modules/features/minimap/init.lua @@ -5,7 +5,7 @@ minimap.settings = {} minimap.packages = { ["minimap.vim"] = { "wfxr/minimap.vim", - commit = "5d44fe7a3a5f7041c4220a71e8fe83d8c8498042", + commit = "3801d9dfaa5431e7b83ae6f98423ac077d9f5c3f", opt = true, cmd = { "Minimap", @@ -17,7 +17,6 @@ minimap.packages = { }, } - minimap.configs = {} minimap.binds = { @@ -34,7 +33,7 @@ minimap.binds = { }, }, }, - } + }, } return minimap diff --git a/lua/doom/modules/features/neogit/init.lua b/lua/doom/modules/features/neogit/init.lua index 7bec7f8a6..94866b88f 100644 --- a/lua/doom/modules/features/neogit/init.lua +++ b/lua/doom/modules/features/neogit/init.lua @@ -17,7 +17,7 @@ neogit.settings = {} neogit.packages = { ["neogit"] = { "TimUntersberger/neogit", - commit = "0ce803d22e361080ec0daf6bee7aad45e8cf8b07", + commit = "06e986fab0d0c31ba981b9f21c712dc72b3d237f", cmd = "Neogit", opt = true, }, diff --git a/lua/doom/modules/features/neorg/init.lua b/lua/doom/modules/features/neorg/init.lua index a442693a2..28ad6a3bd 100644 --- a/lua/doom/modules/features/neorg/init.lua +++ b/lua/doom/modules/features/neorg/init.lua @@ -59,7 +59,7 @@ neorg.settings = { neorg.packages = { ["neorg"] = { "nvim-neorg/neorg", - commit = "c0ebefa516aa9e93431f0a55e033db0dec072857", + commit = "2c4305eb32b10710a043380069c5538632160260", after = "nvim-treesitter", requires = "nvim-neorg/neorg-telescope", -- https://github.com/nvim-neorg/neorg-telescope#installation }, @@ -87,22 +87,22 @@ neorg.autocmds = { install_info = { url = "https://github.com/nvim-neorg/tree-sitter-norg", files = { "src/parser.c", "src/scanner.cc" }, - branch = "main" - } + branch = "main", + }, } parsers.norg_meta = { install_info = { url = "https://github.com/nvim-neorg/tree-sitter-norg-meta", files = { "src/parser.c" }, - branch = "main" - } + branch = "main", + }, } parsers.norg_table = { install_info = { url = "https://github.com/nvim-neorg/tree-sitter-norg-table", files = { "src/parser.c" }, - branch = "main" - } + branch = "main", + }, } vim.defer_fn(function() @@ -112,7 +112,7 @@ neorg.autocmds = { ensure_installed("norg_table") end, 0) end, - } + }, } -- If you're using the automatic keybind generation provided by Neorg you can diff --git a/lua/doom/modules/features/netrw/init.lua b/lua/doom/modules/features/netrw/init.lua index 9f883b951..d62fa5c6f 100644 --- a/lua/doom/modules/features/netrw/init.lua +++ b/lua/doom/modules/features/netrw/init.lua @@ -247,19 +247,29 @@ end local netrw = {} netrw.autocmds = { - { "FileType", "netrw", function() - draw_icons() - netrw_maps() - end}, - { "TextChanged", "*", function() - draw_icons() - end} + { + "FileType", + "netrw", + function() + draw_icons() + netrw_maps() + end, + }, + { + "TextChanged", + "*", + function() + draw_icons() + end, + }, } netrw.binds = { - 'o', name = '+open/close', { - { 'e', ':Lexplore', name = 'Explorer' } - } + "o", + name = "+open/close", + { + { "e", ":Lexplore", name = "Explorer" }, + }, } return netrw diff --git a/lua/doom/modules/features/projects/init.lua b/lua/doom/modules/features/projects/init.lua index f86cafe1c..87d146d87 100644 --- a/lua/doom/modules/features/projects/init.lua +++ b/lua/doom/modules/features/projects/init.lua @@ -1,6 +1,6 @@ local projects = {} -projects.settings ={ +projects.settings = { -- Manual mode doesn't automatically change your root directory, so you have -- the option to manually do so using `:ProjectRoot` command. manual_mode = false, @@ -38,7 +38,7 @@ projects.settings ={ projects.packages = { ["project.nvim"] = { "ahmedkhalf/project.nvim", - commit = "541115e762764bc44d7d3bf501b6e367842d3d4f", + commit = "e449497c0bceb6e50947b840ec3658bf1108bf0b", requires = { "nvim-treesitter/nvim-treesitter" }, }, -- https://github.com/shaeinst/penvim @@ -48,11 +48,11 @@ projects.configs = {} projects.configs["project.nvim"] = function() require("project_nvim").setup(doom.features.projects.settings) - table.insert(doom.features.telescope.settings.extensions, 'projects') + table.insert(doom.features.telescope.settings.extensions, "projects") end projects.binds = { - { 'fp', 'Telescope projects', name = 'Switch project' } + { "fp", "Telescope projects", name = "Switch project" }, } return projects diff --git a/lua/doom/modules/features/repl/init.lua b/lua/doom/modules/features/repl/init.lua new file mode 100644 index 000000000..9f1054930 --- /dev/null +++ b/lua/doom/modules/features/repl/init.lua @@ -0,0 +1,93 @@ +local repl = {} + +repl.settings = { + config = { + -- If iron should expose `(...)` mappings for the plugins + should_map_plug = false, + -- Whether a repl should be discarded or not + scratch_repl = true, + -- Your repl definitions come here + repl_definition = { + sh = { + command = { "zsh" }, + }, + }, + position = "right", + size = 20, + }, + -- Iron doesn't set keymaps by default anymore. Set them here + -- or use `should_map_plug = true` and map from you vim files + keymaps = { + send_motion = "rc", + visual_send = "rc", + send_file = "rf", + send_line = "rl", + -- send_mark = "sm", + -- mark_motion = "mc", + -- mark_visual = "mc", + -- remove_mark = "md", + cr = "s", + interrupt = "s", + exit = "sq", + clear = "cl", + }, + -- If the highlight is on, you can change how it looks + -- For the available options, check nvim_set_hl + highlight = { + italic = true, + }, +} + +repl.packages = { + ["iron.nvim"] = { + "hkupty/iron.nvim", + commit = "8fe71532ff25020970b0d216c22525f92097d573", + }, +} + +repl.configs = { + ["iron.nvim"] = function() + local iron = require("iron.core") + + local settings = vim.tbl_deep_extend("force", {}, doom.features.repl.settings) + settings.config.repl_open_command = + require("iron.view").curry[settings.config.position](settings.config.size) + + iron.setup(settings) + end, +} +repl.binds = { + { + "r", + name = "+repl", + { + { "r", "IronRepl", name = "Repl" }, + { "f", "", name = "Send file" }, + { "s", "", name = "Send line" }, + { "c", "", name = "Send visual / motion" }, + { "i", "", name = "Interupt repl" }, + { "", "", name = "Enter" }, + { "C", "", name = "Clear" }, + }, + }, + { + "", + function() + local iron = require("iron.core") + iron.send_line() + end, + name = "Repl send line", + mode = "n", + }, + { + "", + function() + local iron = require("iron.core") + iron.visual_send() + end, + name = "Repl visual send", + mode = "v", + }, +} + +return repl diff --git a/lua/doom/modules/features/restclient/init.lua b/lua/doom/modules/features/restclient/init.lua index 9e1c175c0..1203f3c1c 100644 --- a/lua/doom/modules/features/restclient/init.lua +++ b/lua/doom/modules/features/restclient/init.lua @@ -14,7 +14,6 @@ restclient.packages = { }, } - restclient.configs = {} restclient.configs["rest.nvim"] = function() require("rest-nvim").setup(doom.features.restclient.settings) @@ -34,7 +33,7 @@ restclient.binds = { }, }, }, - } + }, } return restclient diff --git a/lua/doom/modules/features/snippets/init.lua b/lua/doom/modules/features/snippets/init.lua deleted file mode 100644 index c186b5748..000000000 --- a/lua/doom/modules/features/snippets/init.lua +++ /dev/null @@ -1,22 +0,0 @@ -local snippets = {} - -snippets.settings = { - history = true, - updateevents = "TextChanged,TextChangedI", -} - -snippets.packages = { - ["LuaSnip"] = { - "L3MON4D3/LuaSnip", - commit = "52f4aed58db32a3a03211d31d2b12c0495c45580", - requires = { "rafamadriz/friendly-snippets", opt = true }, - }, -} - -snippets.configs = {} -snippets.configs["LuaSnip"] = function() - require("luasnip").config.set_config(doom.features.snippets.settings) - require("luasnip.loaders.from_vscode").lazy_load() -end - -return snippets diff --git a/lua/doom/modules/features/statusline/init.lua b/lua/doom/modules/features/statusline/init.lua index 7d0d21db3..2f06ded6c 100644 --- a/lua/doom/modules/features/statusline/init.lua +++ b/lua/doom/modules/features/statusline/init.lua @@ -133,7 +133,7 @@ end statusline.packages = { ["heirline.nvim"] = { "rebelot/heirline.nvim", - commit = "efbf99c48d03f456b19680a46f0e21acd6df5188", + commit = "805a158b2b44b015f7966b03cd9def489984be8f", }, } @@ -251,11 +251,8 @@ statusline.configs["heirline.nvim"] = function() init = function(self) local filename = self.filename local extension = vim.fn.fnamemodify(filename, ":e") - self.icon, self.icon_color = require("nvim-web-devicons").get_icon_color( - filename, - extension, - { default = true } - ) + self.icon, self.icon_color = + require("nvim-web-devicons").get_icon_color(filename, extension, { default = true }) end, provider = function(self) return self.icon and (self.icon .. " ") @@ -429,7 +426,7 @@ statusline.configs["heirline.nvim"] = function() require("heirline").setup(heirline_config) end -statusline.try_refresh = function () +statusline.try_refresh = function() xpcall(doom.modules.features.statusline.configs["heirline.nvim"], debug.traceback) end diff --git a/lua/doom/modules/features/symbols/init.lua b/lua/doom/modules/features/symbols/init.lua index 66e54b2ad..7ed13996a 100644 --- a/lua/doom/modules/features/symbols/init.lua +++ b/lua/doom/modules/features/symbols/init.lua @@ -29,8 +29,6 @@ symbols.packages = { }, } - - symbols.configs = {} symbols.configs["symbols_outline.nvim"] = function() vim.g.symbols_outline = doom.features.symbols.settings @@ -50,7 +48,7 @@ symbols.binds = { }, }, }, - } + }, } return symbols diff --git a/lua/doom/modules/features/tabline/init.lua b/lua/doom/modules/features/tabline/init.lua index 568bdd9ae..f3d20e2ea 100644 --- a/lua/doom/modules/features/tabline/init.lua +++ b/lua/doom/modules/features/tabline/init.lua @@ -138,7 +138,6 @@ tabline.packages = { }, } - tabline.configs = {} tabline.configs["bufferline.nvim"] = function() require("bufferline").setup(doom.features.tabline.settings) diff --git a/lua/doom/modules/features/telescope/init.lua b/lua/doom/modules/features/telescope/init.lua index b4a0dc0e5..74b6957c0 100644 --- a/lua/doom/modules/features/telescope/init.lua +++ b/lua/doom/modules/features/telescope/init.lua @@ -51,7 +51,7 @@ telescope.settings = { telescope.packages = { ["telescope.nvim"] = { "nvim-telescope/telescope.nvim", - commit = "e6b69b1488c598ff7b461c4d9cecad57ef708f9b", + commit = "b5833a682c511885887373aad76272ad70f7b3c2", cmd = "Telescope", opt = true, }, @@ -102,7 +102,7 @@ telescope.binds = function() { "`", function() - require("telescope.builtin").find_files({ cwd = vim.fn.expand("%:p:n") }) + vim.cmd(("Telescope find_files cwd=%s"):format(vim.fn.getcwd())) end, name = "Browse cwd", }, diff --git a/lua/doom/modules/features/terminal/init.lua b/lua/doom/modules/features/terminal/init.lua index b97503272..1edef0272 100644 --- a/lua/doom/modules/features/terminal/init.lua +++ b/lua/doom/modules/features/terminal/init.lua @@ -41,7 +41,7 @@ terminal.settings = { terminal.packages = { ["toggleterm.nvim"] = { "akinsho/toggleterm.nvim", - commit = "50f88d316261bfe56854cb75b9d092061c38b21e", + commit = "a7c9a6fd135f96639e2ac686691a32db6d011471", cmd = { "ToggleTerm", "TermExec" }, opt = true, }, diff --git a/lua/doom/modules/features/todo_comments/init.lua b/lua/doom/modules/features/todo_comments/init.lua index 25ec22273..02e7a03d5 100644 --- a/lua/doom/modules/features/todo_comments/init.lua +++ b/lua/doom/modules/features/todo_comments/init.lua @@ -9,8 +9,6 @@ todo_comments.packages = { }, } - - todo_comments.configs = {} todo_comments.configs["todo-comments.nvim"] = function() require("todo-comments").setup(doom.features.todo_comments.settings) diff --git a/lua/doom/modules/features/zen/init.lua b/lua/doom/modules/features/zen/init.lua index 595fa97e8..0abfc9d7a 100644 --- a/lua/doom/modules/features/zen/init.lua +++ b/lua/doom/modules/features/zen/init.lua @@ -57,7 +57,6 @@ zen.packages = { }, } - zen.configs = {} zen.configs["TrueZen.nvim"] = function() require("true-zen").setup(doom.features.zen.settings) @@ -66,8 +65,8 @@ end zen.binds = { { "", ":TZAtaraxis", name = "Enter Nirvana" }, { "t", name = "+tweaks", { - { "z", ":TZAtaraxis", name = 'Toggle Zen' } - } } + { "z", ":TZAtaraxis", name = "Toggle Zen" }, + } }, } return zen diff --git a/lua/doom/modules/langs/bash/init.lua b/lua/doom/modules/langs/bash/init.lua index 5e6cbff20..ec8ba9db2 100644 --- a/lua/doom/modules/langs/bash/init.lua +++ b/lua/doom/modules/langs/bash/init.lua @@ -1,7 +1,7 @@ local bash = {} bash.settings = { - language_server_name = 'bashls', + language_server_name = "bashls", } bash.autocmds = { @@ -9,7 +9,7 @@ bash.autocmds = { "BufWinEnter", "*.sh", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.bash.settings.language_server_name) vim.defer_fn(function() @@ -21,10 +21,11 @@ bash.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.shfmt + null_ls.builtins.formatting.shfmt, + null_ls.builtins.code_actions.shellcheck, + null_ls.builtins.diagnostics.shellcheck, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/c_sharp/init.lua b/lua/doom/modules/langs/c_sharp/init.lua index cbdd642ee..33e192e4a 100644 --- a/lua/doom/modules/langs/c_sharp/init.lua +++ b/lua/doom/modules/langs/c_sharp/init.lua @@ -1,7 +1,7 @@ local c_sharp = {} c_sharp.settings = { - language_server_name = 'omnisharp', + language_server_name = "omnisharp", } c_sharp.autocmds = { @@ -9,16 +9,16 @@ c_sharp.autocmds = { "BufWinEnter", "*.cs", function() - local langs_utils = require('doom.modules.langs.utils') - local lsp_util = require 'lspconfig.util'; + local langs_utils = require("doom.modules.langs.utils") + local lsp_util = require("lspconfig.util") langs_utils.use_lsp(doom.langs.c_sharp.settings.language_server_name, { config = { root_dir = function(fname) - return lsp_util.root_pattern '*.sln'(fname) - or lsp_util.root_pattern '*.csproj'(fname) - or lsp_util.root_pattern 'ProjectSettings'(fname) -- Add support for unity projects - end - } + return lsp_util.root_pattern("*.sln")(fname) + or lsp_util.root_pattern("*.csproj")(fname) + or lsp_util.root_pattern("ProjectSettings")(fname) -- Add support for unity projects + end, + }, }) require("nvim-treesitter.install").ensure_installed("c_sharp") diff --git a/lua/doom/modules/langs/config/init.lua b/lua/doom/modules/langs/config/init.lua index 197b8a3e9..d82c55ffd 100644 --- a/lua/doom/modules/langs/config/init.lua +++ b/lua/doom/modules/langs/config/init.lua @@ -4,12 +4,12 @@ local config = {} config.settings = { json_schemas = { - '.eslintrc', - 'package.json', - 'prettierrc.json', - 'tsconfig.json' + ".eslintrc", + "package.json", + "prettierrc.json", + "tsconfig.json", }, - json_language_server_name = 'jsonls', + json_language_server_name = "jsonls", -- toml_language_server_name = 'taplo', -- Currently broken -- yaml_language_server_name = 'yamlls', -- Currently broken } @@ -17,25 +17,25 @@ config.settings = { config.packages = { ["SchemaStore.nvim"] = { "b0o/SchemaStore.nvim", - commit = "442b79a05eea082f22273e59dd3da365e7077aa2", - ft = { "json", "yaml", "toml" } + commit = "65e845c491db027f93648dbf6241bc73e68a44d0", + ft = { "json", "yaml", "toml" }, }, -- git@github.com:someone-stole-my-name/yaml-companion.nvim.git -- https://github.com/cuducos/yaml.nvim } config.configs = {} config.configs["SchemaStore.nvim"] = function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.config.settings.json_language_server_name, { config = { settings = { json = { - schemas = require('schemastore').json.schemas { + schemas = require("schemastore").json.schemas({ select = doom.langs.config.settings.json_schemas, - }, + }), }, }, - } + }, }) end @@ -44,7 +44,7 @@ config.autocmds = { "BufWinEnter", "*.json,*.yaml,*.toml", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") -- langs_utils.use_lsp(doom.langs.config.settings.toml_language_server_name) -- langs_utils.use_lsp(doom.langs.config.settings.yaml_language_server_name) @@ -62,7 +62,6 @@ config.autocmds = { null_ls.builtins.diagnostics.jsonlint, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/dockerfile/init.lua b/lua/doom/modules/langs/dockerfile/init.lua new file mode 100644 index 000000000..622fd4f61 --- /dev/null +++ b/lua/doom/modules/langs/dockerfile/init.lua @@ -0,0 +1,38 @@ +local dockerfile = {} + +dockerfile.settings = { + --- Enable/Disable linting via hadolint + --- @type boolean + disable_linter = true, + --- Language server name + --- @type string + language_server_name = "dockerls", +} + +dockerfile.autocmds = { + { + "FileType", + "dockerfile", + function() + local settings = doom.langs.dockerfile.settings + local langs_utils = require("doom.modules.langs.utils") + langs_utils.use_lsp(settings.language_server_name) + + vim.defer_fn(function() + require("nvim-treesitter.install").ensure_installed("dockerfile") + end, 0) + + -- Setup null-ls + if doom.features.linter and not settings.disable_linter then + local null_ls = require("null-ls") + + langs_utils.use_null_ls_source({ + null_ls.builtins.diagnostics.hadolint, + }) + end + end, + once = true, + }, +} + +return dockerfile diff --git a/lua/doom/modules/langs/fish/init.lua b/lua/doom/modules/langs/fish/init.lua index fad8614dd..a7c597957 100644 --- a/lua/doom/modules/langs/fish/init.lua +++ b/lua/doom/modules/langs/fish/init.lua @@ -1,8 +1,6 @@ local fish = {} -fish.settings = { - -} +fish.settings = {} fish.autocmds = { { "BufWinEnter", @@ -13,13 +11,12 @@ fish.autocmds = { -- Setup null-ls if doom.features.linter then local null_ls = require("null-ls") - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_null_ls_source({ null_ls.builtins.formatting.fish_indent, null_ls.builtins.diagnostics.fish, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/glsl/init.lua b/lua/doom/modules/langs/glsl/init.lua index 9a6f9c0a1..f2e227db8 100644 --- a/lua/doom/modules/langs/glsl/init.lua +++ b/lua/doom/modules/langs/glsl/init.lua @@ -1,7 +1,6 @@ local glsl = {} -glsl.settings = { -} +glsl.settings = {} glsl.autocmds = { { @@ -9,7 +8,7 @@ glsl.autocmds = { "glsl", function() pcall(function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") require("nvim-treesitter.install").ensure_installed("glsl") @@ -18,7 +17,7 @@ glsl.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.shfmt + null_ls.builtins.formatting.shfmt, }) end end) @@ -29,7 +28,7 @@ glsl.autocmds = { "BufWinEnter", "*.glsl,*.vs,*.fs,*.frag,*.vert", function() - vim.bo.filetype = 'glsl' + vim.bo.filetype = "glsl" end, }, } diff --git a/lua/doom/modules/langs/go/init.lua b/lua/doom/modules/langs/go/init.lua index 5d81c9423..c0515d200 100644 --- a/lua/doom/modules/langs/go/init.lua +++ b/lua/doom/modules/langs/go/init.lua @@ -1,7 +1,7 @@ local go = {} go.settings = { - language_server_name = 'gopls', + language_server_name = "gopls", } -- go.packages = { @@ -13,7 +13,7 @@ go.autocmds = { "BufWinEnter", "*.go", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.go.settings.language_server_name) require("nvim-treesitter.install").ensure_installed("go") @@ -23,10 +23,9 @@ go.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.diagnostics.golangci_lint + null_ls.builtins.diagnostics.golangci_lint, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/haskell/init.lua b/lua/doom/modules/langs/haskell/init.lua index 3668a9371..170095ea9 100644 --- a/lua/doom/modules/langs/haskell/init.lua +++ b/lua/doom/modules/langs/haskell/init.lua @@ -1,7 +1,7 @@ local haskell = {} haskell.settings = { - language_server_name = 'hls', + language_server_name = "hls", } -- -- https://github.com/neovimhaskell/nvim-hs @@ -19,15 +19,15 @@ haskell.autocmds = { "BufWinEnter", "*.hs", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.haskell.settings.language_server_name) - local parser_config = require "nvim-treesitter.parsers".get_parser_configs() + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() parser_config.haskell = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-haskell", - files = {"src/parser.c", "src/scanner.c"} - } + files = { "src/parser.c", "src/scanner.c" }, + }, } require("nvim-treesitter.install").ensure_installed("haskell") @@ -36,10 +36,9 @@ haskell.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.fouremolu + null_ls.builtins.formatting.fouremolu, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/java/init.lua b/lua/doom/modules/langs/java/init.lua index b96754ada..1018514da 100644 --- a/lua/doom/modules/langs/java/init.lua +++ b/lua/doom/modules/langs/java/init.lua @@ -1,7 +1,7 @@ local java = {} java.settings = { - language_server_name = 'jdtls', + language_server_name = "jdtls", } java.autocmds = { @@ -9,7 +9,7 @@ java.autocmds = { "BufWinEnter", "*.java", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.java.settings.language_server_name) require("nvim-treesitter.install").ensure_installed("java") @@ -19,10 +19,9 @@ java.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.google_java_format + null_ls.builtins.formatting.google_java_format, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/javascript/init.lua b/lua/doom/modules/langs/javascript/init.lua index a9aa4baa7..c0ca5192e 100644 --- a/lua/doom/modules/langs/javascript/init.lua +++ b/lua/doom/modules/langs/javascript/init.lua @@ -1,3 +1,3 @@ -- Because javascript and typescript use the same tooling, -- this module is just an alias for the typescript module. -return require('doom.modules.langs.typescript') +return require("doom.modules.langs.typescript") diff --git a/lua/doom/modules/langs/kotlin/init.lua b/lua/doom/modules/langs/kotlin/init.lua index e0805ba72..c9fb8080c 100644 --- a/lua/doom/modules/langs/kotlin/init.lua +++ b/lua/doom/modules/langs/kotlin/init.lua @@ -1,7 +1,7 @@ local kotlin = {} kotlin.settings = { - language_server_name = 'kotlin_language_server', + language_server_name = "kotlin_language_server", } kotlin.autocmds = { @@ -9,7 +9,7 @@ kotlin.autocmds = { "BufWinEnter", "*.kt,*.kts", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.kotlin.settings.language_server_name) require("nvim-treesitter.install").ensure_installed("kotlin") @@ -18,7 +18,7 @@ kotlin.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.ktlint + null_ls.builtins.formatting.ktlint, }) end end, diff --git a/lua/doom/modules/langs/markdown/init.lua b/lua/doom/modules/langs/markdown/init.lua index b214e49f9..caf89aae3 100644 --- a/lua/doom/modules/langs/markdown/init.lua +++ b/lua/doom/modules/langs/markdown/init.lua @@ -1,7 +1,6 @@ local markdown = {} -markdown.settings = { -} +markdown.settings = {} markdown.autocmds = { { diff --git a/lua/doom/modules/langs/ocaml/init.lua b/lua/doom/modules/langs/ocaml/init.lua new file mode 100644 index 000000000..bcbc8370b --- /dev/null +++ b/lua/doom/modules/langs/ocaml/init.lua @@ -0,0 +1,26 @@ +local ocaml = {} + +ocaml.settings = { + language_server_name = "ocamllsp", +} + +ocaml.autocmds = { + { + "Filetype", + "ocaml,ocaml_interface,ocamllex", + function() + local langs_utils = require("doom.modules.langs.utils") + langs_utils.use_lsp(doom.langs.ocaml.settings.language_server_name) + + vim.schedule(function() + require("nvim-treesitter.install").ensure_installed("ocaml", "ocaml_interface") + if vim.fn.executable("tree-sitter-cli") == 1 then + require("nvim-treesitter.install").ensure_installed("ocamllex") + end + end) + end, + once = true, + }, +} + +return ocaml diff --git a/lua/doom/modules/langs/python/init.lua b/lua/doom/modules/langs/python/init.lua index a4fa73252..1a5444569 100644 --- a/lua/doom/modules/langs/python/init.lua +++ b/lua/doom/modules/langs/python/init.lua @@ -1,7 +1,7 @@ local python = {} python.settings = { - language_server_name = 'pyright', + language_server_name = "pyright", } -- lua.packages = { @@ -18,7 +18,7 @@ python.autocmds = { "BufWinEnter", "*.py", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.python.settings.language_server_name) require("nvim-treesitter.install").ensure_installed("python") @@ -29,10 +29,9 @@ python.autocmds = { langs_utils.use_null_ls_source({ null_ls.builtins.formatting.black, - null_ls.builtins.diagnostics.mypy + null_ls.builtins.diagnostics.mypy, }) end - end, once = true, }, diff --git a/lua/doom/modules/langs/ruby/init.lua b/lua/doom/modules/langs/ruby/init.lua index c99050eea..62851a953 100644 --- a/lua/doom/modules/langs/ruby/init.lua +++ b/lua/doom/modules/langs/ruby/init.lua @@ -1,23 +1,35 @@ --- https://github.com/lucapette/vim-ruby-doc - local ruby = {} --- ruby.settings = { --- language_server_name = '', --- } +ruby.settings = { + language_server_name = "solargraph", +} + +-- https://github.com/lucapette/vim-ruby-doc -- ruby.packages = { -- } --- ruby.autocmds = { --- { --- "", --- "", --- function() --- end, --- once = true, --- }, --- } +ruby.autocmds = { + { + "BufWinEnter", + "*.rb", + function() + local langs_utils = require("doom.modules.langs.utils") + langs_utils.use_lsp(doom.langs.ruby.settings.language_server_name) -return ruby + require("nvim-treesitter.install").ensure_installed("ruby") + + -- Setup null-ls + if doom.features.linter then + local null_ls = require("null-ls") + langs_utils.use_null_ls_source({ + null_ls.builtins.diagnostics.rubocop, + }) + end + end, + once = true, + }, +} + +return ruby diff --git a/lua/doom/modules/langs/rust/init.lua b/lua/doom/modules/langs/rust/init.lua index 8cb330e7d..58b375004 100644 --- a/lua/doom/modules/langs/rust/init.lua +++ b/lua/doom/modules/langs/rust/init.lua @@ -1,7 +1,6 @@ local rust = {} -rust.settings = { -} +rust.settings = {} -- lua.packages = { -- https://github.com/Saecki/crates.nvim @@ -17,9 +16,9 @@ rust.autocmds = { "BufWinEnter", "*.rs", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") - langs_utils.use_lsp('rust_analyzer') + langs_utils.use_lsp("rust_analyzer") require("nvim-treesitter.install").ensure_installed("rust") @@ -27,7 +26,7 @@ rust.autocmds = { if doom.features.linter then local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.rustfmt + null_ls.builtins.formatting.rustfmt, }) end end, diff --git a/lua/doom/modules/langs/svelte/init.lua b/lua/doom/modules/langs/svelte/init.lua index 437df7649..07c723d76 100644 --- a/lua/doom/modules/langs/svelte/init.lua +++ b/lua/doom/modules/langs/svelte/init.lua @@ -1,7 +1,7 @@ local svelte = {} svelte.settings = { - language_server_name = 'svelte', + language_server_name = "svelte", } svelte.autocmds = { @@ -9,7 +9,7 @@ svelte.autocmds = { "BufWinEnter", "*.svelte", function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") langs_utils.use_lsp(doom.langs.svelte.settings.language_server_name) vim.defer_fn(function() diff --git a/lua/doom/modules/langs/tailwindcss/init.lua b/lua/doom/modules/langs/tailwindcss/init.lua index e34cd6f77..2746435e3 100644 --- a/lua/doom/modules/langs/tailwindcss/init.lua +++ b/lua/doom/modules/langs/tailwindcss/init.lua @@ -1,17 +1,16 @@ -local utils = require('doom.utils'); +local utils = require("doom.utils") local tailwindcss = {} -tailwindcss.settings = { -} +tailwindcss.settings = {} tailwindcss.autocmds = { { "BufWinEnter", utils.make_run_once_function(function() - local langs_utils = require('doom.modules.langs.utils') + local langs_utils = require("doom.modules.langs.utils") - langs_utils.use_lsp('tailwindcss') + langs_utils.use_lsp("tailwindcss") vim.defer_fn(function() require("nvim-treesitter.install").ensure_installed("css") @@ -22,10 +21,9 @@ tailwindcss.autocmds = { local null_ls = require("null-ls") langs_utils.use_null_ls_source({ - null_ls.builtins.formatting.rustywind + null_ls.builtins.formatting.rustywind, }) end - end), once = true, }, diff --git a/lua/doom/modules/langs/terraform/init.lua b/lua/doom/modules/langs/terraform/init.lua index 1ae622e6c..18411bad8 100644 --- a/lua/doom/modules/langs/terraform/init.lua +++ b/lua/doom/modules/langs/terraform/init.lua @@ -1,18 +1,27 @@ local terraform = {} terraform.settings = { + language_server_name = "terraformls", } terraform.autocmds = { { - "FileType", - "terraform", + "BufWinEnter", + "*.hcl,*.tf,*.tfvars,*.nomad", function() - local langs_utils = require('doom.modules.langs.utils') - langs_utils.use_lsp('terraformls') + local langs_utils = require("doom.modules.langs.utils") + langs_utils.use_lsp(doom.langs.terraform.settings.language_server_name) local ts_install = require("nvim-treesitter.install") ts_install.ensure_installed("hcl") + -- + -- Setup null-ls + if doom.features.linter then + local null_ls = require("null-ls") + langs_utils.use_null_ls_source({ + null_ls.builtins.formatting.terraform_fmt, + }) + end end, once = true, }, diff --git a/lua/doom/modules/langs/typescript/init.lua b/lua/doom/modules/langs/typescript/init.lua index cb8f12c61..8e1193530 100644 --- a/lua/doom/modules/langs/typescript/init.lua +++ b/lua/doom/modules/langs/typescript/init.lua @@ -1,9 +1,8 @@ -local utils = require('doom.utils'); +local utils = require("doom.utils") local typescript = {} -typescript.settings = { -} +typescript.settings = {} -- https://github.com/jose-elias-alvarez/typescript.nvim @@ -12,8 +11,8 @@ typescript.autocmds = { "BufWinEnter", "*.js,*.jsx,*.ts,*.tsx", utils.make_run_once_function(function() - local langs_utils = require('doom.modules.langs.utils') - langs_utils.use_lsp('tsserver') + local langs_utils = require("doom.modules.langs.utils") + langs_utils.use_lsp("tsserver") vim.defer_fn(function() local ts_install = require("nvim-treesitter.install") diff --git a/lua/doom/modules/langs/utils.lua b/lua/doom/modules/langs/utils.lua index 5c218d4cd..3dc698fa1 100644 --- a/lua/doom/modules/langs/utils.lua +++ b/lua/doom/modules/langs/utils.lua @@ -1,4 +1,4 @@ -local log = require('doom.utils.logging') +local log = require("doom.utils.logging") local module = {} @@ -10,24 +10,31 @@ module.use_null_ls_source = function(sources) local null_ls = require("null-ls") for _, source in ipairs(sources) do -- Generate a unique key from the name/methods - local methods = type(source.method) == 'string' and source.method or table.concat(source.method, ' ') + local methods = type(source.method) == "string" and source.method + or table.concat(source.method, " ") local key = source.name .. methods -- If it's unique, register it if not registered_sources[key] then registered_sources[key] = source null_ls.register(source) else - log.warn(string.format('Attempted to register a duplicate null_ls source. ( %s with methods %s).', source.name, methods)) + log.warn( + string.format( + "Attempted to register a duplicate null_ls source. ( %s with methods %s).", + source.name, + methods + ) + ) end end end module.use_lsp = function(lsp_name, options) - local utils = require('doom.utils') + local utils = require("doom.utils") if not utils.is_module_enabled("features", "lsp") then return end - local lsp = require('lspconfig') + local lsp = require("lspconfig") local lsp_configs = require("lspconfig.configs") local opts = options or {} @@ -43,29 +50,31 @@ module.use_lsp = function(lsp_name, options) if utils.is_module_enabled("features", "illuminate") then table.insert(on_attach_functions, utils.illuminate_attach) end - if (opts.config and opts.config.on_attach) then + if opts.config and opts.config.on_attach then table.insert(on_attach_functions, opts.config.on_attach) end local capabilities_config = { capabilities = module.get_capabilities(), - on_attach = function (client) + on_attach = function(client) for _, handler in ipairs(on_attach_functions) do handler(client) end - end + end, } -- Start server and bind to buffers local start_lsp = function(server) - local final_config = vim.tbl_deep_extend('keep', opts.config or {}, capabilities_config) + local final_config = vim.tbl_deep_extend("keep", opts.config or {}, capabilities_config) if server and not is_custom_config then -- If using lsp-installer server:setup(final_config) else lsp[config_name].setup(final_config) local lsp_config_server = lsp[config_name] if lsp_config_server.manager then - local buffer_handler = lsp_config_server.filetypes and lsp_config_server.manager.try_add_wrapper or lsp_config_server.manager.try_add + local buffer_handler = lsp_config_server.filetypes + and lsp_config_server.manager.try_add_wrapper + or lsp_config_server.manager.try_add for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do buffer_handler(bufnr) end @@ -74,7 +83,7 @@ module.use_lsp = function(lsp_name, options) end -- Auto install if possible - if utils.is_module_enabled('auto_install') and not opts.no_installer then + if utils.is_module_enabled("features", "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/modules/langs/vue/init.lua b/lua/doom/modules/langs/vue/init.lua index 6090e68a1..4a11a0e7b 100644 --- a/lua/doom/modules/langs/vue/init.lua +++ b/lua/doom/modules/langs/vue/init.lua @@ -108,7 +108,7 @@ vue.autocmds = { -- Contains base configuration necessary for volar to start local base_config = { default_config = { - cmd = { 'vue-language-server', '--stdio' }, + cmd = { "vue-language-server", "--stdio" }, -- cmd = volar.document_config.default_config.cmd, root_dir = volar_root_dir, on_new_config = on_new_config, @@ -120,34 +120,22 @@ vue.autocmds = { }, } - local volar_api_config = vim.tbl_deep_extend( - "force", - {}, - doom.langs.vue.settings.volar_api, - base_config - ) + local volar_api_config = + vim.tbl_deep_extend("force", {}, doom.langs.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.langs.vue.settings.volar_doc, - base_config - ) + local volar_doc_config = + vim.tbl_deep_extend("force", {}, doom.langs.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.langs.vue.settings.volar_html, - base_config - ) + local volar_html_config = + vim.tbl_deep_extend("force", {}, doom.langs.vue.settings.volar_html, base_config) langs_utils.use_lsp("volar", { name = "volar_html", config = volar_html_config, diff --git a/lua/doom/services/keymaps.lua b/lua/doom/services/keymaps.lua index e9d42dc08..0a325d291 100644 --- a/lua/doom/services/keymaps.lua +++ b/lua/doom/services/keymaps.lua @@ -147,7 +147,7 @@ default_integration.handler = function(node, node_settings) local buffer = (node_settings.buffer == true) and 0 or node_settings.buffer local options = vim.tbl_extend("force", { - buffer = buffer + buffer = buffer, }, node_settings.options) vim.keymap.set(sanitizedMode, node.lhs, node.rhs, options) end diff --git a/lua/doom/tools/docs/keybind_doc_integration.lua b/lua/doom/tools/docs/keybind_doc_integration.lua index a7157ee74..19c7be439 100644 --- a/lua/doom/tools/docs/keybind_doc_integration.lua +++ b/lua/doom/tools/docs/keybind_doc_integration.lua @@ -16,20 +16,20 @@ --- @type NestIntegration local module = {} -module.name = 'keybind_doc_integration'; +module.name = "keybind_doc_integration" module.data = {} --- @param node NestIntegrationNode --- @param node_settings NestSettings -module.handler = function (node) +module.handler = function(node) -- If node.rhs is a table, this is a group of keymaps, if it is a string then it is a keymap - local is_keymap_group = type(node.rhs) == 'table' + local is_keymap_group = type(node.rhs) == "table" if not is_keymap_group then local row = {} for _, key in ipairs(module.keys) do - table.insert(row, node[key] or 'unset') + table.insert(row, node[key] or "unset") end table.insert(module.data, row) end @@ -39,7 +39,7 @@ module.set_table_fields = function(cols) module.keys = {} module.header = {} module.data = {} - for _, col in ipairs(cols)do + for _, col in ipairs(cols) do table.insert(module.keys, col.key) table.insert(module.header, col.name) end @@ -55,11 +55,11 @@ module.get_rows = function() end local pad_left = function(string, length, char) - local c = char or ' ' + local c = char or " " local current_length = string.len(string) local difference = length - current_length if difference > 0 then - for _=1,difference do + for _ = 1, difference do string = c .. string end end @@ -76,7 +76,9 @@ local get_max_lengths = function(rows) for _, row in ipairs(rows) do for index, cell in ipairs(row) do - print(index .. '| ' .. cell .. ' length is ' .. string.len(cell) .. ' vs ' .. max_lengths[index]) + print( + index .. "| " .. cell .. " length is " .. string.len(cell) .. " vs " .. max_lengths[index] + ) max_lengths[index] = math.max(max_lengths[index], string.len(cell)) end end @@ -89,19 +91,19 @@ module.print_markdown = function() local result = {} -- Print header line and divider - local header_line = '|' - local divider_line = '|' + local header_line = "|" + local divider_line = "|" for index, cell in ipairs(module.header) do - header_line = header_line .. string.format(' %s |', pad_left(cell, max_lengths[index])) - divider_line = divider_line .. string.format(' %s |', pad_left('', max_lengths[index], '-')) + header_line = header_line .. string.format(" %s |", pad_left(cell, max_lengths[index])) + divider_line = divider_line .. string.format(" %s |", pad_left("", max_lengths[index], "-")) end table.insert(result, header_line) table.insert(result, divider_line) for _, row in ipairs(module.data) do - local line = '|' + local line = "|" for index, cell in ipairs(row) do - line = line .. string.format(' %s |', pad_left(cell, max_lengths[index])) + line = line .. string.format(" %s |", pad_left(cell, max_lengths[index])) end table.insert(result, line) end @@ -113,8 +115,6 @@ module.print_markdown = function() return result end -module.clear = function() -end - -return module; +module.clear = function() end +return module diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index c62b6ffd4..43adf3989 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -9,7 +9,8 @@ utils.version = { minor = 0, patch = 0, } -utils.doom_version = string.format("%d.%d.%d", utils.version.major, utils.version.minor, utils.version.patch) +utils.doom_version = + string.format("%d.%d.%d", utils.version.major, utils.version.minor, utils.version.patch) -- Finds `filename` (where it is a doom config file). utils.find_config = function(filename) @@ -24,10 +25,8 @@ utils.find_config = function(filename) if fs.file_exists(path) then return path end - local candidates = vim.api.nvim_get_runtime_file( - get_filepath("*" .. system.sep .. "doon-nvim"), - false - ) + local candidates = + vim.api.nvim_get_runtime_file(get_filepath("*" .. system.sep .. "doon-nvim"), false) if not vim.tbl_isempty(candidates) then return candidates[1] end @@ -58,18 +57,12 @@ end --- Wraps lua's require function in an xpcall and logs errors. ---@param path string ---@return any -utils.safe_require = function (path) +utils.safe_require = function(path) local log = require("doom.utils.logging") log.debug(string.format("Doom: loading '%s'... ", path)) local ok, result = xpcall(require, debug.traceback, path) if not ok and result then - log.error( - string.format( - "There was an error requiring '%s'. Traceback:\n%s", - path, - result - ) - ) + log.error(string.format("There was an error requiring '%s'. Traceback:\n%s", path, result)) return nil else log.debug(string.format("Successfully loaded '%s' module", path)) @@ -98,10 +91,8 @@ end -- @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) + 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) @@ -121,9 +112,7 @@ utils.make_autocmd = function(event, pattern, action, group, nested, once) cmd = cmd .. "++once " end - cmd = type(action) == "function" - and cmd .. utils.commandify_function(action) - or cmd .. action + cmd = type(action) == "function" and cmd .. utils.commandify_function(action) or cmd .. action vim.cmd(cmd) end @@ -143,7 +132,7 @@ utils.make_augroup = function(group_name, cmds, existing_group) end end -utils.get_sysname = function () +utils.get_sysname = function() return vim.loop.os_uname().sysname end @@ -207,8 +196,7 @@ end utils.is_module_enabled = function(section, plugin) local modules = require("doom.core.modules").enabled_modules - return modules[section] - and vim.tbl_contains(modules[section], plugin) + return modules[section] and vim.tbl_contains(modules[section], plugin) end local modules_list_cache = {} @@ -225,7 +213,7 @@ utils.get_all_modules_as_list = function() all_modules[k].name = section_name end end - modules_list_cache = table.sort(all_modules, function (a, b) + modules_list_cache = table.sort(all_modules, function(a, b) return (a.priority or 100) < (b.priority or 100) end) return modules_list_cache diff --git a/lua/doom/utils/logging.lua b/lua/doom/utils/logging.lua index 106726965..9cdf81c19 100644 --- a/lua/doom/utils/logging.lua +++ b/lua/doom/utils/logging.lua @@ -70,13 +70,8 @@ log.new = function(config, standalone) local console_output = vim.schedule_wrap(function(level_config, info, nameupper, msg) local console_lineinfo = vim.fn.fnamemodify(info.short_src, ":t") .. ":" .. info.currentline - local console_string = string.format( - "[%-6s%s] %s: %s", - nameupper, - os.date("%H:%M:%S"), - console_lineinfo, - msg - ) + local console_string = + string.format("[%-6s%s] %s: %s", nameupper, os.date("%H:%M:%S"), console_lineinfo, msg) if config.highlights and level_config.hl then vim.cmd(string.format("echohl %s", level_config.hl)) @@ -111,9 +106,13 @@ log.new = function(config, standalone) -- Output to log file if config.use_file then local fp = io.open(outfile, "a") - local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg) - fp:write(str) - fp:close() + if not fp then + vim.cmd(string.format([[echom "Couldn't open log file [%s]"]], outfile)) + else + local str = string.format("[%-6s%s] %s: %s\n", nameupper, os.date(), lineinfo, msg) + fp:write(str) + fp:close() + end end end diff --git a/lua/user/modules/features/char_counter/init.lua b/lua/user/modules/features/char_counter/init.lua index 6df471cbb..1b8634c1a 100644 --- a/lua/user/modules/features/char_counter/init.lua +++ b/lua/user/modules/features/char_counter/init.lua @@ -2,7 +2,7 @@ local char_counter = {} char_counter.settings = { popup = { - position = '50%', + position = "50%", size = { width = 80, height = 40, @@ -20,8 +20,21 @@ char_counter.settings = { buf_options = { modifiable = true, readonly = true, - } - } + }, + }, +} + +char_counter.packages = { + ["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 @@ -36,49 +49,71 @@ char_counter._get_current_buffer_char_count = function() 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}, + { + "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) + { + "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} + 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` - } } + { + "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 diff --git a/modules.lua b/modules.lua index f9920987e..406a7efe3 100644 --- a/modules.lua +++ b/modules.lua @@ -4,6 +4,7 @@ -- what features are being used. -- -- Uncomment a plugin to enable it and comment out to disable and uninstall it. +-- Once done, restart doom-nvim and run `:PackerInstall`. -- TODO: REDO COMMENT HEADERS WITH FIGLET @@ -90,7 +91,7 @@ return { -- "vim_ui", -- improved `vim.ui` "virtual_types", -- ??? -- "code_outline", - -- "transparent" + -- "transparent", ------------------------------------------------------------------ -- ::: VCS / GIT ::: -- @@ -142,6 +143,7 @@ return { -- "markdown_tools", -- ?? -- "google_docs", "zen", + -- "repl", ------------------------------------------------------------------ -- ::: TABULAR ::: -- @@ -256,13 +258,13 @@ return { -- "ui_pipeline", -- "ui_toggle_components", -- "vigoux_templar", - }, langs = { -- Scripts "lua", "python", "bash", + -- "fish", -- Web "javascript", @@ -275,6 +277,7 @@ return { -- Compiled "rust", "cc", + -- "ocaml", -- JIT -- "c_sharp", @@ -283,10 +286,12 @@ return { "config", -- JSON, YAML, TOML "markdown", + -- "terraform", -- Terraform / hcl files support + "dockerfile", -- "fennel", -- "latex", - -- lisp + -- "lisp", -- "solidity", -- ethereum lang }, themes = { @@ -360,7 +365,6 @@ return { -- "zenbones", -- "zephyr", -- "zephyrium", - } } diff --git a/settings.lua b/settings.lua index 18e040cfe..832927905 100644 --- a/settings.lua +++ b/settings.lua @@ -1,7 +1,8 @@ --- this is only the `doom.settings` table so that user can make --- important overrides here if they like. We use treesitter to make sure --- that this file is in sync with the core. return { + -- Use the global statusline + -- @default = true + global_statusline = true, + -- Leader key for keybinds -- @default = ' ' leader_key = ' ', @@ -39,6 +40,18 @@ return { -- @default = false disable_suspension = true, + -- Set numbering + -- false : Enable number lines + -- true : Disable number lines + -- @default = false + disable_numbering = false, + + -- Set numbering style + -- false : Shows absolute number lines + -- true : Shows relative number lines + -- @default = true + relative_num = true, + -- h,l, wrap lines movement_wrap = true, @@ -73,6 +86,12 @@ return { -- @default = true highlight_yank = true, + -- Use clipboard outside of vim + -- false : won't use third party clipboard + -- true : enables third part clipboard + -- @default = true + clipboard = true, + -- Enable guicolors -- Enables gui colors on GUI versions of Neovim -- @default = true @@ -102,6 +121,12 @@ return { -- @default = false use_floating_win_packer = false, + -- Set max cols + -- Defines the column to show a vertical marker + -- Set to false to disable + -- @default = 80 + max_columns = 80, + -- Default indent size -- @default = 4 indent = 4, diff --git a/contribute/Dockerfile b/tools/Dockerfile similarity index 80% rename from contribute/Dockerfile rename to tools/Dockerfile index abea988a9..cb311e5cf 100644 --- a/contribute/Dockerfile +++ b/tools/Dockerfile @@ -24,12 +24,18 @@ RUN pacman -Sy neovim --noconfirm # Install runtime dependencies of doom-nvim RUN pacman -Sy ripgrep nodejs-lts-fermium npm git bash gcc jq --noconfirm +# Lua +RUN pacman -Sy luacheck stylua --noconfirm + # Required for nvim-lsp-installer -RUN pacman -Sy wget unzip +RUN pacman -Sy wget unzip make --noconfirm # Required for watching Doom-nvim-contrib for changes RUN npm i -g chokidar-cli +# Required for OCaml language +# RUN pacman -Sy opam diffutils patch ocaml --noconfirm + # Create the doom user and group RUN groupadd doom RUN useradd -m -g doom doom @@ -40,6 +46,9 @@ RUN chown -R ${UNAME}:${GNAME} /usr/local/lib/node_modules/ USER doom WORKDIR /home/doom +# Required for OCaml language +# RUN opam init --disable-sandboxing && opam install ocaml-lsp-server -y + COPY _docker_entry.sh /usr/local/bin/ # Doom-nvim-contrib diff --git a/contribute/README.md b/tools/README.md similarity index 79% rename from contribute/README.md rename to tools/README.md index 809570fe6..d0a8224c7 100644 --- a/contribute/README.md +++ b/tools/README.md @@ -1,6 +1,6 @@ # Contributing Tools for Doom Neovim -This directory stores various tools and automations to help contributors or develpers of doom-nvim. +This directory stores various tools and automations to help contributors or develpers of doom-nvim. ## Doom Contrib Docker Image `./start_docker.sh` @@ -19,13 +19,13 @@ options: -h Shows this help menu ``` -The script will start an instance of neovim that uses `./contribute/doom-nvim-contrib/` for configuration. +The script will start an instance of neovim that uses `./tools/doom-nvim-contrib/` for configuration. You will then be able to start making changes within `doom-nvim-contrib` without breaking your existing config. ### What this script does 1. On first execution it will setup a git worktree of doom-nvim, this means your main config and this copy of the repo will share the same git history. - - This worktree will be placed in the `contribute/doom-nvim-contrib` folder inside of this repository. + - This worktree will be placed in the `tools/doom-nvim-contrib` folder inside of this repository. - Because they share history you wont be able to checkout the same branch on both copies of the repository. Unless specified, a new branch called `doom-nvim-contrib` will be created off the latest version of `develop`. 2. It will setup a new docker image to run this config within (if necessary). 3. It will then start the docker image and enter you into neovim. @@ -34,13 +34,13 @@ You will then be able to start making changes within `doom-nvim-contrib` without These are the folders used by this docker image, they will be auto generated when `./start_docker.sh` is run -`contribute/doom-nvim-contrib/` - Git worktree for doom-nvim contributions -`contribute/local-share-nvim/` - Stores the data from `~/.local/share/nvim/` -`contribute/workspace/` - Directory to store test files and project that you want to test your changes upon +`tools/doom-nvim-contrib/` - Git worktree for doom-nvim contributions +`tools/local-share-nvim/` - Stores the data from `~/.local/share/nvim/` +`tools/workspace/` - Directory to store test files and project that you want to test your changes upon ## Pinned Dependencies `./update_dependencies.sh` -This script parses the `lua/doom/modules/init.lua` file and pins each plugin to the latest commit in the default branch. +This script parses the `lua/doom/modules/init.lua` file and pins each plugin to the latest commit in the default branch. We should update these dependencies with each release of doom-nvim, and test everything working together to ensure a stable experience for users. Pinned/frozen dependencies can be disabled using the `freeze_dependencies` configuration option in `doom_config.lua`. @@ -48,7 +48,7 @@ Pinned/frozen dependencies can be disabled using the `freeze_dependencies` confi Run the following command in the root of the neovim folder. ```bash -cd contribute && ./update_dependencies.sh` +cd tools && ./update_dependencies.sh` ``` ### Issues diff --git a/contribute/_docker_entry.sh b/tools/_docker_entry.sh similarity index 100% rename from contribute/_docker_entry.sh rename to tools/_docker_entry.sh diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 000000000..aaf25de43 --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash + +declare -r XDG_DATA_HOME="${XDG_DATA_HOME:-"$HOME/.local/share"}" +declare -r XDG_CACHE_HOME="${XDG_CACHE_HOME:-"$HOME/.cache"}" +declare -r XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"$HOME/.config"}" + +DOOM_REPO_URL="https://github.com/NTBBloodbath/doom-nvim" +declare -r DOOM_CONFIG_DIR="${DOOM_CONFIG_DIR:-"$XDG_CONFIG_HOME/nvim"}" + +declare BASEDIR +BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)" +BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")" +readonly BASEDIR + +RED=$(tput setaf 1) +YELLOW=$(tput setaf 3) +GREEN=$(tput setaf 2) +NC=$(tput sgr0) # No Color + +function help() { + echo "Usage: install.sh []" + echo "Automatically installs doom-nvim to your machine." + echo "" + echo "Options:" + echo " -h, --help Print this message" + echo " -y, --yes Skip all prompts" +} + +declare -a system_dependencies=("nvim" "git" "node" "npm" "fd;optional" "rg;optional" "wget;optional" "unzip;optional") +declare -a npm_dependencies=("tree-sitter") + +function banner() { + echo " " + echo "================= =============== =============== ======== ========" + echo "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //" + echo "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||" + echo "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||" + echo "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||" + echo "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||" + echo "||. . || ||-' || || \`-|| || . .|| ||. . || ||-' || || \`|\\_ . .|. .||" + echo "|| . _|| || || || || ||_ . || || . _|| || || || |\\ \`-_/| . ||" + echo "||_-' || .|/ || || \\|. || \`-_|| ||_-' || .|/ || || | \\ / |-_.||" + echo "|| ||_-' || || \`-_|| || || ||_-' || || | \\ / | \`||" + echo "|| \`' || || \`' || || \`' || || | \\ / | ||" + echo "|| .===' \`===. .==='.\`===. .===' /==. | \\/ | ||" + echo "|| .==' \\_|-_ \`===. .===' _|_ \`===. .===' _-|/ \`== \\/ | ||" + echo "|| .==' _-' \`-_ \`=' _-' \`-_ \`=' _-' \`-_ /| \\/ | ||" + echo "|| .==' _-' \`-__\\._-' \`-_./__-' \`' |. /| | ||" + echo "||.==' _-' \`' | /==.||" + echo "==' _-' N E O V I M \\/ \`==" + echo "\\ _-' \`-_ /" + echo " \`'' \`\`' " +} + +function executable_exists () { + if ! command -v "$1" &>/dev/null; then + return 0 + fi + return 1 +} + +function check_dependency_group () { + local dependency_group_name=$1 + local install_message=$2 + shift + shift + echo "Checking $dependency_group_name dependencies..." + local missing_dependencies=0 + for i in "$@"; do + # The recommended changes break the string splitting + # shellcheck disable=2206 + local split_result=(${i//;/ }) + local executable="${split_result[0]}" + local optional=${split_result[1]} + + executable_exists "${executable}" + local dependency_status=$? + + if [ $dependency_status -eq 1 ]; then + echo "$GREEN [*]$NC Found \"$executable\"." + else + missing_dependencies=1 + if [ "$optional" = "optional" ]; then + echo "$YELLOW [ ]$NC Could not find optional dependency \"$executable\"." + else + echo "$RED [ ]$NC Could not find dependency \"$executable\"." + fi + fi + done + + if [ $missing_dependencies -eq 1 ]; then + echo "Missing dependencies detected. Optional dependencies can be ignored but may be necessary for some modules." + echo "$install_message" + fi + echo " " +} + +function backup_existing_config() { + if [ -d "$DOOM_CONFIG_DIR" ]; then + echo "${YELLOW}Warning:$NC There is already a config at $DOOM_CONFIG_DIR." + echo " " + echo "Do you want to continue installing doom-nvim? (y/n)" + echo "Note: The old config will be backed up to ${XDG_CONFIG_HOME}/nvim-old" + echo " " + read -p "" -n 1 -r + echo " " # (optional) move to a new line + if [[ $REPLY =~ ^[Yy]$ ]]; then + # If nvim-old directory doesn`t exist, move `nvim/` to `nvim-old/' + if [ ! -d "${XDG_CONFIG_HOME}/nvim-old" ]; then + mv "${XDG_CONFIG_HOME}/nvim" "${XDG_CONFIG_HOME}/nvim-old" + echo "Moved old config from \`${XDG_CONFIG_HOME}/nvim\` to \`${XDG_CONFIG_HOME}/nvim-old\`" + else + # If it already exists try placing it in `nvim-old-1/` then `nvim-old-2/` (up until 10) + local i=1 + local has_found_directory=0 + while [[ $has_found_directory -eq 0 && $i -lt 10 ]]; do + i=$((i+1)) + has_found_directory=$([ -d "${XDG_CONFIG_HOME}/nvim-old-${i}" ]) + done + + if [[ $has_found_directory -eq 1 ]]; then + mv "${XDG_CONFIG_HOME}/nvim" "${XDG_CONFIG_HOME}/nvim-old-${i}" + echo "Moved old config from \`${XDG_CONFIG_HOME}/nvim\` to \`${XDG_CONFIG_HOME}/nvim-old-${i}\`" + fi + fi + fi + fi + echo " " +} + +function install_doom_nvim() { + echo "Cloning..." + git clone "$DOOM_REPO_URL" "${DOOM_CONFIG_DIR}" --depth=10 + cd "${DOOM_CONFIG_DIR}" || exit + # Setup user with their own custom branch + git checkout -b my-config + + # Checkout the latest version if there are no uncommitted changes + # NOTE: There shouldn't ever be uncommitted changes on a freshly cloned repo + # but I still don't want to risk the possibility of destroying someone's code. + local is_dirty=0 + git diff-index --quiet HEAD -- || is_dirty=1; + + echo " " + if [ $is_dirty -eq 0 ]; then + local tag + tag="$(git tag -l --sort -version:refname | head -n 1)" + git reset --hard "$tag" + echo "${GREEN}Installed doom-nvim ${tag}!" + else + echo "${GREEN}Installed doom-nvim!" + echo "${YELLOW}Warn: Could not checkout latest tag due to uncommitted changes. \`:DoomUpdate\` command may not work." + fi + +} + +function main() { + banner + + check_dependency_group "system" "Install missing dependencies using your operating system's package manager (brew/pacman/apt-get/dnf/...)." "${system_dependencies[@]}" + check_dependency_group "npm" "Install missing dependencies using npm/yarn/pnpm." "${npm_dependencies[@]}" + + backup_existing_config + install_doom_nvim + + echo "Run \`nvim\` in your terminal to start doom-nvim." +} + +main "$@" diff --git a/contribute/start_docker.sh b/tools/start_docker.sh similarity index 89% rename from contribute/start_docker.sh rename to tools/start_docker.sh index 4aaeb5a67..4e77d4d6c 100755 --- a/contribute/start_docker.sh +++ b/tools/start_docker.sh @@ -49,7 +49,7 @@ if [[ ! -d "$SCRIPT_DIR"/doom-nvim-contrib ]]; then if git show-ref --quiet refs/heads/"$BRANCH_NAME"; then git worktree add ./doom-nvim-contrib "$BRANCH_NAME" else - git worktree add ./doom-nvim-contrib origin/develop -b "$BRANCH_NAME" + git worktree add ./doom-nvim-contrib origin/develop -b "$BRANCH_NAME" fi fi @@ -58,15 +58,17 @@ cd ./doom-nvim-contrib || exit echo "1. Setting up branch" # If branch exists just check it out -if git show-ref --quiet refs/heads/"$BRANCH_NAME"; then +if ! git symbolic-ref -q HEAD; then + echo "In detached HEAD state, not moving branch" +elif git show-ref --quiet refs/heads/"$BRANCH_NAME"; then if [[ ! $( git rev-parse --abbrev-ref HEAD ) == "$BRANCH_NAME" ]]; then echo " - Checking out branch $BRANCH_NAME..." git checkout "$BRANCH_NAME" fi -else - # Pull latest version of develop - echo " - Creating new branch off develop..." - git checkout -b "$BRANCH_NAME" develop +else + # Pull latest version of main + echo " - Creating new branch off main..." + git checkout -b "$BRANCH_NAME" main git fetch --quiet # If changes between local and origin, get latest changes if [[ ! $( git rev-list develop...origin/develop --count ) -eq 0 ]]; then @@ -98,6 +100,7 @@ fi # Create docker container if haven't already echo " - Success! Running docker container doom-nvim-contrib-container..." +mkdir -p "${SCRIPT_DIR}/local-share-nvim" "${SCRIPT_DIR}/workspace" echo "" docker run \ -it \ @@ -108,6 +111,6 @@ docker run \ -v "$SCRIPT_DIR"/workspace:/home/doom/workspace \ --name doom-nvim-contrib-container \ --user doom \ - doom-nvim-contrib + doom-nvim-contrib diff --git a/contribute/update_dependencies.sh b/tools/update_dependencies.sh similarity index 100% rename from contribute/update_dependencies.sh rename to tools/update_dependencies.sh