diff --git a/.gitignore b/.gitignore index fb3a9c1dc..a58273cfb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ # My temp files -plugin/ -sessions/ -undodir/ time_cost.txt tags # Backup files @@ -16,3 +13,5 @@ tags contribute/doom-nvim-contrib contribute/local-share-nvim contribute/workspace +# Editor files +.luarc.json diff --git a/.luacheckrc b/.luacheckrc index 8646d0643..10336acbe 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,13 +1,17 @@ stds.nvim = { globals = { - vim = { fields = { "g" } }, + vim = { fields = { "g", "opt" } }, table = { fields = { "unpack" } }, package = { fields = { "searchers" } }, + doom = { fields = { "packages", "binds", "autocmds" } }, + _doom = { fields = { "cmp_enable" } } }, read_globals = { "vim", "jit", "packer_plugins", + "doom", + "_doom" }, } std = "lua51+nvim" @@ -22,8 +26,4 @@ ignore = { "631", -- Line is too long. } -exclude_files = { - "plugin/packer_compiled.lua", -} - -- vim: ft=lua sw=2 ts=2 diff --git a/README.md b/README.md index 442f2a127..1b8e931aa 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ Its design is guided by these mantras: - `nodejs` and `npm` (optional, required to use some Language Server Protocols) - `wget`, `unzip` (optional, required for auto installing LSPs) -Doom is comprised of [~40 optional plugins][modules], some of which may have +Doom is comprised of [~40 optional modules][modules], some of which may have additional dependencies. [Please visit their documentation][modules]. ## Install @@ -111,9 +111,6 @@ First you'll want to backup your current Neovim configuration if you have one. > > 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 -> [installing with cheovim](#installing-with-cheovim). ```sh [ -d ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ] && mv ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ${XDG_CONFIG_HOME:-$HOME/.config}/nvim.bak @@ -132,27 +129,6 @@ Or if you want to live in the bleeding-edge with the latest features: git clone --depth 1 -b develop https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ``` -### Installing with cheovim - -If you're using cheovim as your Neovim configurations manager you can install `doom-nvim` and then -use the recipe listed in cheovim documentation: - -```sh -# Clone doom-nvim under a specific directory under our '~/.config' directory -git clone --depth 1 https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/doom-nvim - -# Change the doom-nvim internal path -sed -i "37s/nvim/doom-nvim/" ${XDG_CONFIG_HOME:-$HOME/.config}/doom-nvim/lua/doom/core/system/init.lua -``` - -```lua --- In your '~/.config/nvim/profiles.lua' -doom_nvim = { "~/.config/doom-nvim", { - plugins = "packer", - preconfigure = "doom-nvim" - } -} -``` --- Then [read our Getting Started guide][getting-started] to be walked through @@ -160,7 +136,7 @@ installing, configuring and maintaining Doom Nvim. ## Getting help -Neovim is not very difficult. Although you will occasionally run into problems +Although Neovim is not very difficult, you will occasionally run into problems if you are not an advanced vimmer. When you do, here are some places you can look help: - [Our documentation][documentation] covers many use cases. @@ -175,15 +151,14 @@ if you are not an advanced vimmer. When you do, here are some places you can loo ## Acknowledgements -- [hlissner](https://github.com/hlissner) per doing Doom Emacs :heart:. -- [romgrk](https://github.com/romgrk) per doing a port to Vim of Doom One - colorscheme from Doom Emacs (and everyone who improves the colorscheme!). +- [hlissner](https://github.com/hlissner) for making Doom Emacs :heart:. +- [romgrk](https://github.com/romgrk) for making a port of Doom One to Vim :heart:. - [All our contributors](#contributors) per helping improve Doom :heart: ## Contribute - I really :heart: pull requests and bug reports (please see the [Contributing Guidelines][contribute] before contributing)! -- Don't hesitate to [tell me my Lua coding style sucks](https://github.com/NTBBloodbath/doom-nvim/issues/new), +- Don't hesitate to [tell me my Lua sucks](https://github.com/NTBBloodbath/doom-nvim/issues/new), but please tell me why. ## Contributors diff --git a/config.lua b/config.lua new file mode 100644 index 000000000..bfe4aebc0 --- /dev/null +++ b/config.lua @@ -0,0 +1,7 @@ +-- doom_config - Doom Nvim user configurations file +-- +-- This file contains the user-defined configurations for Doom nvim. +-- Just override stuff in the `doom` global table (it's injected into scope +-- automatically). + +-- vim: sw=2 sts=2 ts=2 expandtab diff --git a/docs/contributing.md b/docs/contributing.md index f75a16425..6f025a9f4 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -52,7 +52,7 @@ thus reach a solution more quickly. Some important data would be: - Your custom configuration if you have one - (`doom_modules.lua`, `doom_config.lua` and `doom_userplugins.lua`) + (`modules.lua` and `config.lua`) - Which branch of Doom Nvim are you using - Which plugins are you using diff --git a/docs/faq.md b/docs/faq.md index c44878f83..17203bc81 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -4,42 +4,17 @@ ### What type of vimmer is Doom Nvim intended for? -Doom Nvim is intended for all types of Vimmer who want a stable and efficient +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 to: - -- some features would be lost -- Not all Lua plugins have good alternatives in Vimscript, so the experience - would not be the same -- performance would not be the same as Lua cannot be used +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. - -> **NOTE**: In case that you're using cheovim (with `/home/user/.config/doom-nvim` -> as your Doom Nvim path) then you will need to change this variable value manually -> by tweaking [this](../lua/doom/core/system/init.lua) file. - -After changing your configurations path you will surely want to remove your -`~/.config/nvim/plugin/packer_compiled.lua` and running `:PackerCompile` again. - -Also you will need to create a symlink from your new path to the old one for -avoiding issues when updating Doom Nvim. Here is a snippet for this task. - -```sh -# Change this variable path if you have installed Doom Nvim in other place -DOOM_ROOT="${XDG_CONFIG_HOME:-$HOME/.config}/nvim" -# Change this variable path if you have changed the Doom Nvim doom_configs_root variable -DOOM_CONFIG_ROOT="${XDG_CONFIG_HOME:-$HOME/.config}/doom-nvim" - -# Let's iterate over the configurations path directory files and create a symlink for them -for _config_file in $(ls "$DOOM_CONFIG_ROOT"); do - ln -s "${DOOM_CONFIG_ROOT}/$_config_file" "${DOOM_ROOT}/$_config_file" -done -``` diff --git a/docs/getting_started.md b/docs/getting_started.md index b2827c874..9aacf69b2 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -10,9 +10,9 @@ This is what you will have installed by the end of this section: - **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 LanguageServerProtocols (LSP) and the plugins using LSP, like the symbols-outline plugin. +- **Optional**: node & npm, required to use some Language Server Protocols (LSP) and packages using LSP, like the symbols-outline plugin. -These packages ought to be available through the package managers of your OS; +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 @@ -81,6 +81,8 @@ MacPorts currently only has Neovim v0.4.4 #### On Windows +> **NOTE**: new module architecture is pending tests on Windows. + ##### [Chocolatey](https://community.chocolatey.org/) ``` @@ -237,37 +239,17 @@ Or if you want to live in the bleeding-edge with the latest features: git clone --depth 1 -b develop https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/nvim ``` -#### Using cheovim - -If you're using cheovim as your Neovim configurations manager you can install `doom-nvim` and then -use the recipe listed in cheovim documentation: - -```sh -# Clone doom-nvim under a specific directory under our '~/.config' directory -git clone --depth 1 https://github.com/NTBBloodbath/doom-nvim.git ${XDG_CONFIG_HOME:-$HOME/.config}/doom-nvim - -# Change the doom-nvim internal path -sed -i "37s/nvim/doom-nvim/" ${XDG_CONFIG_HOME:-$HOME/.config}/doom-nvim/lua/doom/core/system/init.lua -``` - -```lua --- In your '~/.config/nvim/profiles.lua' -doom_nvim = { "~/.config/doom-nvim", { - plugins = "packer", - preconfigure = "doom-nvim" - } -} -``` - ## Update & Rollback ### Update Doom Nvim -To update Doom Nvim, you have two options, run `:DoomUpdate` or SPC - d - u +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 @@ -296,7 +278,7 @@ rm -rf ${XDG_CONFIG_HOME:-$HOME/.config}/nvim \ #### Rolling Back Doom -Did the update screwed up your setup because of a bug or a breaking change and you want to rollback? +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). @@ -305,351 +287,89 @@ a previous release (for main branch) or a previous commit (for development branc ## Configuration -You can configure Doom Nvim by tweaking the `doom_config.lua`, -`doom_modules.lua` and the `doom_userplugins.lua` files located in your -Doom Nvim root directory (`$HOME/.config/doom-nvim/` by default). - -### doom_modules.lua - -This file handles all the Doom Nvim modules, its structure is really simple and -easy to understand. - -This one will look like that: - -```lua -local M = {} -M.source = debug.getinfo(1, "S").source:sub(2) - -M.modules = { - ui = { - "dashboard", -- Start screen - -- "doom-themes", -- Additional doom emacs' colorschemes - -- "indentlines", -- Show indent lines - -- "show_registers", -- popup that shows register contents - "statusline", -- Statusline - "tabline", -- Tabline, shows your buffers list at top - "which-key", -- Keybindings popup menu like Emacs' guide-key - -- "zen", -- Distraction free environment - }, - doom = { - -- "compiler", -- Compile (and run) your code with just pressing three keys! - -- "neorg", -- Life Organization Tool - -- "runner", -- Open a REPL for the current language or run the current file - }, - editor = { - "autopairs", -- Autopairs - "auto-session", -- A small automated session manager for Neovim - "dap", -- Debug Adapter Protocol - -- "editorconfig", -- EditorConfig support for Neovim - "explorer", -- Tree explorer - "formatter", -- File formatting - "gitsigns", -- Git signs - "kommentary", -- Comments plugin - "lsp", -- Language Server Protocols - -- "minimap", -- Code minimap, requires github.com/wfxr/code-minimap - -- "ranger", -- Ranger File Browser, requires ranger file browser - "snippets", -- LSP snippets - "symbols", -- LSP symbols and tags - "telescope", -- Highly extendable fuzzy finder over lists - -- "terminal", -- Terminal for Neovim (NOTE: needed for runner and compiler) - }, - langs = { - -- To enable the language server for a language just add the +lsp flag - -- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter - -- parser and rust-analyzer - -- - -- "bash", -- The terminal gods language - -- "config", -- Configuration files (JSON, YAML, TOML) - -- "cpp", -- C++ support - -- "css", -- CSS support - -- "dockerfile", -- Do you like containers, right? - -- "elixir", -- Build scalable and maintainable software - -- "go", -- Hello, gopher - -- "haskell", -- Because Functional programming is fun, isn't it? - -- "html", -- HTML support - -- "java", -- Java support - -- "javascript", -- JavaScript support - "lua", -- Support for our gods language - -- "python +lsp", -- Python support + lsp - -- "ruby", -- Look ma, I love the gems! - -- "rust +lsp", -- Let's get rusty! - -- "typescript", -- TypeScript support - }, - utilities = { - -- "lazygit", -- LazyGit integration for Neovim, requires LazyGit - -- "neogit", -- Magit for Neovim - "range-highlight", -- hightlights ranges you have entered in commandline - -- "suda", -- Write and read files without sudo permissions - }, - web = { - -- "colorizer", -- Fastest colorizer for Neovim - -- "firenvim", -- requires firenvim browser extension; change fontsize by increasing guifontsize in doom_config - -- "restclient", -- A fast Neovim http client - } -} - -return M -``` +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 -And as the `doom_modules.lua` file self-documentation says, you will only need to uncomment -or comment the plugins names in order to enable or disable them. e.g. to enable the `terminal` -plugin you will only need to uncomment the `-- 'terminal',` line and restart Neovim. -Doom will automatically handle your changes and install the `terminal` plugin for you. +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]. -### doom_config.lua +### config.lua This file handles all the Doom Nvim configurations, including the ability to easily create new custom mappings and global Neovim variables. -All the options are self-documented on it so you can easily modify them and know -exactly what you are doing. - -This is its structure: - -```lua -local doom = { - -- Here lies all the Doom Nvim configurations -} - -local nvim = { - -- Here lies all the custom Neovim configurations -} - -return { - doom = doom, - nvim = nvim, -} -``` +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. -### doom_userplugins.lua - -This file handles your custom plugins, in other words, it handles all the extra -plugins you need that are not covered by Doom Nvim. - -If you are familiar with [packer.nvim] then you can see this file as a wrapper -for its `use` function. - -This one just contains a `return {}` statement. Your plugins should be declared -inside the returned table, e.g. if you want to install `markdown-preview.nvim`: - -```lua -return { - { - 'iamcco/markdown-preview.nvim', - run = 'cd app && yarn install', - event = 'BufRead', - }, -} -``` - -And as with the `doom_modules.lua` file, Doom Nvim will automatically handle your changes -and install or uninstall the plugins declared on here. - -> **NOTE**: all the valid options for declaring plugins can be found in -> [specifying plugins](https://github.com/wbthomason/packer.nvim#specifying-plugins). - -### Modules - -Doom Nvim consists of around 5 modules. A Doom Nvim Module is a bundle of plugins, -configuration and commands, organized into a unit that can be toggled easily by -tweaking your `doom_modules.lua` (found in `$HOME/.config/doom-nvim`). - -Please see [Plugin Management](#plugin-management) for more information. - ### Plugin Management Doom Nvim uses a declarative and use-package inspired package manager called [packer.nvim](https://github.com/wbthomason/packer.nvim). -Modules and plugins are declared in `lua/doom/modules/init.lua` file, located -in your Doom Nvim root directory. Read on to learn how to use this system to install -your own plugins. +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 install plugins directly in `lua/doom/modules/init.lua`. Instead, -> use your `doom_modules.lua` and `doom_userplugins.lua` files to modify them. +> **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 `doom_config.lua` file, -please see :h doom_nvim_options to know how to. - -#### Configuring plugins - -Do you want to change some configurations of some modules? - -Go to `lua/doom/modules/config` directory and you will find the configurations -for the plugins. - -Otherwise if you want to configure a plugin declared in your `doom_userplugins.lua` you -can use the packer's `config` field, e.g. - -```lua -{ - 'TimUntersberger/neogit', - config = function() - require('neogit').setup() - end, -} -``` +You can change Doom's default settings by tweaking your `config.lua` file, +please see [modules] to know how. -##### Configuring LSP - -[Language Server Protocols](https://microsoft.github.io/language-server-protocol/) is installed as a plugin. - -To easily install language servers and without having to do it system-wide or having to -manually configure servers, Doom Nvim makes use of [MordechaiHadad/nvim-lspmanager](https://github.com/MordechaiHadad/nvim-lspmanager). - -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 and install `rust-analyzer`: - -```lua -local doom = { - langs = { - 'rust +lsp', -- Let's get rusty! - } -} -``` - -You can also override or add additional LSPs for a language using the `+lsp(OVERRIDE)` syntax. - -```lua -local doom = { - langs = { - 'html +lsp(html, tailwindcss)' -- Enable extra LSPs for a language - 'vue +lsp(volar)' -- Or override the default - } -} -``` - -> **NOTE**: You can see a list of currently supported languages at [bundled installers](https://github.com/MordechaiHadad/nvim-lspmanager#supported-language-servers). - -### Binding keys - -You can modify the default keybindings by modifying the following files: - -- `lua/doom/extras/keybindings/init.lua` - General and SPC keybindings -- `lua/doom/modules/config` - lua plugins keybindings - -You can also define your own keybindings in your `doom_config.lua` with the `nvim.mappings` field. - -## Migrating to 3.0.0 +## 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 dying in the -attempt. - -But first let's see what's new: +This section is made to help you migrate to this version without having to +respawn. ### Changes for end users -- Raw speed, never go slow again. - Reduced average startuptime from 400ms to 40ms (tested with old hardware), - special thanks to [vhyrro]! -- New and better doom-one colorscheme written in pure Lua. Because the - colorscheme matters. -- Fragmented configuration file (`doomrc`) so it will be more easy to customize - Doom. See [New configurations](#new-configurations). -- Easily add new Neovim settings by using your `doom_config.lua` file. - Extensibility is a feature that you cannot miss, and what better than being - able to extend Doom as much as you want? -- New logging system powered by [vlog]. A faster and smaller logging system - because complexity is not always the best choice. -- Easily enable and disable plugins. Now toggling the doom default plugins is easier - than before, just comment or uncomment it in your `doom_modules.lua`! -- Better custom plugins management. Now the custom plugins are being directly - handled by packer as it should be, no more nonsense wrappers around it. -- Better updating mechanism. Forget these annoying merging issues and save the - current state of your Doom Nvim installation in case that you need to rollback - your Doom Nvim version because of the demons! -- Added a `DoomRollback` command. Something went wrong after updating? No worries, - just rollback to a previous version (stable branch) or a previous commit - (development branch) and be piece of mind! -- Built-in plugins. Because we should have some utilities to make our lives - easier, isn't this how it should be? See [modules/doom] for more information. -- A lot of bug fixes. +- 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 -- Better documentation. Added docs for each doom lua module because - documentation is the core of all projects. -- Restructured source code. Now the doom nvim source code is much cleaner and - easier to understand. - -Now that we know what's new we will surely want to update, isn't it? - -Due to the new raw speed we highly recommend that you do a fresh installation so -everything will be work as it should. **Make sure to backup your doomrc changes -so you can apply your changes to the new `doom_config.lua` configuration file**. - -We don't recommend using the `:DoomUpdate` command for this task because of the -huge changes that doom nvim gotten. This command will only end in a really -bad status for this release due to git merging issues. - -With that being said, you can run the following command snippet: - -> **IMPORTANT:** -> -> 1. Make sure to read everything it does before executing it. -> -> 2. If you are using cheovim just remove and clone the doom-nvim repository again. - -```sh -cp $HOME/.config/doom-nvim/doomrc $HOME/.config/doomrc.bak \ - && rm -rf $HOME/.config/doom-nvim $HOME/.local/share/nvim/site/pack/packer \ - && unlink $HOME/.config/nvim \ - && curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/bin/install.sh | bash -s -- -d -``` - -This snippet will do the following tasks for you: - -1. Create a copy of your doomrc so you can use a diff tool later with the - actual breaking changes to doomrc structure. -2. Remove the doom-nvim configuration directory and all plugins (including packer). -3. Remove the residual symlink that doom-nvim have created before during the - installation (**omit that step if you're using cheovim**). -4. Clone doom-nvim source to where it belongs again by using the installer - (installing the development branch because this version is not released yet). - -Then you'll only need to start Neovim and start using it as usual! +- 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 -Since version 3.0.0 the doomrc has been fragmented into some files, but why? - -This was done to benefit both contributors and end users as follows: - -- Improve understanding. One file that handles everything doesn't seem like a - good thing on a large scale. -- Easier to maintain. Divided by function, the new files make the code more - readable and easy to modify. - -And now, how can I start using the new configuration files? - -I'm going to explain you in a short way because the new configuration files has -a rich documentation inside them. - -- `doom_modules.lua`, this file handles the Doom Nvim modules, in other words, which - plugins are being installed and loaded and which plugins are not. -- `doom_config.lua`, this file handles the user configurations for doom nvim, - e.g. if mouse is enabled or not. This one also handles user-defined Neovim - configurations like global variables and mappings. -- `doom_userplugins.lua`, this file handles the user-defined plugins, it is the - replacement for the `custom_plugins` field in the old doomrc. - -> Are you having issues with the 3.0.0 version? Don't hesitate to [report them] -> so we can fix them and make doom more stable because that's the way to improve software. -[vlog]: https://github.com/tjdevries/vlog.nvim [packer.nvim]: https://github.com/wbthomason/packer.nvim [vhyrro]: https://github.com/vhyrro [modules]: ./modules.md -[modules/doom]: https://github.com/NTBBloodbath/doom-nvim/tree/develop/lua/doom/modules/doom [report them]: https://github.com/NTBBloodbath/doom-nvim/issues/new diff --git a/docs/modules.md b/docs/modules.md index 9b485fd89..5cdc1374c 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -2,69 +2,76 @@ ## Introduction -Doom Nvim consists of around 5 modules with ~40 plugins and growing. -A Doom Nvim module is a bundle of plugins, configurations and commands, -organized into a unit that can be toggled easily. +Doom Nvim consists of around 40 plugins and growing. +A Doom Nvim module is a bundle of packages, configurations, autocommands and +binds, organized into a unit that can be toggled easily. > **NOTE**: Doom Nvim uses [packer.nvim] as its plugins manager. -## Tweaking Doom Nvim Modules +## Toggling Doom Nvim Modules -You can easily tweak Doom Nvim Modules by tweaking your `doom_modules.lua` file -(found in `~/.config/doom-nvim`). +You can easily toggle Doom Nvim Modules by tweaking your `doom-nvim/modules.lua` file +(found in `~/.config/doom-nvim`). Return from this file a flat list of modules +you want. The `core` module is required and need not be listed. ## List of modules First of all, we must know which modules are there and their plugins. -> **NOTE:** all plugins can be disabled, including the UI ones. +> **NOTE:** all modules can be disabled, except `core`. Also, anything can be +overriden in `doom-nvim/config.lua`, from packer specs to vim options. -### Essentials +### Essentials in core -This ones are implicit plugins so the end user cannot disable them. But why? +This is the one module you cannot disable. But why? -That is because these plugins are the core of Doom so in fact, things can break -without them. These plugins are the following: +That is because these plugins are the core of Doom, why would you want a +framework without these basic functionalies? These plugins are the following: - [packer.nvim] - A use-package inspired plugin manager for Neovim. -- [treesitter] +- [nvim-treesitter and companions] - An incremental parsing system for programming tools. +- [nest.nvim] + - A better way to set keybindings and create nvim-mapper structures. +- [nvim-mapper] + - A cheatsheet generator for your binds. -### UI +### UI modules +- [colorizer] + - Fastest colorizer for Neovim. - [dashboard] - Vim dashboard (start screen). -- [doom-themes] +- [doom_themes] - Additional doom emacs' colorschemes. - [indentlines] - Show indent lines. +- [range_highlight] + - Highlights ranges you have entered in commandline - [statusline] - Neovim statusline. - [tabline] - Tabline, shows your buffers list at top. -- [which-key] - - Keybindings popup like Emacs' guide-key. +- [whichkey] + - Keybindings popup like Emacs' whichj-key. - [zen] - Distraction free environment. -### Doom -- [compiler] (built-in) - - Compile _and run_ your projects with only a few keystrokes. +### Lang modules + - [neorg] - Life Organization Tool. -- [runner] (built-in) - - A code runner for your interpreted code. -### Editor +### Editor modules - [autopairs] - Autopairs. -- [auto-session] +- [auto_session] - A small automated session manager for Neovim. - [editorconfig] - - EditorConfig support for Neovim, let other argue about tabs vs spaces. + - EditorConfig support for Neovim, let other people argue about tabs vs spaces. - [explorer] - Tree explorer. - [formatter] @@ -74,7 +81,7 @@ without them. These plugins are the following: - [kommentary] - Comments plugin. - [lsp] - - Language Server Protocols ([compe] + [lspinstall]). + - Language Server Protocols ([cmp] + [lspconfig]). - [minimap] - Code minimap, requires [wfxr/code-minimap](https://github.com/wfxr/code-minimap). - snippets @@ -86,195 +93,53 @@ without them. These plugins are the following: - [terminal] - Terminal for Neovim. -### Langs - -The languages module entries has some flags that improves their experience and -makes your life easier. - -The currently available flags are the following: - -- `+lsp` - enables and installs the Language Server Protocol for the language. - e.g. `rust +lsp` will automatically install `rust-analyzer`. -- `+debug` - enables and installs the Debug Adapter Protocol client for the - language. e.g. `python +debug` will automatically install `debugpy`. - -> **NOTE**: when the language entry is not commented, doom-nvim will automatically -> install the TreeSitter parser for that language too. - -#### Web development - -- **css** - - CSS support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **html** - - HTML support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **javascript** - - JavaScript support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes, by using TSServer. - - DAP client: yes. -- **PHP** - - PHP support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **typescript** - - TypeScript support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes (via javascript). -- **Svelte** - - Svelte support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes (via javascript). -- **Vue** - - Vue support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes (via javascript). - -#### Scripting - -- **bash** - - BASH support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **clojure** - - Clojure support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **elixir** - - Elixir support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. -- **lua** - - Lua support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no (it has but isn't supported by Doom _yet_, requires extra setup). -- **powershell** - - PowerShell support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **python** - - Python support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes. -- **ruby** - - Ruby support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes. - -#### Compiled - -- **cpp** - - CPP support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes (not supported _yet_ by Doom for automatic installation). -- **c_sharp (C#)** - - C# support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **go** - - Golang support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes. -- **haskell** - - Haskell support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **java** - - Java support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **kotlin** - - Kotlin support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: no. -- **rust** - - Rust support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - - DAP client: yes (not supported _yet_ by Doom for automatic installation). - -#### Configs & DevOps - -- **json**/**json5** - - JSON support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. -- **yaml** - - YAML support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. -- **toml** - - TOML support. - - TreeSitter based syntax highlighting: yes. - - LSP: no. -- **xml** - - XML support. - - TreeSitter based syntax highlighting: yes. - - LSP: no. -- **dockerfile** - - Docker support. - - TreeSitter based syntax highlighting: yes. - - LSP: yes. - -> **NOTE**: this group requires the `lsp` installed for the `+lsp` flags. - -### Utilities +### Utilities modules - [lazygit] - LazyGit integration for neovim, requires LazyGit. - [neogit] - Magit for Neovim. -- [range-highlight] - - Highlights ranges you have entered in commandline - [suda] - Write and read files without sudo permissions. - -### Web - -- [colorizer] - - Fastest colorizer for Neovim. +- [superman] + - Manage man files. - [restclient] - A fast Neovim http client. ## Managing modules -Since version 3.0.0 managing the modules plugins is really easy because you -don't need to learn nothing anymore. Just comment the plugins that you don't -want to use and uncomment the ones that you are going to use! - -So by example, if you want to disable the tree explorer you can simply comment it. - -```lua --- Before, the plugin is enabled -'explorer', -- Tree explorer - --- After, the plugin is disabled --- 'explorer', -- Tree explorer -``` - -After doing the changes, just restart Neovim and Doom Nvim will handle the plugins -changes for you! +Configurations go in `doom-nvim/config.lua`. In this file, a `doom` global variable +is injected with defaults suh that you can override or insert to your liking. + +Common patterns: + +> **NOTE**: prefer setting the leaf keys, setting an entire table will override +> everything. + +- Install package/override existing if name is already there: + ```lua + -- Use fork. + doom.packages[name][1] = "myfork/name.nvim" + -- Add config to be run after module config. + doom.packages[name].config = function() + require("name.whatever").do_something({ + -- .. + }) + end + ``` +- Add binds to your liking: + ```lua + table.insert(doom.binds, { + { "RnT", "RipAndTear", name = "Until it is done" }, + }) + ``` +- Add autocmds (`doom_` will be prefixed to the name): + ```lua + doom.autocmds[augroup_name] = { + { "BufReadPre", "*.lua", "setlocal sw=2", --[[once and nested are boolean keys here]] }, + { "InsertEnter", "*", function() print("Lua functions are valid!") end, once = true } + } + ``` @@ -300,7 +165,7 @@ changes for you! [neorg]: https://github.com/vhyrro/neorg [lsp]: https://github.com/neovim/nvim-lspconfig -[compe]: https://github.com/hrsh7th/nvim-compe +[cmp]: https://github.com/hrsh7th/nvim-cmp [lsp-installer]: https://github.com/williamboman/nvim-lsp-installer [LuaSnip]: https://github.com/L3MON4D3/LuaSnip [friendly-snippets]: https://github.com/rafamadriz/friendly-snippets diff --git a/doom_config.lua b/doom_config.lua deleted file mode 100644 index 5b06596bd..000000000 --- a/doom_config.lua +++ /dev/null @@ -1,480 +0,0 @@ --- doom_config - Doom Nvim user configurations file --- --- This file contains the user-defined configurations for Doom nvim and consists --- in two Lua tables: --- 1. Doom, this one defines all the Doom nvim configurations that you can --- tweak to fit your needs or tastes. --- --- 2. Nvim, this one defines all the custom configurations that you want to --- use in Neovim, e.g. a colorscheme italic_comments global variable - -local M = {} - -M.source = debug.getinfo(1, "S").source:sub(2) - -M.config = { - doom = { - -- Pins plugins to a commit sha to prevent breaking changes - -- @default = true - freeze_dependencies = true, - - -- Autosave - -- false : Disable autosave - -- true : Enable autosave - -- @default = false - autosave = false, - - -- Format on save - -- false : Disable format on save - -- true : Enable format on save - -- @default = false - fmt_on_save = false, - - -- Disable Vim macros - -- false : Enable Vim macros - -- true : Disable Vim macros - -- @default = false - disable_macros = false, - - -- Use netrw as files explorer - -- false : Use nvim-tree.lua - -- true : Use netrw - -- @default = false - use_netrw = false, - - -- Enable folding - -- true : fold is enabled - -- false : fold is disabled - -- @default = true - foldenable = true, - - -- Autosave sessions - -- false : Disable session autosave - -- true : Enable session autosave - -- @default = false - autosave_sessions = false, - - -- Autoload sessions - -- false : Disable session autoload - -- true : Enable session autoload - -- @default = false - autoload_last_session = false, - - -- Enable Swap files - -- false : no swap files - -- true : enables swap files - -- @default = false - swap_files = false, - - -- Undo Directories - -- the backup variable enables backup related settings (undofile, undodir) - -- false : ignores undo Directories (this code block will be ignored) - -- true : enable undo files/undo dirs. - -- @default = false - -- WARNING: if you change this to false and you have an undo dir already, - -- it will REMOVE the undodir (loss of data might take place) - backup = false, - - -- Enable Line wrapping - -- false : disables line wrapping - -- true : enables line wrapping - -- @default = false - line_wrap = false, - - -- Enable Show mode ( -- INSERT --, -- NORMAL --, -- VISUAL -- ) - -- false : disables show mode - -- true : enables show mode - -- @default = false - show_mode = false, - - -- Enable scroll off - -- false : disables scroll off - -- true : enables scroll off - -- @default = true, @default scrolloff_amount = 4, - scrolloff = true, - scrolloff_amount = 4, - - -- Enable mouse - -- false : disables mouse - -- true : enables mouse - -- @default = true - mouse = true, - - -- Preserve last editing position - -- false : Disable preservation of last editing position - -- true : Enable preservation of last editing position - -- @default = false - preserve_edit_pos = false, - - -- Allow overriding the default Doom Nvim keybinds - -- false : Default keybinds cannot be overwritten - -- true : Default keybinds can be overwritten - -- @default = true - allow_default_keymaps_overriding = true, - - -- horizontal split on creating a new file (fn) - -- false : doesn't split the window when creating a new file - -- true : horizontal split on creating a new file - -- @default = true - new_file_split = true, - - -- enable current line highlight - -- false : disables current line highlight - -- true : enables current line highlight - -- @default = true - line_highlight = true, - - -- Automatically split right - -- false : splits left (vertically) - -- true : splits right (vertically) - -- @default = true - split_right = true, - - -- Automatically split above - -- false : splits above (horizontally) - -- true : splits below (horizontally) - -- @default = true - split_below = true, - - -- Use clipboard outside of vim - -- false : won't use third party clipboard - -- true : enables third part clipboard - -- @default = true - clipboard = true, - - -- Enable auto comment (current line must be commented) - -- false : disables auto comment - -- true : enables auto comment - -- @default = false - auto_comment = false, - - -- Show indent lines - -- @default = true - show_indent = true, - - -- Expand tabs - -- Specifies if spaces or tabs must be used - -- false : spaces - -- true : tabs - -- @default = true - expand_tabs = 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, - - -- Enable winwidth - -- false : Manually set win width - -- true : Active window auto sets width - -- @default = false, @default win_width_nr = 85 - win_width = false, - win_width_nr = 85, - - -- Enable Highlight on yank - -- false : disables highligh on yank - -- true : enables highlight on yank - -- @default = true - highlight_yank = true, - - -- Enable guicolors - -- Enables gui colors on GUI versions of Neovim - -- @default = true - enable_guicolors = true, - - -- Tree explorer on the right - -- Places the Tree explorer buffer to the right when enabled - -- @default = false - explorer_right = false, - - -- Show hidden files - -- @default = true - show_hidden = true, - - -- Checkupdates on start - -- @default = false - check_updates = false, - - -- Auto install plugins on launch, useful if you don't want to run - -- PackerInstall every time you add a new plugin - -- @default = true - auto_install_plugins = true, - - -- Disable dashboard status line (does not work perfectly) - -- false : disables dashboard status line - -- true : enables dashboard status line - -- @default = true - dashboard_statline = true, - - -- Show the editing file path in your status line - -- false : show only file name on status line - -- true : show file name and the updir in status line - statusline_show_file_path = true, - - -- Set the keybindings modules that you want to use - -- false : disables keybindings module - -- true : enables keybindings module - keybinds_modules = { - -- Core doom keybindings - core = true, - -- Movement keybindings, jump between your windows, buffers and code - movement = true, - -- Leader keybindings, a bunch of useful keybindings managed by space key - -- WARNING: disabling this will break which-key plugin if the plugin is enabled - leader = true, - -- Completion and snippets keybindings - completion = true, - }, - - -- sequences used for escaping insert mode - -- @default = { 'jk', 'kj' } - escape_sequences = { "jk", "kj" }, - - -- Disable or enable Doom autocommands, this can break some configuration options (they will stop working) - -- e.g. preserve_edit_pos or autosave - -- - -- false : enable autocommands module - -- true : disable autocommands module - -- @default = false - disable_autocommands = false, - - -- Enable LSP diagnostics virtual text - -- @default = false - enable_lsp_virtual_text = false, - - -- Use floating windows for plugins manager (packer) operations - -- @default = false - use_floating_win_packer = false, - - -- Default indent size - -- @default = 4 - indent = 4, - - -- Set max cols - -- Defines the column to show a vertical marker - -- @default = 80 - max_columns = 80, - - -- Completion box height - -- @default = 10 - complete_size = 10, - - -- Completion box transparency - -- 0 = no transparency - -- 100 = fully transparent - -- @default = 25 - complete_transparency = 25, - - -- Sidebar sizing - -- Specifies the default width of Tree Explorer and Tagbar - -- @default = 25 - sidebar_width = 25, - - -- Set the Terminal width - -- Applies only to float direction - -- @default = 70 - terminal_width = 70, - - -- Set the Terminal height - -- Applies to all directions except window - -- @default = 20 - terminal_height = 20, - - -- Conceal level - -- Set Neovim conceal level - -- 0 : Disable indentline and show all - -- 1 : Conceal some functions and show indentlines - -- 2 : Concealed text is completely hidden unless it has a custom replacement - -- character defined - -- 3 : Concealed text is completely hidden - conceallevel = 0, - - -- Logging level - -- Set Doom logging level - -- Available levels: - -- · trace - -- · debug - -- · info - -- · warn - -- · error - -- · fatal - -- @default = 'info' - logging = "info", - - -- Set the Terminal direction - -- Available directions: - -- - vertical - -- - horizontal - -- - window - -- - float - -- @default = 'horizontal' - terminal_direction = "horizontal", - - -- NOTE: This will only be activated if 'backup' is true. - -- We don'recommend you put this outside of neovim so we've restricted to the path: ~/.config/nvim - -- WARNING: only put the folder name that you want. (eg: undo_dir = '/undodir') - -- @default_directory = '~/.config/nvim/undodir' - undo_dir = "/undodir", - - -- Default colorscheme - -- @default = doom-one - colorscheme = "doom-one", - - -- Background color - -- @default = dark - colorscheme_bg = "dark", - - -- Doom One colorscheme settings - doom_one = { - -- If the cursor color should be blue - -- @default = false - cursor_coloring = false, - -- If TreeSitter highlighting should be enabled - -- @default = true - enable_treesitter = true, - -- If the comments should be italic - -- @default = false - italic_comments = false, - -- If the telescope plugin window should be colored - -- @default = true - telescope_highlights = true, - -- If the built-in Neovim terminal should use the doom-one - -- colorscheme palette - -- @default = false - terminal_colors = true, - -- If the Neovim instance should be transparent - -- @default = false - transparent_background = false, - }, - - -- Set gui fonts here - -- @default = "FiraCode Nerd Font", @default font size = 15, - -- WARNING: Font sizes must be in string format! - guifont = "FiraCode Nerd Font", - guifont_size = "15", - - -- Change Which Key background color - -- can use hex, or normal color names (eg: Red, Gree, Blue) - -- @default = #202328 - whichkey_bg = "#202328", - - -- Set your custom lsp diagnostic symbols below - lsp_error = "", - lsp_warn = "", - lsp_hint = "", - lsp_info = "", - lsp_virtual_text = " ", - - -- Set your linters for the programming languages that you use, - -- see https://github.com/mfussenegger/nvim-lint#available-linters - linters = { - c = {}, - cpp = {}, - css = {}, - html = {}, - javascript = {}, - lua = {}, - markdown = {}, - nix = {}, - python = {}, - ruby = {}, - sh = {}, - typescript = {}, - }, - - -- Set your dashboard custom colors below - -- @default = doom emacs' default dashboard colors - dashboard_custom_colors = { - header_color = "#586268", - center_color = "#51afef", - shortcut_color = "#a9a1e1", - footer_color = "#586268", - }, - - -- Set your custom dashboard header below - -- @default = doom emacs' default dashboard header - dashboard_custom_header = {}, - }, - - nvim = { - -- Set custom Neovim global variables - -- @default = {} - -- example: - -- { - -- ['sonokai_style'] = 'andromeda', - -- ['modelineexpr'] = true, - -- } - -- - -- modeline feature was turned off to reduce security exploit surfaces. - -- Since modeline now uses whitelist approach since nvim 0.4 /vim 8.1, - -- enabling this is as safe as external packages such as securemodelines. - -- See https://github.com/neovim/neovim/issues/2865 - -- - global_variables = {}, - - -- Set custom autocommands - -- @default = {} - -- example: - -- augroup_name = { - -- { 'BufNewFile,BufRead', 'doom_modules.lua', 'set ft=lua'} - -- } - autocmds = {}, - - -- Set custom key bindings - -- @default = {} - -- example: - -- { - -- {'n', 'ca', ':Lspsaga code_action', options} - -- } - -- - -- where - -- 'n' is the map scope - -- 'ca' is the map activator - -- ':Lspsaga ...' is the command to be executed - -- options is a Lua table containing the mapping options, e.g. - -- { silent = true }, see ':h map-arguments'. - mappings = {}, - - -- Set custom commands - -- @default = {} - -- example: - -- { - -- 'echo "Hello, custom commands!"' - -- } - commands = {}, - - -- Set custom functions - -- @default = {} - -- example: - -- { - -- { - -- hello_custom_func = function() - -- print("Hello, custom functions!") - -- end, - -- -- If the function should be ran on neovim launch or if it should - -- -- be a global function accesible from anywhere - -- run_on_start = false, - -- }, - -- } - functions = {}, - - -- Set custom options - -- @default = {} - -- example: - -- { - -- ['shiftwidth'] = 4 - -- } - options = {}, - }, -} - -return M - --- vim: sw=2 sts=2 ts=2 fdm=indent noexpandtab diff --git a/doom_modules.lua b/doom_modules.lua deleted file mode 100644 index 7ef434ebb..000000000 --- a/doom_modules.lua +++ /dev/null @@ -1,100 +0,0 @@ --- doom_modules - Doom nvim module selection --- --- The doom_modules controls what Doom nvim plugins modules are enabled and --- what features are being used. --- --- Comment out a plugin to enable it and comment a non-commented one to --- disable and uninstall it. --- --- NOTE: you can open the Doom nvim documentation by pressing `SPC d h`. You --- will find a table of content where you will see a "Doomrc" section under the --- "Configuration" one. In that section you will find a comprehensive list of --- the available modules and all their supported flags. - -local M = {} - -M.source = debug.getinfo(1, "S").source:sub(2) - -M.modules = { - ui = { - "dashboard", -- Start screen - -- "doom-themes", -- Additional doom emacs' colorschemes - -- "indentlines", -- Show indent lines - -- "show_registers", -- popup that shows register contents - "statusline", -- Statusline - "tabline", -- Tabline, shows your buffers list at top - "which-key", -- Keybindings popup menu like Emacs' guide-key - -- "zen", -- Distraction free environment - -- "illuminated", -- Highlight other uses of the word under the cursor like VSC - }, - doom = { - -- "compiler", -- Compile (and run) your code with just pressing three keys! - -- "contrib", -- Special plugins intended for Doom Nvim contributors (lua docs, etc) - "neorg", -- Life Organization Tool, used by Doom Nvim user manual - -- "runner", -- Open a REPL for the current language or run the current file - }, - editor = { - "autopairs", -- Autopairs - "auto-session", -- A small automated session manager for Neovim - "dap", -- Debug Adapter Protocol - -- "editorconfig", -- EditorConfig support for Neovim - "explorer", -- Tree explorer - "formatter", -- File formatting - "gitsigns", -- Git signs - "kommentary", -- Comments plugin - -- "linter", -- Asynchronous linter, see errors in your code on the fly - "lsp", -- Language Server Protocols - -- "minimap", -- Code minimap, requires github.com/wfxr/code-minimap - -- "ranger", -- Ranger File Browser, requires ranger file browser - "snippets", -- Code snippets - -- "symbols", -- LSP symbols and tags - "telescope", -- Highly extendable fuzzy finder over lists - -- "terminal", -- Terminal for Neovim (NOTE: needed for runner and compiler) - -- "trouble", -- A pretty list to help you solve all the trouble your code is causing. - }, - langs = { - -- To enable the language server for a language just add the +lsp flag - -- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter - -- parser and rust-analyzer - -- - -- "css", -- CSS support - -- "html", -- HTML support - -- "javascript", -- JavaScript support - -- "typescript", -- TypeScript support - - -- "bash", -- The terminal gods language - -- "elixir", -- Build scalable and maintainable software - "lua", -- Support for our gods language - -- "python +lsp", -- Python support + lsp - -- "ruby", -- Look ma, I love the gems! - - -- "c", -- Core dumped: segmentation fault - -- "cpp", -- C++ support - -- "go", -- Hello, gopher - -- "haskell", -- Because Functional programming is fun, isn't it? - -- "java", -- Java support - -- "rust +lsp", -- Let's get rusty! - -- "scala", -- Java, but good - - -- "comment", -- Better annotations and comments - -- "config", -- Configuration files (JSON, YAML, TOML) - -- "dockerfile", -- Do you like containers, right? - }, - utilities = { - -- "lazygit", -- LazyGit integration for Neovim, requires LazyGit - -- "neogit", -- Magit for Neovim - "range-highlight", -- Hightlights ranges you have entered in commandline - -- "suda", -- Write and read files without sudo permissions - -- "superman", -- Read Unix man pages faster than a speeding bullet! - -- "todo_comments", -- Highlight, list and search todo comments in your projects - }, - web = { - -- "colorizer", -- Fastest colorizer for Neovim - -- "firenvim", -- Requires firenvim browser extension; change fontsize by increasing guifontsize in doom_config - -- "restclient", -- A fast Neovim http client - }, -} - -return M - --- vim: sw=2 sts=2 ts=2 fdm=indent noexpandtab diff --git a/doom_userplugins.lua b/doom_userplugins.lua deleted file mode 100644 index a03700002..000000000 --- a/doom_userplugins.lua +++ /dev/null @@ -1,23 +0,0 @@ --- doom_userplugins - Doom nvim custom plugins --- --- This file contains all the custom plugins that are not in Doom nvim but that --- the user requires. All the available fields can be found here --- https://github.com/wbthomason/packer.nvim#specifying-plugins --- --- By example, for including a plugin with a dependency on telescope: --- M.plugins { --- { --- 'user/repository', --- requires = { 'nvim-lua/telescope.nvim' }, --- }, --- } - -local M = {} - -M.source = debug.getinfo(1, "S").source:sub(2) - -M.plugins = {} - -return M - --- vim: sw=2 sts=2 ts=2 noexpandtab diff --git a/init.lua b/init.lua index d43728559..76baae827 100644 --- a/init.lua +++ b/init.lua @@ -1,56 +1,29 @@ ----[[---------------------------------------]]--- --- init.lua - Init file of Doom Nvim -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - ----- Doom Utilities ----------------------------- -------------------------------------------------- --- Store startup time in seconds -vim.g.start_time = vim.fn.reltime() --- Lua modules loader, when loading our modules with this --- we avoid breaking all the configuration if something fails -local load_modules = require("doom.utils.modules").load_modules - --- Disable some unused built-in Neovim plugins -vim.g.loaded_gzip = false -vim.g.loaded_tarPlugin = false -vim.g.loaded_zipPlugin = false -vim.g.loaded_2html_plugin = false - ----- Doom Configurations ------------------------ -------------------------------------------------- --- Load Doom core and UI related stuff (colorscheme, background) -load_modules("doom", { "core" }) - --- Defer and schedule loading of plugins and extra functionalities until the --- Neovim API functions are safe to call to avoid weird errors with plugins stuff +-- 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. +vim.opt.runtimepath:append(vim.fn.stdpath("data")) + +-- From here on, we have a hidden global `_doom` that holds state the user +-- shouldn't mess with. +_G._doom = {} + +-- From here on, we have a global `doom` with config. +require("doom.core.config"):load() +-- Load Doom core and UI related stuff (colorscheme, background). +local utils = require("doom.utils") +utils.load_modules("doom", { "core" }) + +-- Defer and schedule loading of modules until the Neovim API functions are +-- safe to call to avoid weird errors with plugins stuff. vim.defer_fn(function() - -- Load Doom extra stuff and plugins (modules, extras) - load_modules("doom", { "modules", "extras" }) + -- Load Doom modules. + utils.load_modules("doom", { "modules" }) - -- This loads certain plugins related to UI - vim.cmd("doautocmd ColorScheme") - - -- If the current buffer name is empty then trigger Dashboard. - -- NOTE: this is done to avoid some weird issues with Dashboard and - -- number / signcolumn when Dashboard gets triggered automatically + -- Start dashboard if it is enabled and an empty buffer is opened initially. if - (vim.api.nvim_buf_get_name(0):len() == 0) - and (packer_plugins and packer_plugins["dashboard-nvim"]) + not require("doom.utils").is_plugin_disabled("dashboard") + and vim.api.nvim_buf_get_name(0):len() == 0 then vim.cmd("Dashboard") end - - vim.cmd([[ - PackerLoad nvim-treesitter - " This BufEnter call should fix some issues with concealing in neorg - doautocmd BufEnter - ]]) - - if not require("doom.utils").is_plugin_disabled("which-key") then - vim.cmd([[ - PackerLoad which-key.nvim - ]]) - end end, 0) diff --git a/lua/colors/doom-one/init.lua b/lua/colors/doom-one/init.lua index 4fbeb9168..868e001f8 100644 --- a/lua/colors/doom-one/init.lua +++ b/lua/colors/doom-one/init.lua @@ -479,10 +479,10 @@ doom_one.load_colorscheme = function() -- netrw {{{ local netrw = { - netrwClassify = { fg = blue }, - netrwDir = { fg = blue }, - netrwExe = { fg = green }, - netrwMakefile = { fg = yellow }, + netrwClassify = { fg = blue }, + netrwDir = { fg = blue }, + netrwExe = { fg = green }, + netrwMakefile = { fg = yellow }, } apply_highlight(netrw) @@ -930,7 +930,11 @@ doom_one.load_colorscheme = function() if configuration.enable_treesitter then -- We will set a special definition for TSStrike here local treesitter = { - TSStrike = { fg = utils.Darken(violet, 0.2), cterm = "strikethrough", gui = "strikethrough" }, + TSStrike = { + fg = utils.Darken(violet, 0.2), + cterm = "strikethrough", + gui = "strikethrough", + }, } apply_highlight(treesitter) diff --git a/lua/colors/doom-one/utils/init.lua b/lua/colors/doom-one/utils/init.lua index e95019f1f..ae9fff005 100644 --- a/lua/colors/doom-one/utils/init.lua +++ b/lua/colors/doom-one/utils/init.lua @@ -1,12 +1,5 @@ ----[[------------------------]]--- --- COLOR UTILITIES -- ----]]------------------------[[--- - local M = {} -------------------------------------------------------------------------------- --- Functions {{{ - -- Convert RGB to Hex color. -- @param r Red value -- @param g Green value @@ -28,10 +21,6 @@ local function Hex_to_RGB(color) } end --- }}} -------------------------------------------------------------------------------- --- Composed functions {{{ - M.Lighten = function(color, percentage) local amount = percentage == nil and 5.0 or percentage @@ -102,8 +91,5 @@ M.Mix = function(first, second, percentage) return RGB_to_Hex(r, g, b) end --- }}} return M - --- vim: fdm=marker diff --git a/lua/colors/utils/init.lua b/lua/colors/utils/init.lua index e95019f1f..ae9fff005 100644 --- a/lua/colors/utils/init.lua +++ b/lua/colors/utils/init.lua @@ -1,12 +1,5 @@ ----[[------------------------]]--- --- COLOR UTILITIES -- ----]]------------------------[[--- - local M = {} -------------------------------------------------------------------------------- --- Functions {{{ - -- Convert RGB to Hex color. -- @param r Red value -- @param g Green value @@ -28,10 +21,6 @@ local function Hex_to_RGB(color) } end --- }}} -------------------------------------------------------------------------------- --- Composed functions {{{ - M.Lighten = function(color, percentage) local amount = percentage == nil and 5.0 or percentage @@ -102,8 +91,5 @@ M.Mix = function(first, second, percentage) return RGB_to_Hex(r, g, b) end --- }}} return M - --- vim: fdm=marker diff --git a/lua/doom/README.md b/lua/doom/README.md index a05ec1faf..ec17fffa1 100644 --- a/lua/doom/README.md +++ b/lua/doom/README.md @@ -5,12 +5,10 @@ divided into three different sub-modules. - [core](./core/README.md) - The Doom core, herein lies the entire Doom core, e.g. configurations. -- [extras](./extras/README.md) - Doom extras, herein lies the Doom keybindings, - autocommands, etc. -- [modules](./modules/README.md) - The Doom modules, herein lies the Doom plugins - and their configurations. -- [utils](./utils/README.md) - The Doom utilities, herein lies the Doom utility - functions. +- [modules](./modules/README.md) - The Doom modules, herein lies the Doom modules + and their configurations, bindings, autocmds and package management. +- [utils](./utils/README.md) - The Doom utilities, herein lies the glorious + Doom utility functions. ## Note: dev w/ctags diff --git a/lua/doom/core/README.md b/lua/doom/core/README.md index aa1a2ec85..71525e534 100644 --- a/lua/doom/core/README.md +++ b/lua/doom/core/README.md @@ -5,8 +5,10 @@ be Doom. Those modules are the following: -- config - Doom configurations, handles `doom_*` file and UI settings. -- settings - Doom configurations for Neovim, e.g. `tabwidth`, `showmode`. +- config - Doom configurations, handles `doom-nvim/*.lua` files. + - init - `config.lua` handler, initializes the `doom` global. + - modules - `modules.lua` handler. - functions - Doom core functions, e.g. `create_report`. -- health - Doom health add-on. - system - Doom system detection utilities. +- ui - Doom UI settings. +- netrw - Optional netrw configs. diff --git a/lua/doom/core/commands.lua b/lua/doom/core/commands.lua new file mode 100644 index 000000000..b8be48d25 --- /dev/null +++ b/lua/doom/core/commands.lua @@ -0,0 +1,18 @@ +-- This file only has side-effects. + +-- Doom Nvim commands. + +-- Set a custom command to update Doom Nvim can be called by using :DoomUpdate. +vim.cmd([[command! DoomUpdate lua require("doom.core.functions").update_doom()]]) +-- Set a custom command to rollback Doom Nvim version can be called by using +-- :DoomRollback. +vim.cmd([[command! DoomRollback lua require("doom.core.functions").rollback_doom()]]) +-- Set a custom command to open Doom Nvim user manual can be called by using +-- :DoomManual. +vim.cmd([[command! DoomManual lua require("doom.core.functions").open_docs()]]) +-- Set a custom command to fully reload Doom Nvim and simulate a new Neovim run +-- can be called by using :DoomReload. +vim.cmd([[command! DoomReload lua require("doom.modules.built-in.reloader").full_reload()]]) +-- Set a custom command to create a crash report can be called by using +-- :DoomReport. +vim.cmd([[command! DoomReport lua require("doom.core.functions").create_report(]]) diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua index 22d48fc8b..b1a7d9112 100644 --- a/lua/doom/core/config/init.lua +++ b/lua/doom/core/config/init.lua @@ -1,519 +1,293 @@ ----[[------------------------------]]--- --- config - Core of Doom Nvim -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[------------------------------]]--- - -local config = {} - -local log = require("doom.extras.logging") -local system = require("doom.core.system") - -log.debug("Loading Doom config module ...") - --- Check if running Neovim or Vim and fails if: --- 1. Running Vim instead of Neovim --- 2. Running Neovim 0.4 or below -if vim.fn.has("nvim") == 1 then - if vim.fn.has("nvim-0.5") ~= 1 then - log.fatal("Doom Nvim requires Neovim 0.5.0, please update it") - end -else - log.fatal("Doom Nvim does not have support for Vim, please use it with Neovim instead") +local utils = require("doom.utils") +local enabled_modules = require("doom.core.config.modules").modules +-- `core` is required, doom wouldn't make sense without it. +if not vim.tbl_contains(enabled_modules, "core") then + table.insert(enabled_modules, "core") end --- Set termguicolors on load -if vim.fn.has("vim_starting") then - vim.opt.termguicolors = true -end +local config = {} +local filename = "config.lua" +-- TODO: Consider moving this to its own file. -- {{{ Default doom_config values -config.config = { - -- {{{ Doom - doom = { - -- Autosave - -- false : Disable autosave - -- true : Enable autosave - -- @default = false - autosave = false, - - -- Format on save - -- false : Disable format on save - -- true : Enable format on save - -- @default = false - fmt_on_save = false, - - -- Disable Vim macros - -- false : Enable Vim macros - -- true : Disable Vim macros - -- @default = false - disable_macros = false, - - -- Autosave sessions - -- false : Disable session autosave - -- true : Enable session autosave - -- @default = false - autosave_sessions = false, - - -- Autoload sessions - -- false : Disable session autoload - -- true : Enable session autoload - -- @default = false - autoload_last_session = false, - - -- Enable Swap files - -- false : no swap files - -- true : enables swap files - -- @default = false - swap_files = false, - - -- Undo Directories - -- the backup variable enables backup related settings (undofile, undodir) - -- false : ignores undo Directories (this code block will be ignored) - -- true : enable undo files/undo dirs. - -- @default = false - -- WARNING: if you change this to false and you have an undo dir already, - -- it will REMOVE the undodir (loss of data might take place) - backup = false, - - -- Enable Line wrapping - -- false : disables line wrapping - -- true : enables line wrapping - -- @default = false - line_wrap = false, - - -- Enable Show mode ( -- INSERT --, -- NORMAL --, -- VISUAL -- ) - -- false : disables show mode - -- true : enables show mode +config.defaults = { + -- Pins plugins to a commit sha to prevent breaking changes + -- @default = true + freeze_dependencies = true, + + -- Autosave + -- false : Disable autosave + -- true : Enable autosave + -- @default = false + autosave = false, + + -- Disable Vim macros + -- false : Enable + -- true : Disable + -- @default = false + disable_macros = false, + + -- Disable ex mode + -- false : Enable + -- true : Disable + -- @default = false + disable_ex = true, + + -- Disable suspension + -- false : Enable + -- true : Disable + -- @default = false + disable_suspension = true, + + -- h,l, wrap lines + movement_wrap = true, + + -- Undo directory (set to nil to disable) + -- @default = vim.fn.stdpath("data") .. "/undodir/" + undo_dir = vim.fn.stdpath("data") .. "/undodir/", + + -- Set preferred border style across UI + border_style = "single", + + -- Preserve last editing position + -- false : Disable preservation of last editing position + -- true : Enable preservation of last editing position + -- @default = false + preserve_edit_pos = false, + + -- horizontal split on creating a new file (fn) + -- false : doesn't split the window when creating a new file + -- true : horizontal split on creating a new file + -- @default = true + new_file_split = "vertical", + + -- Enable auto comment (current line must be commented) + -- false : disables auto comment + -- true : enables auto comment + -- @default = false + auto_comment = false, + + -- Enable Highlight on yank + -- false : disables highligh on yank + -- true : enables highlight on yank + -- @default = true + highlight_yank = true, + + -- Enable guicolors + -- Enables gui colors on GUI versions of Neovim + -- @default = true + guicolors = true, + + -- Show hidden files + -- @default = true + show_hidden = true, + + -- Hide files listed in .gitignore from file browsers + -- @default = true + hide_gitignore = true, + + -- Checkupdates on start + -- @default = false + check_updates = false, + + -- sequences used for escaping insert mode + -- @default = { 'jk', 'kj' } + escape_sequences = { "jk", "kj" }, + + -- Use floating windows for plugins manager (packer) operations + -- @default = false + use_floating_win_packer = false, + + -- Default indent size + -- @default = 4 + indent = 4, + + -- Logging level + -- Set Doom logging level + -- Available levels: + -- · trace + -- · debug + -- · info + -- · warn + -- · error + -- · fatal + -- @default = 'info' + logging = "warn", + + -- Default colorscheme + -- @default = doom-one + colorscheme = "doom-one", + + -- Doom One colorscheme settings + doom_one = { + -- If the cursor color should be blue -- @default = false - show_mode = false, - - -- Enable scroll off - -- false : disables scroll off - -- true : enables scroll off - -- @default = true, @default scrolloff_amount = 4, - scrolloff = true, - scrolloff_amount = 4, - - -- Enable mouse - -- false : disables mouse - -- true : enables mouse + cursor_coloring = false, + -- If TreeSitter highlighting should be enabled -- @default = true - mouse = true, - - -- Preserve last editing position - -- false : Disable preservation of last editing position - -- true : Enable preservation of last editing position + enable_treesitter = true, + -- If the comments should be italic -- @default = false - preserve_edit_pos = false, - - -- Allow overriding the default Doom Nvim keybinds - -- false : Default keybinds cannot be overwritten - -- true : Default keybinds can be overwritten - -- @default = true - allow_default_keymaps_overriding = true, - - -- horizontal split on creating a new file (fn) - -- false : doesn't split the window when creating a new file - -- true : horizontal split on creating a new file - -- @default = true - new_file_split = true, - - -- enable current line highlight - -- false : disables current line highlight - -- true : enables current line highlight - -- @default = true - line_highlight = true, - - -- Automatically split right - -- false : splits right (vertically) - -- true : splits left (vertically) + italic_comments = false, + -- If the telescope plugin window should be colored -- @default = true - split_right = true, - - -- Automatically split above - -- false : splits above (horizontally) - -- true : splits below (horizontally) - -- @default = true - split_below = true, - - -- Use clipboard outside of vim - -- false : won't use third party clipboard - -- true : enables third part clipboard - -- @default = true - clipboard = true, - - -- Enable auto comment (current line must be commented) - -- false : disables auto comment - -- true : enables auto comment + telescope_highlights = true, + -- If the built-in Neovim terminal should use the doom-one + -- colorscheme palette -- @default = false - auto_comment = false, - - -- Show indent lines - -- @default = true - show_indent = true, - - -- Expand tabs - -- Specifies if spaces or tabs must be used - -- false : spaces - -- true : tabs - -- @default = true - expand_tabs = true, - - -- Set numbering - -- false : Enable number lines - -- true : Disable number lines + terminal_colors = true, + -- If the Neovim instance should be transparent -- @default = false - disable_numbering = false, - - -- Set numbering style - -- false : Shows absolute number lines - -- true : Shows relative number lines - -- @default = true - relative_num = true, - - -- Enable winwidth - -- false : Manually set win width - -- true : Active window auto sets width - -- @default = false, @default win_width_nr = 85 - win_width = false, - win_width_nr = 85, - - -- Enable Highlight on yank - -- false : disables highligh on yank - -- true : enables highlight on yank - -- @default = true - highlight_yank = true, - - -- Enable guicolors - -- Enables gui colors on GUI versions of Neovim - -- @default = true - enable_guicolors = true, + transparent_background = false, + }, +} - -- Tree explorer on the right - -- Places the Tree explorer buffer to the right when enabled - -- @default = false - explorer_right = false, +-- }}} - -- Show hidden files - -- @default = true - show_hidden = true, +config.source = nil +config.load = function() + -- Set vim defaults on first load. To override these, the user can just + -- override vim.opt in their own config, no bells or whistles attached. + local first_load = vim.tbl_isempty(doom or {}) + if first_load then + vim.opt.hidden = true + vim.opt.updatetime = 200 + vim.opt.timeoutlen = 400 + vim.opt.background = "dark" + vim.opt.completeopt = { + "menu", + "menuone", + "preview", + "noinsert", + "noselect", + } + vim.opt.shortmess = "atsc" + vim.opt.inccommand = "split" + 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 = "▕", + fold = " ", + eob = " ", + diff = "─", + msgsep = "‾", + foldopen = "▾", + foldclose = "▸", + foldsep = "│", + } + 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 + vim.opt.scrolloff = 4 + vim.opt.showmode = false + 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 + vim.opt.foldtext = require("doom.core.functions").sugar_folds() + doom = config.defaults + doom.packages = {} + doom.autocmds = {} + doom.binds = {} + for _, module in ipairs(enabled_modules) do + local init = require(("doom.modules.%s"):format(module)) + doom[module] = init.defaults + doom.packages = vim.tbl_extend( + "force", + doom.packages, + require(("doom.modules.%s.packages"):format(module)) + ) + doom.autocmds[module] = {} + end + end - -- Checkupdates on start - -- @default = false - check_updates = false, + dofile(config.source) - -- Auto install plugins on launch, useful if you don't want to run - -- PackerInstall every time you add a new plugin - -- @default = true - auto_install_plugins = true, + for module, _ in pairs(doom.autocmds) do + local ok, cmds = xpcall(require, debug.traceback, ("doom.modules.%s.autocmds"):format(module)) - -- Disable dashboard status line (does not work perfectly) - -- false : disables dashboard status line - -- true : enables dashboard status line - -- @default = true - dashboard_statline = true, - - -- Show the editing file path in your status line - -- false : show only file name on status line - -- true : show file name and the updir in status line - statusline_show_file_path = true, - - -- Set the keybindings modules that you want to use - -- false : disables keybindings module - -- true : enables keybindings module - keybinds_modules = { - -- Core doom keybindings - core = true, - -- Movement keybindings, jump between your windows, buffers and code - movement = true, - -- Leader keybindings, a bunch of useful keybindings managed by space key - -- WARNING: disabling this will break which-key plugin if the plugin is enabled - leader = true, - -- Completion and snippets keybindings - completion = true, - }, - - -- sequences used for escaping insert mode - -- @default = { 'jk', 'kj' } - escape_sequences = { "jk", "kj" }, - - -- Disable or enable Doom autocommands, this can break some configuration options (they will stop working) - -- e.g. preserve_edit_pos or autosave - -- - -- false : enable autocommands module - -- true : disable autocommands module - -- @default = false - disable_autocommands = false, + if ok then + for _, cmd in ipairs(cmds) do + table.insert(doom.autocmds[module], cmd) + end + end + end + local module_binds = {} + for _, module in ipairs(enabled_modules) do + local ok, binds = xpcall(require, debug.traceback, ("doom.modules.%s.binds"):format(module)) - -- Enable LSP diagnostics virtual text - -- @default = false - enable_lsp_virtual_text = false, + if ok and not vim.tbl_isempty(binds) then + table.insert(module_binds, binds) + end + end + if not vim.tbl_isempty(module_binds) then + if not vim.tbl_isempty(doom.binds) then + doom.binds = { module_binds, doom.binds } + else + doom.binds = module_binds + end + end - -- Use floating windows for plugins manager (packer) operations - -- @default = false - use_floating_win_packer = false, - - -- Default indent size - -- @default = 4 - indent = 4, - - -- Set max cols - -- Defines the column to show a vertical marker - -- @default = 80 - max_columns = 80, - - -- Completion box height - -- @default = 10 - complete_size = 10, - - -- Completion box transparency - -- 0 = no transparency - -- 100 = fully transparent - -- @default = 25 - complete_transparency = 25, - - -- Sidebar sizing - -- Specifies the default width of Tree Explorer and Tagbar - -- @default = 25 - sidebar_width = 25, - - -- Set the Terminal width - -- Applies only to float direction - -- @default = 70 - terminal_width = 70, - - -- Set the Terminal height - -- Applies to all directions except window - -- @default = 20 - terminal_height = 20, - - -- Conceal level - -- Set Neovim conceal level - -- 0 : Disable indentline and show all - -- 1 : Conceal some functions and show indentlines - -- 2 : Concealed text is completely hidden unless it has a custom replacement - -- character defined - -- 3 : Concealed text is completely hidden - conceallevel = 0, - - -- Logging level - -- Set Doom logging level - -- Available levels: - -- · trace - -- · debug - -- · info - -- · warn - -- · error - -- · fatal - -- @default = 'info' - logging = "info", - - -- Set the Terminal direction - -- Available directions: - -- - vertical - -- - horizontal - -- - window - -- - float - -- @default = 'horizontal' - terminal_direction = "horizontal", - - -- NOTE: This will only be activated if 'backup' is true. - -- We don'recommend you put this outside of neovim so we've restricted to the path: ~/.config/nvim - -- WARNING: only put the folder name that you want. (eg: undo_dir = '/undodir') - -- @default_directory = '~/.config/nvim/undodir' - undo_dir = "/undodir", - - -- Default colorscheme - -- @default = doom-one - colorscheme = "doom-one", - - -- Background color - -- @default = dark - colorscheme_bg = "dark", - - -- Doom One colorscheme settings - doom_one = { - -- If the cursor color should be blue - -- @default = false - cursor_coloring = false, - -- If TreeSitter highlighting should be enabled - -- @default = true - enable_treesitter = true, - -- If the comments should be italic - -- @default = false - italic_comments = false, - -- If the telescope plugin window should be colored - -- @default = true - telescope_highlights = true, - -- If the built-in Neovim terminal should use the doom-one - -- colorscheme palette - -- @default = false - terminal_colors = true, - -- If the Neovim instance should be transparent - -- @default = false - transparent_background = false, - }, - - -- Set gui fonts here - -- @default = "FiraCode Nerd Font", @default font size = 15, - -- WARNING: Font sizes must be in string format! - guifont = "FiraCode Nerd Font", - guifont_size = "15", - - -- Change Which Key background color - -- can use hex, or normal color names (eg: Red, Gree, Blue) - -- @default = #202328 - whichkey_bg = "#202328", - - -- Set your custom lsp diagnostic symbols below - lsp_error = "", - lsp_warn = "", - lsp_hint = "", - lsp_info = "", - lsp_virtual_text = " ", - - -- Set your linters for the programming languages that you use, - -- see https://github.com/mfussenegger/nvim-lint#available-linters - linters = { - c = {}, - cpp = {}, - css = {}, - html = {}, - javascript = {}, - lua = {}, - markdown = {}, - nix = {}, - python = {}, - ruby = {}, - sh = {}, - typescript = {}, - }, - - -- Set your dashboard custom colors below - -- @default = doom emacs' default dashboard colors - dashboard_custom_colors = { - header_color = "#586268", - center_color = "#51afef", - shortcut_color = "#a9a1e1", - footer_color = "#586268", - }, - - -- Set your custom dashboard header below - -- @default = doom emacs' default dashboard header - dashboard_custom_header = {}, - }, - -- }}} - - -- {{{ Nvim - nvim = { - -- Set custom Neovim global variables - -- @default = {} - -- example: - -- { - -- ['sonokai_style'] = 'andromeda', - -- ['modelineexpr'] = true, - -- } - -- - -- modeline feature was turned off to reduce security exploit surfaces. - -- Since modeline now uses whitelist approach since nvim 0.4 /vim 8.1, - -- enabling this is as safe as external packages such as securemodelines. - -- See https://github.com/neovim/neovim/issues/2865 - -- - global_variables = {}, - - -- Set custom autocommands - -- @default = {} - -- example: - -- augroup_name = { - -- { 'BufNewFile,BufRead', 'doom_modules.lua', 'set ft=lua'} - -- } - autocmds = {}, - - -- Set custom key bindings - -- @default = {} - -- example: - -- { - -- {'n', 'ca', ':Lspsaga code_action', options} - -- } - -- - -- where - -- 'n' is the map scope - -- 'ca' is the map activator - -- ':Lspsaga ...' is the command to be executed - -- options is a Lua table containing the mapping options, e.g. - -- { silent = true }, see ':h map-arguments'. - mappings = {}, - - -- Set custom commands - -- @default = {} - -- example: - -- { - -- 'echo "Hello, custom commands!"' - -- } - commands = {}, - - -- Set custom functions - -- @default = {} - -- example: - -- { - -- { - -- hello_custom_func = function() - -- print("Hello, custom functions!") - -- end, - -- -- If the function should be ran on neovim launch or if it should - -- -- be a global function accesible from anywhere - -- run_on_start = false, - -- }, - -- } - functions = {}, - - -- Set custom options - -- @default = {} - -- example: - -- { - -- { ['shiftwidth'] = 4 } - -- } - options = {}, - }, - -- }}} -} + -- If we shouldn't freeze, remove commit SHAs. + if not doom.freeze_dependencies then + for _, spec in pairs(doom.packages) do + spec.commit = nil + end + end --- }}} + -- Check plugins updates on start if enabled. + if doom.check_updates then + require("doom.core.functions").check_updates() + end -config.source = nil + -- These are the few vim options we wrap directly, because their usual + -- interface is either error-prone or verbose. + if first_load then + vim.opt.shiftwidth = doom.indent + vim.opt.softtabstop = doom.indent + vim.opt.tabstop = doom.indent + if doom.guicolors then + if vim.fn.exists("+termguicolors") == 1 then + vim.opt.termguicolors = true + elseif vim.fn.exists("+guicolors") == 1 then + vim.opt.guicolors = true + end + end -log.debug("Loading Doom config module ...") + if doom.auto_comment then + vim.opt.formatoptions:append("croj") + end + if doom.movement_wrap then + vim.cmd("set whichwrap+=<,>,[,],h,l") + end --- Path cases: --- 1. /home/user/.config/doom-nvim/doom_config.lua --- 2. stdpath('config')/doom_config.lua --- 3. /doom_config.lua -local ok, ret = xpcall(dofile, debug.traceback, system.doom_configs_root .. "/doom_config.lua") -if ok then - config.config = ret.config - config.source = ret.source -else - ok, ret = xpcall(dofile, debug.traceback, system.doom_root .. "/doom_config.lua") - if ok then - config.config = ret.config - config.source = ret.source - else - ok, ret = xpcall(require, debug.traceback, "doom_config") - if ok then - config.config = ret.config - config.source = ret.source + if doom.undo_dir then + vim.opt.undofile = true + vim.opt.undodir = doom.undo_dir else - log.error("Error while loading doom_config.lua. Traceback:\n" .. ret) + vim.opt.undofile = false + vim.opt.undodir = nil end end end --- Check plugins updates on start if enabled -if config.config.doom.check_updates then - require("doom.core.functions").check_updates() -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/config/modules.lua b/lua/doom/core/config/modules.lua index dfd2f8d62..fd707327a 100644 --- a/lua/doom/core/config/modules.lua +++ b/lua/doom/core/config/modules.lua @@ -1,111 +1,13 @@ ----[[---------------------------------------------]]--- --- modules - Load Doom Nvim doom_modules.lua -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------------]]--- - -local system = require("doom.core.system") -local log = require("doom.extras.logging") +local utils = require("doom.utils") +local filename = "modules.lua" local modules = {} -modules.modules = { - ui = { - "dashboard", -- Start screen - -- "doom-themes", -- Additional doom emacs' colorschemes - -- "indentlines", -- Show indent lines - -- "show_registers", -- popup that shows register contents - "statusline", -- Statusline - "tabline", -- Tabline, shows your buffers list at top - "which-key", -- Keybindings popup menu like Emacs' guide-key - -- "zen", -- Distraction free environment - }, - doom = { - -- "compiler", -- Compile (and run) your code with just pressing three keys! - -- "neorg", -- Life Organization Tool - -- "runner", -- Open a REPL for the current language or run the current file - }, - editor = { - "autopairs", -- Autopairs - "auto-session", -- A small automated session manager for Neovim - "dap", -- Debug Adapter Protocol - -- "editorconfig", -- EditorConfig support for Neovim - "explorer", -- Tree explorer - "formatter", -- File formatting - "gitsigns", -- Git signs - "kommentary", -- Comments plugin - "lsp", -- Language Server Protocols - -- "minimap", -- Code minimap, requires github.com/wfxr/code-minimap - -- "ranger", -- Ranger File Browser, requires ranger file browser - "snippets", -- LSP snippets - "symbols", -- LSP symbols and tags - "telescope", -- Highly extendable fuzzy finder over lists - -- "terminal", -- Terminal for Neovim (NOTE: needed for runner and compiler) - }, - langs = { - -- To enable the language server for a language just add the +lsp flag - -- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter - -- parser and rust-analyzer - -- - -- "css", -- CSS support - -- "html", -- HTML support - -- "javascript", -- JavaScript support - -- "typescript", -- TypeScript support - - -- "bash", -- The terminal gods language - -- "elixir", -- Build scalable and maintainable software - "lua", -- Support for our gods language - -- "python +lsp", -- Python support + lsp - -- "ruby", -- Look ma, I love the gems! - - -- "cpp", -- C++ support - -- "go", -- Hello, gopher - -- "haskell", -- Because Functional programming is fun, isn't it? - -- "java", -- Java support - -- "rust +lsp", -- Let's get rusty! - - -- "config", -- Configuration files (JSON, YAML, TOML) - -- "dockerfile", -- Do you like containers, right? - }, - utilities = { - -- "lazygit", -- LazyGit integration for Neovim, requires LazyGit - -- "neogit", -- Magit for Neovim - "range-highlight", -- hightlights ranges you have entered in commandline - -- "suda", -- Write and read files without sudo permissions - }, - web = { - -- "colorizer", -- Fastest colorizer for Neovim - -- "firenvim", -- requires firenvim browser extension; change fontsize by increasing guifontsize in doom_config - -- "restclient", -- A fast Neovim http client - }, -} - -modules.source = nil - -log.debug("Loading Doom modules module ...") - -- Path cases: --- 1. /home/user/.config/doom-nvim/doom_modules.lua --- 2. stdpath('config')/doom_modules.lua --- 3. /doom_modules.lua -local ok, ret = xpcall(dofile, debug.traceback, system.doom_configs_root .. "/doom_modules.lua") -if ok then - modules.modules = ret.modules - modules.source = ret.source -else - ok, ret = xpcall(dofile, debug.traceback, system.doom_root .. "/doom_modules.lua") - if ok then - modules.modules = ret.modules - modules.source = ret.source - else - ok, ret = xpcall(require, debug.traceback, "doom_modules") - if ok then - modules.modules = ret.modules - modules.source = ret.source - else - log.error("Error while loading doom_modules.lua. Traceback:\n" .. ret) - end - end -end +-- 1. stdpath('config')/../doom-nvim/modules.lua +-- 2. stdpath('config')/modules.lua +-- 3. /doom-nvim/modules.lua +modules.source = utils.find_config(filename) +modules.modules = dofile(modules.source) return modules diff --git a/lua/doom/core/config/ui.lua b/lua/doom/core/config/ui.lua deleted file mode 100644 index bf8679c2b..000000000 --- a/lua/doom/core/config/ui.lua +++ /dev/null @@ -1,70 +0,0 @@ ----[[---------------------------------------]]--- --- ui.lua - Doom Nvim UI settings -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local utils = require("doom.utils") -local log = require("doom.extras.logging") -local config = require("doom.core.config").config - -log.debug("Loading Doom UI module ...") - --- If no colorscheme was established then fallback to defauls -if not utils.is_empty(config.doom.colorscheme) then - local loaded_colorscheme = xpcall(function() - vim.opt.background = config.doom.colorscheme_bg - vim.api.nvim_command("colorscheme " .. config.doom.colorscheme) - end, debug.traceback) - - if not loaded_colorscheme then - log.warn("Colorscheme '" .. config.doom.colorscheme .. "' not found, falling to doom-one") - vim.api.nvim_command("colorscheme doom-one") - end -else - log.warn("Forced default Doom colorscheme") - vim.api.nvim_command("colorscheme doom-one") -end - --- Set colors based on environment (GUI, TUI) -if config.doom.enable_guicolors then - if vim.fn.exists("+termguicolors") == 1 then - vim.opt.termguicolors = true - elseif vim.fn.exists("+guicolors") == 1 then - vim.opt.guicolors = true - end -end - --- Set custom WhichKey background -vim.cmd("highlight WhichKeyFloat guibg=" .. config.doom.whichkey_bg) - --- Set doom-one colorscheme settings -if config.doom.colorscheme == "doom-one" then - require("colors.doom-one").setup({ - cursor_coloring = config.doom.doom_one.cursor_coloring, - terminal_colors = config.doom.doom_one.terminal_colors, - italic_comments = config.doom.doom_one.italic_comments, - enable_treesitter = config.doom.doom_one.enable_treesitter, - transparent_background = config.doom.doom_one.transparent_background, - pumblend = { - enable = true, - transparency_amount = config.doom.complete_transparency, - }, - plugins_integrations = { - neorg = true, - barbar = false, - bufferline = true, - gitgutter = false, - gitsigns = true, - telescope = config.doom.doom_one.telescope_highlights, - neogit = true, - nvim_tree = true, - dashboard = true, - startify = false, - whichkey = true, - indent_blankline = true, - vim_illuminate = true, - lspsaga = false, - }, - }) -end diff --git a/lua/doom/core/config/userplugins.lua b/lua/doom/core/config/userplugins.lua deleted file mode 100644 index 03c6f620a..000000000 --- a/lua/doom/core/config/userplugins.lua +++ /dev/null @@ -1,42 +0,0 @@ ----[[---------------------------------------]]--- --- userplugins - Load Doom Nvim doom_userplugins -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local system = require("doom.core.system") -local log = require("doom.extras.logging") - -local userplugins = {} - -userplugins.plugins = {} - -userplugins.source = nil - -log.debug("Loading Doom userplugins module...") - --- Path cases: --- 1. /home/user/.config/doom-nvim/doom_userplugins.lua --- 2. stdpath('config')/doom_userplugins.lua --- 3. /doom_userplugins.lua -local ok, ret = xpcall(dofile, debug.traceback, system.doom_configs_root .. "/doom_userplugins.lua") -if ok then - userplugins.plugins = ret.plugins - userplugins.source = ret.source -else - ok, ret = xpcall(dofile, debug.traceback, system.doom_root .. "/doom_userplugins.lua") - if ok then - userplugins.plugins = ret.plugins - userplugins.source = ret.source - else - ok, ret = xpcall(require, debug.traceback, "doom_userplugins") - if ok then - userplugins.plugins = ret.plugins - userplugins.source = ret.source - else - log.error("Error while loading doom_userplugins.lua. Traceback:\n" .. ret) - end - end -end - -return userplugins diff --git a/lua/doom/core/functions/init.lua b/lua/doom/core/functions.lua similarity index 60% rename from lua/doom/core/functions/init.lua rename to lua/doom/core/functions.lua index ac88f863f..3de5af7bd 100644 --- a/lua/doom/core/functions/init.lua +++ b/lua/doom/core/functions.lua @@ -1,122 +1,19 @@ ----[[---------------------------------------]]--- --- functions - Doom Nvim Functions -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local log = require("doom.extras.logging") -local utils, fs = require("doom.utils"), require("doom.utils.fs") +-- NOTE: Can't require "doom.utils.logging" in the top level, because `doom` +-- may not exist here. +local utils = require("doom.utils") +local fs = require("doom.utils.fs") local system = require("doom.core.system") -local config = require("doom.core.config").config -local async = require("doom.modules.built-in.async") +local async = require("doom.utils.async") +local is_plugin_disabled = utils.is_plugin_disabled local functions = {} -log.debug("Loading Doom functions module ...") - --- Load user-defined settings from the Neovim field in the doom_config.lua --- @param settings_tbl The settings table to iterate over --- @param scope The settings scope, e.g. autocmds -functions.load_custom_settings = function(settings_tbl, scope) - -- If the provided settings table is not empty - if next(settings_tbl) ~= nil then - log.debug("Loading custom " .. scope .. " ...") - if scope == "functions" then - for _, func in ipairs(settings_tbl) do - -- Copy the function table so we can modify it safely - local func_tbl = func - -- Remove the additional table parameters - func_tbl.run_on_start = nil - local func_name = vim.tbl_keys(func_tbl)[1] - - -- If we should run the function on launch or set it as a global function - if func.run_on_start then - func_tbl[func_name]() - else - _G[func_name] = func_tbl[func_name] - end - end - elseif scope == "mappings" then - for _, map in ipairs(settings_tbl) do - -- scope, lhs, rhs, options - vim.api.nvim_set_keymap(map[1], map[2], map[3], map[4] and map[4] or {}) - end - elseif scope == "autocmds" then - utils.create_augroups(settings_tbl) - elseif scope == "commands" then - for _, cmd in ipairs(settings_tbl) do - vim.cmd(cmd) - end - elseif scope == "variables" then - for var, val in pairs(settings_tbl) do - vim.g[var] = val - end - elseif scope == "options" then - for var, val in pairs(settings_tbl) do - vim.opt[var] = val - end - end - end -end - --- reload_custom_settings reloads all the user-defined configurations --- in the 'doom_config.lua' file. -functions.reload_custom_settings = function() - -- Get the user-defined settings, the 'nvim' field in our 'doom_config.lua' - local custom_settings = require("doom.core.config").config.nvim - -- iterate over all the custom settings fields, e.g. global_variables, mappings, etc. - for scope, _ in pairs(custom_settings) do - functions.load_custom_settings(custom_settings[scope], scope) - end -end - --- Change the 'doom_config.lua' file configurations for the colorscheme and the --- background if they were changed by the user within Neovim -functions.change_colors_and_bg = function() - local changed_colorscheme, err = xpcall(function() - log.debug("Checking if the colorscheme or background were changed ...") - local target_colorscheme = vim.g.colors_name - local target_background = vim.opt.background:get() - - -- Set the correct path for the 'doom_config.lua' file - local doom_config_path = require("doom.core.config").source - - if target_colorscheme ~= config.doom.colorscheme then - local doom_config = fs.read_file(doom_config_path) - doom_config = string.gsub( - doom_config, - string.format('"%s"', utils.escape_str(config.doom.colorscheme)), - string.format('"%s"', utils.escape_str(target_colorscheme)) - ) - fs.write_file(doom_config_path, doom_config, "w+") - log.debug("Colorscheme successfully changed to " .. target_colorscheme) - end - if target_background ~= config.doom.colorscheme_bg then - local doom_config = fs.read_file(doom_config_path) - doom_config = string.gsub( - doom_config, - string.format('"%s"', config.doom.colorscheme_bg), - string.format('"%s"', target_background) - ) - fs.write_file(doom_config_path, doom_config, "w+") - log.debug("Background successfully changed to " .. target_background) - end - end, debug.traceback) - - if not changed_colorscheme then - log.error("Unable to write to the doom_config.lua file. Traceback:\n" .. err) - end -end - --- Quit Neovim and change the colorscheme at doom_config.lua if the colorscheme is not the same, --- dump all messages to doom.log file --- @tparam bool write If doom should save before exiting +-- Quit Neovim and dump all messages to doom.log file. +-- @tparam bool dont_write If doom shouldn't save before exiting -- @tparam bool force If doom should force the exiting -functions.quit_doom = function(write, force) - functions.change_colors_and_bg() - +functions.quit_doom = function(dont_write, force) local quit_cmd = "" - if write then + if not dont_write then quit_cmd = "wa | " end if force then @@ -128,6 +25,7 @@ end -- check_updates checks for plugins updates functions.check_updates = function() + local log = require("doom.utils.logging") local updated_plugins, err = xpcall(function() log.info("Updating the outdated plugins ...") vim.cmd("PackerSync") @@ -176,6 +74,7 @@ end -- create_report creates a markdown report. It's meant to be used when a bug -- occurs, useful for debugging issues. functions.create_report = function() + local log = require("doom.utils.logging") local date = os.date("%Y-%m-%d %H:%M:%S") local created_report, err = xpcall(function() -- Get and save only the warning and error logs from today @@ -260,6 +159,7 @@ end -- save_backup_hashes saves the commits or releases SHA for future rollbacks local function save_backup_hashes() + local log = require("doom.utils.logging") -- Check for the current branch local git_branch = utils.get_git_output("branch --show-current", true) @@ -334,7 +234,9 @@ end -- update_doom saves the current commit/release hash into a file for future -- restore if needed and then updates Doom. +-- TODO: Port to module architecture functions.update_doom = function() + local log = require("doom.utils.logging") save_backup_hashes() log.info("Pulling Doom remote changes ...") @@ -346,7 +248,7 @@ functions.update_doom = function() if data then log.info("Successfully updated Doom!") --- Completely reload Doom Nvim - require("doom.modules.built-in.reloader").full_reload() + require("doom.utils.reloader").full_reload() end end, on_stderr = function(err, data) @@ -362,7 +264,9 @@ end -- rollback_doom will rollback the local doom version to an older one -- in case that the local one is broken +-- TODO: Port to module architecture functions.rollback_doom = function() + local log = require("doom.utils.logging") -- Backup file for main (stable) branch local releases_database_path = string.format("%s%s.doom_releases", system.doom_root, system.sep) -- Backup file for development branch @@ -462,186 +366,122 @@ functions.rollback_doom = function() end end --- edit_config creates a prompt to modify a doom configuration file -functions.edit_config = function() - local selected_config = tonumber(vim.fn.inputlist({ - "Select a configuration file to edit:", - "1. doom_config.lua", - "2. doom_modules.lua", - "3. doom_userplugins.lua", - })) - local direction = config.doom.vertical_split and "vert " or "" - local open_command = config.doom.new_file_split and "split" or "edit" - - if selected_config == 1 then - vim.cmd(("%s%s %s"):format(direction, open_command, require("doom.core.config").source)) - elseif selected_config == 2 then - vim.cmd(("%s%s %s"):format(direction, open_command, require("doom.core.config.modules").source)) - elseif selected_config == 3 then - vim.cmd( - ("%s%s %s"):format(direction, open_command, require("doom.core.config.userplugins").source) - ) - elseif selected_config ~= 0 then - log.error("Invalid option selected.") - end +local function bool2str(bool) + return bool and "on" or "off" end --- followings are called from lua/doom/extras/keybindings/leader.lua --- --- toggle_background() -- tb -- toggle background light/dark +-- Toggle background="dark"|"light" functions.toggle_background = function() local background = vim.go.background if background == "light" then vim.go.background = "dark" - print("background=dark") else vim.go.background = "light" - print("background=light") end + -- XXX: Should we "just print"? Maybe and info log? + print(string.format("background=%s", vim.go.background)) end --- toggle_completion() -- tc -- toggle completion -vim.g.cmp_toggle_flag = true -- initialize -local normal_buftype = function() - return vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" -end -functions.toggle_completion = function() - local ok, cmp = xpcall(require, debug.traceback, "cmp") - if ok then - local next_cmp_toggle_flag = not vim.g.cmp_toggle_flag - if next_cmp_toggle_flag then - print("completion on") - else - print("completion off") - end - cmp.setup({ - enabled = function() - vim.g.cmp_toggle_flag = next_cmp_toggle_flag - if next_cmp_toggle_flag then - return normal_buftype - else - return next_cmp_toggle_flag - end - end, - }) - else - print("completion not available") +-- Only define if lsp enabled, it only makes sense there. +if not is_plugin_disabled("lsp") then + -- Toggle completion (by running cmp setup again). + functions.toggle_completion = function() + _doom.cmp_enable = not _doom.cmp_enable + print(string.format("completion=%s", bool2str(_doom.cmp_enable))) end end --- toggle_signcolumn() -- tg -- signcolumn auto/no +-- Toggle signcolumn="auto"|"no" functions.toggle_signcolumn = function() local signcolumn = vim.o.signcolumn if signcolumn == "no" then - vim.o.signcolumn = "auto" - print("signcolumn=auto") + vim.opt.signcolumn = "auto" else - vim.o.signcolumn = "no" - print("signcolumn=no") + vim.opt.signcolumn = "no" end + print(string.format("signcolumn=%s", vim.opt.signcolumn)) end --- set_indent() -- ti -- set the indent and tab related numbers +-- 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 all tab related options to a specified number and set expandtab\n(0 to reset to vim defaults, ? to print current settings): " - ) + vim.fn.input("Set indent (>0 uses spaces, <0 uses tabs, 0 uses vim defaults): ") ) - if (indent == nil) or (indent < 0) then - vim.cmd("set softtabstop? tabstop? shiftwidth? expandtab?") - elseif indent > 0 then - vim.o.tabstop = indent - vim.o.softtabstop = indent - vim.o.shiftwidth = indent - vim.o.expandtab = true - print(("\nindent=%i, expandtab"):format(indent)) - else -- indent == 0 - vim.o.tabstop = 8 - vim.o.softtabstop = 0 - vim.o.shiftwidth = 8 - vim.o.expandtab = false - print("\nindent=8, noexpandtab") + if not indent then + indent = -8 end + vim.opt.expandtab = indent > 0 + indent = math.abs(indent) + vim.opt.tabstop = indent + vim.opt.softtabstop = indent + vim.opt.shiftwidth = indent + print(string.format("indent=%d %s", indent, vim.opt.expandtab and "spaces" or "tabs")) end --- change_number() -- tn -- change the number display modes +-- Change the number display modes. functions.change_number = function() - local number = vim.o.number - local relativenumber = vim.o.relativenumber + local number = vim.opt.number + local relativenumber = vim.opt.relativenumber if (number == false) and (relativenumber == false) then - vim.o.number = true - vim.o.relativenumber = false - print("number on, relativenumber off") + vim.opt.number = true + vim.opt.relativenumber = false elseif (number == true) and (relativenumber == false) then - vim.o.number = false - vim.o.relativenumber = true - print("number off, relativenumber on") + vim.opt.number = false + vim.opt.relativenumber = true elseif (number == false) and (relativenumber == true) then - vim.o.number = true - vim.o.relativenumber = true - print("number on, relativenumber on") + vim.opt.number = true + vim.opt.relativenumber = true else -- (number == true) and (relativenumber == true) then - vim.o.number = false - vim.o.relativenumber = false - print("number off, relativenumber off") + vim.opt.number = false + vim.opt.relativenumber = false end + print("number=%s, relativenumber=%s", bool2str(vim.opt.number), bool2str(vim.opt.relativenumber)) end --- toggle_autopairs() -- tp -- toggle autopairs -functions.toggle_autopairs = function() - local ok, autopairs = xpcall(require, debug.traceback, "nvim-autopairs") - if ok then +-- Toggle autopairs. +if not is_plugin_disabled("autopairs") then + functions.toggle_autopairs = function() + local autopairs = require("nvim-autopairs") if autopairs.state.disabled then autopairs.enable() - print("autopairs on") else autopairs.disable() - print("autopairs off") end - else - print("autopairs not available") end end --- toggle_spell() -- ts -- toggle spell +-- Toggle spell. functions.toggle_spell = function() - if vim.o.spell then - vim.o.spell = false - print("spell off") - else - if vim.o.spelllang == nil then - vim.o.spelllang = "en_us" - end - vim.o.spell = true - print(("spell on, lang %s"):format(vim.o.spelllang)) - end + vim.opt.spell = not vim.opt.spell + print(string.format("spell=%s", bool2str(vim.opt.spell))) end --- change_syntax() -- tx -- toggle syntax/treesetter +-- Toggle syntax/treesitter functions.change_syntax = function() - local ok, parsers = xpcall(require, debug.traceback, "nvim-treesitter.parsers") - if ok and parsers and parsers.has_parser() then - if vim.o.syntax then + local parsers = require("nvim-treesitter.parsers") + if parsers.has_parser() then + if vim.opt.syntax then vim.cmd("TSBufDisable highlight") vim.cmd("syntax off") - print("syntax off, treesetter off") else vim.cmd("TSBufEnable highlight") vim.cmd("syntax on") - print("syntax on, treesetter on") end + local state = bool2str(vim.opt.syntax) + print(string.format("syntax=%s, treesitter=%s", state, state)) else if vim.o.syntax then vim.cmd("syntax off") - print("syntax off") else vim.cmd("syntax on") - print("syntax on") end + local state = bool2str(vim.opt.syntax) + print(string.format("syntax=%s", state)) end end +-- Better folding function. functions.sugar_folds = function() local start_line = vim.fn.getline(vim.v.foldstart):gsub("\t", ("\t"):rep(vim.opt.tabstop:get())) return string.format("%s ... (%d lines)", start_line, vim.v.foldend - vim.v.foldstart + 1) diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua index fb544585e..17d95ac9f 100644 --- a/lua/doom/core/init.lua +++ b/lua/doom/core/init.lua @@ -2,30 +2,14 @@ --- This file loads all doom core components --- (ui, options, doomrc, etc) -local log = require("doom.extras.logging") +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled -log.debug("Loading Doom core ...") - -local core_modules = { "settings", "settings.netrw", "config.ui", "config" } -for i = 1, #core_modules, 1 do - local ok, err = xpcall(require, debug.traceback, ("doom.core.%s"):format(core_modules[i])) - if ok then - if core_modules[i] == "settings" then - -- Neovim configurations, e.g. shiftwidth - require("doom.core.settings").load_default_options() - -- User-defined settings (global variables, mappings, ect) - require("doom.core.settings").custom_options() - -- Doom Nvim custom commands - require("doom.core.settings").doom_commands() - end - log.debug(string.format("Successfully loaded 'doom.core.%s' module", core_modules[i])) - else - log.error( - string.format( - "There was an error loading the module 'doom.core.%s'. Traceback:\n%s", - core_modules[i], - err - ) - ) - end +-- Required setup modules. +local core_modules = { "commands", "ui" } +-- If the explorer is disabled, the user probably wants a better netrw. +-- Otherwise, don't bother configuring it. +if is_plugin_disabled("explorer") then + table.insert(core_modules, "netrw") end +utils.load_modules("doom.core", core_modules) diff --git a/lua/doom/core/settings/netrw.lua b/lua/doom/core/netrw.lua similarity index 86% rename from lua/doom/core/settings/netrw.lua rename to lua/doom/core/netrw.lua index 4d3560ad9..6419e1531 100644 --- a/lua/doom/core/settings/netrw.lua +++ b/lua/doom/core/netrw.lua @@ -1,12 +1,9 @@ ----[[---------------------------------------]]--- --- netrw - Doom Nvim netrw setup -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - local utils = require("doom.utils") local system = require("doom.core.system") -local config = require("doom.core.config").config.doom + +-- Netew winsize +-- @default = 20 +vim.g.netrw_winsize = 20 -- Netrw banner -- 0 : Disable banner @@ -38,10 +35,7 @@ vim.g.netrw_list_hide = vim.fn["netrw_gitignore#Hide"]() -- 0 : show all files -- 1 : show not-hidden files -- 2 : show hidden files only -vim.g.netrw_hide = config.show_hidden and 0 or 1 - --- Change the size of the Netrw window when it creates a split -vim.g.netrw_winsize = (0 - config.sidebar_width) +vim.g.netrw_hide = not doom.show_hidden -- Preview files in a vertical split window -- vim.g.netrw_preview = 1 @@ -71,16 +65,12 @@ end -- Highlight marked files in the same way search matches are vim.cmd("hi! link netrwMarkFile Search") ------ KEYBINDS ------------------------ ---------------------------------------- local function netrw_maps() if vim.bo.filetype ~= "netrw" then return end local opts = { silent = true } - ----- General ----------------------- - ------------------------------------- -- Toggle dotfiles vim.api.nvim_buf_set_keymap(0, "n", ".", "gh", opts) @@ -103,8 +93,6 @@ local function netrw_maps() -- Close netrw vim.api.nvim_buf_set_keymap(0, "n", "q", ":Lexplore", opts) - ----- Files and Directories --------- - ------------------------------------- -- Create a new file and save it vim.api.nvim_buf_set_keymap(0, "n", "ff", "%:w:buffer #", opts) @@ -151,8 +139,6 @@ local function netrw_maps() opts ) - ----- Marks (selections) ------------ - ------------------------------------- -- Toggle the mark on a file or directory vim.api.nvim_buf_set_keymap(0, "n", "", "mf", opts) @@ -162,8 +148,6 @@ local function netrw_maps() -- Remove all the marks on all files vim.api.nvim_buf_set_keymap(0, "n", "", "mu", opts) - ----- Bookmarks --------------------- - ------------------------------------- -- Create a bookmark vim.api.nvim_buf_set_keymap(0, "n", "bc", "mb", opts) @@ -174,13 +158,11 @@ local function netrw_maps() vim.api.nvim_buf_set_keymap(0, "n", "bj", "gb", opts) end ------ ICONS --------------------------- ---------------------------------------- local function draw_icons() if vim.bo.filetype ~= "netrw" then return end - local is_devicons_available, devicons = pcall(require, "nvim-web-devicons") + local is_devicons_available, devicons = xpcall(require, debug.traceback, "nvim-web-devicons") if not is_devicons_available then return end diff --git a/lua/doom/core/settings/init.lua b/lua/doom/core/settings/init.lua deleted file mode 100644 index ac95600b2..000000000 --- a/lua/doom/core/settings/init.lua +++ /dev/null @@ -1,195 +0,0 @@ ----[[---------------------------------------]]--- --- settings - Doom Nvim settings -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local functions = require("doom.core.functions") -local log = require("doom.extras.logging") -local config = require("doom.core.config").config - -local settings = {} - -log.debug("Loading Doom defaults module ...") - --- load_default_options sets and loads default Neovim options based on doom_config.lua values -settings.load_default_options = function() - ----- Default Neovim configurations - -- Global options - vim.opt.hidden = true - vim.opt.updatetime = 200 - vim.opt.timeoutlen = 500 - vim.opt.completeopt = { - "menu", - "menuone", - "preview", - "noinsert", - "noselect", - } - vim.opt.shortmess:append("atsc") - vim.opt.inccommand = "split" - vim.opt.path = "**" - vim.opt.signcolumn = "auto:2-3" - vim.opt.foldcolumn = "auto:9" - - vim.opt.fillchars = { - vert = "▕", - fold = " ", - eob = " ", - diff = "─", - msgsep = "‾", - foldopen = "▾", - foldclose = "▸", - foldsep = "│", - } - - -- Buffer options - vim.opt.smartindent = true - vim.opt.copyindent = true - vim.opt.preserveindent = true - - -- Set Gui Fonts - vim.opt.guifont = config.doom.guifont .. ":h" .. config.doom.guifont_size - - -- Use clipboard outside vim - if config.doom.clipboard then - vim.opt.clipboard = "unnamedplus" - end - - if config.doom.line_highlight then - vim.opt.cursorline = true - else - vim.opt.cursorline = false - end - - -- Automatic split locations - if config.doom.split_right then - vim.opt.splitright = true - else - vim.opt.splitright = false - end - - if config.doom.split_below then - vim.opt.splitbelow = true - else - vim.opt.splitbelow = false - end - - -- Enable scroll off - if config.doom.scrolloff then - vim.opt.scrolloff = config.doom.scrolloff_amount - end - - -- Enable showmode - if not config.doom.show_mode then - vim.opt.showmode = false - else - vim.opt.showmode = true - end - - -- Enable mouse input - if config.doom.mouse then - vim.opt.mouse = "a" - end - - -- Enable wrapping - if not config.doom.line_wrap then - vim.opt.wrap = false - else - vim.opt.wrap = true - end - - -- Enable swap files - if not config.doom.swap_files then - vim.opt.swapfile = false - else - vim.opt.swapfile = true - end - - -- Set numbering - if not config.doom.disable_numbering then - if config.doom.relative_num then - vim.opt.number = true - vim.opt.relativenumber = true - else - vim.opt.number = true - end - end - - -- Enable winwidth - if config.doom.win_width then - vim.opt.winwidth = config.doom.win_width_nr - end - - -- Checks to see if undo_dir does not exist. If it doesn't, it will create a undo folder - local undo_dir = vim.fn.stdpath("data") .. config.doom.undo_dir - if config.doom.backup and vim.fn.empty(vim.fn.glob(undo_dir)) >= 0 then - if vim.fn.isdirectory(undo_dir) ~= 1 then - vim.api.nvim_command("!mkdir -p " .. undo_dir) - end - vim.opt.undofile = true - end - - -- If backup is false but `undo_dir` still exists then it will delete it. - if not config.doom.backup and vim.fn.empty(vim.fn.glob(undo_dir)) == 0 then - vim.api.nvim_command("!rm -rf " .. undo_dir) - vim.opt.undofile = false - end - - -- Set local-buffer options - if config.doom.expand_tabs then - vim.opt.expandtab = true - else - vim.opt.expandtab = false - end - vim.opt.tabstop = config.doom.indent - vim.opt.shiftwidth = config.doom.indent - vim.opt.softtabstop = config.doom.indent - vim.opt.colorcolumn = tostring(config.doom.max_columns) - vim.opt.conceallevel = config.doom.conceallevel - vim.opt.foldenable = config.doom.foldenable - - -- Better folding - vim.cmd([[set foldtext=luaeval(\"require('doom.core.functions').sugar_folds()\")]]) -end - --- Doom Nvim commands -settings.doom_commands = function() - -- Set a custom command to update Doom Nvim - -- can be called by using :DoomUpdate - vim.cmd('command! DoomUpdate lua require("doom.core.functions").update_doom()') - -- Set a custom command to rollback Doom Nvim version - -- can be called by using :DoomRollback - vim.cmd('command! DoomRollback lua require("doom.core.functions").rollback_doom()') - -- Set a custom command to open Doom Nvim user manual - -- can be called by using :DoomManual - vim.cmd('command! DoomManual lua require("doom.core.functions").open_docs()') - -- Set a custom command to edit Doom Nvim private configurations - -- can be called by using :DoomConfigs - vim.cmd('command! DoomConfigs lua require("doom.core.functions").edit_config()') - -- Set a custom command to reload Doom Nvim custom mappings, autocommands, etc - -- can be called by using :DoomConfigsReload - vim.cmd('command! DoomConfigsReload lua require("doom.core.functions").reload_custom_settings()') - -- Set a custom command to fully reload Doom Nvim and simulate a new Neovim run - -- can be called by using :DoomReload - vim.cmd('command! DoomReload lua require("doom.modules.built-in.reloader").full_reload()') - -- Set a custom command to create a crash report - -- can be called by using :DoomReport - vim.cmd('command! DoomReport lua require("doom.core.functions").create_report()') - -- Set a custom command to display an information dashboard - -- can be called by using :DoomInfo - vim.cmd('command! DoomInfo lua require("doom.modules.built-in.info").toggle()') -end - --- Custom Doom Nvim options -settings.custom_options = function() - -- Load user-defined settings from the Neovim field in the doom_config.lua file - functions.load_custom_settings(config.nvim.functions, "functions") - functions.load_custom_settings(config.nvim.autocmds, "autocmds") - functions.load_custom_settings(config.nvim.commands, "commands") - functions.load_custom_settings(config.nvim.mappings, "mappings") - functions.load_custom_settings(config.nvim.global_variables, "variables") - functions.load_custom_settings(config.nvim.options, "options") -end - -return settings diff --git a/lua/doom/core/system/init.lua b/lua/doom/core/system.lua similarity index 59% rename from lua/doom/core/system/init.lua rename to lua/doom/core/system.lua index 822f8553a..8628ed5ff 100644 --- a/lua/doom/core/system/init.lua +++ b/lua/doom/core/system.lua @@ -1,20 +1,14 @@ ----[[---------------------------------------]]--- --- system - Doom Nvim system integration -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - local system = {} local stdpath = vim.fn.stdpath local config_dir = stdpath("config"):match(".*[/\\]"):sub(1, -2) system.sep = package.config:sub(1, 1) --- The doom-nvim root directory, works as a fallback for looking Doom Nvim configurations --- in case that doom_configs_root directory does not exists. +-- The nvim root directory, works as a fallback for looking Doom Nvim configurations +-- in case that doom_configs_root directory does not exist. system.doom_root = stdpath("config") --- The doom-nvim configurations root directory +-- The doom-nvim configurations root directory. system.doom_configs_root = table.concat({ config_dir, "doom-nvim" }, system.sep) local testdir = vim.loop.fs_opendir(system.doom_configs_root) @@ -24,6 +18,8 @@ else system.doom_configs_root = stdpath("config") end +system.doom_compile_path = vim.fn.stdpath("data") .. "/plugin/packer_compiled.lua" + -- The doom-nvim logs file path system.doom_logs = table.concat({ stdpath("data"), "doom.log" }, system.sep) @@ -31,6 +27,6 @@ system.doom_logs = table.concat({ stdpath("data"), "doom.log" }, system.sep) system.doom_report = table.concat({ stdpath("data"), "doom_report.md" }, system.sep) -- The git workspace for doom-nvim, e.g. 'git -C /home/JohnDoe/.config/nvim' -system.git_workspace = string.format("git -C %s ", stdpath("config")) +system.git_workspace = string.format("git -C %s ", system.doom_root) return system diff --git a/lua/doom/core/ui.lua b/lua/doom/core/ui.lua new file mode 100644 index 000000000..942a3260e --- /dev/null +++ b/lua/doom/core/ui.lua @@ -0,0 +1,48 @@ +local utils = require("doom.utils") +local log = require("doom.utils.logging") + +-- If the colorscheme was not found then fallback to defaults. +if not utils.is_empty(doom.colorscheme) then + local loaded_colorscheme = xpcall(function() + vim.api.nvim_command("colorscheme " .. doom.colorscheme) + end, debug.traceback) + + if not loaded_colorscheme then + log.warn("Colorscheme '" .. doom.colorscheme .. "' not found, falling back to doom-one") + vim.api.nvim_command("colorscheme doom-one") + end +else + log.warn("Forced default Doom colorscheme") + vim.api.nvim_command("colorscheme doom-one") +end + +-- Set doom-one colorscheme settings +if doom.colorscheme == "doom-one" then + require("colors.doom-one").setup({ + cursor_coloring = doom.doom_one.cursor_coloring, + terminal_colors = doom.doom_one.terminal_colors, + italic_comments = doom.doom_one.italic_comments, + enable_treesitter = doom.doom_one.enable_treesitter, + transparent_background = doom.doom_one.transparent_background, + pumblend = { + enable = true, + transparency_amount = doom.complete_transparency, + }, + plugins_integrations = { + neorg = true, + barbar = false, + bufferline = true, + gitgutter = false, + gitsigns = true, + telescope = doom.doom_one.telescope_highlights, + neogit = true, + nvim_tree = true, + dashboard = true, + startify = false, + whichkey = true, + indent_blankline = true, + vim_illuminate = true, + lspsaga = false, + }, + }) +end diff --git a/lua/doom/extras/README.md b/lua/doom/extras/README.md deleted file mode 100644 index fae1a5483..000000000 --- a/lua/doom/extras/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Core - -Herein lies the core of Doom. In other words, the modules needed for Doom to -be Doom. - -Those modules are the following: - -- autocmds - Doom autocommands. -- keybindings - Doom keybindings. -- logging - Doom logging system. diff --git a/lua/doom/extras/autocmds/init.lua b/lua/doom/extras/autocmds/init.lua deleted file mode 100644 index e47ad53eb..000000000 --- a/lua/doom/extras/autocmds/init.lua +++ /dev/null @@ -1,201 +0,0 @@ ----[[---------------------------------------]]--- --- autocmds - Doom Nvim Autocmds -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local utils = require("doom.utils") -local log = require("doom.extras.logging") -local config = require("doom.core.config").config -local is_plugin_disabled = require("doom.utils").is_plugin_disabled - -log.debug("Loading Doom autocmds module ...") - -local autocmds = { - doom_core = { - -- Compile new plugins configurations changes at save - { - "BufWritePost", - "*/config/doom-*.lua", - "PackerCompile profile=true", - }, - -- Compile modules and custom plugins changes at exit, in that way we avoid - -- weird errors of Packer complaining about uninstalled plugins on startup - { - "VimLeavePre", - "doom_modules.lua,doom_userplugins.lua", - "PackerCompile profile=true", - }, - -- Live-reload plugins and automatically install or clean them at save - { - "BufWritePost", - "doom_modules.lua,doom_userplugins.lua", - "lua require('doom.modules.built-in.reloader').reload_plugins_definitions()", - }, - -- Live-reload user-defined settings when 'doom_config.lua' file was modified - { - "BufWritePost", - "doom_config.lua", - "lua require('doom.core.functions').reload_custom_settings()", - }, - -- Live-reload plugins configuration files - { - "BufWritePost", - "*/config/doom-*.lua", - "lua require('doom.modules.built-in.reloader').reload_lua_module(vim.fn.expand('%:p'))", - }, - -- Automatically change colorscheme and background on exit - { - "VimLeavePre", - "*", - "lua require('doom.core.functions').change_colors_and_bg()", - }, - }, - doom_extras = { - -- Set up vim_buffer_previewer in telescope.nvim - { "User", "TelescopePreviewerLoaded", "setlocal wrap" }, - }, -} - --- Set numbering -if not config.doom.disable_numbering then - if config.doom.relative_num then - table.insert(autocmds["doom_core"], { - "BufEnter,WinEnter", - "*", - "if &nu | set rnu | endif", - }) - else - table.insert(autocmds["doom_core"], { - "BufEnter,WinEnter", - "*", - "if &nu | set nornu | endif", - }) - end -end - --- Install plugins on launch -if config.doom.auto_install_plugins then - vim.defer_fn(function() - -- Check if there is only packer installed so we can decide if we should - -- use PackerInstall or PackerSync, useful for generating the - -- `plugin/packer_compiled.lua` on first doom launch - if - vim.tbl_count(vim.fn.globpath(vim.fn.stdpath("data") .. "/site/pack/packer/opt", "*", 0, 1)) - == 1 - then - vim.cmd("PackerSync") - else - -- Clean disabled plugins - vim.cmd("PackerClean") - -- Defer the installation of new plugins to avoid a weird bug where packer - -- tries to clean the plugins that are being installed right now - vim.defer_fn(function() - -- Install the plugins - vim.cmd("PackerInstall") - end, 200) - end - end, 400) -end - --- Set autosave -if config.doom.autosave then - table.insert(autocmds["doom_core"], { - "TextChanged,InsertLeave", - "", - "silent! write", - }) -end - --- Enable auto comment -if not config.doom.auto_comment then - vim.opt.formatoptions:remove({ "c", "r", "o" }) -end - --- Enable highlight on yank -if config.doom.highlight_yank then - table.insert(autocmds["doom_core"], { - { - "TextYankPost", - "*", - "lua require('vim.highlight').on_yank({higroup = 'Search', timeout = 200})", - }, - }) -end - --- Format on save --- NOTE: Requires formatter to be enabled! -if config.doom.fmt_on_save then - table.insert(autocmds["doom_core"], { - "BufWritePre", - "*", - "FormatWrite", - }) -end - --- Preserve last editing position -if config.doom.preserve_edit_pos then - table.insert(autocmds["doom_core"], { - "BufReadPost", - "*", - [[ - if line("'\"") > 1 && line("'\"") <= line("$") | - exe "normal! g'\"" | - endif - ]], - }) -end - --- Linting -if not is_plugin_disabled("linter") and packer_plugins and packer_plugins["nvim-lint"] then - table.insert(autocmds["doom_extras"], { - "BufWinEnter,BufWritePost", - "", - "lua require('lint').try_lint()", - }) -end - --- Quickly exit Neovim on dashboard -if not is_plugin_disabled("dashboard") then - table.insert(autocmds["doom_extras"], { - "FileType", - "dashboard", - "nnoremap q :q", - }) -end - --- Show line diagnostics on hover -if not config.doom.enable_lsp_virtual_text then - local show_diagnostics_function = "vim.diagnostic.open_float(nil, { focus = false })" - if utils.nvim_is_05 then - show_diagnostics_function = - 'vim.lsp.diagnostic.show_line_diagnostics({ focusable = false, border = "single" })' - end - table.insert(autocmds["doom_extras"], { - "CursorHold,CursorHoldI", - "", - string.format("lua %s", show_diagnostics_function), - }) -end - --- Eye candy netrw (add icons) -if config.doom.use_netrw then - table.insert(autocmds["doom_extras"], { - "FileType", - "netrw", - "lua require('doom.core.settings.netrw').set_maps()", - }) - table.insert(autocmds["doom_extras"], { - "FileType", - "netrw", - "lua require('doom.core.settings.netrw').draw_icons()", - }) - table.insert(autocmds["doom_extras"], { - "TextChanged", - "*", - "lua require('doom.core.settings.netrw').draw_icons()", - }) -end - --- Create augroups -utils.create_augroups(autocmds) diff --git a/lua/doom/extras/init.lua b/lua/doom/extras/init.lua deleted file mode 100644 index c3fc659d8..000000000 --- a/lua/doom/extras/init.lua +++ /dev/null @@ -1,14 +0,0 @@ ---- Main Doom extras file ---- This file loads all doom extra components ---- (autocommands, keybindings) - -require("doom.extras.logging").debug("Loading Doom extras ...") - -local extra_modules = { "keybindings" } - -local disabled_autocommands = require("doom.core.config").config.doom.disable_autocommands -if not disabled_autocommands then - vim.list_extend(extra_modules, { "autocmds" }) -end - -require("doom.utils.modules").load_modules("doom.extras", extra_modules) diff --git a/lua/doom/extras/keybindings/completion.lua b/lua/doom/extras/keybindings/completion.lua deleted file mode 100644 index f9d89b90e..000000000 --- a/lua/doom/extras/keybindings/completion.lua +++ /dev/null @@ -1,144 +0,0 @@ ----[[-----------------]]--- --- LSP Keybindings -- ----]]-----------------[[--- - -local mappings = require("doom.utils.mappings") -local check_plugin = require("doom.utils").check_plugin - -local opts = { silent = true } -local lsp_opts = vim.tbl_extend("force", opts, { expr = true }) - --- gd: jump to definition -mappings.map( - "n", - "gd", - ":lua vim.lsp.buf.definition()", - opts, - "LSP", - "jump_to_definition", - "Jump to definition" -) --- gr: go to reference -mappings.map( - "n", - "gr", - ":lua vim.lsp.buf.references()", - opts, - "LSP", - "goto_reference", - "Goto reference" -) --- gi: buf implementation -mappings.map( - "n", - "gi", - ":lua vim.lsp.buf.implementation()", - opts, - "LSP", - "goto_implementation", - "List implementations" -) --- ca: code actions -mappings.map( - "n", - "ca", - ":lua vim.lsp.buf.code_action()", - opts, - "LSP", - "code_action", - "Code action" -) --- K: hover doc -mappings.map( - "n", - "K", - ":lua vim.lsp.buf.hover()", - opts, - "LSP", - "hover_doc", - "Hover documentation" -) --- Control+p: Jump to previous diagnostic --- TODO: Find the equivalent for the new vim.diagnostic api -mappings.map( - "n", - "", - ":lua vim.lsp.diagnostic.goto_prev()", - opts, - "LSP", - "prev_diagnostic", - "Jump to previous diagnostic" -) --- Control+n: Jump to next diagnostic --- TODO: Find the equivalent for the new vim.diagnostic api -mappings.map( - "n", - "", - ":lua vim.lsp.diagnostic.goto_next()", - opts, - "LSP", - "next_diagnostic", - "Jump to next diagnostic" -) - -vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()') - --- LuaSnip mappings -if check_plugin("LuaSnip", "opt") then - mappings.map( - "n", - "", - 'luasnip#expand_or_jumpable() ? "luasnip-expand-or-jump" : ""', - lsp_opts, - "Snippets", - "luasnip_expand", - "Expand snippet" - ) - mappings.map( - "i", - "", - 'lua require("luasnip").jump(-1)', - opts, - "Snippets", - "luasnip_prev_sel", - "Previous snippet" - ) - - mappings.map( - "s", - "", - 'lua require("luasnip").jump(1)', - opts, - "Snippets", - "luasnip_next_sel", - "Next snippet" - ) - mappings.map( - "s", - "", - 'lua require("luasnip").jump(-1)', - opts, - "Snippets", - "luasnip_prev_sel_s", - "Previous snippet (Select mode)" - ) - - mappings.map( - "i", - "", - 'luasnip#choice_active() ? "luasnip-next-choice" : ""', - lsp_opts, - "Snippets", - "luasnip_next_choice", - "Next snippets field" - ) - mappings.map( - "s", - "", - 'luasnip#choice_active() ? "luasnip-next-choice" : ""', - lsp_opts, - "Snippets", - "luasnip_next_choice_s", - "Next snippet field" - ) -end diff --git a/lua/doom/extras/keybindings/core.lua b/lua/doom/extras/keybindings/core.lua deleted file mode 100644 index 30b4ec586..000000000 --- a/lua/doom/extras/keybindings/core.lua +++ /dev/null @@ -1,126 +0,0 @@ -local mappings = require("doom.utils.mappings") -local config = require("doom.core.config").config -local is_plugin_disabled = require("doom.utils").is_plugin_disabled - --- Additional options for mappings -local opts = { silent = true } - --- Fast exit from Doom Nvim -mappings.map( - "n", - "ZZ", - 'lua require("doom.core.functions").quit_doom(true, true)', - opts, - "Editor", - "fast_exit", - "Fast exit from Doom Nvim" -) - --- ESC to turn off search highlighting -mappings.map( - "n", - "", - ":noh", - opts, - "Editor", - "no_highlight", - "Turn off search highlighting" -) - ----[[-----------------]]--- --- Disable keys -- ----]]-----------------[[--- --- Disable accidentally pressing ctrl-z and suspending -mappings.map("n", "", "", opts, "Editor", "disable_suspending", "Disable suspending") - --- Disable ex mode -mappings.map("n", "Q", "", opts, "Editor", "disable_ex", "Disable ex mode") - --- Disable recording macros -if config.doom.disable_macros then - mappings.map("n", "q", "", opts, "Editor", "disable_macros", "Disable macros") -end - ----[[-----------------]]--- --- Escape Remaps -- ----]]-----------------[[--- -for _, esc_seq in pairs(config.doom.escape_sequences or { "jk", "kj" }) do - mappings.map( - "i", - esc_seq, - "", - opts, - "Editor", - "exit_insert" .. esc_seq, - "Exit insert mode `" .. esc_seq .. "`" - ) -end - ----[[-----------------]]--- --- Make inclusive -- ----]]-----------------[[--- --- BUG: my nvim freezes from this when which key shows up --- NOTE: IMO inclusive is better --- mappings.map("o", "T", "vT", opts, "Editor", "occurence_backw_inclusive", "Backwards occurence inclusive") --- mappings.map("o", "F", "vF", opts, "Editor", "occurence_backw_till_inclusive", "Backwards occurence till inclusive") - ----[[------------------]]--- --- F keybindings -- ----]]------------------[[--- -if not is_plugin_disabled("symbols") then - mappings.map( - "n", - "", - ":SymbolsOutline", - opts, - "Editor", - "open_symbols", - "Toggle SymbolsOutline (LSP tags)" - ) -end -if not is_plugin_disabled("explorer") and not config.doom.use_netrw then - mappings.map( - "n", - "", - ":NvimTreeToggle", - opts, - "Editor", - "open_tree", - "Toggle file explorer" - ) -else - mappings.map( - "n", - "", - string.format(":Lexplore%s", config.doom.explorer_right and "!" or ""), - opts, - "Editor", - "open_tree", - "Toggle file explorer" - ) -end -if not is_plugin_disabled("minimap") then - mappings.map( - "n", - "", - ":MinimapToggle", - opts, - "Editor", - "open_minimap", - "Toggle code minimap" - ) -end -if not is_plugin_disabled("zen") then - mappings.map("n", "", ":TZAtaraxis", opts, "Editor", "open_zen", "Toggle Zen mode") -end -if not is_plugin_disabled("restclient") then - mappings.map( - "n", - "", - ":RestNvim", - opts, - "Editor", - "exec_http", - "Execute http client under cursor" - ) -end diff --git a/lua/doom/extras/keybindings/init.lua b/lua/doom/extras/keybindings/init.lua deleted file mode 100644 index 11b2e0670..000000000 --- a/lua/doom/extras/keybindings/init.lua +++ /dev/null @@ -1,70 +0,0 @@ ----[[---------------------------------------]]--- --- keybindings - Doom Nvim keybindings -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local log = require("doom.extras.logging") -local config = require("doom.core.config").config - -log.debug("Loading Doom keybindings module ...") - -------------------------------------------------- - ----[[---------------------------------]]--- --- Custom Key mappings -- --- -- --- b = +buffers -- --- c = +code -- --- d = +debug -- --- l = +lsp -- --- d = +doom -- --- f = +file -- --- g = +git -- --- p = +plugins -- --- q = +quit/sessions -- --- s = +search -- --- t = +tweak -- --- w = +windows -- --- o = +open -- --- j = +jumps -- --- -- --- TAB = Cycle buffers -- --- ESC = Search highlight off -- --- F2 = Toggle Symbols-Outline -- --- F3 = Toggle Tree Explorer -- --- F4 = Toggle Terminal -- --- F5 = Toggle Minimap -- --- F6 = Toggle Zen Mode -- --- F7 = Run restclient -- ----]]---------------------------------[[--- - -------------------------------------------------- - -local keybinds_modules = config.doom.keybinds_modules - or { - -- Core doom keybindings - core = true, - -- Movement keybindings, jump between your windows, buffers and code - movement = true, - -- Leader keybindings, a bunch of useful keybindings managed by space key - -- WARNING: disabling this will break which-key plugin if the plugin is enabled - leader = true, - -- Completion and snippets keybindings - completion = true, - } - -for module in pairs(keybinds_modules) do - if keybinds_modules[module] then - local ok, err = xpcall(require, debug.traceback, ("doom.extras.keybindings.%s"):format(module)) - if not ok then - log.error( - string.format( - "There was an error loading the module 'doom.extras.keybindings.%s'. Traceback:\n%s", - module, - err - ) - ) - end - end -end diff --git a/lua/doom/extras/keybindings/leader.lua b/lua/doom/extras/keybindings/leader.lua deleted file mode 100644 index 7fd5b5120..000000000 --- a/lua/doom/extras/keybindings/leader.lua +++ /dev/null @@ -1,858 +0,0 @@ ----[[-----------------]]--- --- WhichKey binds -- ----]]-----------------[[--- - -local mappings = require("doom.utils.mappings") -local config = require("doom.core.config").config -local is_plugin_disabled = require("doom.utils").is_plugin_disabled - --- Additional options for mappings -local opts = { silent = true } - --- Set Space key as leader -if is_plugin_disabled("which-key") then - mappings.map("n", "", "", opts, "Editor", "open_whichkey", "Open WhichKey menu") -end -vim.g.mapleader = " " - -if config.doom.new_file_split then - if config.doom.vertical_split then - mappings.map( - "n", - "fn", - ":vert new", - opts, - "Editor", - "new_buffer_split_vertical", - "Open a new unnamed buffer in a vertical split window" - ) - else - mappings.map( - "n", - "fn", - ":new", - opts, - "Editor", - "new_buffer_split", - "Open a new unnamed buffer in a split window" - ) - end -else - mappings.map( - "n", - "fn", - ":enew", - opts, - "Editor", - "new_buffer", - "Open a new unnamed buffer" - ) -end - --- Misc -mappings.map( - "n", - "`", - "lua require('telescope.builtin').find_files({cwd=vim.fn.expand('%:p:h')})", - opts, - "Editor", - "cwd_file_browser", - "Find file from CWD of current file" -) -mappings.map( - "n", - ".", - "Telescope file_browser", - opts, - "Editor", - "file_browser", - "Browse files" -) -mappings.map( - "n", - ",", - "Telescope buffers show_all_buffers=true", - opts, - "Movement", - "switch_buffers", - "Switch buffers" -) -mappings.map( - "n", - "/", - "Telescope live_grep", - opts, - "Editor", - "live_grep", - "Search a word" -) -mappings.map( - "n", - ":", - "Telescope command_history", - opts, - "Editor", - "command_history", - "Command history" -) - --- buffers -mappings.map( - "n", - "bc", - 'lua require("bufferline").handle_close_buffer(vim.fn.bufnr("%"))', - opts, - "Buffer", - "close_current_buffer", - "Close current buffer" -) -mappings.map( - "n", - "bb", - "e #", - opts, - "Buffer", - "switch_buffer", - "Switch to other buffer" -) -mappings.map( - "n", - "b]", - 'lua require("bufferline").cycle(1)', - opts, - "Buffer", - "next_buffer_alt", - "Goto next buffer" -) -mappings.map( - "n", - "bn", - 'lua require("bufferline").cycle(1)', - opts, - "Buffer", - "next_buffer", - "Goto next buffer" -) -mappings.map( - "n", - "bg", - 'lua require("bufferline").pick_buffer()', - opts, - "Buffer", - "goto_buffer", - "Goto buffer" -) -mappings.map( - "n", - "b[", - 'lua require("bufferline").cycle(-1)', - opts, - "Buffer", - "prev_buffer_alt", - "Goto previous buffer" -) -mappings.map( - "n", - "bp", - 'lua require("bufferline").cycle(-1)', - opts, - "Buffer", - "prev_buffer", - "Goto previous buffer" -) -mappings.map( - "n", - "bf", - "FormatWrite", - opts, - "Buffer", - "format_buffer", - "Format buffer" -) - --- doom -mappings.map( - "n", - "dc", - "DoomConfigs", - opts, - "Doom", - "edit_doom_config", - "Edit Doom configuration" -) -mappings.map( - "n", - "dd", - "DoomManual", - opts, - "Doom", - "help_doom", - "Open Doom user manual" -) -mappings.map( - "n", - "du", - "DoomUpdate", - opts, - "Doom", - "update_doom", - "Update Doom Nvim" -) -mappings.map( - "n", - "dr", - "DoomRollback", - opts, - "Doom", - "rollback_doom", - "Rollback Doom Nvim version" -) -mappings.map( - "n", - "dR", - "DoomReport", - opts, - "Doom", - "create_crash_report", - "Create crash report" -) -mappings.map( - "n", - "ds", - "lua require('telescope.builtin.internal').colorscheme({enable_preview = true})", - opts, - "Editor", - "change_colorscheme", - "Change colorscheme" -) -mappings.map( - "n", - "db", - "Telescope mapper", - opts, - "Doom", - "show_keybindings", - "Show Doom keybindings" -) -mappings.map( - "n", - "dl", - "DoomConfigsReload", - opts, - "Doom", - "reload_user_settings", - "Reload user custom settings" -) -mappings.map( - "n", - "di", - "DoomInfo", - opts, - "Doom", - "display_info_dashboard", - "Display information dashboard" -) - --- plugins -mappings.map( - "n", - "ps", - "PackerSync", - opts, - "Plugins", - "packer_sync", - "Synchronize your plugins" -) -mappings.map( - "n", - "pi", - "PackerInstall", - opts, - "Plugins", - "packer_install", - "Install missing plugins" -) -mappings.map( - "n", - "pc", - "PackerClean", - opts, - "Plugins", - "packer_clean", - "Clean unused plugins" -) -mappings.map( - "n", - "pC", - "PackerCompile", - opts, - "Plugins", - "packer_compile", - "Compile your plugins changes" -) -mappings.map( - "n", - "pS", - "PackerStatus", - opts, - "Plugins", - "packer_status", - "Plugins status" -) -mappings.map( - "n", - "pp", - "PackerProfile", - opts, - "Plugins", - "packer_profile", - "Profile the time taken loading your plugins" -) - --- files -mappings.map( - "n", - "fc", - "e $MYVIMRC", - opts, - "Editor", - "edit_vimrc", - "Edit your Neovim rc" -) -mappings.map( - "n", - "ff", - "Telescope find_files", - opts, - "Editor", - "find_files_alt", - "Find files" -) - -mappings.map( - "n", - "fr", - "Telescope oldfiles", - opts, - "Editor", - "recent_files", - "Recently opened files" -) -mappings.map( - "n", - "ft", - "Telescope help_tags", - opts, - "Editor", - "help_tags", - "Help tags" -) -mappings.map( - "n", - "fR", - "SudaRead", - opts, - "Editor", - "read_sudo", - "Re-open file with sudo permissions" -) -mappings.map( - "n", - "fw", - "SudaWrite", - opts, - "Editor", - "write_sudo", - "Write file with sudo permissions" -) - --- search -mappings.map( - "n", - "sg", - "Telescope live_grep", - opts, - "Editor", - "live_grep_alt", - "Search a word" -) -mappings.map( - "n", - "sb", - "Telescope current_buffer_fuzzy_find", - opts, - "Editor", - "fzf", - "Search in buffer" -) -mappings.map( - "n", - "ss", - "Telescope lsp_document_symbols", - opts, - "LSP", - "lsp_symbols", - "Goto symbol" -) -mappings.map( - "n", - "sh", - "Telescope command_history", - opts, - "Editor", - "command_history_alt", - "Command history" -) -mappings.map( - "n", - "sm", - "Telescope marks", - opts, - "Editor", - "jump_mark", - "Jump to mark" -) - --- tweak -mappings.map( - "n", - "tb", - 'lua require("doom.core.functions").toggle_background()', - opts, - "Tweak", - "toggle_background", - "Toggle background" -) -mappings.map( - "n", - "tc", - 'lua require("doom.core.functions").toggle_completion()', - opts, - "Tweak", - "toggle_completion", - "Toggle completion" -) --- "g" as gutter, git, ... (but this tweak is applicable for linter like ALE, too) -mappings.map( - "n", - "tg", - 'lua require("doom.core.functions").toggle_signcolumn()', - opts, - "Tweak", - "toggle_signcolumn", - "Toggle signcolumn" -) -mappings.map( - "n", - "ti", - 'lua require("doom.core.functions").set_indent()', - opts, - "Tweak", - "set_indent", - "Set tab and indent" -) -mappings.map( - "n", - "tn", - 'lua require("doom.core.functions").change_number()', - opts, - "Tweak", - "change_number", - "Change number" -) -if not is_plugin_disabled("autopairs") then - mappings.map( - "n", - "tp", - 'lua require("doom.core.functions").toggle_autopairs()', - opts, - "Tweak", - "toggle_autopairs", - "Toggle autopairs" - ) -end -mappings.map( - "n", - "ts", - 'lua require("doom.core.functions").toggle_spell()', - opts, - "Tweak", - "toggle_spell", - "Toggle spell" -) -mappings.map( - "n", - "tx", - 'lua require("doom.core.functions").change_syntax()', - opts, - "Tweak", - "change_syntax", - "Change syntax" -) - --- windows -mappings.map("n", "ww", "p", opts, "Window", "other_window", "Goto other window") -mappings.map("n", "wd", "c", opts, "Window", "close_window", "Close current window") -mappings.map("n", "w-", "s", opts, "Window", "split_below", "Split window below") -mappings.map("n", "w|", "v", opts, "Window", "split_right", "Split window right") -mappings.map("n", "w2", "v", opts, "Window", "double_layout", "Layout double columns") -mappings.map("n", "wh", "h", opts, "Window", "window_left", "Window left") -mappings.map("n", "wj", "j", opts, "Window", "window_below", "Window below") -mappings.map("n", "wl", "l", opts, "Window", "window_right", "Window right") -mappings.map("n", "wk", "k", opts, "Window", "window_up", "Window up") -mappings.map( - "n", - "wH", - "5<", - opts, - "Window", - "expand_window_left", - "Expand window left" -) -mappings.map( - "n", - "wJ", - "resize +5", - opts, - "Window", - "expand_window_below", - "Expand window below" -) -mappings.map( - "n", - "wL", - "5>", - opts, - "Window", - "expand_window_right", - "Expand window right" -) -mappings.map( - "n", - "wK", - "resize -5", - opts, - "Window", - "expand_window_up", - "Expand window up" -) -mappings.map("n", "w=", "=", opts, "Window", "balance_window", "Balance window") -mappings.map("n", "ws", "s", opts, "Window", "split_below_alt", "Split window below") -mappings.map("n", "wv", "v", opts, "Window", "split_right_alt", "Split window right") - --- quit / sessions -mappings.map( - "n", - "qq", - 'lua require("doom.core.functions").quit_doom()', - opts, - "Editor", - "save_nvim", - "Exit Neovim" -) -mappings.map( - "n", - "qw", - 'lua require("doom.core.functions").quit_doom(true, true)', - opts, - "Editor", - "save_exit_nvim", - "Save and exit Neovim" -) -mappings.map( - "n", - "qr", - "lua require('persistence').load({ last = true })", - opts, - "Editor", - "restore_session", - "Restore previously saved session" -) - --- open -mappings.map( - "n", - "ob", - "lua require('dapui').toggle()", - opts, - "Editor", - "open_dapui", - "Open debugging UI" -) -mappings.map( - "n", - "od", - "Dashboard", - opts, - "Editor", - "open_dashboard", - "Open start screen" -) -if not config.doom.use_netrw then - mappings.map( - "n", - "oe", - "NvimTreeToggle", - opts, - "Editor", - "open_tree_alt", - "Toggle file explorer" - ) -else - mappings.map( - "n", - "oe", - string.format("Lexplore%s", config.doom.explorer_right and "!" or ""), - opts, - "Editor", - "open_tree_alt", - "Toggle file explorer" - ) -end -mappings.map( - "n", - "om", - "MinimapToggle", - opts, - "Editor", - "open_minimap_alt", - "Toggle code minimap" -) -mappings.map( - "n", - "or", - "Ranger", - opts, - "Editor", - "open_ranger_browser", - "Toggle Ranger File Browser" -) -mappings.map( - "n", - "os", - "SymbolsOutline", - opts, - "Editor", - "open_symbols_alt", - "Toggle SymbolsOutline (LSP symbols)" -) -mappings.map( - "n", - "ot", - "ToggleTerm", - opts, - "Editor", - "open_terminal", - "Toggle terminal" -) - --- git -mappings.map("n", "go", "LazyGit", opts, "Git", "lazygit", "Open LazyGit") -mappings.map( - "n", - "gl", - 'TermExec cmd="git pull"', - opts, - "Git", - "git_pull", - "Pull remote changes" -) -mappings.map( - "n", - "gp", - 'TermExec cmd="git push"', - opts, - "Git", - "git_push", - "Push git changes" -) -mappings.map( - "n", - "gs", - "Telescope git_status", - opts, - "Git", - "git_status", - "Browse git status" -) -mappings.map( - "n", - "gB", - "Telescope git_branches", - opts, - "Git", - "git_branches", - "Browse git branches" -) -mappings.map( - "n", - "gc", - "Telescope git_commits", - opts, - "Git", - "git_commits", - "Browse git commits" -) - --- code -mappings.map( - "n", - "ch", - "RestNvim", - opts, - "Editor", - "exec_http_alt", - "Execute http client under cursor" -) -mappings.map( - "n", - "ci", - 'lua require("doom.modules.built-in.runner").start_repl()', - opts, - "Editor", - "start_repl", - "Start a REPL" -) -mappings.map( - "n", - "cr", - 'lua require("doom.modules.built-in.runner").run_code()', - opts, - "Editor", - "run_file", - "Run the current file" -) -mappings.map( - "n", - "cb", - 'lua require("doom.modules.built-in.compiler").compile()', - opts, - "Editor", - "compile", - "Compile project" -) -mappings.map( - "n", - "cc", - 'lua require("doom.modules.built-in.compiler").compile_and_run()', - opts, - "Editor", - "compile_and_run", - "Compile and run project" -) - --- debugging -mappings.map( - "n", - "cdb", - "lua require('dap').toggle_breakpoint()", - opts, - "DAP", - "dap_toggle_brkpt", - "Toggle breakpoint on current line" -) -mappings.map( - "n", - "cdc", - "lua require('dap').continue()", - opts, - "DAP", - "dap_continue", - "Start (or continue) a debug session" -) -mappings.map( - "n", - "cdd", - "lua require('dap').disconnect()", - opts, - "DAP", - "dap_disconnect", - "End debugging session" -) -mappings.map( - "n", - "cde", - "lua require('dapui').eval()", - opts, - "DAP", - "dap_eval", - "Evaluate word under cursor" -) -mappings.map( - "v", - "cds", - "lua require('dapui').eval()", - opts, - "DAP", - "dap_eval_selection", - "Evaluate selection" -) - --- lsp -mappings.map("n", "cli", "LspInfo", opts, "LSP", "lsp_info", "LSP Information") -mappings.map( - "n", - "cla", - "lua vim.lsp.buf.code_action()", - opts, - "LSP", - "code_action_alt", - "Code actions" -) -mappings.map( - "n", - "cld", - "lua vim.lsp.buf.type_definition()", - opts, - "LSP", - "type_definition", - "Show type definition" -) -mappings.map( - "n", - "cll", - 'lua vim.lsp.diagnostic.show_line_diagnostics({ focusable = false, border = "single" })', - opts, - "LSP", - "line_diagnostic", - "Show line diagnostics" -) -mappings.map( - "n", - "clq", - "lua vim.lsp.diagnostic.set_loclist()", - opts, - "LSP", - "diagnostic_list", - "Diagnostics into location list" -) -mappings.map( - "n", - "clr", - "lua vim.lsp.buf.rename()", - opts, - "LSP", - "rename_reference", - "Rename the reference under cursor" -) - --- jumps -mappings.map("n", "ja", "", opts, "Jumps", "jump_alternate_file", "Alternate file") -mappings.map("n", "jj", "", opts, "Jumps", "jump_older", "Jump to older pos") -mappings.map("n", "jk", "", opts, "Jumps", "jump_newer", "Jump to newer pos") -mappings.map("n", "jp", ":pop", opts, "Jumps", "jump_pop_tag", "Pop from tag stack") -mappings.map( - "n", - "jt", - ":tag", - opts, - "Jumps", - "jump_folow_tag", - "Follow tag / add to stack" -) --- save -mappings.map("n", "v", "w", opts, "Save", "save_left", "Save v") -mappings.map("n", "m", "w", opts, "Save", "save_right", "Save m") - --- man pages -mappings.map("n", "h", ":Man ", { silent = false }, "Man page", "man_page", "Man page") diff --git a/lua/doom/extras/keybindings/movement.lua b/lua/doom/extras/keybindings/movement.lua deleted file mode 100644 index fc3b63f19..000000000 --- a/lua/doom/extras/keybindings/movement.lua +++ /dev/null @@ -1,167 +0,0 @@ -local mappings = require("doom.utils.mappings") - --- Additional options for mappings -local opts = { silent = true } - --- TAB to cycle buffers too, why not? -mappings.map("n", "", ":bnext", opts, "Movement", "cycle_next_buffer", "Goto next buffer") -mappings.map( - "n", - "", - ":bprevious", - opts, - "Movement", - "cycle_prev_buffer", - "Goto prev buffer" -) - ----[[-------------------------]]--- --- Window Movements keys -- ----]]-------------------------]]--- -mappings.map("n", "", "h", opts, "Movement", "left_window", "Goto left window") -mappings.map("n", "", "j", opts, "Movement", "down_window", "Goto down window") -mappings.map("n", "", "k", opts, "Movement", "up_window", "Goto upper window") -mappings.map("n", "", "l", opts, "Movement", "right_window", "Goto right window") - ----[[-----------------]]--- --- Move Lines -- ----]]-----------------[[--- -mappings.map( - "n", - "", - ":m .+1==", - opts, - "Editor", - "normal_move_line_down", - "Normal Move line down" -) -mappings.map( - "n", - "", - ":m .-2==", - opts, - "Editor", - "normal_move_line_up", - "Normal Move line up" -) -mappings.map( - "i", - "", - ":m .+1==gi", - opts, - "Editor", - "instert_move_line_down", - "Insert Move line down" -) -mappings.map( - "i", - "", - ":m .-2==gi", - opts, - "Editor", - "instert_move_line_up", - "Insert Move line up" -) -mappings.map( - "v", - "", - ":m '>+1gv=gv", - opts, - "Editor", - "visual_move_line_down", - "Visual Move line down" -) -mappings.map( - "v", - "", - ":m '<-2gv=gv", - opts, - "Editor", - "visual_move_line_up", - "Visual Move line up" -) - ----[[-----------------]]--- --- Select Movement -- ----]]-----------------[[--- -mappings.map( - "x", - "K", - ":move '<-2gv-gv", - opts, - "Editor", - "select_right", - "Move selection right" -) -mappings.map("x", "J", ":move '>+1gv-gv", opts, "Editor", "select_left", "Move selection left") - --- stay in visual mode after indenting with < or > -mappings.map( - "v", - ">", - ">gv", - opts, - "Editor", - "stay_vselect_indent", - "Stay in visual mode after indenting a selection" -) -mappings.map( - "v", - "<", - "", - "", - opts, - "Editor", - "exit_insert_term", - "Exit insert mode (inside a terminal)" -) - ----[[-----------------]]--- --- Resizing Splits -- ----]]-----------------[[--- -mappings.map( - "n", - "", - ":resize +2", - opts, - "Window", - "resize_up", - "Resize window (increase width)" -) -mappings.map( - "n", - "", - ":resize -2", - opts, - "Window", - "resize_down", - "Resize window (decrease width)" -) -mappings.map( - "n", - "", - ":vertical resize -2", - opts, - "Window", - "resize_right", - "Resize window (decrease height)" -) -mappings.map( - "n", - "", - ":vertical resize +2", - opts, - "Window", - "resize_left", - "Resize window (increase height)" -) diff --git a/lua/doom/modules/annotations/binds.lua b/lua/doom/modules/annotations/binds.lua new file mode 100644 index 000000000..5305a83bd --- /dev/null +++ b/lua/doom/modules/annotations/binds.lua @@ -0,0 +1,17 @@ +local binds = { + { + "", + name = "+prefix", + { + { + "c", + name = "+code", + { + { "g", require("neogen").generate, name = "Generate annotations" }, + }, + }, + }, + }, +} + +return binds diff --git a/lua/doom/modules/annotations/init.lua b/lua/doom/modules/annotations/init.lua new file mode 100644 index 000000000..f7e789d19 --- /dev/null +++ b/lua/doom/modules/annotations/init.lua @@ -0,0 +1,19 @@ +local annotations = {} + +annotations.defaults = { + enabled = true, + languages = { + lua = { + template = { + annotation_convention = "ldoc", + }, + }, + }, +} + +annotations.packer_config = {} +annotations.packer_config["neogen"] = function() + require("neogen").setup(doom.annotations) +end + +return annotations diff --git a/lua/doom/modules/annotations/packages.lua b/lua/doom/modules/annotations/packages.lua new file mode 100644 index 000000000..b26523467 --- /dev/null +++ b/lua/doom/modules/annotations/packages.lua @@ -0,0 +1,7 @@ +return { + ["neogen"] = { + "danymat/neogen", + commit = "966d09146857af9ba23a4633dce0e83ad51f2b23", + after = "nvim-treesitter", + }, +} diff --git a/lua/doom/modules/auto_install/init.lua b/lua/doom/modules/auto_install/init.lua new file mode 100644 index 000000000..e9cd588d9 --- /dev/null +++ b/lua/doom/modules/auto_install/init.lua @@ -0,0 +1,22 @@ +local auto_install = {} + +auto_install.defaults = { + lsp_dir = vim.fn.stdpath("data") .. "/lsp-install/", + dap_dir = vim.fn.stdpath("data") .. "/dap-install/", +} + +auto_install.packer_config = {} +auto_install.packer_config["nvim-lsp-installer"] = function() + local lsp_installer = require("nvim-lsp-installer") + lsp_installer.settings({ + install_root_dir = doom.auto_install.lsp_dir, + }) +end +auto_install.packer_config["DAPInstall.nvim"] = function() + local dap_install = require("dap-install") + dap_install.setup({ + installation_path = doom.auto_install.dap_dir, + }) +end + +return auto_install diff --git a/lua/doom/modules/auto_install/packages.lua b/lua/doom/modules/auto_install/packages.lua new file mode 100644 index 000000000..da914c063 --- /dev/null +++ b/lua/doom/modules/auto_install/packages.lua @@ -0,0 +1,23 @@ +local is_plugin_disabled = require("doom.utils").is_plugin_disabled + +return { + ["DAPInstall.nvim"] = { + "Pocco81/DAPInstall.nvim", + commit = "dd09e9dd3a6e29f02ac171515b8a089fb82bb425", + after = "nvim-dap", + cmd = { + "DIInstall", + "DIList", + "DIUninstall", + }, + disabled = is_plugin_disabled("dap"), + module = "dap-install", + }, + ["nvim-lsp-installer"] = { + "williamboman/nvim-lsp-installer", + commit = "7a4f43beaf579f48b190e4a0784d4b3317157495", + opt = true, + disabled = is_plugin_disabled("lsp"), + module = "nvim-lsp-install", + }, +} diff --git a/lua/doom/modules/auto_session/binds.lua b/lua/doom/modules/auto_session/binds.lua new file mode 100644 index 000000000..15e293bc0 --- /dev/null +++ b/lua/doom/modules/auto_session/binds.lua @@ -0,0 +1,28 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "q", + name = "+quit", + { + { + "r", + function() + require("persistence").load({ last = true }) + end, + name = "Restore session", + }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/auto_session/init.lua b/lua/doom/modules/auto_session/init.lua new file mode 100644 index 000000000..81e64f703 --- /dev/null +++ b/lua/doom/modules/auto_session/init.lua @@ -0,0 +1,12 @@ +local auto_session = {} + +auto_session.defaults = { + dir = vim.fn.stdpath("data") .. "/sessions/", +} + +auto_session.packer_config = {} +auto_session.packer_config["persistence.nvim"] = function() + require("persistence").setup(doom.auto_session) +end + +return auto_session diff --git a/lua/doom/modules/auto_session/packages.lua b/lua/doom/modules/auto_session/packages.lua new file mode 100644 index 000000000..42eaeb0c9 --- /dev/null +++ b/lua/doom/modules/auto_session/packages.lua @@ -0,0 +1,6 @@ +return { + ["persistence.nvim"] = { + "folke/persistence.nvim", + commit = "77cf5a6ee162013b97237ff25450080401849f85", + }, +} diff --git a/lua/doom/modules/autopairs/binds.lua b/lua/doom/modules/autopairs/binds.lua new file mode 100644 index 000000000..e2447705d --- /dev/null +++ b/lua/doom/modules/autopairs/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "t", + name = "+tweak", + { + { "p", require("doom.core.functions").toggle_autopairs, name = "Toggle autopairs" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/autopairs/init.lua b/lua/doom/modules/autopairs/init.lua new file mode 100644 index 000000000..79ed8d09d --- /dev/null +++ b/lua/doom/modules/autopairs/init.lua @@ -0,0 +1,14 @@ +local autopairs = {} + +autopairs.defaults = { + enable_afterquote = true, + enable_check_bracket_line = true, + enable_moveright = true, +} + +autopairs.packer_config = {} +autopairs.packer_config["nvim-autopairs"] = function() + require("nvim-autopairs").setup(vim.tbl_deep_extend("force", doom.autopairs, { check_ts = true })) +end + +return autopairs diff --git a/lua/doom/modules/autopairs/packages.lua b/lua/doom/modules/autopairs/packages.lua new file mode 100644 index 000000000..e202feccc --- /dev/null +++ b/lua/doom/modules/autopairs/packages.lua @@ -0,0 +1,7 @@ +return { + ["nvim-autopairs"] = { + "windwp/nvim-autopairs", + commit = "e6b1870cd2e319f467f99188f99b1c3efc5824d2", + event = "BufReadPost", + }, +} diff --git a/lua/doom/modules/built-in/README.md b/lua/doom/modules/built-in/README.md deleted file mode 100644 index 75f30f3d0..000000000 --- a/lua/doom/modules/built-in/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# Doom Modules - -Here lies all the built-in modules for Doom Nvim. But what are these modules? - -All the submodules here are Doom plugins, that is, they are plugins made in -Doom and for Doom that you will find only in Doom _or we hope so_. - -## List of plugins - -- runner - - A built-in function for pressing a few keybinds and executing a REPL for - the current filetype, inspired by SpaceVim one. e.g. if you are editing a - Python file then `SPC - c - i` will open a terminal window with Python REPL - _obviously_. Or if you want to run the current file then you can press - `SPC - c - r`. -- compiler - - A built-in function for compiling _and running (optionally)_ your projects. - By example, for compiling and running your Rust program you will only need - to press `SPC - c - c` and Doom will take care of your rusty code. - Otherwise if you only want to compile then you can press `SPC - c - b`. - -## FAQ - -- Why are we using toggleterm for the runner and the compiler plugins? - -That's because toggleterm is a pretty nice plugin that wraps the existing -Neovim terminal integration (`term://`) feature and there is no need to -reinvent the wheel for introducing unneeded complexity in the doom codebase. - -> **NOTE:** you can find more information about each plugin in the respective -> plugin directory. diff --git a/lua/doom/modules/built-in/compiler/README.md b/lua/doom/modules/built-in/compiler/README.md deleted file mode 100644 index 9adba99d4..000000000 --- a/lua/doom/modules/built-in/compiler/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Compiler - -This plugin aims to take care of your projects by helping you to: - -- Compile your entire project. -- Compiling and running your project. - -## Currently supported languages - -- Rust -- Golang - -> **NOTE**: Do you want to give support for other languages? Feel free to open -> a pull request! - -## Keybindings - -- Compile - - `SPC - c - b` -- Compile and run - - `SPC - c - c` - -## FAQ - -- Why we are using a toggleterm `exec_command` function? - -That's because of if we use a custom terminal like in the runner REPL then we -will find an issue: - -The terminal closes when the process ends so that's it, you will not see a -correct output for compilation processes or even while running the code. That's -why we are spawning a terminal and then executing the commands for building and -running. diff --git a/lua/doom/modules/built-in/compiler/init.lua b/lua/doom/modules/built-in/compiler/init.lua deleted file mode 100644 index c11c94f6d..000000000 --- a/lua/doom/modules/built-in/compiler/init.lua +++ /dev/null @@ -1,82 +0,0 @@ -local log = require("doom.extras.logging") -local term - -if packer_plugins and packer_plugins["toggleterm.nvim"] then - term = require("toggleterm.terminal").Terminal -else - log.error( - "Doom compiler needs toggleterm plugin, please uncomment the 'terminal' entry in your doom_modules.lua" - ) -end - -local M = {} - --- Currently supported languages, --- filetype → binary to execute -local languages = { - rust = "rust", - go = "go", -} - --- compile will compile the project in the current working directory -M.compile = function() - local filetype = vim.bo.filetype - local lang_bin = languages[filetype] - - local compiled_code, err = xpcall(function() - if lang_bin then - -- Set the properly builder command for the project - local compiler_cmd - if lang_bin == "rust" then - compiler_cmd = "cargo build" - elseif lang_bin == "go" then - -- NOTE: Untested because I am not using Go anymore, this - -- command should look for a main program in the cwd - compiler_cmd = "go build ." - end - local compiler = term:new({ cmd = compiler_cmd, hidden = true, close_on_exit = false }) - compiler:open() - else - log.error("The filetype " .. filetype .. " is not yet supported in the Doom compiler plugin") - end - end, debug.traceback) - - if not compiled_code then - log.error("Error while trying to compile the project. Traceback:\n" .. err) - end -end - --- compile_and_run compiles the project and then runs it -M.compile_and_run = function() - local filetype = vim.bo.filetype - local lang_bin = languages[filetype] - - local compiled_code, err = xpcall(function() - if lang_bin then - -- Set the properly builder command for the project - local compiler_cmd - if lang_bin == "rust" then - compiler_cmd = "cargo run" - elseif lang_bin == "go" then - -- NOTE: Untested because I am not using Go anymore - -- TODO: Maybe try to find other way for this if not everyone - -- uses a main.go file as their entry points? - compiler_cmd = "go run main.go" - end - local compiler_and_runner = term:new({ - cmd = compiler_cmd, - hidden = true, - close_on_exit = false, - }) - compiler_and_runner:open() - else - log.error("The filetype " .. filetype .. " is not yet supported in the Doom compiler plugin") - end - end, debug.traceback) - - if not compiled_code then - log.error("Error while trying to compile and run the project. Traceback:\n" .. err) - end -end - -return M diff --git a/lua/doom/modules/built-in/info/init.lua b/lua/doom/modules/built-in/info/init.lua deleted file mode 100644 index 04e2710f3..000000000 --- a/lua/doom/modules/built-in/info/init.lua +++ /dev/null @@ -1,617 +0,0 @@ -local utils = require("doom.utils") -local system = require("doom.core.system") - ---- @class Info -local info = {} - ---- Info buffer namespace -local info_ns = vim.api.nvim_create_namespace("doom_info_ns") ---- Info buffer ID -local info_buffer ---- Current buffer ID, meant to be used for getting buffer information like treesitter parser -local curr_buffer = vim.api.nvim_win_get_buf(0) - ---- Doom Nvim banner -local doom_banner = { - " ", - "================= =============== =============== ======== ========", - "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //", - "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||", - "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||", - "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||", - "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||", - "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||", - "|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||", - "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||", - "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||", - "|| `' || || `' || || `' || || | \\ / | ||", - "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||", - "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||", - "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||", - "|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||", - "||.==' _-' `' | /==.||", - "==' _-' N E O V I M \\/ `==", - "\\ _-' `-_ /", - " `'' ``' ", - " ", -} - ---- System-wide commands required by Doom (some of them are optional) -local additional_executables = { "rg", "fd", "git", "npm", "node", "tree-sitter" } - ---- Gets padding with N length ---- @param n number ---- @return string -local function get_padding(n) - return (" "):rep(n) -end - ---- Padding levels -local padding_level = { - get_padding(2), - get_padding(4), - get_padding(6), - get_padding(10), -} - ---- Aligns text to center ---- @param text_lines table ---- @param align_mode string ---- @return table -local function align_text(text_lines, align_mode) - local aligned_text = {} - local padding_amount - local window_width = vim.api.nvim_win_get_width(0) - - for _, line in ipairs(text_lines) do - if align_mode == "left" then - padding_amount = 2 - elseif align_mode == "center" then - padding_amount = math.floor(window_width / 2) - math.floor(line:len() / 2) - end - local padding = get_padding(padding_amount) - table.insert(aligned_text, padding .. line) - end - - return aligned_text -end - ---- Checks if a system command exists ---- @param command string ---- @return boolean -local function command_exists(command) - return vim.fn.executable(command) == 1 -end - ---- Extract the basename of given filepath, suffix is not trimed. -local function basename(path) - return string.match(path, string.format(".*%s(.*)", system.sep)) -end - ---- Get the active language servers, extracted from my galaxyline fork ---- @return string -local get_lsp_clients = function(bufnr) - local msg = "No Active Lsp" - local clients = vim.lsp.buf_get_clients(bufnr) - if next(clients) == nil then - return msg - end - - local client_names = "" - for _, client in pairs(clients) do - if string.len(client_names) < 1 then - client_names = client_names .. client.name - else - client_names = client_names .. ", " .. client.name - end - end - return string.len(client_names) > 0 and client_names or msg -end - -local function get_doom_info() - local doom_info = {} - - ----- DOOM INFORMATION ------------------------ - ----------------------------------------------- - -- Doom version - local doom_version = utils.doom_version - -- Doom branch - local doom_branch = utils.get_git_output("branch --show-current", true) - -- Configurations path - local config_path = require("doom.core.config").source - local modules_path = require("doom.core.config.modules").source - local userplugins_path = require("doom.core.config.userplugins").source - - ----- NVIM INFORMATION ------------------------ - ----------------------------------------------- - local nvim_dev_version = false - -- Neovim version - local version = vim.version() - if version.minor == 7 then - nvim_dev_version = true - end - local nvim_version = string.format( - "%s.%s.%s %s", - version.major, - version.minor, - version.patch, - nvim_dev_version and "(prerelease)" or "" - ) - - -- Local commit and last update date - local current_commit = utils.get_git_output("rev-parse HEAD", true) - local last_update_date = utils.get_git_output("show -s --format=%cD " .. current_commit, true) - - vim.list_extend(doom_info, { - "Doom Nvim Information", - string.format("%s• Neovim version: %s%s", padding_level[1], padding_level[1], nvim_version), - string.format( - "%s• Doom version: %s%s (%s branch)", - padding_level[1], - padding_level[2], - doom_version, - doom_branch - ), - string.format( - "%s• Doom root:%s%s", - padding_level[1], - padding_level[2]:rep(2), - system.doom_root - ), - string.format("%s• Last update date: %s", padding_level[1], last_update_date), - }) - if doom_branch == "develop" then - -- Current commit relevant information - local current_commit_author = utils.get_git_output( - 'show -s --format="%cN <%cE>" ' .. current_commit, - true - ) - local current_commit_message = utils.get_git_output( - "show -s --format=%s " .. current_commit, - true - ) - local current_commit_body = utils.get_git_output( - "show -s --format=%b " .. current_commit, - false - ) - - vim.list_extend(doom_info, { - "", - string.format("%s▶ Doom current commit", padding_level[1]), - string.format("%s• Commit short hash: %s", padding_level[2], current_commit:sub(1, 7)), - string.format( - "%s• Commit author: %s%s", - padding_level[2], - padding_level[2], - current_commit_author - ), - string.format( - "%s• Commit subject:%s%s", - padding_level[2], - padding_level[2], - current_commit_message - ), - }) - -- Check if the commit body is empty before trying to add it - if current_commit_body:gsub("[\r\n]", ""):len() > 0 then - vim.list_extend(doom_info, { - "", - string.format("%s○ Commit body", padding_level[2]), - }) - -- Add each line separately because Neovim does not like newlines - for _, body_part in ipairs(vim.split(current_commit_body, "\n")) do - if body_part:len() > 0 then - vim.list_extend(doom_info, { - string.format( - "%s", - body_part - :gsub("^", string.format("%s", padding_level[3])) - :gsub("^%s+", string.format("%s", padding_level[3])) - :gsub("^%s+%-", string.format("%s-", padding_level[3])) - ), - }) - end - end - end - end - vim.list_extend(doom_info, { - "", - string.format("%s▶ Doom configurations paths", padding_level[1]), - string.format("%s- %s", padding_level[2], config_path), - string.format("%s- %s", padding_level[2], modules_path), - string.format("%s- %s", padding_level[2], userplugins_path), - }) - - ----- TREESITTER INFORMATION ------------------ - ----------------------------------------------- - vim.list_extend(doom_info, { - "", - string.format("%s▶ Installed treesitter parsers", padding_level[1]), - }) - for _, parser in ipairs(require("nvim-treesitter.info").installed_parsers()) do - table.insert(doom_info, string.format("%s- %s", padding_level[2], parser)) - end - - ----- LSP INFORMATION ------------------------- - ----------------------------------------------- - if not require("doom.utils").is_plugin_disabled("lsp") and packer_plugins["nvim-lspinstall"] then - vim.list_extend(doom_info, { - "", - string.format("%s▶ Installed language servers", padding_level[1]), - }) - for _, server in ipairs(require("lspinstall").installed_servers()) do - -- Get the real name for the language server because lspinstall names them like the filetype - local server_path = require("lspconfig")[server].cmd[1] - local real_server_name = basename(server_path) - if not real_server_name then - -- If we were unable to get the server executable name then fallback to default server name (filetype) - real_server_name = server - else - -- Fix some server names that are "incorrect" - real_server_name = real_server_name - :gsub("%-language%-server", "") - :gsub("%-langserver", "") - :gsub("typescript", "tsserver") - :gsub("sumneko%-lua", "sumneko_lua") - end - table.insert(doom_info, string.format("%s- %s", padding_level[2], real_server_name)) - end - end - return doom_info -end - -local function get_buffer_info() - local buffer_info = {} - local buffer_ft = vim.api.nvim_buf_get_option(curr_buffer, "filetype") - - vim.list_extend(buffer_info, { - "Buffer Information", - string.format( - "%s• %s%s%s", - padding_level[1], - "Is read-only?", - padding_level[3], - vim.api.nvim_buf_get_option(curr_buffer, "readonly") and "yes" or "no" - ), - string.format("%s• %s: %s", padding_level[1], "Detected filetype", buffer_ft), - "", - string.format("%s▶ Settings", padding_level[1]), - string.format( - "%s• %s: %s%s", - padding_level[2], - "File format", - padding_level[3], - vim.api.nvim_buf_get_option(curr_buffer, "fileformat"):upper() - ), - }) - if vim.api.nvim_buf_get_option(curr_buffer, "fileencoding"):len() > 0 then - vim.list_extend(buffer_info, { - string.format( - "%s• %s: %s%s", - padding_level[2], - "File encoding", - padding_level[2], - vim.api.nvim_buf_get_option(curr_buffer, "fileencoding"):upper() - ), - }) - end - vim.list_extend(buffer_info, { - string.format( - "%s• %s: %s", - padding_level[2], - "Indentation width", - vim.api.nvim_buf_get_option(curr_buffer, "tabstop") - ), - string.format( - "%s• %s: %s", - padding_level[2], - "Indentation style", - vim.api.nvim_buf_get_option(curr_buffer, "expandtab") and "Tabs" or "Spaces" - ), - "", - ----- TREESITTER INFORMATION ------------------ - ----------------------------------------------- - string.format("%s▶ TreeSitter", padding_level[1]), - string.format( - "%s• %s%s", - padding_level[2], - "Is parser installed?" .. padding_level[2]:rep(3), - utils.has_value(require("nvim-treesitter.info").installed_parsers(), buffer_ft) and "yes" - or "no" - ), - string.format( - "%s• %s %s", - padding_level[2], - "Is indentation enabled?" .. padding_level[2]:rep(2), - require("nvim-treesitter.configs").is_enabled("indent", buffer_ft) and "yes" or "no" - ), - string.format( - "%s• %s %s", - padding_level[2], - "Is syntax highlighting enabled?", - require("nvim-treesitter.configs").is_enabled("highlight", buffer_ft) and "yes" or "no" - ), - }) - - ----- LSP INFORMATION ------------------------- - ----------------------------------------------- - if not require("doom.utils").is_plugin_disabled("lsp") and packer_plugins["nvim-lspinstall"] then - vim.list_extend(buffer_info, { - "", - string.format("%s▶ Language Servers", padding_level[1]), - string.format( - "%s• %s %s", - padding_level[2], - "Is language server installed?", - utils.has_value(require("lspinstall").installed_servers(), buffer_ft) and "yes" or "no" - ), - string.format( - "%s• %s:%s%s", - padding_level[2], - "Active language servers", - padding_level[3], - get_lsp_clients(curr_buffer) - ), - }) - end - - return buffer_info -end - -local function get_system_info() - local sys_info = {} - - ----- OS -------------------------------------- - ----------------------------------------------- - -- Get the current OS and if the user is running Linux then get also the - -- distribution name, e.g. Manjaro - local sysname = vim.loop.os_uname().sysname - local distro_name - -- If the user is running Linux then get the distribution name - if sysname == "Linux" then - distro_name = vim.trim( - -- PRETTY_NAME="Distribution (Additional info)", e.g. - -- PRETTY_NAME="Fedora 34 (KDE Plasma)" - vim.fn.system( - 'cat /etc/os-release | grep "^PRETTY_NAME" | sed ' - .. "'s/^PRETTY_NAME=\"//' | sed " - .. "'s/\"//'" - ) - ) - end - vim.list_extend(sys_info, { - "System Information", - string.format("%s• %s: %s%s", padding_level[1], "OS", padding_level[4], sysname), - }) - if distro_name then - vim.list_extend(sys_info, { - string.format("%s• %s: %s%s", padding_level[1], "Distro", padding_level[3], distro_name), - }) - end - vim.list_extend(sys_info, { - string.format("%s• %s: %s", padding_level[1], "Architecture", vim.loop.os_uname().machine), - }) - - ----- PROGRAMS -------------------------------- - ----------------------------------------------- - vim.list_extend(sys_info, { - "", - string.format("%s▶ Programs", padding_level[1]), - }) - for _, program in ipairs(additional_executables) do - local opt_message, extra_padding = "", "" - - -- We add an extra whitespace to 'no' so we can have an uniform format - local is_installed = command_exists(program) and "yes" or "no" - if (program == "node" or program == "npm") and (not command_exists(program)) then - opt_message = "(Optional, required by some language servers)" - elseif program == "fd" and (not command_exists(program)) then - opt_message = "(Optional, improves performance for many file indexing commands)" - elseif program == "rg" and (not command_exists(program)) then - opt_message = "(Optional, improves performance for many file indexing commands)" - elseif program == "tree-sitter" and (not command_exists(program)) then - opt_message = "(Optional, only needed for :TSInstallFromGrammar, not required for :TSInstall)" - end - - -- Add padding after the question, e.g. Found fd? yes/no - -- ^^ - -- padding - if program:len() ~= 11 then - extra_padding = get_padding(11 - program:len()) - end - table.insert( - sys_info, - string.format( - "%s• Found `%s`? %s%s%s", - padding_level[2], - program, - extra_padding, - -- Add extra whitespace to "no" - is_installed == "yes" and is_installed or is_installed .. " ", - opt_message:len() < 1 and opt_message or " " .. opt_message - ) - ) - end - - return sys_info -end - ---- Set buffer contents ---- @param buffer_id number -local function set_buffer_content(buffer_id) - local content = {} - - -- Doom banner - for _, banner_line in ipairs(align_text(doom_banner, "center")) do - table.insert(content, banner_line) - end - - -- Doom Nvim information - local doom_info = get_doom_info() - local buffer_info = get_buffer_info() - local system_info = get_system_info() - - for _, info_section in ipairs({ doom_info, { "", "" }, buffer_info, { "", "" }, system_info }) do - local aligned_info = align_text(info_section, "left") - vim.list_extend(content, aligned_info) - end - vim.api.nvim_buf_set_lines(buffer_id, 0, info_ns, false, content) -end - -local function set_syntax_highlighting(buffer_id) - for lnum, line in ipairs(vim.api.nvim_buf_get_lines(buffer_id, 0, vim.fn.line("$"), true)) do - if lnum < #doom_banner then - vim.api.nvim_buf_add_highlight(buffer_id, -1, "Comment", lnum, 0, -1) - else - local hl = "NONE" - local endl = -1 - if line:find("Information") then - -- Information headers - hl = "Title" -- "Structure" - elseif line:find("▶") then - -- Information subheaders (level 2) - hl = "VariableBuiltin" - elseif line:find("○") then - -- Information subheaders (level 3) - hl = "FunctionBuiltin" - elseif line:find(": ") or line:find("? ") then - -- Information fields - hl = "Bold" - if #vim.split(line, "?") < 2 then - -- Highlight only the field name, e.g. 'Version' - endl = vim.split(line, ":")[1]:len() - else - -- Highlight only the field name - endl = vim.split(line, "?")[1]:len() - end - end - vim.api.nvim_buf_add_highlight(buffer_id, -1, hl, lnum - 1, 0, endl) - end - end - - -- Extra highlights that we can't manually set with nvim_buf_add_highlight - -- NOTE: these extra newlines are for improving code readability, don't remove! - vim.cmd([[ - " True / False - " NOTE: Use String and ErrorMsg as a fallback if TextXBold does not exists in the current colorscheme - call matchadd(match(execute("hi TextSuccessBold"), "cleared") =~ -1 ? "TextSuccessBold" : "String", "yes") - call matchadd(match(execute("hi TextErrorBold"), "cleared") =~ -1 ? "TextErrorBold" : "ErrorMsg", '\(no\s\)\|\(no$\)\|\(No Active Lsp\)') - - " Commit author email - call matchadd("Bold", '\([-a-zA-Z0-9_]\+@[-a-zA-Z0-9_]\+\.\w\+\)') - - " Commit SHA - call matchadd("Constant", '\(\s[a-f0-9]\{7}$\)') - - " Commits scopes - call matchadd("Msg", '\(hotfix\)\|\(fix\)') - call matchadd("MoreMsg", "feat") - call matchadd("WarningMsg", "refact") - call matchadd("ErrorMsg", '\(refact\!\)\|\(BREAKING CHANGE\)') - call matchadd("SpecialComment", "docs") - call matchadd("Comment", "chore") - call matchadd("Constant", "release") - call matchadd("SpecialComment", '\(([-a-zA-Z0-9_]\+):\)\@>') - - " Release type and branches - call matchadd("Bold", '\(prerelease\)\|\(develop\|main\)\sbranch') - - " Strings - call matchadd("String", '".*"') - - " Numbers - call matchadd("Number", '\s[0-9]\+$') - - " Fields - call matchadd("String", "•") - - " Lists and delimiters - call matchadd("Operator", '\(\s\+-\s\)\|:\s\+\|<\|>\|@\|(\|)') - - " Neovim commands - " NOTE: Use Comment as a fallback if CommentBold does not exists in the current colorscheme - call matchadd(match(execute("hi CommentBold"), "cleared") =~ -1 ? "CommentBold" : "Comment", '\(:[A-Za-z]\+\)') - - " Inline code like markdown - call matchadd(match(execute("hi CommentBold"), "cleared") =~ -1 ? "CommentBold" : "Comment", '\(`[-a-zA-Z0-9_,\.\<\>@\$#+\!]\+`\)') - " Conceal start ` - call matchadd("Conceal", '\(`[-a-zA-Z0-9_,\.\<\>@\$#+\!]\+`\)\@=', 10, -1, {"conceal": ""}) - " Conceal ending ` - call matchadd("Conceal", '\(\(`?\)\|\(`$\)\|\(`\s\)\|\(`,\s\)\)\@=', 10, -1, {"conceal": ""}) - ]]) -end - ---- Open Doom information floating window -info.open = function() - -- Create a new scratch buffer - info_buffer = vim.api.nvim_create_buf(false, true) - vim.api.nvim_buf_set_option(info_buffer, "bufhidden", "wipe") - vim.api.nvim_buf_set_option(info_buffer, "filetype", "DoomInfo") - - -- Get terminal dimensions - local width = vim.api.nvim_get_option("columns") - local height = vim.api.nvim_get_option("lines") - -- Floating window dimensions and start position - local win_height = math.ceil(height * 0.9 - 2) - local win_width = math.ceil(width * 0.9) - local row = math.ceil((height - win_height) / 2 - 1) - local col = math.ceil((width - win_width) / 2) - -- Set our floating window options - local win_opts = { - style = "minimal", -- Disable most UI options - border = "single", -- Single whitespace padding - relative = "editor", -- Relative to global editor grid - width = win_width, -- Width - height = win_height, -- Height - row = row, -- Row position - col = col, -- Column position - } - - -- Create our window with attached buffer - vim.api.nvim_open_win(info_buffer, true, win_opts) - - -- Set the buffer contents - set_buffer_content(info_buffer) - - -- Set the buffer options - vim.api.nvim_buf_set_option(info_buffer, "modifiable", false) - -- Concealing for inline code - vim.opt_local.conceallevel = 2 - vim.opt_local.concealcursor = "nc" - -- Folding - vim.opt_local.foldtext = - [[substitute(substitute(substitute(getline(v:foldstart), '?\s\+', '? ', 'g'), ':\s\+', ': ', 'g'), '\\t', repeat('\ ',&tabstop), 'g') . ' ... ' . '(' . (v:foldend - v:foldstart + 1) . ' fields)']] - vim.opt_local.shiftwidth = 6 - vim.opt_local.foldignore = [[=\\\|]] - vim.opt_local.foldmethod = "indent" - vim.opt_local.fillchars = { - eob = " ", -- suppress ~ at EndOfBuffer - fold = " ", -- supress dots between folds info - } - - -- Set the buffer keybinds - vim.api.nvim_buf_set_keymap( - info_buffer, - "n", - "q", - "bdelete", - { noremap = true, silent = true } - ) - - -- Set the buffer syntax - set_syntax_highlighting(info_buffer) -end - -info.close = function() - vim.api.nvim_buf_delete(info_buffer, {}) -end - -info.toggle = function() - if info_buffer and vim.fn.bufexists(info_buffer) == 1 then - info.close() - else - info.open() - end -end - -return info diff --git a/lua/doom/modules/built-in/runner/README.md b/lua/doom/modules/built-in/runner/README.md deleted file mode 100644 index 59982c5f0..000000000 --- a/lua/doom/modules/built-in/runner/README.md +++ /dev/null @@ -1,34 +0,0 @@ -# Runner - -This plugin aims to take care of your interpreted code by helping you to: - -- Opening a REPL for fast testing. -- Running the current file. - -## Currently supported languages - -- V -- Lua -- Ruby -- Python - -> **NOTE**: Do you want to give support for other languages? Feel free to open -> a pull request! - -## Keybindings - -- REPL - - `SPC - c - i` -- Run the current file - - `SPC - c - r` - -## FAQ - -- Why we are using a toggleterm `exec_command` function for running the file? - -That's because of if we use a custom terminal like in the runner REPL then we -will find an issue: - -The terminal closes when the process ends so that's it, you will not see a -correct output while running the code. That's why we are spawning a terminal -and then executing the commands for running. diff --git a/lua/doom/modules/built-in/runner/init.lua b/lua/doom/modules/built-in/runner/init.lua deleted file mode 100644 index b1cc7ab77..000000000 --- a/lua/doom/modules/built-in/runner/init.lua +++ /dev/null @@ -1,76 +0,0 @@ -local log = require("doom.extras.logging") -local term - -if packer_plugins and packer_plugins["toggleterm.nvim"] then - term = require("toggleterm.terminal").Terminal -else - log.error( - "Doom runner needs toggleterm plugin, please uncomment the 'terminal' entry in your doom_modules.lua" - ) -end - -local M = {} - --- Currently supported languages, --- filetype → binary to execute -local languages = { - vlang = "v", - lua = "lua", - ruby = "ruby", - python = "python3", - javascript = "node", - typescript = "ts-node", -} - --- start_repl starts a REPL for the current filetype, e.g. a Python file --- will open a Python3 REPL -M.start_repl = function() - local filetype = vim.bo.filetype - local repl_cmd = languages[filetype] - - local opened_repl, err = xpcall(function() - if repl_cmd then - local repl = term:new({ cmd = repl_cmd, hidden = true }) - repl:open() - else - log.error( - "There is no REPL for " - .. filetype - .. ". Maybe it is not yet supported in the Doom runner plugin?" - ) - end - end, debug.traceback) - - if not opened_repl then - log.error("Error while trying to opening a repl for " .. filetype .. ". Traceback:\n" .. err) - end -end - --- run_code runs the current file -M.run_code = function() - local filetype = vim.bo.filetype - local lang_bin = languages[filetype] - - local run_code, err = xpcall(function() - if lang_bin then - local runner = term:new({ - cmd = lang_bin .. " " .. vim.fn.expand("%"), - hidden = true, - close_on_exit = false, - }) - runner:open() - else - log.error( - "There is no available executable for " - .. filetype - .. ". Maybe it is not yet supported in the Doom runner plugin?" - ) - end - end, debug.traceback) - - if not run_code then - log.error("Error while trying to run the current file. Traceback:\n" .. err) - end -end - -return M diff --git a/lua/doom/modules/colorizer/init.lua b/lua/doom/modules/colorizer/init.lua new file mode 100644 index 000000000..cf893737b --- /dev/null +++ b/lua/doom/modules/colorizer/init.lua @@ -0,0 +1,14 @@ +local colorizer = {} + +colorizer.defaults = { + "*", + css = { rgb_fn = true }, + html = { names = false }, +} + +colorizer.packer_config = {} +colorizer.packer_config["nvim-colorizer.lua"] = function() + require("colorizer").setup(doom.colorizer) +end + +return colorizer diff --git a/lua/doom/modules/colorizer/packages.lua b/lua/doom/modules/colorizer/packages.lua new file mode 100644 index 000000000..8f2d62628 --- /dev/null +++ b/lua/doom/modules/colorizer/packages.lua @@ -0,0 +1,7 @@ +return { + ["nvim-colorizer.lua"] = { + "norcalli/nvim-colorizer.lua", + commit = "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6", + event = "ColorScheme", + }, +} diff --git a/lua/doom/modules/comment/binds.lua b/lua/doom/modules/comment/binds.lua new file mode 100644 index 000000000..71c0bb8f6 --- /dev/null +++ b/lua/doom/modules/comment/binds.lua @@ -0,0 +1,31 @@ +local binds = { + { + "gc", + [[lua require("Comment.api").call("toggle_linewise_op")g@]], + name = "Comment motion", + }, + { + "gc", + [[lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())]], + name = "Comment line", + mode = "v", + }, + { + "gb", + [[lua require("Comment.api").toggle_blockwise_op(vim.fn.visualmode())]], + name = "Comment block", + mode = "v", + }, + { + "gcc", + [[lua require("Comment.api").call("toggle_current_linewise_op")g@$]], + name = "Comment line", + }, + { + "gcA", + [[lua require("Comment.api").insert_linewise_eol()]], + name = "Comment end of line", + }, +} + +return binds diff --git a/lua/doom/modules/comment/init.lua b/lua/doom/modules/comment/init.lua new file mode 100644 index 000000000..4296d12f5 --- /dev/null +++ b/lua/doom/modules/comment/init.lua @@ -0,0 +1,58 @@ +local comment = {} + +comment.defaults = { + --- Add a space b/w comment and the line + --- @type boolean + padding = true, + + --- Whether the cursor should stay at its position + --- NOTE: This only affects NORMAL mode mappings and doesn't work with dot-repeat + --- @type boolean + sticky = true, + + --- Lines to be ignored while comment/uncomment. + --- Could be a regex string or a function that returns a regex string. + --- Example: Use '^$' to ignore empty lines + --- @type string|fun():string + ignore = nil, + + --- Passes to ts-context-commentstring to get commentstring in JSX + pre_hook = function(ctx) + -- Only calculate commentstring for tsx filetypes + if vim.bo.filetype == "typescriptreact" then + local comment_utils = require("Comment.utils") + + -- Detemine whether to use linewise or blockwise commentstring + local type = ctx.ctype == comment_utils.ctype.line and "__default" or "__multiline" + + -- Determine the location where to calculate commentstring from + local location = nil + if ctx.ctype == comment_utils.ctype.block then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == comment_utils.cmotion.v or ctx.cmotion == comment_utils.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring({ + key = type, + location = location, + }) + end + end, +} + +comment.packer_config = {} +comment.packer_config["Comment.nvim"] = function() + local config = vim.tbl_extend("force", doom.comment, { + -- Disable mappings as we'll handle it in binds.lua + mappings = { + basic = false, + extra = false, + extended = false, + }, + }) + + require("Comment").setup(config) +end + +return comment diff --git a/lua/doom/modules/comment/packages.lua b/lua/doom/modules/comment/packages.lua new file mode 100644 index 000000000..90bceb687 --- /dev/null +++ b/lua/doom/modules/comment/packages.lua @@ -0,0 +1,7 @@ +return { + ["Comment.nvim"] = { + "numToStr/Comment.nvim", + commit = "90df2f87c0b17193d073d1f72cea2e528e5b162d", + module = "Comment", + }, +} diff --git a/lua/doom/modules/config/doom-autopairs.lua b/lua/doom/modules/config/doom-autopairs.lua deleted file mode 100644 index d0c0c3927..000000000 --- a/lua/doom/modules/config/doom-autopairs.lua +++ /dev/null @@ -1,9 +0,0 @@ -return function() - local is_plugin_disabled = require("doom.utils").is_plugin_disabled - require("nvim-autopairs").setup({ - check_ts = is_plugin_disabled("treesitter") and false or true, - enable_afterquote = true, - enable_moveright = true, - enable_check_bracket_line = true, - }) -end diff --git a/lua/doom/modules/config/doom-blankline.lua b/lua/doom/modules/config/doom-blankline.lua deleted file mode 100644 index b23bc58cd..000000000 --- a/lua/doom/modules/config/doom-blankline.lua +++ /dev/null @@ -1,13 +0,0 @@ -return function() - local config = require("doom.core.config").config - - require("indent_blankline").setup({ - enabled = config.doom.show_indent, - char = "│", - -- If treesitter plugin is enabled then use its indentation - use_treesitter = require("doom.utils").check_plugin("nvim-treesitter", "opt"), - show_first_indent_level = false, - filetype_exclude = { "help", "dashboard", "packer", "norg", "DoomInfo" }, - buftype_exclude = { "terminal" }, - }) -end diff --git a/lua/doom/modules/config/doom-bufferline.lua b/lua/doom/modules/config/doom-bufferline.lua deleted file mode 100644 index e27dc031b..000000000 --- a/lua/doom/modules/config/doom-bufferline.lua +++ /dev/null @@ -1,147 +0,0 @@ -return function() - require("bufferline").setup({ - options = { - numbers = function(opts) - return string.format("%s", opts.id) - end, - indicator_icon = "▎", - buffer_close_icon = "", - modified_icon = "●", - close_icon = "", - left_trunc_marker = "", - right_trunc_marker = "", - max_name_length = 20, - max_prefix_length = 15, -- prefix used when a buffer is de-duplicated - tab_size = 25, - diagnostics = "nvim_lsp", - diagnostics_indicator = function(_, _, diagnostics_dict, _) - local s = " " - for e, n in pairs(diagnostics_dict) do - local sym = e == "error" and "  " or (e == "warning" and "  " or "  ") - s = s .. n .. sym - end - return s - end, - -- NOTE: this will be called a lot so don't do any heavy processing here - custom_filter = function(buf_number) - if vim.bo[buf_number].filetype ~= "dashboard" then - return true - end - end, - groups = { - options = { - toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible - }, - items = { - { - name = "Tests", - auto_close = true, - matcher = function(buf) - return buf.filename:match("%_test") or buf.filename:match("%_spec") - end, - }, - { - name = "Docs", - auto_close = true, - matcher = function(buf) - return buf.filename:match("%.md") or buf.filename:match("%.txt") - end, - }, - { - name = "Doom", - auto_close = true, - matcher = function(buf) - if buf.filename:find("doom_") or buf.filename:find("doom-", 1, true) then - return true - end - return false - end, - }, - }, - }, - offsets = { - { - filetype = "NvimTree", - text = "File Explorer", - text_align = "center", - }, - { - filetype = "netrw", - text = "File Explorer", - text_align = "center", - }, - { - filetype = "minimap", - text = "Minimap", - text_align = "center", - }, - { - filetype = "Outline", - text = "Symbols", - text_align = "center", - }, - { - filetype = "packer", - text = "Plugins manager", - text_align = "center", - }, - }, - show_buffer_icons = true, - show_buffer_close_icons = true, - show_close_icon = false, - show_tab_indicators = true, - persist_buffer_sort = true, - separator_style = "thick", - enforce_regular_tabs = true, - always_show_bufferline = false, - sort_by = "directory", - custom_areas = { - right = function() - local nvim_is_05 = require("doom.utils").nvim_is_05 - - local result = {} - local error = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) - local warning = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN }) - local info = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO }) - local hint = vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT }) - - if nvim_is_05 then - error = vim.lsp.diagnostic.get_count(0, [[Error]]) - warning = vim.lsp.diagnostic.get_count(0, [[Warning]]) - info = vim.lsp.diagnostic.get_count(0, [[Information]]) - hint = vim.lsp.diagnostic.get_count(0, [[Hint]]) - end - - if error ~= 0 then - result[1] = { - text = "  " .. error, - guifg = "#ff6c6b", - } - end - - if warning ~= 0 then - result[2] = { - text = "  " .. warning, - guifg = "#ECBE7B", - } - end - - if hint ~= 0 then - result[3] = { - text = "  " .. hint, - guifg = "#98be65", - } - end - - if info ~= 0 then - result[4] = { - text = "  " .. info, - guifg = "#51afef", - } - end - return result - end, - }, - }, - }) -end diff --git a/lua/doom/modules/config/doom-cmp.lua b/lua/doom/modules/config/doom-cmp.lua deleted file mode 100644 index 43302d21f..000000000 --- a/lua/doom/modules/config/doom-cmp.lua +++ /dev/null @@ -1,129 +0,0 @@ -return function() - local cmp = require("cmp") - local luasnip = require("luasnip") - - local kind_icons = { - Text = "  ", - Method = "  ", - Function = "  ", - Constructor = "  ", - Field = " ﴲ ", - Variable = "  ", - Class = "  ", - Interface = " ﰮ ", - Module = "  ", - Property = " ﰠ ", - Unit = "  ", - Value = "  ", - Enum = " 練", - Keyword = "  ", - Snippet = "  ", - Color = "  ", - File = "  ", - Reference = "  ", - Folder = "  ", - EnumMember = "  ", - Constant = " ﲀ ", - Struct = " ﳤ ", - Event = "  ", - Operator = "  ", - TypeParameter = "  ", - } - --- Given an LSP item kind, returns a nerdfont icon - --- @param kind_type string LSP item kind - --- @return string Nerdfont Icon - local function get_kind_icon(kind_type) - return kind_icons[kind_type] - end - - --- Wraps nvim_replace_termcodes - --- @param str string - --- @return string - local function replace_termcodes(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) - end - --- Helper function to check what behaviour to use - --- @return boolean - local function check_backspace() - local col = vim.fn.col(".") - 1 - return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") - end - - cmp.setup({ - completion = { - completeopt = "menu,menuone,preview,noinsert", - }, - documentation = { - border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, - }, - formatting = { - format = function(entry, item) - item.kind = string.format("%s %s", get_kind_icon(item.kind), item.kind) - item.menu = ({ - nvim_lsp = "[LSP]", - luasnip = "[Snp]", - buffer = "[Buf]", - nvim_lua = "[Lua]", - path = "[Path]", - })[entry.source.name] - item.dup = ({ - buffer = 1, - path = 1, - nvim_lsp = 0, - })[entry.source.name] or 0 - return item - end, - }, - mapping = { - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - -- [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - 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") - else - fallback() - end - end, { - "i", - "s", - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - vim.fn.feedkeys(replace_termcodes("luasnip-jump-prev"), "") - else - fallback() - end - end, { - "i", - "s", - }), - }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - sources = { - { name = "nvim_lua" }, - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "path" }, - { name = "buffer" }, - }, - }) -end diff --git a/lua/doom/modules/config/doom-colorizer.lua b/lua/doom/modules/config/doom-colorizer.lua deleted file mode 100644 index 7062bf793..000000000 --- a/lua/doom/modules/config/doom-colorizer.lua +++ /dev/null @@ -1,8 +0,0 @@ --- https://github.com/norcalli/nvim-colorizer.lua#customization -return function() - require("colorizer").setup({ - "*", -- Highlight all files, but customize some others. - css = { rgb_fn = true }, -- Enable parsing rgb(...) functions in css. - html = { names = false }, -- Disable parsing "names" like Blue or Gray - }) -end diff --git a/lua/doom/modules/config/doom-dap-install.lua b/lua/doom/modules/config/doom-dap-install.lua deleted file mode 100644 index bae5aef06..000000000 --- a/lua/doom/modules/config/doom-dap-install.lua +++ /dev/null @@ -1,71 +0,0 @@ -return function() - local log = require("doom.extras.logging") - local utils = require("doom.utils") - -- Init dap-install - local dap_install = require("dap-install") - dap_install.setup({ - installation_path = vim.fn.stdpath("data") .. "/dapinstall/", - }) - - local dap_lang_lookup = { - cpp = { "ccppr_vsc" }, - c = { "ccppr_vsc" }, - rust = { "ccppr_vsc" }, - go = { "go_delve" }, - javascript = { "chrome", "jsnode" }, - typescript = { "chrome", "jsnode" }, - ruby = { "ruby_vsc" }, - } - - -- Iterates through langs and installs clients where possible - local install_dap_clients = function() - local modules = require("doom.core.config.modules").modules - local langs = modules.langs - - local installed_clients = require("dap-install.api.debuggers").get_installed_debuggers() - local available_clients = vim.tbl_keys(require("dap-install.api.debuggers").get_debuggers()) - - local daps_to_install = {} - - -- Iterate over each lang, get the required daps and push it to daps_to_install (to avoid duplicates) - for _, lang in ipairs(langs) do - local lang_str = lang - lang = lang:gsub("%s+%+lsp", ""):gsub("%s+%+debug", "") - - -- DAPInstall.nvim has different names for the DAPs so sometimes we need to lookup the correct DAP to install - if dap_lang_lookup[lang] ~= nil then - lang = dap_lang_lookup[lang] - else - lang = { lang } - end - - -- Iterate over DAPs installing them one by one - for _, dap_name in ipairs(lang) do - -- If the +debug flag exists and the language client is not installed yet - if lang_str:find("%+debug") and (not utils.has_value(installed_clients, dap_name)) then - -- Try to install the client only if there is a client available for - -- the language, oterwise raise a warning - if utils.has_value(available_clients, dap_name) then - -- Avoid installing duplicate daps - if not utils.has_value(daps_to_install, dap_name) then - table.insert(daps_to_install, dap_name) - end - else - log.warn( - "The language " - .. dap_name - .. ' does not have a DAP client, please remove the "+debug" flag' - ) - end - end - end - end - - -- Install the daps one by one - for _, dap_name in ipairs(daps_to_install) do - require("dap-install.core.install").install_debugger(dap_name) - end - end - - install_dap_clients() -end diff --git a/lua/doom/modules/config/doom-dap-ui.lua b/lua/doom/modules/config/doom-dap-ui.lua deleted file mode 100644 index 480228df9..000000000 --- a/lua/doom/modules/config/doom-dap-ui.lua +++ /dev/null @@ -1,48 +0,0 @@ -return function() - local dap, dapui = require("dap"), require("dapui") - dap.listeners.after.event_initialized["dapui_config"] = function() - dapui.open() - end - dap.listeners.before.event_terminated["dapui_config"] = function() - dapui.close() - end - dap.listeners.before.event_exited["dapui_config"] = function() - dapui.close() - end - dapui.setup({ - icons = { - expanded = "▾", - collapsed = "▸", - }, - mappings = { - -- Use a table to apply multiple mappings - expand = { "", "<2-LeftMouse>" }, - open = "o", - remove = "d", - edit = "e", - repl = "r", - }, - sidebar = { - elements = { - -- You can change the order of elements in the sidebar - "scopes", - "breakpoints", - "stacks", - "watches", - }, - size = 40, - position = "left", -- Can be "left" or "right" - }, - tray = { - elements = { - "repl", - }, - size = 10, - position = "bottom", -- Can be "bottom" or "top" - }, - floating = { - max_height = nil, -- These can be integers or a float between 0 and 1. - max_width = nil, -- Floats will be treated as percentage of your screen. - }, - }) -end diff --git a/lua/doom/modules/config/doom-dashboard.lua b/lua/doom/modules/config/doom-dashboard.lua deleted file mode 100644 index 430ea3ff5..000000000 --- a/lua/doom/modules/config/doom-dashboard.lua +++ /dev/null @@ -1,74 +0,0 @@ -return function() - local config = require("doom.core.config").config - - vim.g.dashboard_session_directory = require("doom.core.system").doom_root .. "/sessions" - vim.g.dashboard_default_executive = "telescope" - - vim.g.dashboard_custom_section = { - a = { - description = { " Load Last Session SPC s r" }, - command = "lua require('persistence').load({ last = true })", - }, - b = { - description = { " Recently Opened Files SPC f r" }, - command = "Telescope oldfiles", - }, - c = { - description = { " Jump to Bookmark SPC s m" }, - command = "Telescope marks", - }, - d = { - description = { " Find File SPC f f" }, - command = "Telescope find_files", - }, - e = { - description = { " Find Word SPC s g" }, - command = "Telescope live_grep", - }, - f = { - description = { " Open Private Configuration SPC d c" }, - command = 'lua require("doom.core.functions").edit_config()', - }, - g = { - description = { " Open Documentation SPC d d" }, - command = 'lua require("doom.core.functions").open_docs()', - }, - } - - vim.g.dashboard_custom_footer = { - "Doom Nvim loaded in " .. vim.fn.printf( - "%.3f", - vim.fn.reltimefloat(vim.fn.reltime(vim.g.start_time)) - ) .. " seconds.", - } - - vim.g.dashboard_custom_header = vim.tbl_isempty(config.doom.dashboard_custom_header) - and { - " ", - "================= =============== =============== ======== ========", - "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //", - "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||", - "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||", - "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||", - "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||", - "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||", - "|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||", - "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||", - "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||", - "|| `' || || `' || || `' || || | \\ / | ||", - "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||", - "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||", - "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||", - "|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||", - "||.==' _-' `' | /==.||", - "==' _-' N E O V I M \\/ `==", - "\\ _-' `-_ /", - " `'' ``' ", - } - or config.doom.dashboard_custom_header - -- Header color - vim.cmd("hi! dashboardHeader guifg=" .. config.doom.dashboard_custom_colors.header_color) - vim.cmd("hi! dashboardCenter guifg=" .. config.doom.dashboard_custom_colors.center_color) - vim.cmd("hi! dashboardShortcut guifg=" .. config.doom.dashboard_custom_colors.shortcut_color) - vim.cmd("hi! dashboardFooter guifg=" .. config.doom.dashboard_custom_colors.footer_color) -end diff --git a/lua/doom/modules/config/doom-devicons.lua b/lua/doom/modules/config/doom-devicons.lua deleted file mode 100644 index 3db041cf4..000000000 --- a/lua/doom/modules/config/doom-devicons.lua +++ /dev/null @@ -1,81 +0,0 @@ -return function() - require("nvim-web-devicons").setup({ - override = { - html = { - icon = "", - color = "#E34F26", - name = "HTML", - }, - css = { - icon = "", - color = "#1572B6", - name = "CSS", - }, - js = { - icon = "", - color = "#F7DF1E", - name = "JavaScript", - }, - ts = { - icon = "ﯤ", - color = "#3178C6", - name = "TypeScript", - }, - Dockerfile = { - icon = "", - color = "#2496ED", - name = "Dockerfile", - }, - rb = { - icon = "", - color = "#CC342D", - name = "Ruby", - }, - vue = { - icon = "﵂", - color = "#4FC08D", - name = "Vue", - }, - py = { - icon = "", - color = "#3776AB", - name = "Python", - }, - json = { - icon = "", - color = "#999999", - name = "JSON", - }, - toml = { - icon = "", - color = "#999999", - name = "TOML", - }, - yaml = { - icon = "", - color = "#999999", - name = "YAML", - }, - lock = { - icon = "", - color = "#DE6B74", - name = "lock", - }, - bash = { - icon = "", - color = "#4EAA25", - name = "BASH", - }, - zsh = { - icon = "", - color = "#4EAA25", - name = "Zsh", - }, - doomrc = { - icon = "", - color = "#7F5AB6", - name = "doomrc", - }, - }, - }) -end diff --git a/lua/doom/modules/config/doom-eviline.lua b/lua/doom/modules/config/doom-eviline.lua deleted file mode 100644 index bf9372f5a..000000000 --- a/lua/doom/modules/config/doom-eviline.lua +++ /dev/null @@ -1,311 +0,0 @@ -return function() - local utils = require("doom.utils") - local config = require("doom.core.config").config - local colors = require("galaxyline.themes.colors").get_color - - local gl = require("galaxyline") - local lsp = require("galaxyline.providers.lsp") - local buffer = require("galaxyline.providers.buffer") - local condition = require("galaxyline.condition") - - local gls = gl.section - - gl.short_line_list = { - "NvimTree", - "packer", - "minimap", - "Outline", - "toggleterm", - "netrw", - } - - if not config.doom.dashboard_statline then - table.insert(gl.exclude_filetypes, "dashboard") - end - - -- {{{ Utility functions - local function is_dashboard() - local buftype = buffer.get_buffer_filetype() - return buftype == "DASHBOARD" - end - - local function is_not_dashboard() - local buftype = buffer.get_buffer_filetype() - return buftype ~= "DASHBOARD" - end - -- }}} - - -- Left side - gls.left[1] = { - RainbowLeft = { - provider = function() - return "▊ " - end, - highlight = { colors("blue"), colors("bg") }, - }, - } - gls.left[2] = { - ViMode = { - provider = function() - -- auto change color according the vim mode - -- TODO: find a less dirty way to set ViMode colors - local mode_color = { - n = colors("red"), - i = colors("green"), - v = colors("blue"), - [""] = colors("blue"), - V = colors("blue"), - c = colors("magenta"), - no = colors("red"), - s = colors("orange"), - S = colors("orange"), - [""] = colors("orange"), - ic = colors("yellow"), - R = colors("magenta"), - Rv = colors("magenta"), - cv = colors("red"), - ce = colors("red"), - r = colors("cyan"), - rm = colors("cyan"), - ["r?"] = colors("cyan"), - ["!"] = colors("red"), - t = colors("red"), - } - vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()]()) - return " " - end, - highlight = { colors("red"), colors("bg"), "bold" }, - }, - } - gls.left[3] = { - FileSize = { - provider = "FileSize", - condition = condition.buffer_not_empty and condition.hide_in_width, - highlight = { - colors("fg"), - colors("bg"), - }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.left[4] = { - FileIcon = { - provider = "FileIcon", - condition = condition.buffer_not_empty and is_not_dashboard, - highlight = { - require("galaxyline.providers.fileinfo").get_file_icon_color, - colors("bg"), - }, - }, - } - gls.left[5] = { - FileName = { - provider = config.doom.statusline_show_file_path and "FilePath" or "FileName", - condition = condition.buffer_not_empty and is_not_dashboard, - highlight = { colors("fg"), colors("bg"), "bold" }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.left[6] = { - LineInfo = { - provider = function() - local line = vim.fn.line(".") - local column = vim.fn.col(".") - return string.format("%3d : %2d ", line, column) - end, - condition = is_not_dashboard, - highlight = { colors("fg_alt"), colors("bg") }, - }, - } - gls.left[7] = { - LinePercent = { - provider = "LinePercent", - condition = is_not_dashboard, - highlight = { colors("fg_alt"), colors("bg") }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.left[8] = { - DiagnosticError = { - provider = "DiagnosticError", - condition = is_not_dashboard, - icon = config.doom.lsp_error .. " ", - highlight = { colors("red"), colors("bg") }, - }, - } - gls.left[9] = { - DiagnosticWarn = { - provider = "DiagnosticWarn", - condition = is_not_dashboard, - icon = config.doom.lsp_warn .. " ", - highlight = { colors("orange"), colors("bg") }, - }, - } - gls.left[10] = { - DiagnosticInfo = { - provider = "DiagnosticInfo", - condition = is_not_dashboard, - icon = config.doom.lsp_hint .. " ", - highlight = { colors("blue"), colors("bg") }, - }, - } - - -- Right side - -- alternate separator colors if the current buffer is a dashboard - gls.right[1] = { - FileFormat = { - provider = "FileFormat", - condition = condition.hide_in_width and is_not_dashboard, - highlight = { colors("fg"), colors("bg") }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - - gls.right[2] = { - FileEncode = { - provider = "FileEncode", - condition = condition.hide_in_width and is_not_dashboard, - highlight = { colors("fg"), colors("bg") }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.right[3] = { - ShowLspClientOrFileType = { - provider = function() - -- Check if there's a LSP client running to avoid redundant - -- statusline elements - if lsp.get_lsp_client() ~= "No Active Lsp" then - return string.format(" %s » %s ", vim.bo.filetype, lsp.get_lsp_client()) - else - -- Use the filetype instead - return string.format(" %s ", vim.bo.filetype) - end - end, - condition = function() - local tbl = { ["dashboard"] = true, [""] = true } - if tbl[vim.bo.filetype] then - return false - end - return true - end, - highlight = { colors("blue"), colors("bg") }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.right[4] = { - GitIcon = { - provider = function() - return " " - end, - condition = condition.check_git_workspace, - highlight = { colors("red"), colors("bg") }, - separator = " ", - separator_highlight = { colors("bg"), colors("bg") }, - }, - } - gls.right[5] = { - GitBranch = { - provider = "GitBranch", - condition = condition.check_git_workspace, - highlight = { colors("green"), colors("bg"), "bold" }, - }, - } - gls.right[6] = { - DiffSeparator = { - provider = function() - return " " - end, - condition = condition.hide_in_width, - highlight = { colors("bg"), colors("bg") }, - }, - } - gls.right[7] = { - DiffAdd = { - provider = "DiffAdd", - condition = condition.hide_in_width, - icon = " ", - highlight = { colors("green"), colors("bg") }, - }, - } - gls.right[8] = { - DiffModified = { - provider = "DiffModified", - condition = condition.hide_in_width, - icon = " ", - highlight = { colors("orange"), colors("bg") }, - }, - } - gls.right[9] = { - DiffRemove = { - provider = "DiffRemove", - condition = condition.hide_in_width, - icon = " ", - highlight = { colors("red"), colors("bg") }, - }, - } - - -- If the current buffer is the dashboard then show Doom Nvim version - if is_dashboard then - gls.right[10] = { - DoomVersion = { - provider = function() - return "DOOM v" .. utils.doom_version .. " " - end, - condition = is_dashboard, - highlight = { colors("blue"), colors("bg"), "bold" }, - separator = " ", - separator_highlight = { - colors("bg"), - colors("bg"), - }, - }, - } - end - gls.right[11] = { - RainbowRight = { - provider = function() - return " ▊" - end, - highlight = { colors("blue"), colors("bg") }, - }, - } - - -- Short status line - gls.short_line_left[1] = { - ShortRainbowLeft = { - provider = function() - return "▊ " - end, - highlight = { colors("blue"), colors("bg") }, - }, - } - gls.short_line_left[2] = { - BufferType = { - provider = "FileTypeName", - condition = is_not_dashboard, - highlight = { colors("fg"), colors("bg") }, - }, - } - - gls.short_line_right[1] = { - BufferIcon = { - provider = "BufferIcon", - condition = is_not_dashboard, - highlight = { colors("yellow"), colors("bg") }, - }, - } - gls.short_line_right[2] = { - ShortRainbowRight = { - provider = function() - return " ▊" - end, - highlight = { colors("blue"), colors("bg") }, - }, - } -end diff --git a/lua/doom/modules/config/doom-fire.lua b/lua/doom/modules/config/doom-fire.lua deleted file mode 100644 index 39d273e86..000000000 --- a/lua/doom/modules/config/doom-fire.lua +++ /dev/null @@ -1,32 +0,0 @@ -return function() - -- TODO: this option should make firenvim NOT trigger on enter textarea - -- so that user can trigger nvim with keybinding instead. - -- however, something is not working here so... - -- NOTE: see this issue for help https://github.com/glacambre/firenvim/issues/991 - - -- required global config object - vim.g.firenvim_config = { - globalSettings = { - alt = "all", - }, - localSettings = { - [".*"] = { - cmdline = "neovim", - content = "text", - priority = 0, - selector = "textarea", - takeover = "never", - }, - }, - } - - -- disable nvim from triggering on entering textarea - local fc = vim.g.firenvim_config.localSettings - fc["https?://github.com/"] = { - takeover = "always", - priority = 1, - } - - -- Change the filetype to enable proper syntax highlighting - vim.cmd([[ autocmd BufEnter github.com_*.txt set filetype=markdown ]]) -end diff --git a/lua/doom/modules/config/doom-format.lua b/lua/doom/modules/config/doom-format.lua deleted file mode 100644 index e2a33ebf1..000000000 --- a/lua/doom/modules/config/doom-format.lua +++ /dev/null @@ -1,115 +0,0 @@ -return function() - local fmt = string.format - - require("format").setup({ - ["*"] = { - -- remove trailing whitespaces - { - cmd = { - "sed -i 's/[ \t]*$//'", - }, - }, - }, - vim = { - { - cmd = { - function(file) - return fmt("stylua --config-path ~/.config/stylua/stylua.toml %s", file) - end, - }, - start_pattern = "^lua << EOF$", - end_pattern = "^EOF$", - }, - }, - vimwiki = { - { - cmd = { "prettier -w --parser babel" }, - start_pattern = "^{{{javascript$", - end_pattern = "^}}}$", - }, - }, - lua = { - { - cmd = { - function(file) - return fmt("stylua --config-path ~/.config/stylua/stylua.toml %s", file) - end, - }, - }, - }, - python = { - { - cmd = { - function(file) - return fmt("yapf -i %s", file) - end, - }, - }, - }, - go = { - { - cmd = { - "gofmt -w", - "goimports -w", - }, - tempfile_postfix = ".tmp", - }, - }, - javascript = { - { - cmd = { - "prettier -w", - "./node_modules/.bin/eslint --fix", - }, - }, - }, - typescript = { - { - cmd = { "prettier -w --parser typescript" }, - }, - }, - html = { - { - cmd = { "prettier -w --parser html" }, - }, - }, - markdown = { - { - cmd = { "prettier -w --parser markdown" }, - }, - { - cmd = { - "yapf -i", - }, - start_pattern = "^```python$", - end_pattern = "^```$", - target = "current", - }, - }, - css = { - { - cmd = { "prettier -w --parser css" }, - }, - }, - scss = { - { - cmd = { "prettier -w --parser scss" }, - }, - }, - json = { - { - cmd = { "prettier -w --parser json" }, - }, - }, - toml = { - { - cmd = { "prettier -w --parser toml" }, - }, - }, - yaml = { - { - cmd = { "prettier -w --parser yaml" }, - }, - }, - }) -end diff --git a/lua/doom/modules/config/doom-gitsigns.lua b/lua/doom/modules/config/doom-gitsigns.lua deleted file mode 100644 index ac3f9374f..000000000 --- a/lua/doom/modules/config/doom-gitsigns.lua +++ /dev/null @@ -1,74 +0,0 @@ -return function() - require("gitsigns").setup({ - signs = { - add = { - hl = "GitSignsAdd", - text = "│", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "│", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - }, - numhl = false, - linehl = false, - keymaps = { - -- Default keymap options - noremap = true, - buffer = true, - - ["n ]c"] = { - expr = true, - "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'", - }, - ["n [c"] = { - expr = true, - "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'", - }, - - ["n gS"] = 'lua require"gitsigns".stage_hunk()', - ["n gu"] = 'lua require"gitsigns".undo_stage_hunk()', - ["n gr"] = 'lua require"gitsigns".reset_hunk()', - ["n gR"] = 'lua require"gitsigns".reset_buffer()', - ["n gh"] = 'lua require"gitsigns".preview_hunk()', - ["n gb"] = 'lua require"gitsigns".blame_line()', - - -- Text objects - ["o ih"] = ':lua require"gitsigns".select_hunk()', - ["x ih"] = ':lua require"gitsigns".select_hunk()', - }, - watch_gitdir = { interval = 1000, follow_files = true }, - current_line_blame_opts = { - delay = 1000, - position = "eol", - }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - diff_opts = { - internal = true, -- If luajit is present - }, - }) -end diff --git a/lua/doom/modules/config/doom-lint.lua b/lua/doom/modules/config/doom-lint.lua deleted file mode 100644 index 34de56abb..000000000 --- a/lua/doom/modules/config/doom-lint.lua +++ /dev/null @@ -1,18 +0,0 @@ -return function() - local linters = require("doom.core.config").config.doom.linters - - require("lint").linters_by_ft = { - c = linters.c, - cpp = linters.cpp, - css = linters.css, - html = linters.html, - javascript = linters.javascript, - lua = linters.lua, - markdown = linters.markdown, - nix = linters.nix, - python = linters.python, - ruby = linters.ruby, - sh = linters.sh, - typescript = linters.typescript, - } -end diff --git a/lua/doom/modules/config/doom-lsp-installer.lua b/lua/doom/modules/config/doom-lsp-installer.lua deleted file mode 100644 index 0d05a542b..000000000 --- a/lua/doom/modules/config/doom-lsp-installer.lua +++ /dev/null @@ -1,261 +0,0 @@ -return function() - local log = require("doom.extras.logging") - local utils = require("doom.utils") - local is_plugin_disabled = require("doom.utils").is_plugin_disabled - - -- Commented out defualt servers don't have treesitter configs - local servers = { - lua = { "sumneko_lua" }, - ansible = { "ansiblels" }, - angular = { "angularls" }, - bash = { "bashls" }, - -- bicep = { 'bicep' }, - c_sharp = { "omnisharp" }, - c = { "clangd" }, - cpp = { "clangd" }, - cmake = { "cmake" }, - css = { "cssls" }, - clojure = { "clojure_lsp" }, - -- codeql = { 'codeqlls' }, - -- deno = { 'denols' }, - -- dlang = { 'serve_d' }, - dockerfile = { "dockerls" }, - dot = { "dotls" }, - elixer = { "elixerls" }, - elm = { "elmls" }, - ember = { "ember" }, - fortran = { "fortls" }, - -- ['f#'] = { 'fsautocomplete' }, - go = { "gopls" }, - graphql = { "graphql" }, - groovy = { "groovyls" }, - html = { "html" }, - haskel = { "hls" }, - json = { "jsonls" }, - json5 = { "jsonls" }, - java = { "jdtls" }, - javascript = { "tsserver" }, - kotlin = { "kotlin_language_server" }, - latex = { "texlab" }, - ocaml = { "ocamells" }, - php = { "phpactor" }, - powershell = { "powershell_es" }, - -- prisma = { 'prismals' }, - -- puppet = { 'puppet' }, - -- purescript = { 'purescriptls' }, - python = { "pyright" }, - -- rescript = { 'rescriptls' }, - -- rome = { 'rome' }, - ruby = { "solargraph" }, - rust = { "rust_analyzer" }, - -- solang = { 'solang' }, - -- sorbet = { 'sorbet' }, - svelte = { "svelte" }, - typescript = { "tsserver" }, - -- vala = { 'valals' }, - vim = { "vimls" }, - vue = { "vuels" }, - xml = { "lemminx" }, - yaml = { "yamlls" }, - config = { "jsonls", "yamlls" }, - } - -- Add out-of-the-box support for Scala metals LSP - local should_setup_scala_lsp = false - - -- Snippets support - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.textDocument.completion.completionItem.preselectSupport = true - capabilities.textDocument.completion.completionItem.insertReplaceSupport = true - capabilities.textDocument.completion.completionItem.labelDetailsSupport = true - capabilities.textDocument.completion.completionItem.deprecatedSupport = true - capabilities.textDocument.completion.completionItem.commitCharactersSupport = true - capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } - capabilities.textDocument.completion.completionItem.snippetSupport = true - capabilities.textDocument.completion.completionItem.resolveSupport = { - properties = { "documentation", "detail", "additionalTextEdits" }, - } - capabilities.textDocument.codeAction = { - dynamicRegistration = false, - codeActionLiteralSupport = { - codeActionKind = { - valueSet = { - "", - "quickfix", - "refactor", - "refactor.extract", - "refactor.inline", - "refactor.rewrite", - "source", - "source.organizeImports", - }, - }, - }, - } - - --- Intelligent highlighting of word under cursor - local on_attach - if not is_plugin_disabled("illuminated") and packer_plugins["vim-illuminate"] then - on_attach = function(client) - require("illuminate").on_attach(client) - -- Set underline highlighting for Lsp references - vim.cmd("hi! LspReferenceText cterm=underline gui=underline") - vim.cmd("hi! LspReferenceWrite cterm=underline gui=underline") - vim.cmd("hi! LspReferenceRead cterm=underline gui=underline") - end - end - - local lua_lsp = require("lua-dev").setup({ - lspconfig = { - settings = { - Lua = { - workspace = { - preloadFileSize = 200, - }, - diagnostics = { - globals = { "packer_plugins" }, - }, - }, - }, - capabilities = capabilities, - on_attach = on_attach, - }, - }) - - -- Load langs from doom_modules, install servers with +lsp flag and sets up their config - local function setup_servers() - local lsp_installer = require("nvim-lsp-installer") - - local modules = require("doom.core.config.modules").modules - local langs = modules.langs - - -- Find all LSPs that need to be installed - local ensure_installed = {} - for _, lang in ipairs(langs) do - -- Lang name used for key in servers table - local lang_name = lang - :gsub("%s+%+lsp(%(%a+%))", "") - :gsub("%s+%+lsp", "") - :gsub("%s+%+debug", "") - -- Get LSP override +lsp() if it exists - local lsp_override = lang:match("+lsp%((.+)%)") - -- Array of lsps to ensure are installed - local lang_lsps = lsp_override ~= nil and vim.split(lsp_override, ",") - or servers[lang_name] ~= nil and servers[lang_name] - or nil - - local should_install_lsp = lang:find("+lsp") - - -- Save all lsps to ensure_installed - if should_install_lsp then - if lang_lsps ~= nil then - for _, lsp_name in ipairs(lang_lsps) do - local trimmed_lsp_name = vim.trim(lsp_name) - if utils.has_value(ensure_installed, trimmed_lsp_name) == false then - table.insert(ensure_installed, trimmed_lsp_name) - end - end - else - if lang:find("scala") then - -- Enable setup for Scala Metals LSP - should_setup_scala_lsp = true - else - log.error( - 'The language "' .. lang .. '" does not have an LSP, please remove the "+lsp" flag.' - ) - end - end - end - end - - -- Flatten the array of default servers. - -- Default servers will be automatically uninstalled if no +lsp flag is provided. - local default_servers = {} - for _, lang_servers in pairs(servers) do - for _, lsp_name in ipairs(lang_servers) do - if not utils.has_value(default_servers, lsp_name) then - table.insert(default_servers, lsp_name) - end - end - end - -- Save which servers were installed/uninstalled so this info can be presented to user - local installing_servers = {} - local uninstalling_servers = {} - -- Install all LSPs that should be installed - for _, lsp_name in ipairs(default_servers) do - local ok, server = lsp_installer.get_server(lsp_name) - if ok then - if not utils.has_value(ensure_installed, lsp_name) then - if server:is_installed() then - table.insert(uninstalling_servers, lsp_name) - server:uninstall() - log.info("doom-lsp-installer: Uninstalling server " .. lsp_name .. ".") - end - else - local server_config = server.name == "sumneko_lua" and lua_lsp - or { - capabilities = capabilities, - on_attach = on_attach, - } - -- Setup server once it's ready - server:on_ready(function() - server:setup(server_config) - end) - if not server:is_installed() then - table.insert(installing_servers, lsp_name) - server:install() - log.info("doom-lsp-installer: Installing server " .. lsp_name .. ".") - end - end - end - end - - -- Install and setup non-default LSPs - for _, lsp_name in ipairs(ensure_installed) do - if not utils.has_value(default_servers, lsp_name) then - local ok, server = lsp_installer.get_server(lsp_name) - - if ok then - server:on_ready(function() - server:setup({ - capabilities = capabilities, - on_attach = on_attach, - }) - end) - if not server:is_installed() then - table.insert(installing_servers, lsp_name) - server:install() - log.info("doom-lsp-installer: Installing server " .. lsp_name .. ".") - end - end - end - end - - -- Setup Scala Metals LSP - if should_setup_scala_lsp then - require("lspconfig").metals.setup({ - capabilities = capabilities, - on_attach = on_attach, - }) - end - - -- Print intalling/uninstalling information to user on startup - if next(installing_servers) ~= nil or next(uninstalling_servers) ~= nil then - local msg = "Doom: " - local installing_count = #installing_servers - if installing_count > 0 then - msg = msg .. "Installing " .. installing_count .. " LSPs. " - end - local uninstalling_count = #uninstalling_servers - if uninstalling_count > 0 then - msg = msg .. "Uninstalling " .. installing_count .. " LSPs. " - end - msg = msg .. "Use :LspInstallInfo to check status. " - vim.notify(msg) - end - end - - -- Defer auto install to unblock startup - vim.defer_fn(function() - setup_servers() - end, 50) -end diff --git a/lua/doom/modules/config/doom-lsp-signature.lua b/lua/doom/modules/config/doom-lsp-signature.lua deleted file mode 100644 index 64c17e6ac..000000000 --- a/lua/doom/modules/config/doom-lsp-signature.lua +++ /dev/null @@ -1,31 +0,0 @@ -return function() - -- Signature help - local cfg = { - bind = true, - doc_lines = 10, - floating_window = false, -- show hint in a floating window, set to false for virtual text only mode - floating_window_above_cur_line = true, - fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters - hint_enable = true, -- virtual hint enable - -- hint_prefix = "🐼 ", -- Panda for parameter - hint_prefix = " ", - hint_scheme = "String", - -- use_lspsaga = false, -- set to true if you want to use lspsaga popup - hi_parameter = "Search", -- how your parameter will be highlight - max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down - -- to view the hiding contents - max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width - handler_opts = { - border = "single", -- double, single, shadow, none - }, - -- transpancy = 80, - extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} - zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom - debug = false, -- set to true to enable debug logging - log_path = "debug_log_file_path", -- debug log path - padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc - shadow_blend = 36, -- if you using shadow as border use this set the opacity - shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' - } - require("lsp_signature").setup(cfg) -end diff --git a/lua/doom/modules/config/doom-lspconfig.lua b/lua/doom/modules/config/doom-lspconfig.lua deleted file mode 100644 index 6a32f830a..000000000 --- a/lua/doom/modules/config/doom-lspconfig.lua +++ /dev/null @@ -1,89 +0,0 @@ -return function() - local fn = vim.fn - local lsp = vim.lsp - local config = require("doom.core.config").config - - -- Lsp Symbols - local signs, hl - if vim.fn.has("nvim-0.6.0") == 1 then - signs = { - Error = config.doom.lsp_error, - Warn = config.doom.lsp_warn, - Info = config.doom.lsp_info, - Hint = config.doom.lsp_hint, - } - hl = "DiagnosticSign" - else - signs = { - Error = config.doom.lsp_error, - Warning = config.doom.lsp_warn, - Information = config.doom.lsp_info, - Hint = config.doom.lsp_hint, - } - hl = "LspDiagnosticsSign" - end - - for severity, icon in pairs(signs) do - local highlight = hl .. severity - - fn.sign_define(highlight, { - text = icon, - texthl = highlight, - numhl = highlight, - }) - end - - lsp.handlers["textDocument/publishDiagnostics"] = - lsp.with(lsp.diagnostic.on_publish_diagnostics, { - virtual_text = config.doom.enable_lsp_virtual_text and { - prefix = config.doom.lsp_virtual_text, -- change this to whatever you want your diagnostic icons to be - } or false, - }) - -- Border for lsp_popups - lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { - border = "single", - }) - lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { - border = "single", - }) - -- symbols for autocomplete - lsp.protocol.CompletionItemKind = { - "  (Text) ", - "  (Method)", - "  (Function)", - "  (Constructor)", - " ﴲ (Field)", - "  (Variable)", - "  (Class)", - " ﰮ (Interface)", - "  (Module)", - " ﰠ (Property)", - "  (Unit)", - "  (Value)", - " 練 (Enum)", - "  (Keyword)", - "  (Snippet)", - "  (Color)", - "  (File)", - "  (Reference)", - "  (Folder)", - "  (EnumMember)", - " ﲀ (Constant)", - " ﳤ (Struct)", - "  (Event)", - "  (Operator)", - "  (TypeParameter)", - } - - -- suppress error messages from lang servers - vim.notify = function(msg, log_level, _opts) - if msg:match("exit code") then - return - end - if log_level == vim.log.levels.ERROR then - vim.api.nvim_err_writeln(msg) - else - vim.api.nvim_echo({ { msg } }, true, {}) - end - end -end diff --git a/lua/doom/modules/config/doom-luasnip.lua b/lua/doom/modules/config/doom-luasnip.lua deleted file mode 100644 index 6b4b6a3ae..000000000 --- a/lua/doom/modules/config/doom-luasnip.lua +++ /dev/null @@ -1,27 +0,0 @@ -return function() - local mappings = require("doom.utils.mappings") - local luasnip = require("luasnip") - - luasnip.config.set_config({ - history = true, - -- Update more often, :h events for more info. - updateevents = "TextChanged,TextChangedI", - }) - - require("luasnip/loaders/from_vscode").load() - - --- to jump to next snippet's placeholder - local function on_tab() - return luasnip.jump(1) and "" or mappings.t("") - end - - --- to jump to next snippet's placeholder - local function on_s_tab() - return luasnip.jump(-1) and "" or mappings.t("") - end - - mappings.imap("", on_tab, { expr = true }) - mappings.smap("", on_tab, { expr = true }) - mappings.imap("", on_s_tab, { expr = true }) - mappings.smap("", on_s_tab, { expr = true }) -end diff --git a/lua/doom/modules/config/doom-neorg.lua b/lua/doom/modules/config/doom-neorg.lua deleted file mode 100644 index bea69f79b..000000000 --- a/lua/doom/modules/config/doom-neorg.lua +++ /dev/null @@ -1,55 +0,0 @@ -return function() - local doom_root = require("doom.core.system").doom_root - - -- Default setup for Neorg - require("neorg").setup({ - -- Tell Neorg what modules to load - load = { - ["core.defaults"] = {}, -- Load all the default modules - ["core.keybinds"] = { -- Configure core.keybinds - config = { - default_keybinds = true, -- Generate the default keybinds - neorg_leader = ",o", -- This is the default if unspecified - }, - }, - ["core.norg.concealer"] = {}, -- Allows for use of icons - ["core.norg.dirman"] = { -- Manage your directories with Neorg - config = { - workspaces = { - default_workspace = "~/neorg", - gtd = "~/neorg/gtd", - doom_docs = string.format("%s/doc", doom_root), - }, - }, - }, - ["core.gtd.base"] = { - config = { - workspace = "gtd", - }, - }, - }, - }) - - -- 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 - vim.defer_fn(function() - local log = require("doom.extras.logging") - local utils = require("doom.utils") - -- Matches logic from nvim-treesitter - local compiler = utils.find_executable_in_path({ - vim.fn.getenv("CC"), - "cc", - "gcc", - "clang", - "cl", - "zig", - }) - local version = vim.fn.systemlist(compiler .. (compiler == "cl" and "" or " --version"))[1] - - if version:match("clang") then - log.warn( - "doom-neorg: clang has poor compatibility compiling treesitter parsers. We recommend using gcc instead, see issue #246 for details. (https://github.com/NTBBloodbath/doom-nvim/issues/246)" - ) - end - end, 1000) -end diff --git a/lua/doom/modules/config/doom-persistence.lua b/lua/doom/modules/config/doom-persistence.lua deleted file mode 100644 index 682514aa3..000000000 --- a/lua/doom/modules/config/doom-persistence.lua +++ /dev/null @@ -1,5 +0,0 @@ -return function() - require("persistence").setup({ - dir = vim.fn.stdpath("data") .. "/sessions/", - }) -end diff --git a/lua/doom/modules/config/doom-symbols.lua b/lua/doom/modules/config/doom-symbols.lua deleted file mode 100644 index f58992c5c..000000000 --- a/lua/doom/modules/config/doom-symbols.lua +++ /dev/null @@ -1,18 +0,0 @@ -return function() - local config = require("doom.core.config").config - - vim.g.symbols_outline = { - highlight_hovered_item = true, - show_guides = true, - position = config.doom.explorer_right and "left" or "right", - keymaps = { - close = "", - goto_location = "", - focus_location = "o", - hover_symbol = "", - rename_symbol = "r", - code_actions = "a", - }, - lsp_blacklist = {}, - } -end diff --git a/lua/doom/modules/config/doom-telescope.lua b/lua/doom/modules/config/doom-telescope.lua deleted file mode 100644 index 06e0b1e9e..000000000 --- a/lua/doom/modules/config/doom-telescope.lua +++ /dev/null @@ -1,77 +0,0 @@ --- https://github.com/nvim-telescope/telescope.nvim#telescope-defaults -return function() - local telescope = require("telescope") - -- Required to close with ESC in insert mode - local actions = require("telescope.actions") - - telescope.setup({ - defaults = { - find_command = { - "rg", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - initial_mode = "insert", - selection_strategy = "reset", - sorting_strategy = "descending", - layout_strategy = "horizontal", - prompt_prefix = "  ", - selection_caret = " ", - layout_config = { - width = 0.75, - preview_cutoff = 120, - prompt_position = "bottom", - vertical = { mirror = false }, - horizontal = { - mirror = false, - preview_width = 0.6, - }, - }, - file_sorter = require("telescope.sorters").get_fuzzy_file, - file_ignore_patterns = { "^%.git/", "^node_modules/", "^__pycache__/" }, - generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, - winblend = 0, - scroll_strategy = "cycle", - border = {}, - borderchars = { - "─", - "│", - "─", - "│", - "╭", - "╮", - "╯", - "╰", - }, - color_devicons = true, - use_less = true, - set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, - file_previewer = require("telescope.previewers").vim_buffer_cat.new, - grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, - qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, - - -- Developer configurations: Not meant for general override - buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, - mappings = { - i = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.smart_send_to_qflist + actions.open_qflist, - ["f"] = actions.close, -- works like a toggle, sometimes can be buggy - [""] = actions.select_default + actions.center, - }, - n = { - [""] = actions.move_selection_next, - [""] = actions.move_selection_previous, - [""] = actions.smart_send_to_qflist + actions.open_qflist, - }, - }, - }, - }) - - -- Load mapper extension - telescope.load_extension("mapper") -end diff --git a/lua/doom/modules/config/doom-todo.lua b/lua/doom/modules/config/doom-todo.lua deleted file mode 100644 index 738e344c9..000000000 --- a/lua/doom/modules/config/doom-todo.lua +++ /dev/null @@ -1,7 +0,0 @@ -return function() - require("todo-comments").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) -end diff --git a/lua/doom/modules/config/doom-toggleterm.lua b/lua/doom/modules/config/doom-toggleterm.lua deleted file mode 100644 index 89f9037ae..000000000 --- a/lua/doom/modules/config/doom-toggleterm.lua +++ /dev/null @@ -1,25 +0,0 @@ -return function() - local config = require("doom.core.config").config - - require("toggleterm").setup({ - size = config.doom.terminal_height, - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - start_in_insert = true, - persist_size = true, - direction = config.doom.terminal_direction, - close_on_exit = true, - float_opts = { - border = "curved", - width = config.doom.terminal_width, - height = config.doom.terminal_height, - winblend = 0, - highlights = { - border = "Special", - background = "Normal", - }, - }, - }) -end diff --git a/lua/doom/modules/config/doom-tree.lua b/lua/doom/modules/config/doom-tree.lua deleted file mode 100644 index 62ccf804d..000000000 --- a/lua/doom/modules/config/doom-tree.lua +++ /dev/null @@ -1,179 +0,0 @@ -return function() - local config = require("doom.core.config").config - local tree_cb = require("nvim-tree.config").nvim_tree_callback - - ----- GLOBAL VARIABLES ------------------------ - ----------------------------------------------- - -- Empty by default - vim.g.nvim_tree_ignore = { ".git", "node_modules", ".cache", "__pycache__" } - - -- False by default, this option shows indent markers when folders are open - vim.g.nvim_tree_indent_markers = 1 - - -- Show hidden files - vim.g.nvim_tree_hide_dotfiles = config.doom.show_hidden - - -- False by default, will enable file highlight for git attributes (can be used without the icons). - vim.g.nvim_tree_git_hl = 1 - - -- False by default - vim.g.nvim_tree_gitignore = 1 - - -- This is the default. See :help filename-modifiers for more options - vim.g.nvim_tree_root_folder_modifier = ":~" - - -- False by default, append a trailing slash to folder names - vim.g.nvim_tree_add_trailing = 1 - - -- False by default, compact folders that only contain a single folder into one node in the file tree - vim.g.nvim_tree_group_empty = 1 - - -- 1000 by default, control how often the tree can be refreshed, - -- 1000 means the tree can be refresh once per 1000ms. - vim.g.nvim_tree_refresh_wait = 500 - - -- Ignored filetypes and buffers when window picker is enabled - vim.g.nvim_tree_window_picker_exclude = { - filetype = { - "notify", - "packer", - "qf", - }, - buftype = { - "terminal", - }, - } - - -- List of filenames that gets highlighted with NvimTreeSpecialFile - vim.g.nvim_tree_special_files = { ["README.md"] = 1, Makefile = 1, MAKEFILE = 1 } - - -- If false, do not show the icons for one of 'git' 'folder' and 'files' - -- true by default, notice that if 'files' is 1, it will only display - -- if nvim-web-devicons is installed and on your runtimepath - vim.g.nvim_tree_show_icons = { git = 1, folders = 1, files = 1, folder_arrows = 0 } - - --- Tree icons - -- default will show icon by default if no icon is provided - -- default shows no icon by default - vim.g.nvim_tree_icons = { - default = "", - symlink = "", - git = { - unstaged = "", - staged = "", - unmerged = "", - renamed = "", - untracked = "", - deleted = "", - ignored = "◌", - }, - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - lsp = { - hint = config.doom.lsp_hint, - info = config.doom.lsp_info, - warning = config.doom.lsp_warn, - error = config.doom.lsp_error, - }, - } - - ----- SETUP CONFIGURATION --------------------- - ----------------------------------------------- - require("nvim-tree").setup({ - -- Completely disable netrw - disable_netrw = false, - -- Hijack netrw window on startup - hijack_netrw = true, - -- open the tree when running this setup function - open_on_setup = false, - -- will not open on setup if the filetype is in this list - ignore_ft_on_setup = {}, - -- closes neovim automatically when the tree is the last **WINDOW** in the view - auto_close = false, - -- opens the tree when changing/opening a new tab if the tree wasn't previously opened - open_on_tab = true, - -- hijack the cursor in the tree to put it at the start of the filename - hijack_cursor = true, - -- updates the root directory of the tree on `DirChanged` (when your run `:cd` usually) - update_cwd = true, - -- show lsp diagnostics in the signcolumn - diagnostics = { - enable = require("doom.utils").is_plugin_disabled("lsp") and false or true, - icons = { - hint = config.doom.lsp_hint, - info = config.doom.lsp_info, - warning = config.doom.lsp_warn, - error = config.doom.lsp_error, - }, - }, - -- update the focused file on `BufEnter`, un-collapses the folders recursively until it finds the file - update_focused_file = { - -- enables the feature - enable = true, - -- update the root directory of the tree to the one of the folder containing the file if the file is not under the current root directory - -- only relevant when `update_focused_file.enable` is true - update_cwd = true, - -- list of buffer names / filetypes that will not update the cwd if the file isn't found under the current root directory - -- only relevant when `update_focused_file.update_cwd` is true and `update_focused_file.enable` is true - ignore_list = {}, - }, - -- configuration options for the system open command (`s` in the tree by default) - system_open = { - -- the command to run this, leaving nil should work in most cases - cmd = nil, - -- the command arguments as a list - args = {}, - }, - - view = { - -- width of the window, can be either a number (columns) or a string in `%` - width = config.doom.sidebar_width, - -- side of the tree, can be one of 'left' | 'right' | 'top' | 'bottom' - side = config.doom.explorer_right and "right" or "left", - -- if true the tree will resize itself after opening a file - auto_resize = true, - mappings = { - -- custom only false will merge the list with the default mappings - -- if true, it will only use your list to set the mappings - custom_only = false, - -- list of mappings to set on the tree manually - list = { - { key = { "o", "<2-LeftMouse>" }, cb = tree_cb("edit") }, - { key = { "", "<2-RightMouse>", "" }, cb = tree_cb("cd") }, - { key = "", cb = tree_cb("vsplit") }, - { key = "", cb = tree_cb("split") }, - { key = "", cb = tree_cb("tabnew") }, - { key = "", cb = tree_cb("close_node") }, - { key = "", cb = tree_cb("close_node") }, - { key = "", cb = tree_cb("preview") }, - { key = "I", cb = tree_cb("toggle_ignored") }, - { key = "H", cb = tree_cb("toggle_dotfiles") }, - { key = "R", cb = tree_cb("refresh") }, - { key = "a", cb = tree_cb("create") }, - { key = "d", cb = tree_cb("remove") }, - { key = "r", cb = tree_cb("rename") }, - { key = "", cb = tree_cb("full_rename") }, - { key = "x", cb = tree_cb("cut") }, - { key = "c", cb = tree_cb("copy") }, - { key = "p", cb = tree_cb("paste") }, - { key = "[c", cb = tree_cb("prev_git_item") }, - { key = "]c", cb = tree_cb("next_git_item") }, - { key = "-", cb = tree_cb("dir_up") }, - { key = "q", cb = tree_cb("close") }, - { key = "g?", cb = tree_cb("toggle_help") }, - }, - }, - }, - }) - - -- Make sure nvim-tree loads itself when lazy loaded - vim.defer_fn(require("nvim-tree").refresh, 25) -end diff --git a/lua/doom/modules/config/doom-treesitter.lua b/lua/doom/modules/config/doom-treesitter.lua deleted file mode 100644 index 99ff91390..000000000 --- a/lua/doom/modules/config/doom-treesitter.lua +++ /dev/null @@ -1,95 +0,0 @@ -return function() - local has_value = require("doom.utils").has_value - local modules = require("doom.core.config.modules").modules - local is_plugin_disabled = require("doom.utils").is_plugin_disabled - - --- Returns treesitter parsers from doom_modules.langs - --- @param languages table - --- @return table - local function get_ts_parsers(languages) - local langs = {} - - for _, lang in ipairs(languages) do - -- If the lang is config then add parsers for JSON, YAML and TOML - if lang == "config" then - table.insert(langs, "json") - table.insert(langs, "yaml") - table.insert(langs, "toml") - else - lang = lang:gsub("%s+%+lsp(%(%a+%))", ""):gsub("%s+%+lsp", ""):gsub("%s+%+debug", "") - table.insert(langs, lang) - end - end - - -- Add TSX parser if TypeScript is enabled - if has_value(langs, "typescript") then - table.insert(langs, "tsx") - end - return langs - end - - -- Set up treesitter for Neorg - local parser_configs = require("nvim-treesitter.parsers").get_parser_configs() - parser_configs.norg = { - install_info = { - url = "https://github.com/nvim-neorg/tree-sitter-norg", - files = { "src/parser.c", "src/scanner.cc" }, - branch = "main", - }, - } - if packer_plugins and packer_plugins["neorg"] then - table.insert(modules.langs, "norg") - end - - if packer_plugins and packer_plugins["rest.nvim"] then - table.insert(modules.langs, "http") - end - - require("nvim-treesitter.configs").setup({ - ensure_installed = get_ts_parsers(modules.langs), - highlight = { enable = true }, - autopairs = { - enable = is_plugin_disabled("autopairs") and false or true, - }, - indent = { enable = true }, - playground = { enable = true }, - tree_docs = { enable = true }, - context_commentstring = { enable = true }, - autotag = { - enable = true, - filetypes = { - "html", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "svelte", - "vue", - "markdown", - }, - }, - }) - - -- 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 - vim.defer_fn(function() - local log = require("doom.extras.logging") - local utils = require("doom.utils") - -- Matches logic from nvim-treesitter - local compiler = utils.find_executable_in_path({ - vim.fn.getenv("CC"), - "cc", - "gcc", - "clang", - "cl", - "zig", - }) - local version = vim.fn.systemlist(compiler .. (compiler == "cl" and "" or " --version"))[1] - - if version:match("clang") then - log.warn( - "doom-treesitter: clang has poor compatibility compiling treesitter parsers. We recommend using gcc, see issue #246 for details. (https://github.com/NTBBloodbath/doom-nvim/issues/246)" - ) - end - end, 1000) -end diff --git a/lua/doom/modules/config/doom-trouble.lua b/lua/doom/modules/config/doom-trouble.lua deleted file mode 100644 index 829285b0b..000000000 --- a/lua/doom/modules/config/doom-trouble.lua +++ /dev/null @@ -1,7 +0,0 @@ -return function() - require("trouble").setup({ - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - }) -end diff --git a/lua/doom/modules/config/doom-whichkey.lua b/lua/doom/modules/config/doom-whichkey.lua deleted file mode 100644 index e6f633158..000000000 --- a/lua/doom/modules/config/doom-whichkey.lua +++ /dev/null @@ -1,231 +0,0 @@ -return function() - local wk = require("which-key") - local presets = require("which-key.plugins.presets") - - -- Disable presets that doom nvim doesn't use - presets.operators["gc"] = nil - - wk.setup({ - plugins = { - marks = false, - registers = false, - presets = { - operators = false, - motions = true, - text_objects = true, - windows = true, - nav = true, - z = true, - g = true, - }, - }, - operators = { - d = "Delete", - c = "Change", - y = "Yank (copy)", - ["g~"] = "Toggle case", - ["gu"] = "Lowercase", - ["gU"] = "Uppercase", - [">"] = "Indent right", - [""] = "Indent left", - ["zf"] = "Create fold", - ["!"] = "Filter though external program", - }, - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "➜", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - key_labels = { - [""] = "SPC", - [""] = "RET", - [""] = "TAB", - }, - window = { - padding = { 0, 0, 0, 0 }, -- extra window padding [top, right, bottom, left] - border = "single", - }, - layout = { - height = { min = 1, max = 10 }, -- min and max height of the columns - spacing = 3, - align = "left", - }, - ignore_missing = true, - hidden = { - "", - "", - "", - "", - "call", - "lua", - "^:", - "^ ", - }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - triggers = "auto", -- automatically setup triggers - }) - - ----- Whichkey binds ------------------------ - --------------------------------------------- - local mappings = { - ["`"] = { "Find file" }, - ["."] = { "Browse files" }, - [","] = { "Switch buffer" }, - ["/"] = { "Search a word" }, - [":"] = { "Command history" }, - ["h"] = { "Manpage" }, - ["m"] = { "Save" }, - ["v"] = { "Save" }, - ["b"] = { - name = "+buffers", - ["c"] = { "Close current buffer" }, - ["f"] = { "Format buffer" }, - ["b"] = { "Switch to other buffer" }, - ["]"] = { "Next buffer" }, - ["n"] = { "Next buffer" }, - ["g"] = { "Goto buffer" }, - ["["] = { "Previous buffer" }, - ["p"] = { "Previous buffer" }, - }, - ["c"] = { - name = "+code", - ["i"] = { "Start a REPL" }, - ["r"] = { "Run current file" }, - ["b"] = { "Compile project" }, - ["c"] = { "Compile and run project" }, - ["h"] = { - "Run restclient on the line that the cursor is currently on", - }, - ["d"] = { - name = "+debug", - ["b"] = { "Toggle breakpoint on current line" }, - ["c"] = { "Start (or continue) a debug session" }, - ["t"] = { "Terminate debug session" }, - ["e"] = { "Evaluate word under cursor" }, - ["s"] = { "Evaluate selection" }, - }, - ["l"] = { - name = "+lsp", - ["a"] = { "Code actions" }, - ["i"] = { "Lsp info" }, - ["d"] = { "Show type definition" }, - ["l"] = { "Show line diagnostics" }, - ["q"] = { "Diagnostics into location list" }, - ["r"] = { "Rename symbol under cursor" }, - }, - }, - ["d"] = { - name = "+doom", - ["b"] = { "Show Doom keybindings" }, - ["c"] = { "Edit your Doom Nvim configuration" }, - ["d"] = { "Open Doom Nvim documentation" }, - ["i"] = { "Open Doom Nvim information dashboard" }, - ["u"] = { "Update Doom Nvim" }, - ["r"] = { "Rollback Doom Nvim version" }, - ["R"] = { "Create crash report" }, - ["s"] = { "Change colorscheme" }, - ["l"] = { "Reload user custom settings" }, - }, - ["f"] = { - name = "+file", - ["c"] = { "Edit Neovim configuration" }, - ["n"] = { "Create a new unnamed buffer" }, - ["f"] = { "Find files" }, - ["t"] = { "Help tags" }, - ["r"] = { "Recently opened files" }, - ["w"] = { "Write file with sudo permissions" }, - ["R"] = { "Re-open file with sudo permissions" }, - }, - ["g"] = { - name = "+git", - ["o"] = { "Open LazyGit" }, - ["l"] = { "Pull" }, - ["p"] = { "Push" }, - ["S"] = { "Stage hunk" }, - ["s"] = { "Status" }, - ["u"] = { "Undo stage hunk" }, - ["R"] = { "Reset buffer" }, - ["r"] = { "Reset hunk" }, - ["h"] = { "Preview hunk" }, - ["b"] = { "Blame line" }, - ["B"] = { "Branches" }, - ["c"] = { "Commits" }, - }, - ["p"] = { - name = "+plugins", - ["c"] = { "Clean disabled or unused plugins" }, - ["C"] = { "Compile your plugins changes" }, - ["i"] = { "Install missing plugins" }, - ["p"] = { "Profile the time taken loading your plugins" }, - ["s"] = { "Sync your plugins" }, - ["S"] = { "Plugins status" }, - }, - ["q"] = { - name = "+quit/sessions", - ["q"] = { "Quit" }, - ["w"] = { "Save and quit" }, - ["r"] = { "Restore previously saved session" }, - }, - ["s"] = { - name = "+search", - ["g"] = { "Grep" }, - ["b"] = { "Buffer" }, - ["s"] = { "Goto symbol" }, - ["h"] = { "Command history" }, - ["m"] = { "Jump to mark" }, - }, - ["t"] = { - name = "+tweak", - ["b"] = { "background" }, - ["c"] = { "completion" }, - ["g"] = { "signcolumn" }, -- "g" for gitsigs (also for ale) - ["i"] = { "indent" }, - ["n"] = { "number" }, - -- ["p"] = { "autopairs" }, -- moved below as conditional - ["s"] = { "spell" }, - ["x"] = { "syntax/treesetter" }, - }, - ["w"] = { - name = "+windows", - ["w"] = { "Other window" }, - ["d"] = { "Delete window" }, - ["-"] = { "Split window below" }, - ["|"] = { "Split window right" }, - ["2"] = { "Layout double columns" }, - ["h"] = { "Window left" }, - ["j"] = { "Window below" }, - ["l"] = { "Window right" }, - ["k"] = { "Window up" }, - ["H"] = { "Expand window left" }, - ["J"] = { "Expand window below" }, - ["L"] = { "Expand window right" }, - ["K"] = { "Expand window up" }, - ["="] = { "Balance window" }, - ["s"] = { "Split window below" }, - ["v"] = { "Split window right" }, - }, - ["o"] = { - name = "+open", - ["b"] = { "Debugging UI " }, - ["d"] = { "Start screen" }, - ["e"] = { "Tree Explorer" }, - ["r"] = { "Ranger File Browser" }, - ["m"] = { "Minimap" }, - ["s"] = { "Symbols" }, - ["t"] = { "Terminal" }, - }, - ["j"] = { - name = "+jumps", - ["a"] = { "Alternate file" }, - ["j"] = { "jump back" }, - ["k"] = { "jump forward" }, - ["p"] = { "pop tag stack" }, - ["t"] = { "jump to tag" }, - }, - } - local is_plugin_disabled = require("doom.utils").is_plugin_disabled - if not is_plugin_disabled("autopairs") then - mappings["t"]["p"] = { "autopairs" } - end - wk.register(mappings, { prefix = "" }) -end diff --git a/lua/doom/modules/config/doom-zen.lua b/lua/doom/modules/config/doom-zen.lua deleted file mode 100644 index ce3385108..000000000 --- a/lua/doom/modules/config/doom-zen.lua +++ /dev/null @@ -1,49 +0,0 @@ -return function() - require("true-zen").setup({ - ui = { - bottom = { - laststatus = 0, - ruler = false, - showmode = false, - showcmd = false, - cmdheight = 1, - }, - top = { - showtabline = 0, - }, - left = { - number = false, - relativenumber = false, - signcolumn = "no", - }, - }, - modes = { - ataraxis = { - left_padding = 30, - right_padding = 30, - top_padding = 0, - bottom_padding = 0, - ideal_writing_area_width = { 0 }, - just_do_it_for_me = true, - keep_default_fold_fillchars = true, - custome_bg = "", - bg_configuration = true, - }, - focus = { - margin_of_error = 5, - focus_method = "experimental", - }, - }, - integrations = { - galaxyline = true, - tmux = true, - gitsigns = true, - nvim_bufferline = true, - }, - misc = { - on_off_commands = false, - ui_elements_commands = false, - cursor_by_mode = false, - }, - }) -end diff --git a/lua/doom/modules/core/autocmds.lua b/lua/doom/modules/core/autocmds.lua new file mode 100644 index 000000000..baf88aae5 --- /dev/null +++ b/lua/doom/modules/core/autocmds.lua @@ -0,0 +1,52 @@ +local is_plugin_disabled = require("doom.utils").is_plugin_disabled + +local autocmds = { + { "BufWritePost", "*/doom/**/*.lua", function() require("doom.utils.reloader").full_reload() end }, + { + "BufWritePost", + "*/doom-nvim/modules.lua,*/doom-nvim/config.lua", + function() require("doom.utils.reloader").full_reload() end, + }, +} + +if doom.autosave then + table.insert(autocmds, { "TextChanged,InsertLeave", "", "silent! write" }) +end + +if doom.highlight_yank then + table.insert(autocmds, { + "TextYankPost", + "*", + function() + require("vim.highlight").on_yank({ higroup = "Search", timeout = 200 }) + end, + }) +end + +if doom.preserve_edit_pos then + table.insert(autocmds, { + "BufReadPost", + "*", + [[if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]], + }) +end + +if is_plugin_disabled("explorer") then + table.insert(autocmds, { + "FileType", + "netrw", + require("doom.core.netrw").set_maps, + }) + table.insert(autocmds, { + "FileType", + "netrw", + require("doom.core.netrw").draw_icons, + }) + table.insert(autocmds, { + "TextChanged", + "*", + require("doom.core.netrw").draw_icons, + }) +end + +return autocmds diff --git a/lua/doom/modules/core/binds.lua b/lua/doom/modules/core/binds.lua new file mode 100644 index 000000000..21b5c5556 --- /dev/null +++ b/lua/doom/modules/core/binds.lua @@ -0,0 +1,273 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { + { "ZZ", require("doom.core.functions").quit_doom, name = "Fast exit" }, + { "", ":noh", name = "Remove search highlight" }, + { "", ":bnext", name = "Jump to next buffer" }, + { "", ":bprevious", name = "Jump to prev buffer" }, + { + "", "h", name = "Jump window left" }, + { "j>", "j", name = "Jump window down" }, + { "k>", "k", name = "Jump window up" }, + { "l>", "l", name = "Jump window right" }, + { + mode = "nv", + { + { "Left>", ":vertical resize -2", name = "Resize window left" }, + { "Down>", ":resize -2", name = "Resize window down" }, + { "Up>", ":resize +2", name = "Resize window up" }, + { "Right>", ":vertical resize +2", name = "Resize window right" }, + }, + }, + }, + }, + { + "", ":m .+1==", name = "Move line down" }, + { "k>", ":m .-2==", name = "Move line up" }, + }, + }, + { + mode = "v", + { + { + "", ":m '<+1gv=gv", name = "Move line down", mode = "v" }, + { "k>", ":m '<-2gv=gv", name = "Move line up", mode = "v" }, + }, + }, + { ">", ">gv", mode = "v" }, -- Stay in visual after indent. + { "<", "", ":m '<+1==gi", name = "Move line down", mode = "i" }, + { "k>", ":m '<-2==gi", name = "Move line up", mode = "i" }, + }, + }, + }, + }, + { mode = "t", { + { "", "", name = "Exit insert in terminal" }, + } }, +} + +-- Conditionally disable macros +if doom.disable_macros then + table.insert(binds, { "q", "" }) +end +-- Conditionally disable ex mode +if doom.disable_ex then + table.insert(binds, { "Q", "" }) +end +-- Conditionally disable suspension +if doom.disable_suspension then + table.insert(binds, { "", "" }) +end + +-- Exit insert mode fast +for _, esc_seq in pairs(doom.escape_sequences) do + table.insert(binds, { esc_seq, "", mode = "i" }) +end + +if is_plugin_disabled("explorer") then + table.insert(binds, { "", ":Lexplore%s", name = "Toggle explorer" }) + if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "e", ":Lexplore%s", name = "Explorer" }, + }, + }, + }, + }) + end +end + +if not is_plugin_disabled("whichkey") then + local split_modes = { + vertical = "vert ", + horizontal = "", + [false] = "e", + } + local split_prefix = split_modes[doom.new_file_split] + table.insert(binds, { + "", + name = "+prefix", + { + { "m", "w", name = "Write" }, + { + "b", + name = "+buffer", + { + { "b", "e #", name = "Jump to recent" }, + { "d", "bd", name = "Delete" }, + }, + }, + { + "D", + name = "+doom", + { + { + "c", + ("e %s"):format(require("doom.core.config").source), + name = "Edit config", + }, + { + "m", + ("e %s"):format(require("doom.core.config.modules").source), + name = "Edit modules", + }, + { "l", "DoomConfigsReload", name = "Reload config" }, + { "r", "DoomRollback", name = "Rollback" }, + { "R", "DoomReport", name = "Report issue" }, + { "u", "DoomUpdate", name = "Update" }, + { "s", "PackerSync", name = "Sync packages" }, + { "I", "PackerInstall", name = "Install packages" }, + { "C", "PackerClean", name = "Clean packages" }, + { "b", "PackerCompile", name = "Build packages" }, + { "S", "PackerStatus", name = "Inform packages" }, + { "p", "PackerProfile", name = "Profile" }, + }, + }, + { + "f", + name = "+file", + { + { "n", (":%snew"):format(split_prefix), name = "Create new" }, + { "w", "w", name = "Write" }, + { + "W", + function() + vim.fn.inputsave() + local new_name = vim.fn.input("New name: ") + vim.fn.inputrestore() + vim.cmd("w " .. new_name) + end, + name = "Write as", + }, + { "s", "w", name = "Save" }, + { + "S", + function() + vim.fn.inputsave() + local new_name = vim.fn.input("New name: ") + vim.fn.inputrestore() + vim.cmd("w " .. new_name) + end, + name = "Save as", + }, + }, + }, + { + "g", + name = "+git", + { + { "p", [[TermExec cmd="git pull"]], name = "Pull" }, + { "P", [[TermExec cmd="git push"]], name = "Push" }, + { + "C", + name = "+commit", + { + { "c", [[TermExec cmd="git commit"]], name = "commit" }, + { "a", [[TermExec cmd="git commit --ammend"]], name = "ammend" }, + }, + }, + }, + }, + { + "h", + name = "+help", + { + { "h", "Man", name = "Manual pages", options = { silent = false } }, + { "D", "DoomManual", name = "Open Doom" }, + }, + }, + { + "j", + name = "+jump", + { + { "a", "", name = "Alternate file" }, + { "j", "", name = "Older file" }, + { "k", "", name = "Newer file" }, + { "p", "tag", name = "Push tag" }, + { "P", "pop", name = "Pop tag" }, + }, + }, + { + "q", + name = "+quit", + { + { "q", require("doom.core.functions").quit_doom, name = "Exit and save" }, + { "w", require("doom.core.functions").quit_doom, name = "Exit and save" }, + { + "d", + function() + require("doom.core.functions").quit_doom(true, true) + end, + name = "Exit and discard", + }, + }, + }, + { + "t", + name = "+tweak", + { + { "b", require("doom.core.functions").toggle_background, name = "Toggle background" }, + { "s", require("doom.core.functions").toggle_signcolumn, name = "Toggle sigcolumn" }, + { "i", require("doom.core.functions").set_indent, name = "Set indent" }, + { "n", require("doom.core.functions").change_number, name = "Toggle number" }, + { "S", require("doom.core.functions").toggle_spell, name = "Toggle spelling" }, + { "x", require("doom.core.functions").change_syntax, name = "Toggle syntax" }, + }, + }, + { + "w", + name = "+window", + { + { "w", "p", name = "Jump to recent" }, + { "d", "c", name = "Delete window" }, + { "-", "s", name = "Split up/down" }, + { "|", "v", name = "Split left/right" }, + { "s", "s", name = "Split up/down" }, + { "v", "v", name = "Split left/right" }, + { "h", "h", name = "Jump left" }, + { "j", "j", name = "Jump down" }, + { "k", "k", name = "Jump up" }, + { "l", "l", name = "Jump right" }, + { "H", "H", name = "Move left" }, + { "J", "J", name = "Move down" }, + { "K", "K", name = "Move up" }, + { "L", "L", name = "Move right" }, + { "=", "=", name = "Move right" }, + { + "", "5<", name = "Expand left" }, + { "J>", "resize +5", name = "Expand down" }, + { "K>", "resize -5", name = "Expand up" }, + { "L>", "L", name = "Expand right" }, + }, + }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/core/init.lua b/lua/doom/modules/core/init.lua new file mode 100644 index 000000000..e39ee1c8a --- /dev/null +++ b/lua/doom/modules/core/init.lua @@ -0,0 +1,93 @@ +local required = {} + +required.defaults = { + mapper = {}, + treesitter = { + highlight = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { + enable = true, + }, + playground = { + enable = true, + }, + context_commentstring = { + enable = true, + }, + autotag = { + enable = true, + filetypes = { + "html", + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "svelte", + "vue", + "markdown", + }, + }, + }, +} + +required.packer_config = {} +required.packer_config["nest.nvim"] = function() + local utils = require("doom.utils") + local is_plugin_disabled = utils.is_plugin_disabled + + local nest_package = require("nest") + + nest_package.enable(require("nest.integrations.mapper")) + if not is_plugin_disabled("whichkey") then + local whichkey_integration = require("nest.integrations.whichkey") + nest_package.enable(whichkey_integration) + end + + nest_package.applyKeymaps(doom.binds) +end +required.packer_config["nvim-mapper"] = function() + require("nvim-mapper").setup(doom.core.mapper) +end +required.packer_config["nvim-treesitter"] = function() + local is_plugin_disabled = require("doom.utils").is_plugin_disabled + require("nvim-treesitter.configs").setup(vim.tbl_deep_extend("force", doom.core.treesitter, { + autopairs = { + enable = not is_plugin_disabled("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 + vim.defer_fn(function() + local log = require("doom.utils.logging") + local utils = require("doom.utils") + -- Matches logic from nvim-treesitter + local compiler = utils.find_executable_in_path({ + vim.fn.getenv("CC"), + "cc", + "gcc", + "clang", + "cl", + "zig", + }) + local version = vim.fn.systemlist(compiler .. (compiler == "cl" and "" or " --version"))[1] + + if version:match("clang") then + log.warn( + "doom-treesitter: clang has poor compatibility compiling treesitter parsers. We recommend using gcc, see issue #246 for details. (https://github.com/NTBBloodbath/doom-nvim/issues/246)" + ) + end + end, 1000) +end + +return required diff --git a/lua/doom/modules/core/packages.lua b/lua/doom/modules/core/packages.lua new file mode 100644 index 000000000..c8ea1d72d --- /dev/null +++ b/lua/doom/modules/core/packages.lua @@ -0,0 +1,57 @@ +local is_plugin_disabled = require("doom.utils").is_plugin_disabled + +return { + ["packer.nvim"] = { + "wbthomason/packer.nvim", + opt = true, + }, + ["nvim-treesitter"] = { + "nvim-treesitter/nvim-treesitter", + commit = vim.fn.has("nvim-0.6.0") == 1 and "afed686e6a8fc1035475d8c56c1b5ff252c346e5" + or "47cfda2c6711077625c90902d7722238a8294982", + run = ":TSUpdate", + branch = vim.fn.has("nvim-0.6.0") == 1 and "master" or "0.5-compat", + }, + ["nvim-ts-context-commentstring"] = { + "JoosepAlviste/nvim-ts-context-commentstring", + commit = "9f5e422e1030e7073e593ad32c5354aa0bcb0176", + opt = true, + after = "nvim-treesitter", + }, + ["nvim-ts-autotag"] = { + "windwp/nvim-ts-autotag", + commit = "80d427af7b898768c8d8538663d52dee133da86f", + opt = true, + after = "nvim-treesitter", + }, + -- Required by some treesitter modules + ["aniseed"] = { + "Olical/aniseed", + commit = "9c8f2cd17d454a38b11cedd323579b579ee27f9c", + module_pattern = "aniseed", + }, + ["plenary.nvim"] = { + "nvim-lua/plenary.nvim", + commit = "1c31adb35fcebe921f65e5c6ff6d5481fa5fa5ac", + module = "plenary", + }, + ["popup.nvim"] = { + "nvim-lua/popup.nvim", + commit = "b7404d35d5d3548a82149238289fa71f7f6de4ac", + module = "popup", + }, + ["nest.nvim"] = { + "connorgmeehan/nest.nvim", + branch = "integrations-api", + after = "nvim-mapper", + }, + ["nvim-mapper"] = { + "lazytanuki/nvim-mapper", + before = is_plugin_disabled("telescope") or "telescope.nvim", + }, + ["nvim-web-devicons"] = { + "kyazdani42/nvim-web-devicons", + commit = "8df4988ecf8599fc1f8f387bbf2eae790e4c5ffb", + module = "nvim-web-devicons", + }, +} diff --git a/lua/doom/modules/dap/binds.lua b/lua/doom/modules/dap/binds.lua new file mode 100644 index 000000000..557b2fc35 --- /dev/null +++ b/lua/doom/modules/dap/binds.lua @@ -0,0 +1,110 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "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", + { + { + "e", + function() + require("dapui").eval() + end, + name = "Evaluate", + }, + }, + }, + { + "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", + }, + }, + }, + }, + }, + { + "o", + name = "+open", + { + { + "d", + function() + require("dapui").toggle() + end, + name = "Debugger", + }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/dap/init.lua b/lua/doom/modules/dap/init.lua new file mode 100644 index 000000000..42439afbe --- /dev/null +++ b/lua/doom/modules/dap/init.lua @@ -0,0 +1,54 @@ +local dap = {} + +dap.defaults = { + debugger_dir = vim.fn.stdpath("data") .. "/dapinstall/", + debugger_map = {}, + dapui = { + icons = { + expanded = "▾", + collapsed = "▸", + }, + mappings = { + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + }, + sidebar = { + elements = { + "scopes", + "breakpoints", + "stacks", + "watches", + }, + size = 40, + position = "left", + }, + tray = { + elements = { + "repl", + }, + size = 10, + position = "bottom", + }, + }, +} + +dap.packer_config = {} +dap.packer_config["nvim-dap-ui"] = function() + local dap_package = require("dap") + local dapui = require("dapui") + dap_package.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() + end + dap_package.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() + end + dap_package.listeners.before.event_exited["dapui_config"] = function() + dapui.close() + end + dapui.setup(doom.dap.dapui) +end + +return dap diff --git a/lua/doom/modules/dap/packages.lua b/lua/doom/modules/dap/packages.lua new file mode 100644 index 000000000..d974b3f39 --- /dev/null +++ b/lua/doom/modules/dap/packages.lua @@ -0,0 +1,12 @@ +return { + ["nvim-dap"] = { + "mfussenegger/nvim-dap", + commit = "4e8bb7ca12dc8ca6f7a500cbb4ecea185665c7f1", + module = "dap", + }, + ["nvim-dap-ui"] = { + "rcarriga/nvim-dap-ui", + commit = "649e0fee4f0b8dc6305dd29065c7623c3dc6a032", + after = { "nvim-dap", "nest.nvim" }, + }, +} diff --git a/lua/doom/modules/dashboard/autocmds.lua b/lua/doom/modules/dashboard/autocmds.lua new file mode 100644 index 000000000..cd5665a47 --- /dev/null +++ b/lua/doom/modules/dashboard/autocmds.lua @@ -0,0 +1,11 @@ +local autocmds = { + { + "FileType", + "dashboard", + function() + require("nest").applyKeymaps({ "q", "q", buffer = true }) + end, + }, +} + +return autocmds diff --git a/lua/doom/modules/dashboard/binds.lua b/lua/doom/modules/dashboard/binds.lua new file mode 100644 index 000000000..817c7af01 --- /dev/null +++ b/lua/doom/modules/dashboard/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "D", "Dashboard", name = "Dashboard" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/dashboard/init.lua b/lua/doom/modules/dashboard/init.lua new file mode 100644 index 000000000..f3474c43c --- /dev/null +++ b/lua/doom/modules/dashboard/init.lua @@ -0,0 +1,91 @@ +local dashboard = {} + +dashboard.defaults = { + entries = { + b = { + description = { " Recently Opened Files SPC f r" }, + command = "Telescope oldfiles", + }, + c = { + description = { " Jump to Bookmark SPC s m" }, + command = "Telescope marks", + }, + d = { + description = { " Open Configuration SPC D c" }, + command = "e " .. require("doom.core.config").source, + }, + e = { + description = { " Open Modules SPC D m" }, + command = "e " .. require("doom.core.config.modules").source, + }, + f = { + description = { " Open Documentation SPC D d" }, + command = [[lua require("doom.core.functions").open_docs()]], + }, + }, + header = { + " ", + "================= =============== =============== ======== ========", + "\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //", + "||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||", + "|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||", + "||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||", + "|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||", + "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||", + "|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||", + "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||", + "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||", + "|| `' || || `' || || `' || || | \\ / | ||", + "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||", + "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||", + "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||", + "|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||", + "||.==' _-' `' | /==.||", + "==' _-' N E O V I M \\/ `==", + "\\ _-' `-_ /", + " `'' ``' ", + }, + footer = { "Doom Nvim loaded" }, + colors = { + header = "#586268", + center = "#51afef", + shortcut = "#a9a1e1", + footer = "#586268", + }, +} + +dashboard.packer_config = {} +dashboard.packer_config["dashboard-nvim"] = function() + local utils = require("doom.utils") + local is_plugin_disabled = utils.is_plugin_disabled + + if not is_plugin_disabled("auto_session") then + vim.g.dashboard_session_directory = doom.auto_session.dir + end + if not is_plugin_disabled("telescope") then + vim.g.dashboard_default_executive = "telescope" + end + if not is_plugin_disabled("auto_session") then + doom.dashboard.entries.a = { + description = { " Load Last Session SPC s r" }, + command = [[lua require("persistence").load({ last = true })]], + } + end + + vim.g.dashboard_custom_section = doom.dashboard.entries + + if type(doom.dashboard.footer) ~= "function" then + vim.g.dashboard_custom_footer = doom.dashboard.footer + end + + if type(doom.dashboard.header) ~= "function" then + vim.g.dashboard_custom_header = doom.dashboard.header + end + -- Header color + vim.cmd("hi! dashboardHeader guifg=" .. doom.dashboard.colors.header) + vim.cmd("hi! dashboardCenter guifg=" .. doom.dashboard.colors.center) + vim.cmd("hi! dashboardShortcut guifg=" .. doom.dashboard.colors.shortcut) + vim.cmd("hi! dashboardFooter guifg=" .. doom.dashboard.colors.footer) +end + +return dashboard diff --git a/lua/doom/modules/dashboard/packages.lua b/lua/doom/modules/dashboard/packages.lua new file mode 100644 index 000000000..43673af04 --- /dev/null +++ b/lua/doom/modules/dashboard/packages.lua @@ -0,0 +1,8 @@ +return { + ["dashboard-nvim"] = { + "glepnir/dashboard-nvim", + commit = "ba98ab86487b8eda3b0934b5423759944b5f7ebd", + cmd = "Dashboard", + opt = true, + }, +} diff --git a/lua/doom/modules/doom_themes/init.lua b/lua/doom/modules/doom_themes/init.lua new file mode 100644 index 000000000..8e796e83d --- /dev/null +++ b/lua/doom/modules/doom_themes/init.lua @@ -0,0 +1,7 @@ +local doom_themes = {} + +doom_themes.defaults = {} + +doom_themes.packer_config = {} + +return doom_themes diff --git a/lua/doom/modules/doom_themes/packages.lua b/lua/doom/modules/doom_themes/packages.lua new file mode 100644 index 000000000..d02a3e0c0 --- /dev/null +++ b/lua/doom/modules/doom_themes/packages.lua @@ -0,0 +1,8 @@ +return { + ["doom-themes.nvim"] = { + "GustavoPrietoP/doom-themes.nvim", + commit = "03d417d3eab71c320744f8da22251715ba6cee53", + event = "ColorScheme", + opt = true, + }, +} diff --git a/lua/doom/modules/editorconfig/init.lua b/lua/doom/modules/editorconfig/init.lua new file mode 100644 index 000000000..f94b4e909 --- /dev/null +++ b/lua/doom/modules/editorconfig/init.lua @@ -0,0 +1,7 @@ +local editorconfig = {} + +editorconfig.defaults = {} + +editorconfig.packer_config = {} + +return editorconfig diff --git a/lua/doom/modules/editorconfig/packages.lua b/lua/doom/modules/editorconfig/packages.lua new file mode 100644 index 000000000..341487ad1 --- /dev/null +++ b/lua/doom/modules/editorconfig/packages.lua @@ -0,0 +1,6 @@ +return { + ["editorconfig-vim"] = { + "editorconfig/editorconfig-vim", + commit = "3078cd10b28904e57d878c0d0dab42aa0a9fdc89", + }, +} diff --git a/lua/doom/modules/explorer/binds.lua b/lua/doom/modules/explorer/binds.lua new file mode 100644 index 000000000..00f5207a2 --- /dev/null +++ b/lua/doom/modules/explorer/binds.lua @@ -0,0 +1,24 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { + { "", ":NvimTreeToggle", name = "Toggle file explorer" }, +} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "e", "NvimTreeToggle", name = "Explorer" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/explorer/init.lua b/lua/doom/modules/explorer/init.lua new file mode 100644 index 000000000..b2b3e14b6 --- /dev/null +++ b/lua/doom/modules/explorer/init.lua @@ -0,0 +1,182 @@ +local explorer = {} + +explorer.defaults = { + refresh_wait = true, + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = {}, + auto_close = false, + open_on_tab = true, + hijack_cursor = true, + update_cwd = true, + respect_buf_cwd = true, + special_files = { + "README.md", + "Makefile", + "MAKEFILE", + }, + window_picker_exclude = { + filetype = { + "notify", + "packer", + "qf", + }, + buftype = { + "terminal", + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + view = { + width = 35, + side = "left", + auto_resize = true, + mappings = { + custom_only = false, + }, + }, + indent_markers = true, + git_highlight = true, + traling_dir_slash = true, + group_empty = true, + show_icons = { + git = true, + folders = true, + files = true, + folder_arrows = true, + }, + icons = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "", + unmerged = "", + renamed = "", + untracked = "", + deleted = "", + ignored = "◌", + }, + folder = { + arrow_open = "", + arrow_closed = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + }, +} + +explorer.packer_config = {} +explorer.packer_config["nvim-tree.lua"] = function() + local utils = require("doom.utils") + local is_plugin_disabled = utils.is_plugin_disabled + + local tree_cb = require("nvim-tree.config").nvim_tree_callback + + vim.g.nvim_tree_ignore = { ".git", "node_modules.editor", ".cache", "__pycache__" } + + vim.g.nvim_tree_indent_markers = utils.bool2num(doom.explorer.indent_markers) + + vim.g.nvim_tree_respect_buf_cwd = utils.bool2num(doom.explorer.respect_buf_cwd) + + vim.g.nvim_tree_hide_dotfiles = utils.bool2num(not doom.show_hidden) + + vim.g.nvim_tree_git_hl = utils.bool2num(doom.explorer.git_highlight) + + vim.g.nvim_tree_gitignore = utils.bool2num(doom.hide_gitignore) + + vim.g.nvim_tree_root_folder_modifier = ":~" + + vim.g.nvim_tree_add_trailing = utils.bool2num(doom.explorer.trailing_dir_slash) + + vim.g.nvim_tree_group_empty = utils.bool2num(doom.explorer.group_empty) + + vim.g.nvim_tree_refresh_wait = utils.bool2num(doom.explorer.refresh_wait) + + vim.g.nvim_tree_window_picker_exclude = doom.explorer.window_picker_exclude + + local special_files = {} + for _, file in ipairs(doom.explorer.special_files) do + special_files[file] = 1 + end + vim.g.nvim_tree_special_files = special_files + + local show_icons = {} + for key, value in pairs(doom.explorer.show_icons) do + show_icons[key] = utils.bool2num(value) + end + vim.g.nvim_tree_show_icons = show_icons + + local override_icons = {} + if not is_plugin_disabled("lsp") then + override_icons = { + lsp = { + hint = doom.lsp.icons.hint, + info = doom.lsp.icons.info, + warning = doom.lsp.icons.warn, + error = doom.lsp.icons.error, + }, + } + end + vim.g.nvim_tree_icons = vim.tbl_deep_extend("force", doom.explorer.icons, override_icons) + + local override_table = { + diagnostics = { + enable = false, + }, + } + if not is_plugin_disabled("lsp") then + override_table = { + diagnostics = { + enable = true, + icons = { + hint = doom.lsp.icons.hint, + info = doom.lsp.icons.info, + warning = doom.lsp.icons.warn, + error = doom.lsp.icons.error, + }, + }, + } + end + require("nvim-tree").setup(vim.tbl_deep_extend("force", { + view = { + mappings = { + list = { + { key = { "o", "<2-LeftMouse>" }, cb = tree_cb("edit") }, + { key = { "", "<2-RightMouse>", "" }, cb = tree_cb("cd") }, + { key = "", cb = tree_cb("vsplit") }, + { key = "", cb = tree_cb("split") }, + { key = "", cb = tree_cb("tabnew") }, + { key = "", cb = tree_cb("close_node") }, + { key = "", cb = tree_cb("close_node") }, + { key = "", cb = tree_cb("preview") }, + { key = "I", cb = tree_cb("toggle_ignored") }, + { key = "H", cb = tree_cb("toggle_dotfiles") }, + { key = "R", cb = tree_cb("refresh") }, + { key = "a", cb = tree_cb("create") }, + { key = "d", cb = tree_cb("remove") }, + { key = "r", cb = tree_cb("rename") }, + { key = "", cb = tree_cb("full_rename") }, + { key = "x", cb = tree_cb("cut") }, + { key = "c", cb = tree_cb("copy") }, + { key = "p", cb = tree_cb("paste") }, + { key = "[c", cb = tree_cb("prev_git_item") }, + { key = "]c", cb = tree_cb("next_git_item") }, + { key = "-", cb = tree_cb("dir_up") }, + { key = "q", cb = tree_cb("close") }, + { key = "g?", cb = tree_cb("toggle_help") }, + }, + }, + }, + }, doom.explorer, override_table)) +end + +return explorer diff --git a/lua/doom/modules/explorer/packages.lua b/lua/doom/modules/explorer/packages.lua new file mode 100644 index 000000000..e84925422 --- /dev/null +++ b/lua/doom/modules/explorer/packages.lua @@ -0,0 +1,14 @@ +return { + ["nvim-tree.lua"] = { + "kyazdani42/nvim-tree.lua", + commit = "5d8453dfbd34ab00cb3e8ce39660f9a54cdd35f3", + cmd = { + "NvimTreeClipboard", + "NvimTreeClose", + "NvimTreeFindFile", + "NvimTreeOpen", + "NvimTreeRefresh", + "NvimTreeToggle", + }, + }, +} diff --git a/lua/doom/modules/firenvim/init.lua b/lua/doom/modules/firenvim/init.lua new file mode 100644 index 000000000..445ade5d9 --- /dev/null +++ b/lua/doom/modules/firenvim/init.lua @@ -0,0 +1,34 @@ +local firenvim = {} + +firenvim.defaults = { + globalSettings = { + alt = "all", + }, + localSettings = { + [".*"] = { + cmdline = "neovim", + content = "text", + priority = 0, + selector = "textarea", + takeover = "never", + }, + ["https?://github.com/"] = { + takeover = "always", + priority = 1, + }, + }, + autocmds = { + { "BufEnter", "github.com", "setlocal filetype=markdown" }, + }, +} + +firenvim.packer_config = {} +firenvim.packer_config["firenvim"] = function() + vim.g.firenvim_config = doom.firenvim + + for _, command in ipairs(doom.firenvim.autocmds) do + vim.cmd(("autocmd %s %s_*.txt %s"):format(command[1], command[2], command[3])) + end +end + +return firenvim diff --git a/lua/doom/modules/firenvim/packages.lua b/lua/doom/modules/firenvim/packages.lua new file mode 100644 index 000000000..2c55d3ffb --- /dev/null +++ b/lua/doom/modules/firenvim/packages.lua @@ -0,0 +1,10 @@ +return { + ["firenvim"] = { + "glacambre/firenvim", + commit = "7320a805f51b4cf03de4e3b30088838d3f84adda", + run = function() + vim.fn["firenvim#install"](0) + end, + opt = true, + }, +} diff --git a/lua/doom/modules/formatter/autocmds.lua b/lua/doom/modules/formatter/autocmds.lua new file mode 100644 index 000000000..345081c1b --- /dev/null +++ b/lua/doom/modules/formatter/autocmds.lua @@ -0,0 +1,11 @@ +local autocmds = {} + +if doom.formatter.on_save then + table.insert(autocmds, { + "BufWritePre", + "*", + "FormatWrite", + }) +end + +return autocmds diff --git a/lua/doom/modules/formatter/binds.lua b/lua/doom/modules/formatter/binds.lua new file mode 100644 index 000000000..1033ed5d3 --- /dev/null +++ b/lua/doom/modules/formatter/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "c", + name = "+code", + { + { "f", "FormatWrite", name = "Format" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/formatter/init.lua b/lua/doom/modules/formatter/init.lua new file mode 100644 index 000000000..9ad58182a --- /dev/null +++ b/lua/doom/modules/formatter/init.lua @@ -0,0 +1,122 @@ +local formatter = {} + +local fmt = string.format + +formatter.defaults = { + ["*"] = { + -- remove trailing whitespaces + { + cmd = { + "sed -i 's/[ \t]*$//'", + }, + }, + }, + vim = { + { + cmd = { + function(file) + return fmt("stylua %s", file) + end, + }, + start_pattern = "^lua << EOF$", + end_pattern = "^EOF$", + }, + }, + vimwiki = { + { + cmd = { "prettier -w --parser babel" }, + start_pattern = "^{{{javascript$", + end_pattern = "^}}}$", + }, + }, + lua = { + { + cmd = { + function(file) + return fmt("stylua --config-path ~/.config/stylua/stylua.toml %s", file) + end, + }, + }, + }, + python = { + { + cmd = { + function(file) + return fmt("yapf -i %s", file) + end, + }, + }, + }, + go = { + { + cmd = { + "gofmt -w", + "goimports -w", + }, + tempfile_postfix = ".tmp", + }, + }, + javascript = { + { + cmd = { + "prettier -w", + "./node_modules/.bin/eslint --fix", + }, + }, + }, + typescript = { + { + cmd = { "prettier -w --parser typescript" }, + }, + }, + html = { + { + cmd = { "prettier -w --parser html" }, + }, + }, + markdown = { + { + cmd = { "prettier -w --parser markdown" }, + }, + { + cmd = { + "yapf -i", + }, + start_pattern = "^```python$", + end_pattern = "^```$", + target = "current", + }, + }, + css = { + { + cmd = { "prettier -w --parser css" }, + }, + }, + scss = { + { + cmd = { "prettier -w --parser scss" }, + }, + }, + json = { + { + cmd = { "prettier -w --parser json" }, + }, + }, + toml = { + { + cmd = { "prettier -w --parser toml" }, + }, + }, + yaml = { + { + cmd = { "prettier -w --parser yaml" }, + }, + }, +} + +formatter.packer_config = {} +formatter.packer_config["format.nvim"] = function() + require("format").setup(doom.formatter) +end + +return formatter diff --git a/lua/doom/modules/formatter/packages.lua b/lua/doom/modules/formatter/packages.lua new file mode 100644 index 000000000..5bc8be45e --- /dev/null +++ b/lua/doom/modules/formatter/packages.lua @@ -0,0 +1,8 @@ +return { + ["format.nvim"] = { + "lukas-reineke/format.nvim", + commit = "c46ab8b46100e26fce4d6ce69a94d4cea8b9f4d7", + cmd = { "Format", "FormatWrite" }, + opt = true, + }, +} diff --git a/lua/doom/modules/gitsigns/init.lua b/lua/doom/modules/gitsigns/init.lua new file mode 100644 index 000000000..969b62e43 --- /dev/null +++ b/lua/doom/modules/gitsigns/init.lua @@ -0,0 +1,80 @@ +local gitsigns = {} + +gitsigns.defaults = { + signs = { + add = { + hl = "GitSignsAdd", + text = "│", + numhl = "GitSignsAddNr", + linehl = "GitSignsAddLn", + }, + change = { + hl = "GitSignsChange", + text = "│", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + delete = { + hl = "GitSignsDelete", + text = "_", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + topdelete = { + hl = "GitSignsDelete", + text = "‾", + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + changedelete = { + hl = "GitSignsChange", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + numhl = false, + linehl = false, + keymaps = { + -- Default keymap options + noremap = true, + buffer = true, + + ["n ]c"] = { + expr = true, + "&diff ? ']c' : 'lua require\"gitsigns\".next_hunk()'", + }, + ["n [c"] = { + expr = true, + "&diff ? '[c' : 'lua require\"gitsigns\".prev_hunk()'", + }, + + ["n gS"] = 'lua require"gitsigns".stage_hunk()', + ["n gu"] = 'lua require"gitsigns".undo_stage_hunk()', + ["n gr"] = 'lua require"gitsigns".reset_hunk()', + ["n gR"] = 'lua require"gitsigns".reset_buffer()', + ["n gh"] = 'lua require"gitsigns".preview_hunk()', + ["n gb"] = 'lua require"gitsigns".blame_line()', + + -- Text objects + ["o ih"] = ':lua require"gitsigns".select_hunk()', + ["x ih"] = ':lua require"gitsigns".select_hunk()', + }, + watch_gitdir = { interval = 1000, follow_files = true }, + current_line_blame_opts = { + delay = 1000, + position = "eol", + }, + sign_priority = 6, + update_debounce = 100, + diff_opts = { + internal = true, -- If luajit is present + }, +} + +gitsigns.packer_config = {} +gitsigns.packer_config["gitsigns.nvim"] = function() + require("gitsigns").setup(doom.gitsigns) +end + +return gitsigns diff --git a/lua/doom/modules/gitsigns/packages.lua b/lua/doom/modules/gitsigns/packages.lua new file mode 100644 index 000000000..fa9f2980a --- /dev/null +++ b/lua/doom/modules/gitsigns/packages.lua @@ -0,0 +1,7 @@ +return { + ["gitsigns.nvim"] = { + "lewis6991/gitsigns.nvim", + commit = "95845ef39ce0a98f68cdfdcf7dd586c5e965acc7", + event = "BufReadPre", + }, +} diff --git a/lua/doom/modules/illuminate/init.lua b/lua/doom/modules/illuminate/init.lua new file mode 100644 index 000000000..2680fde8c --- /dev/null +++ b/lua/doom/modules/illuminate/init.lua @@ -0,0 +1,21 @@ +local illuminate = {} + +illuminate.defaults = { + blacklist = { + "help", + "dashboard", + "packer", + "norg", + "DoomInfo", + "NvimTree", + "Outline", + "toggleterm", + }, +} + +illuminate.packer_config = {} +illuminate.packer_config["vim-illuminate"] = function() + vim.g.Illuminate_ftblacklist = doom.illuminate.blacklist +end + +return illuminate diff --git a/lua/doom/modules/illuminate/packages.lua b/lua/doom/modules/illuminate/packages.lua new file mode 100644 index 000000000..da32df940 --- /dev/null +++ b/lua/doom/modules/illuminate/packages.lua @@ -0,0 +1,6 @@ +return { + ["vim-illuminate"] = { + "RRethy/vim-illuminate", + commit = "2beae0581caa66cf8c09fad7c7c557f92d49d2bd", + }, +} diff --git a/lua/doom/modules/indentlines/init.lua b/lua/doom/modules/indentlines/init.lua new file mode 100644 index 000000000..67bca365e --- /dev/null +++ b/lua/doom/modules/indentlines/init.lua @@ -0,0 +1,20 @@ +local indentlines = {} + +indentlines.defaults = { + char = "│", + use_treesitter = true, + show_first_indent_level = false, + filetype_exclude = { "help", "dashboard", "packer", "norg", "DoomInfo" }, + buftype_exclude = { "terminal" }, +} + +indentlines.packer_config = {} +indentlines.packer_config["indent-blankline.nvim"] = function() + require("indent_blankline").setup(vim.tbl_deep_extend("force", doom.indentlines, { + -- 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/indentlines/packages.lua b/lua/doom/modules/indentlines/packages.lua new file mode 100644 index 000000000..4b7a4d8ab --- /dev/null +++ b/lua/doom/modules/indentlines/packages.lua @@ -0,0 +1,7 @@ +return { + ["indent-blankline.nvim"] = { + "lukas-reineke/indent-blankline.nvim", + commit = "caf7f61e94525bbd97e32f118efd6c0722430616", + event = "ColorScheme", + }, +} diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua index effcf309c..913059031 100644 --- a/lua/doom/modules/init.lua +++ b/lua/doom/modules/init.lua @@ -1,23 +1,14 @@ --- Doom modules, where all the magic goes --- --- NOTE: We do not provide other LSP integration like coc.nvim, please refer --- to our FAQ to see why. +local utils = require("doom.utils") +local use_floating_win_packer = doom.use_floating_win_packer +local log = require("doom.utils.logging") +local system = require("doom.core.system") +local enabled_modules = require("doom.core.config.modules").modules -local is_plugin_disabled = require("doom.utils").is_plugin_disabled -local use_floating_win_packer = require("doom.core.config").config.doom.use_floating_win_packer - --- Freeze dependencies and helper function for clean code -local freeze_dependencies = require("doom.core.config").config.doom.freeze_dependencies -local pin_commit = function(commit_sha) - return freeze_dependencies and commit_sha or nil -end - ----- Packer Bootstrap --------------------------- -------------------------------------------------- +-- Packer Bootstrapping local packer_path = vim.fn.stdpath("data") .. "/site/pack/packer/opt/packer.nvim" if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then - require("doom.extras.logging").info("Bootstrapping packer.nvim, please wait ...") + log.info("Bootstrapping packer.nvim, please wait ...") vim.fn.system({ "git", "clone", @@ -27,11 +18,14 @@ if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then end -- Load packer -vim.cmd([[ packadd packer.nvim ]]) +vim.cmd([[packadd packer.nvim]]) local packer = require("packer") -- Change some defaults +-- Of particular interest is compile_path: we use stdpath("data"), so as to not +-- have anything generated in Doom source (which goes in stdpath("config")). packer.init({ + compile_path = system.doom_compile_path, git = { clone_timeout = 300, -- 5 mins subcommands = { @@ -42,626 +36,49 @@ packer.init({ }, display = { open_fn = use_floating_win_packer and function() - return require("packer.util").float({ border = "single" }) - end or nil, + return require("packer.util").float({ border = doom.border_style }) + end, }, profile = { enable = true, }, + log = { + level = doom.logging, + }, }) -packer.startup(function(use) - -----[[------------]]----- - --- Essentials --- - -----]]------------[[----- - -- Plugins manager - use({ - "wbthomason/packer.nvim", - opt = true, - }) - - -- Tree-Sitter - use({ - "nvim-treesitter/nvim-treesitter", - commit = vim.fn.has("nvim-0.6.0") == 1 and pin_commit( - "afed686e6a8fc1035475d8c56c1b5ff252c346e5" - ) or pin_commit("47cfda2c6711077625c90902d7722238a8294982"), - opt = true, - run = ":TSUpdate", - branch = vim.fn.has("nvim-0.6.0") == 1 and "master" or "0.5-compat", - config = require("doom.modules.config.doom-treesitter"), - }) - use({ - "JoosepAlviste/nvim-ts-context-commentstring", - commit = pin_commit("097df33c9ef5bbd3828105e4bee99965b758dc3f"), - after = "nvim-treesitter", - }) - use({ - "nvim-treesitter/nvim-tree-docs", - commit = pin_commit("15135bd18c8f0c4d67dd1b36d3b2cd64579aab6f"), - after = "nvim-treesitter", - }) - use({ - "windwp/nvim-ts-autotag", - commit = pin_commit("80d427af7b898768c8d8538663d52dee133da86f"), - after = "nvim-treesitter", - }) - - -- Aniseed, required by some treesitter modules - use({ - "Olical/aniseed", - commit = pin_commit("9c8f2cd17d454a38b11cedd323579b579ee27f9c"), - module_pattern = "aniseed", - }) - - -- Neorg - local disabled_neorg = is_plugin_disabled("neorg") - use({ - "nvim-neorg/neorg", - commit = --[[NO AUTO UPDATE]]pin_commit("1a4759d799a382838d793adc55c1faf02236c90a"), - config = require("doom.modules.config.doom-neorg"), - disable = disabled_neorg, - after = { "nvim-treesitter" }, - }) - - -- Sessions - local disabled_sessions = is_plugin_disabled("auto-session") - use({ - "folke/persistence.nvim", - commit = pin_commit("77cf5a6ee162013b97237ff25450080401849f85"), - config = require("doom.modules.config.doom-persistence"), - -- event = "VimEnter", - disable = disabled_sessions, - }) - - -----[[------------]]----- - --- UI Related --- - -----]]------------[[----- - -- Fancy start screen - local disabled_dashboard = is_plugin_disabled("dashboard") - use({ - "glepnir/dashboard-nvim", - commit = pin_commit("ba98ab86487b8eda3b0934b5423759944b5f7ebd"), - config = require("doom.modules.config.doom-dashboard"), - disable = disabled_dashboard, - }) - - -- Doom Colorschemes - local disabled_doom_themes = is_plugin_disabled("doom-themes") - use({ - "GustavoPrietoP/doom-themes.nvim", - commit = pin_commit("03d417d3eab71c320744f8da22251715ba6cee53"), - disable = disabled_doom_themes, - }) - - -- Development icons - use({ - "kyazdani42/nvim-web-devicons", - commit = pin_commit("344331467509802e1af200f08ec3da278be5cbba"), - module = "nvim-web-devicons", - }) - - -- File tree - local disabled_tree = is_plugin_disabled("explorer") - and require("doom.core.config").config.doom.use_netrw - use({ - "kyazdani42/nvim-tree.lua", - commit = pin_commit("f408781a463c2edc3a49091b1bca5a18f790ee3d"), - requires = "nvim-web-devicons", - config = require("doom.modules.config.doom-tree"), - disable = disabled_tree, - cmd = { - "NvimTreeClipboard", - "NvimTreeClose", - "NvimTreeFindFile", - "NvimTreeOpen", - "NvimTreeRefresh", - "NvimTreeToggle", - }, - }) - - -- Ranger File Browser - local disabled_ranger = is_plugin_disabled("ranger") - use({ - "francoiscabrol/ranger.vim", - commit = pin_commit("91e82debdf566dfaf47df3aef0a5fd823cedf41c"), - requires = "rbgrouleff/bclose.vim", - disable = disabled_ranger, - }) - - -- Statusline - -- can be disabled to use your own statusline - local disabled_statusline = is_plugin_disabled("statusline") - use({ - "NTBBloodbath/galaxyline.nvim", - commit = pin_commit("5a2151da17d88403fe7ded65c07be266d8cbc800"), - config = require("doom.modules.config.doom-eviline"), - disable = disabled_statusline, - }) - - -- Tabline - -- can be disabled to use your own tabline - local disabled_tabline = is_plugin_disabled("tabline") - use({ - "akinsho/bufferline.nvim", - commit = pin_commit("463637a3ac86dcaacbcd47aa608f53aaad749696"), - config = require("doom.modules.config.doom-bufferline"), - disable = disabled_tabline, - event = "BufWinEnter", - }) - - -- Better terminal - -- can be disabled to use your own terminal plugin - local disabled_terminal = is_plugin_disabled("terminal") - use({ - "akinsho/toggleterm.nvim", - commit = pin_commit("265bbff68fbb8b2a5fb011272ec469850254ec9f"), - config = require("doom.modules.config.doom-toggleterm"), - disable = disabled_terminal, - module = { "toggleterm", "toggleterm.terminal" }, - cmd = { "ToggleTerm", "TermExec" }, - keys = { "n", "" }, - }) - - -- Viewer & finder for LSP symbols and tags - local disabled_outline = is_plugin_disabled("symbols") - use({ - "simrat39/symbols-outline.nvim", - commit = pin_commit("034792838579c4b1515c8a5037aba58ecd1d9b35"), - config = require("doom.modules.config.doom-symbols"), - disable = disabled_outline, - cmd = { - "SymbolsOutline", - "SymbolsOutlineOpen", - "SymbolsOutlineClose", - }, - }) - - -- Minimap - -- Depends on wfxr/code-minimap to work! - local disabled_minimap = is_plugin_disabled("minimap") - use({ - "wfxr/minimap.vim", - commit = pin_commit("9af90830a95b81ab7f9ef6927f586bfa322b7de8"), - disable = disabled_minimap, - cmd = { - "Minimap", - "MinimapClose", - "MinimapToggle", - "MinimapRefresh", - "MinimapUpdateHighlight", - }, - }) - - -- Keybindings menu like Emacs's guide-key - local disabled_whichkey = is_plugin_disabled("which-key") - use({ - "folke/which-key.nvim", - commit = pin_commit("0fd9de78fe09215e1b7c6173ff1b0b90c8ed6ec4"), - opt = true, - config = require("doom.modules.config.doom-whichkey"), - disable = disabled_whichkey, - }) - - -- popup that shows contents of each register - local disabled_show_registers = is_plugin_disabled("show_registers") - use({ - "tversteeg/registers.nvim", - commit = pin_commit("4d1f3525c6f9be4297e99e6aed515af3677d7241"), - disable = disabled_show_registers, - }) - - -- Distraction free environment - local disabled_zen = is_plugin_disabled("zen") - use({ - "Pocco81/TrueZen.nvim", - commit = pin_commit("508b977d71650da5c9243698614a9a1416f116d4"), - config = require("doom.modules.config.doom-zen"), - disable = disabled_zen, - module = "true-zen", - event = "BufWinEnter", - }) - - -- Highlight other uses of the word under the cursor like VSC - local disabled_illuminate = is_plugin_disabled("illuminated") - use({ - "RRethy/vim-illuminate", - commit = pin_commit("2beae0581caa66cf8c09fad7c7c557f92d49d2bd"), - setup = function() - vim.g.Illuminate_ftblacklist = { - "help", - "dashboard", - "packer", - "norg", - "DoomInfo", - "NvimTree", - "Outline", - "toggleterm", - } - end, - disable = disabled_illuminate, - event = "BufRead", - }) - - -----[[--------------]]----- - --- Fuzzy Search --- - -----]]--------------[[----- - use({ - "nvim-lua/plenary.nvim", - commit = pin_commit("e6267f79481064eee53950571f53cbaafb08417d"), - module = "plenary", - }) - use({ - "nvim-lua/popup.nvim", - commit = pin_commit("b7404d35d5d3548a82149238289fa71f7f6de4ac"), - module = "popup", - }) - - local disabled_telescope = is_plugin_disabled("telescope") - use({ - "nvim-telescope/telescope.nvim", - commit = pin_commit("5f37fbfa837dfee7ecd30f388b271f4a71c0a9e0"), - cmd = "Telescope", - module = "telescope", - requires = { - "popup.nvim", - "plenary.nvim", - }, - config = require("doom.modules.config.doom-telescope"), - disable = disabled_telescope, - }) - use({ - "lazytanuki/nvim-mapper", - commit = pin_commit("e11e852bafa41a4a2c160fcd2d38779add423db9"), - config = function() - local doom_root, sep = require("doom.core.system").doom_root, require("doom.core.system").sep - require("nvim-mapper").setup({ - -- do not assign the default keymap (MM) - no_map = true, - -- where should ripgrep look for your keybinds definitions. - -- Default config search path is ~/.config/nvim/lua - search_path = string.format("%s%slua", doom_root, sep), - -- what should be done with the selected keybind when pressing enter. - -- Available actions: - -- * "definition" - Go to keybind definition (default) - -- * "execute" - Execute the keybind command - action_on_enter = "execute", - }) - end, - disable = disabled_telescope, - }) - - -----[[-------------]]----- - --- GIT RELATED --- - -----]]-------------[[----- - -- Git gutter better alternative, written in Lua - -- can be disabled to use your own git gutter plugin - local disabled_gitsigns = is_plugin_disabled("gitsigns") - use({ - "lewis6991/gitsigns.nvim", - commit = pin_commit("a451f97117bd1ede582a6b9db61c387c48d880b6"), - config = require("doom.modules.config.doom-gitsigns"), - disable = disabled_gitsigns, - requires = "plenary.nvim", - event = "BufRead", - }) - - -- Neogit - local disabled_neogit = is_plugin_disabled("neogit") - use({ - "TimUntersberger/neogit", - commit = pin_commit("0ff8e0c53092a9cb3a2bf138b05f7efd1f6d2481"), - config = function() - require("neogit").setup({}) - end, - disable = disabled_neogit, - cmd = "Neogit", - module = "neogit", - }) - - -- LazyGit integration - local disabled_lazygit = is_plugin_disabled("lazygit") - use({ - "kdheepak/lazygit.nvim", - commit = pin_commit("497ef5578e15f6c79deef1cad71adedd1c80abd4"), - requires = "plenary.nvim", - disable = disabled_lazygit, - cmd = { "LazyGit", "LazyGitConfig" }, - }) - - -----[[------------]]----- - --- Completion --- - -----]]------------[[----- - local disabled_lsp = is_plugin_disabled("lsp") - -- Built-in LSP Config - use({ - "neovim/nvim-lspconfig", - commit = pin_commit("c37bf4a2e87df0da5895402b01b427442e0633ff"), - config = require("doom.modules.config.doom-lspconfig"), - disable = disabled_lsp, - }) - - -- Snippets - local disabled_snippets = is_plugin_disabled("snippets") - - -- Autopairs - -- can be disabled to use your own autopairs - local disabled_autopairs = is_plugin_disabled("autopairs") - - -- Completion plugin - -- can be disabled to use your own completion plugin - use({ - "hrsh7th/nvim-cmp", - commit = pin_commit("8ffaeffa9d7c97131c6dbd3741693bfa044f4c1b"), - wants = { "LuaSnip" }, - requires = { - { - "L3MON4D3/LuaSnip", - commit = pin_commit("09e3bc6da5376aa87a29fde222f321f518e6c120"), - event = "BufReadPre", - wants = "friendly-snippets", - config = require("doom.modules.config.doom-luasnip"), - disable = disabled_snippets, - requires = { "rafamadriz/friendly-snippets" }, - }, - { - "windwp/nvim-autopairs", - commit = pin_commit("e6b1870cd2e319f467f99188f99b1c3efc5824d2"), - config = require("doom.modules.config.doom-autopairs"), - disable = disabled_autopairs, - event = "BufReadPre", - }, - }, - config = require("doom.modules.config.doom-cmp"), - disable = disabled_lsp, - event = "InsertEnter", - }) - use({ - "hrsh7th/cmp-nvim-lua", - commit = pin_commit("d276254e7198ab7d00f117e88e223b4bd8c02d21"), - disable = disabled_lsp, - after = "nvim-cmp", - }) - use({ - "hrsh7th/cmp-nvim-lsp", - commit = pin_commit("134117299ff9e34adde30a735cd8ca9cf8f3db81"), - disable = disabled_lsp, - after = "nvim-cmp", - }) - use({ - "hrsh7th/cmp-path", - commit = pin_commit("d83839ae510d18530c6d36b662a9e806d4dceb73"), - disable = disabled_lsp, - after = "nvim-cmp", - }) - use({ - "hrsh7th/cmp-buffer", - commit = pin_commit("a0fe52489ff6e235d62407f8fa72aef80222040a"), - disable = disabled_lsp, - after = "nvim-cmp", - }) - use({ - "saadparwaiz1/cmp_luasnip", - commit = pin_commit("7bd2612533db6863381193df83f9934b373b21e1"), - disable = disabled_lsp, - after = "nvim-cmp", - }) - - -- Manage Language serverss with ease. - use({ - "williamboman/nvim-lsp-installer", - commit = pin_commit("d7b10b13d72d4bf8f7b34779ddc3514bcc26b0f2"), - config = require("doom.modules.config.doom-lsp-installer"), - disable = disabled_lsp, - }) - - -- Show function signature when you type - use({ - "ray-x/lsp_signature.nvim", - commit = pin_commit("8642896791c31f12ac18af661d91f990b288b4cc"), - config = require("doom.modules.config.doom-lsp-signature"), - after = "nvim-lspconfig", - event = "InsertEnter", - }) - - -- Setup for Lua development in Neovim - use({ - "folke/lua-dev.nvim", - commit = pin_commit("4331626b02f636433b504b9ab6a8c11fb9de4a24"), - disable = disabled_lsp, - module = "lua-dev", - }) - - -----[[-----------]]----- - --- Debugging --- - -----]]-----------[[----- - local disabled_dap = is_plugin_disabled("dap") - use({ - "mfussenegger/nvim-dap", - commit = pin_commit("9b8c27d6dcc21b69834fe9c2d344e49030783390"), - disable = disabled_dap, - event = "BufWinEnter", - }) - - use({ - "rcarriga/nvim-dap-ui", - commit = pin_commit("96813c9a42651b729f50f5d880a8919a155e9721"), - config = require("doom.modules.config.doom-dap-ui"), - disable = disabled_dap, - after = "nvim-dap", - }) - - use({ - "Pocco81/DAPInstall.nvim", - commit = pin_commit("dd09e9dd3a6e29f02ac171515b8a089fb82bb425"), - config = require("doom.modules.config.doom-dap-install"), - disable = disabled_dap, - after = "nvim-dap", - }) - - -----[[--------------]]----- - --- File Related --- - -----]]--------------[[----- - -- Write / Read files without permissions (e.vim.g. /etc files) without having - -- to use `sudo nvim /path/to/file` - local disabled_suda = is_plugin_disabled("suda") - use({ - "lambdalisue/suda.vim", - commit = pin_commit("0290c93c148a14eab2b661a1933003d86436f6ec"), - disable = disabled_suda, - cmd = { "SudaRead", "SudaWrite" }, - }) - - -- File formatting - -- can be disabled to use your own file formatter - local disabled_formatter = is_plugin_disabled("formatter") - use({ - "lukas-reineke/format.nvim", - commit = pin_commit("29a7dccbdee6d657380104958b4b8e81d316803d"), - config = require("doom.modules.config.doom-format"), - disable = disabled_formatter, - cmd = { "Format", "FormatWrite" }, - }) - - -- Linting - local disabled_linter = is_plugin_disabled("linter") - use({ - "mfussenegger/nvim-lint", - commit = pin_commit("4393540dbf7e881cb8fe572a8540284a6ae13201"), - config = require("doom.modules.config.doom-lint"), - disable = disabled_linter, - module = "lint", - }) - - -- Indent Lines - local disabled_indent_lines = is_plugin_disabled("indentlines") - use({ - "lukas-reineke/indent-blankline.nvim", - commit = pin_commit("0f8df7e43f0cae4c44e0e8383436ad602f333419"), - config = require("doom.modules.config.doom-blankline"), - disable = disabled_indent_lines, - event = "ColorScheme", - }) - - -- EditorConfig support - local disabled_editorconfig = is_plugin_disabled("editorconfig") - use({ - "editorconfig/editorconfig-vim", - commit = pin_commit("3078cd10b28904e57d878c0d0dab42aa0a9fdc89"), - disable = disabled_editorconfig, - }) - - -- Comments - -- can be disabled to use your own comments plugin - local disabled_kommentary = is_plugin_disabled("kommentary") - use({ - "b3nj5m1n/kommentary", - commit = pin_commit("2e1c3be90d555cd2c1f70b1c24867cee08d352f4"), - disable = disabled_kommentary, - event = "BufWinEnter", - }) - - local disabled_contrib = is_plugin_disabled("contrib") - -- Lua 5.1 docs - use({ - "milisims/nvim-luaref", - commit = pin_commit("dc40d606549db7df1a6e23efa743c90c178333d4"), - disable = disabled_contrib, - }) - -- LibUV docs - use({ - "nanotee/luv-vimdocs", - commit = pin_commit("fb04e1088a21eefcc396d5a5299468d8742d27a2"), - disable = disabled_contrib, - }) - - -----[[-------------]]----- - --- Web Related --- - -----]]-------------[[----- - -- Fastest colorizer without external dependencies! - local disabled_colorizer = is_plugin_disabled("colorizer") - use({ - "norcalli/nvim-colorizer.lua", - commit = pin_commit("36c610a9717cc9ec426a07c8e6bf3b3abcb139d6"), - config = require("doom.modules.config.doom-colorizer"), - disable = disabled_colorizer, - event = "ColorScheme", - }) - - -- HTTP Client support - -- Depends on bayne/dot-http to work! - local disabled_restclient = is_plugin_disabled("restclient") - use({ - "NTBBloodbath/rest.nvim", - commit = pin_commit("3ab950fe88cf836c83fa15a10e386ccd5f6aa1cb"), - requires = "plenary.nvim", - config = function() - require("rest-nvim").setup() - end, - disable = disabled_restclient, - event = "BufWinEnter", - }) - - local disabled_range_highlight = is_plugin_disabled("range-highlight") - use({ - "winston0410/range-highlight.nvim", - commit = pin_commit("8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9"), - requires = { - { "winston0410/cmd-parser.nvim", module = "cmd-parser" }, - }, - config = function() - require("range-highlight").setup() - end, - disable = disabled_range_highlight, - event = "BufRead", - }) - - local disabled_firenvim = is_plugin_disabled("firenvim") - use({ - "glacambre/firenvim", - commit = pin_commit("7320a805f51b4cf03de4e3b30088838d3f84adda"), - disable = disabled_firenvim, - run = function() - vim.fn["firenvim#install"](0) - end, - config = require("doom.modules.config.doom-fire"), - }) - - local disabled_todo = is_plugin_disabled("todo_comments") - use({ - "folke/todo-comments.nvim", - commit = pin_commit("672cd22bd15928434374ac52d0cf38dd250231df"), - requires = "nvim-lua/plenary.nvim", - config = require("doom.modules.config.doom-todo"), - disable = disabled_todo, - event = "ColorScheme", - }) - - local disabled_trouble = is_plugin_disabled("trouble") - use({ - "folke/trouble.nvim", - commit = pin_commit("c298a17a729b81039d7bbe18566af9d67df9e81c"), - cmd = { "Trouble", "TroubleClose", "TroubleRefresh", "TroubleToggle" }, - requires = "kyazdani42/nvim-web-devicons", - config = require("doom.modules.config.doom-trouble"), - disable = disabled_trouble, - }) - - local disabled_superman = is_plugin_disabled("superman") - use({ - "jez/vim-superman", - commit = pin_commit("19d307446576d9118625c5d9d3c7a4c9bec5571a"), - cmd = "SuperMan", - disable = disabled_superman, - }) - - -----[[----------------]]----- - --- Custom Plugins --- - -----]]----------------[[----- - -- If there are custom plugins then also require them - local custom_plugins = require("doom.core.config.userplugins").plugins +packer.reset() - for _, plug in pairs(custom_plugins or {}) do - packer.use(plug) +-- Flatten the multiple packer config tables into one to rule them all. +local packer_config = {} +for _, module in ipairs(enabled_modules) do + local new_configs = require(("doom.modules.%s"):format(module)).packer_config + for name, value in pairs(new_configs) do + packer_config[name] = value + end +end +-- Iterate packages. These can be added by modules or by the user in +-- `config.lua`. See `load()` in doom/core/config/init.lua +for name, spec in pairs(doom.packages) do + -- Set empty defaults in case the functions don't exist. + if type(packer_config[name]) ~= "function" then + packer_config[name] = function() end end -end) + if type(spec.config) ~= "function" then + spec.config = function() end + end + packer.use(vim.tbl_deep_extend("force", spec, { + -- First, run the module config (sometimes an empty function, see + -- above), then the hook passed by the user. This cannot be done with + -- a function that calls both sequentially, see packer's README on + -- captures and `string.dump`. + config = { packer_config[name], spec.config }, + })) +end + +-- Register autocmds, which, like packages, can come from modules or the +-- user. +for module, cmds in pairs(doom.autocmds) do + local augroup_name = ("doom_%s"):format(module) + utils.make_augroup(augroup_name, cmds) +end diff --git a/lua/doom/modules/lazygit/binds.lua b/lua/doom/modules/lazygit/binds.lua new file mode 100644 index 000000000..f15890df7 --- /dev/null +++ b/lua/doom/modules/lazygit/binds.lua @@ -0,0 +1,29 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "l", "LazyGit", name = "Lazygit" }, + }, + }, + { + "g", + name = "+git", + { + { "o", "LazyGit", name = "Open lazygit" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/lazygit/init.lua b/lua/doom/modules/lazygit/init.lua new file mode 100644 index 000000000..3fee33d1c --- /dev/null +++ b/lua/doom/modules/lazygit/init.lua @@ -0,0 +1,7 @@ +local lazygit = {} + +lazygit.defaults = {} + +lazygit.packer_config = {} + +return lazygit diff --git a/lua/doom/modules/lazygit/packages.lua b/lua/doom/modules/lazygit/packages.lua new file mode 100644 index 000000000..909ba7864 --- /dev/null +++ b/lua/doom/modules/lazygit/packages.lua @@ -0,0 +1,8 @@ +return { + ["lazygit.nvim"] = { + "kdheepak/lazygit.nvim", + commit = "497ef5578e15f6c79deef1cad71adedd1c80abd4", + cmd = { "LazyGit", "LazyGitConfig" }, + opt = true, + }, +} diff --git a/lua/doom/modules/linter/autocmds.lua b/lua/doom/modules/linter/autocmds.lua new file mode 100644 index 000000000..c02968bac --- /dev/null +++ b/lua/doom/modules/linter/autocmds.lua @@ -0,0 +1,11 @@ +local autocmds = { + { + "BufWinEnter,BufWritePost", + "", + function() + require("lint").try_lint() + end, + }, +} + +return autocmds diff --git a/lua/doom/modules/linter/init.lua b/lua/doom/modules/linter/init.lua new file mode 100644 index 000000000..a1f2127fa --- /dev/null +++ b/lua/doom/modules/linter/init.lua @@ -0,0 +1,23 @@ +local linter = {} + +linter.defaults = { + c = { "clang-tidy" }, + cpp = {}, + css = {}, + html = { "tidy" }, + javascript = { "eslint" }, + lua = {}, + markdown = { "markdownlint" }, + nix = { "nix" }, + python = {}, + ruby = {}, + sh = {}, + typescript = { "eslint" }, +} + +linter.packer_config = {} +linter.packer_config["nvim-lint"] = function() + require("lint").linters_by_ft = doom.linter +end + +return linter diff --git a/lua/doom/modules/linter/packages.lua b/lua/doom/modules/linter/packages.lua new file mode 100644 index 000000000..4045c41ca --- /dev/null +++ b/lua/doom/modules/linter/packages.lua @@ -0,0 +1,7 @@ +return { + ["nvim-lint"] = { + "mfussenegger/nvim-lint", + commit = "c3c8a247fda421b0db1f2cbf50ab4340ba0ffc61", + module = "lint", + }, +} diff --git a/lua/doom/modules/lsp/autocmds.lua b/lua/doom/modules/lsp/autocmds.lua new file mode 100644 index 000000000..f4ac385ef --- /dev/null +++ b/lua/doom/modules/lsp/autocmds.lua @@ -0,0 +1,19 @@ +local autocmds = {} + +if doom.lsp.hint_enable then + local show_diagnostics_function = function() + vim.diagnostic.open_float(nil, { focus = false, border = doom.border_style }) + end + if vim.fn.has("nvim-0.6.0") ~= 1 then + show_diagnostics_function = function() + vim.lsp.diagnostic.show_line_diagnostics({ focusable = false, border = doom.border_style }) + end + end + table.insert(autocmds, { + "CursorHold,CursorHoldI", + "", + show_diagnostics_function, + }) +end + +return autocmds diff --git a/lua/doom/modules/lsp/binds.lua b/lua/doom/modules/lsp/binds.lua new file mode 100644 index 000000000..807c9a79f --- /dev/null +++ b/lua/doom/modules/lsp/binds.lua @@ -0,0 +1,88 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { + { "K", vim.lsp.buf.hover, name = "Show hover doc" }, + { "[d", vim.diagnostic.goto_prev, name = "Jump to prev diagnostic" }, + { "]d", vim.diagnostic.goto_next, name = "Jump to next diagnostic" }, + { + "g", + { + { "D", vim.lsp.buf.declaration, "Jump to declaration" }, + { "d", vim.lsp.buf.definition, name = "Jump to definition" }, + { "r", vim.lsp.buf.references, name = "Jump to references" }, + { "i", vim.lsp.buf.implementation, name = "Jump to implementation" }, + { "a", vim.lsp.buf.code_action, name = "Do code action" }, + }, + }, + { + "", vim.lsp.diagnostic.goto_prev, name = "Jump to prev diagnostic" }, + { "n>", vim.lsp.diagnostic.goto_next, name = "Jump to next diagnostic" }, + { "k>", vim.lsp.buf.signature_help, name = "Show signature help" }, + }, + }, +} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "c", + name = "+code", + { + { "r", vim.lsp.buf.rename, name = "Rename" }, + { "a", vim.lsp.buf.code_action, name = "Do action" }, + { "t", vim.lsp.buf.type_definition, name = "Jump to type" }, + { "D", vim.lsp.buf.declaration, "Jump to declaration" }, + { "d", vim.lsp.buf.definition, name = "Jump to definition" }, + { "R", vim.lsp.buf.references, name = "Jump to references" }, + { "i", vim.lsp.buf.implementation, name = "Jump to implementation" }, + { + "l", + name = "+lsp", + { + { "i", "LspInfo", name = "Inform" }, + { "r", "LspRestart", name = "Restart" }, + { "s", "LspStart", name = "Start" }, + { "d", "LspStop", name = "Disconnect" }, + }, + }, + { + "d", + name = "+diagnostics", + { + { "[", vim.diagnostic.goto_prev, name = "Jump to prev" }, + { "]", vim.diagnostic.goto_next, name = "Jump to next" }, + { "p", vim.diagnostic.goto_prev, name = "Jump to prev" }, + { "n", vim.diagnostic.goto_next, name = "Jump to next" }, + { + "L", + function() + vim.lsp.diagnostic.show_line_diagnostics({ + focusable = false, + border = doom.border_style, + }) + end, + name = "Line", + }, + { "l", vim.lsp.diagnostic.set_loclist, name = "Loclist" }, + }, + }, + }, + }, + { + "t", + name = "+tweak", + { + { "c", require("doom.core.functions").toggle_completion, name = "Toggle completion" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/lsp/init.lua b/lua/doom/modules/lsp/init.lua new file mode 100644 index 000000000..82c1ed059 --- /dev/null +++ b/lua/doom/modules/lsp/init.lua @@ -0,0 +1,280 @@ +local lsp = {} + +lsp.defaults = { + signature = { + bind = true, + doc_lines = 10, + floating_window = false, -- show hint in a floating window, set to false for virtual text only mode + floating_window_above_cur_line = true, + fix_pos = false, -- set to true, the floating window will not auto-close until finish all parameters + hint_enable = true, -- virtual hint enable + hint_prefix = " ", + hint_scheme = "String", + hi_parameter = "Search", -- how your parameter will be highlight + max_height = 12, -- max height of signature floating_window, if content is more than max_height, you can scroll down + max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width + transparency = 80, + extra_trigger_chars = {}, -- Array of extra characters that will trigger signature completion, e.g., {"(", ","} + zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom + debug = false, -- set to true to enable debug logging + padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc + shadow_blend = 36, -- if you using shadow as border use this set the opacity + shadow_guibg = "Black", -- if you using shadow as border use this set the color e.g. 'Green' or '#121315' + }, + dont_install = {}, + servers = { + lua = { "sumneko_lua" }, + ansible = { "ansiblels" }, + angular = { "angularls" }, + bash = { "bashls" }, + c_sharp = { "omnisharp" }, + c = { "clangd" }, + cpp = { "clangd" }, + cmake = { "cmake" }, + css = { "cssls" }, + clojure = { "clojure_lsp" }, + dockerfile = { "dockerls" }, + dot = { "dotls" }, + elixer = { "elixerls" }, + elm = { "elmls" }, + ember = { "ember" }, + fortran = { "fortls" }, + go = { "gopls" }, + graphql = { "graphql" }, + groovy = { "groovyls" }, + html = { "html" }, + haskel = { "hls" }, + json = { "jsonls" }, + json5 = { "jsonls" }, + java = { "jdtls" }, + javascript = { "tsserver" }, + kotlin = { "kotlin_language_server" }, + latex = { "texlab" }, + ocaml = { "ocamells" }, + php = { "phpactor" }, + powershell = { "powershell_es" }, + python = { "pyright" }, + ruby = { "solargraph" }, + rust = { "rust_analyzer" }, + svelte = { "svelte" }, + typescript = { "tsserver" }, + vim = { "vimls" }, + vue = { "vuels" }, + xml = { "lemminx" }, + yaml = { "yamlls" }, + }, + icons = { + error = "", + warn = "", + hint = "", + info = "", + }, + virtual_text = { + prefix = " ", + }, + completion = { + kinds = { + Text = " ", + Method = " ", + Function = " ", + Constructor = " ", + Field = "ﴲ ", + Variable = " ", + Class = " ", + Interface = "ﰮ ", + Module = " ", + Property = "ﰠ ", + Unit = " ", + Value = " ", + Enum = "練", + Keyword = " ", + Snippet = " ", + Color = " ", + File = " ", + Reference = " ", + Folder = " ", + EnumMember = " ", + Constant = "ﲀ ", + Struct = "ﳤ ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + completeopt = "menu,menuone,preview,noinsert", + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + sources = { + { name = "nvim_lua" }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer" }, + }, + }, +} + +lsp.packer_config = {} +lsp.packer_config["nvim-lspconfig"] = function() + -- Lsp Symbols + local signs, hl + if vim.fn.has("nvim-0.6.0") == 1 then + signs = { + Error = doom.lsp.icons.error, + Warn = doom.lsp.icons.warn, + Info = doom.lsp.icons.info, + Hint = doom.lsp.icons.hint, + } + hl = "DiagnosticSign" + else + signs = { + Error = doom.lsp.icons.error, + Warning = doom.lsp.icons.warn, + Information = doom.lsp.icons.info, + Hint = doom.lsp.icons.hint, + } + hl = "LspDiagnosticsSign" + end + + for severity, icon in pairs(signs) do + local highlight = hl .. severity + + vim.fn.sign_define(highlight, { + text = icon, + texthl = highlight, + numhl = highlight, + }) + end + + vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, + { + virtual_text = doom.lsp.virtual_text, + } + ) + -- Border for lsp_popups + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = doom.border_style, + }) + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = doom.border_style, + }) + -- symbols for autocomplete + local kinds = {} + for typ, icon in pairs(doom.lsp.completion.kinds) do + table.insert(kinds, " " .. icon .. " (" .. typ .. ") ") + end + vim.lsp.protocol.CompletionItemKind = kinds + + -- suppress error messages from lang servers + vim.notify = function(msg, log_level, _) + if msg:match("exit code") then + return + end + if log_level == vim.log.levels.ERROR then + vim.api.nvim_err_writeln(msg) + else + vim.api.nvim_echo({ { msg } }, true, {}) + end + end +end +lsp.packer_config["nvim-cmp"] = function() + local cmp = require("cmp") + local luasnip = require("luasnip") + local replace_termcodes = require("doom.utils").replace_termcodes + + local source_map = { + nvim_lsp = "[LSP]", + luasnip = "[Snp]", + buffer = "[Buf]", + nvim_lua = "[Lua]", + path = "[Path]", + } + + --- Helper function to check what behaviour to use + --- @return boolean + local function check_backspace() + local col = vim.fn.col(".") - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") + end + + -- Initalize the cmp toggle if it doesn't exist. + if _doom.cmp_enable == nil then + _doom.cmp_enable = true + end + + cmp.setup(vim.tbl_deep_extend("force", doom.lsp.completion, { + completeopt = nil, + completion = { + completeopt = doom.lsp.completion.completeopt, + }, + formatting = { + format = function(entry, item) + item.kind = string.format("%s %s", doom.lsp.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 + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + -- [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + 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") + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + vim.fn.feedkeys(replace_termcodes("luasnip-jump-prev"), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, + }, { + mapping = type(doom.lsp.completion.mapping) == "function" and doom.lsp.completion.mapping(cmp) + or doom.lsp.completion.mapping, + enabled = function() + return _doom.cmp_enable and vim.api.nvim_buf_get_option(0, "buftype") ~= "prompt" + end, + })) +end +lsp.packer_config["lsp_signature.nvim"] = function() + -- Signature help + require("lsp_signature").setup(vim.tbl_deep_extend("force", doom.lsp.signature, { + handler_opts = { + border = doom.border_style, + }, + })) +end + +return lsp diff --git a/lua/doom/modules/lsp/packages.lua b/lua/doom/modules/lsp/packages.lua new file mode 100644 index 000000000..b1ff6598c --- /dev/null +++ b/lua/doom/modules/lsp/packages.lua @@ -0,0 +1,52 @@ +local is_plugin_disabled = require("doom.utils").is_plugin_disabled + +return { + ["nvim-lspconfig"] = { + "neovim/nvim-lspconfig", + commit = "5dc61fa6bf837b91c4de2ed95ba6c840e47d25ac", + opt = true, + cmd = { + "LspStart", + "LspRestart", + "LspStop", + }, + module = "lspconfig", + }, + ["nvim-cmp"] = { + "hrsh7th/nvim-cmp", + commit = "2e4270d02843d15510b3549354e238788ca07ca5", + after = is_plugin_disabled("snippets") or "LuaSnip", + }, + ["cmp-nvim-lua"] = { + "hrsh7th/cmp-nvim-lua", + commit = "d276254e7198ab7d00f117e88e223b4bd8c02d21", + after = "nvim-cmp", + }, + ["cmp-nvim-lsp"] = { + "hrsh7th/cmp-nvim-lsp", + commit = "134117299ff9e34adde30a735cd8ca9cf8f3db81", + after = "nvim-cmp", + }, + ["cmp-path"] = { + "hrsh7th/cmp-path", + commit = "81518cf6ae29f5f0c79cd47770ae90ff5225ee13", + after = "nvim-cmp", + }, + ["cmp-buffer"] = { + "hrsh7th/cmp-buffer", + commit = "a706dc69c49110038fe570e5c9c33d6d4f67015b", + after = "nvim-cmp", + }, + ["cmp_luasnip"] = { + "saadparwaiz1/cmp_luasnip", + commit = "16832bb50e760223a403ffa3042859845dd9ef9d", + after = "nvim-cmp", + disabled = is_plugin_disabled("snippets"), + }, + ["lsp_signature.nvim"] = { + "ray-x/lsp_signature.nvim", + commit = "c7b2b2e14b597c077804ae201f1ec9a7dac76ad0", + after = "nvim-lspconfig", + opt = true, + }, +} diff --git a/lua/doom/modules/lua/autocmds.lua b/lua/doom/modules/lua/autocmds.lua new file mode 100644 index 000000000..eea8a87f3 --- /dev/null +++ b/lua/doom/modules/lua/autocmds.lua @@ -0,0 +1,12 @@ +local autocmds = { + { + "FileType", + "lua", + function() + dofile(vim.api.nvim_get_runtime_file("*/doom/modules/lua/config.lua", false)[1]) + end, + once = true, + }, +} + +return autocmds diff --git a/lua/doom/modules/lua/config.lua b/lua/doom/modules/lua/config.lua new file mode 100644 index 000000000..60237f4fe --- /dev/null +++ b/lua/doom/modules/lua/config.lua @@ -0,0 +1,52 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled +local lspconfig = require("lspconfig") + +local runtime_path = vim.split(package.path, ";") +table.insert(runtime_path, "lua/?.lua") +table.insert(runtime_path, "lua/?/init.lua") + +local config = vim.tbl_deep_extend("force", doom.lua, { + settings = { + Lua = { + runtime = { + path = runtime_path, + }, + }, + }, + capabilities = utils.get_capabilities(), + on_attach = function(client) + if not is_plugin_disabled("illuminate") then + utils.illuminate_attach(client) + end + if type(doom.lua.on_attach) == "function" then + doom.lua.on_attach(client) + end + end, +}) +local start_lsp = function() + lspconfig.sumneko_lua.setup(config) +end + +if not is_plugin_disabled("auto_install") then + local lsp_installer = require("nvim-lsp-installer.servers") + local server_available, server = lsp_installer.get_server("sumneko_lua") + if server_available then + config.cmd_env = server:get_default_options().cmd_env + if not server:is_installed() then + vim.defer_fn(function() + server:install() + end, 50) + end + + server:on_ready(function() + start_lsp() + end) + end +else + start_lsp() +end + +vim.defer_fn(function() + require("nvim-treesitter.install").ensure_installed("lua") +end, 0) diff --git a/lua/doom/modules/lua/init.lua b/lua/doom/modules/lua/init.lua new file mode 100644 index 000000000..11a2b4394 --- /dev/null +++ b/lua/doom/modules/lua/init.lua @@ -0,0 +1,34 @@ +local lua = {} + +lua.defaults = { + settings = { + Lua = { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + globals = { "vim", "doom" }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { + enable = false, + }, + }, + }, + dev = { + library = { + vimruntime = true, + types = true, + plugins = true, + }, + }, +} + +lua.packer_config = {} +lua.packer_config["lua-dev.nvim"] = function() + require("lua-dev").setup(doom.lua.dev) +end + +return lua diff --git a/lua/doom/modules/lua/packages.lua b/lua/doom/modules/lua/packages.lua new file mode 100644 index 000000000..294fa71bb --- /dev/null +++ b/lua/doom/modules/lua/packages.lua @@ -0,0 +1,7 @@ +return { + ["lua-dev.nvim"] = { + "folke/lua-dev.nvim", + commit = "6a7abb62af1b6a4411a3f5ea5cf0cb6b47878cc0", + ft = "lua", + }, +} diff --git a/lua/doom/modules/minimap/binds.lua b/lua/doom/modules/minimap/binds.lua new file mode 100644 index 000000000..29044122d --- /dev/null +++ b/lua/doom/modules/minimap/binds.lua @@ -0,0 +1,23 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { + { "", ":MinimapToggle", name = "Toggle minimap" }, +} +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "m", "MinimapToggle", name = "Minimap" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/minimap/init.lua b/lua/doom/modules/minimap/init.lua new file mode 100644 index 000000000..c4c33500f --- /dev/null +++ b/lua/doom/modules/minimap/init.lua @@ -0,0 +1,7 @@ +local minimap = {} + +minimap.defaults = {} + +minimap.packer_config = {} + +return minimap diff --git a/lua/doom/modules/minimap/packages.lua b/lua/doom/modules/minimap/packages.lua new file mode 100644 index 000000000..43374887b --- /dev/null +++ b/lua/doom/modules/minimap/packages.lua @@ -0,0 +1,14 @@ +return { + ["minimap.vim"] = { + "wfxr/minimap.vim", + commit = "35c0dd759938459d866aba1bdf0f1fc0b670ed61", + opt = true, + cmd = { + "Minimap", + "MinimapClose", + "MinimapToggle", + "MinimapRefresh", + "MinimapUpdateHighlight", + }, + }, +} diff --git a/lua/doom/modules/neogit/binds.lua b/lua/doom/modules/neogit/binds.lua new file mode 100644 index 000000000..3f44d2662 --- /dev/null +++ b/lua/doom/modules/neogit/binds.lua @@ -0,0 +1,29 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "g", "Neogit", name = "Neogit" }, + }, + }, + { + "g", + name = "+git", + { + { "g", "Neogit", name = "Open neogit" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/neogit/init.lua b/lua/doom/modules/neogit/init.lua new file mode 100644 index 000000000..82bbffa40 --- /dev/null +++ b/lua/doom/modules/neogit/init.lua @@ -0,0 +1,10 @@ +local neogit = {} + +neogit.defaults = {} + +neogit.packer_config = {} +neogit.packer_config["neogit"] = function() + require("neogit").setup(doom.neogit) +end + +return neogit diff --git a/lua/doom/modules/neogit/packages.lua b/lua/doom/modules/neogit/packages.lua new file mode 100644 index 000000000..a97aee0d8 --- /dev/null +++ b/lua/doom/modules/neogit/packages.lua @@ -0,0 +1,8 @@ +return { + ["neogit"] = { + "TimUntersberger/neogit", + commit = "ab772d21b108127ad6c703f7457c279f5817f379", + cmd = "Neogit", + opt = true, + }, +} diff --git a/lua/doom/modules/neorg/init.lua b/lua/doom/modules/neorg/init.lua new file mode 100644 index 000000000..abff0b12a --- /dev/null +++ b/lua/doom/modules/neorg/init.lua @@ -0,0 +1,37 @@ +local neorg = {} + +local doom_root = require("doom.core.system").doom_root + +neorg.defaults = { + load = { + ["core.defaults"] = {}, + ["core.keybinds"] = { + config = { + default_keybinds = true, + neorg_leader = ",o", + }, + }, + ["core.norg.concealer"] = {}, + ["core.norg.dirman"] = { + config = { + workspaces = { + default_workspace = "~/neorg", + gtd = "~/neorg/gtd", + doom_docs = string.format("%s/doc", doom_root), + }, + }, + }, + ["core.gtd.base"] = { + config = { + workspace = "gtd", + }, + }, + }, +} + +neorg.packer_config = {} +neorg.packer_config["neorg"] = function() + require("neorg").setup(doom.neorg) +end + +return neorg diff --git a/lua/doom/modules/neorg/packages.lua b/lua/doom/modules/neorg/packages.lua new file mode 100644 index 000000000..e1f77f728 --- /dev/null +++ b/lua/doom/modules/neorg/packages.lua @@ -0,0 +1,8 @@ +return { + ["neorg"] = { + "nvim-neorg/neorg", + --[[NO AUTO UPDATE]] + commit = "139ee79ae7a8a2590baacfeb56cea1ba23b07c55", + after = { "nvim-treesitter" }, + }, +} diff --git a/lua/doom/modules/range_highlight/init.lua b/lua/doom/modules/range_highlight/init.lua new file mode 100644 index 000000000..163da788b --- /dev/null +++ b/lua/doom/modules/range_highlight/init.lua @@ -0,0 +1,10 @@ +local range_highlight = {} + +range_highlight.defaults = {} + +range_highlight.packer_config = {} +range_highlight.packer_config["range-highlight.nvim"] = function() + require("range-highlight").setup(doom.range_highlight) +end + +return range_highlight diff --git a/lua/doom/modules/range_highlight/packages.lua b/lua/doom/modules/range_highlight/packages.lua new file mode 100644 index 000000000..00f4bb18c --- /dev/null +++ b/lua/doom/modules/range_highlight/packages.lua @@ -0,0 +1,10 @@ +return { + ["range-highlight.nvim"] = { + "winston0410/range-highlight.nvim", + commit = "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9", + requires = { + { "winston0410/cmd-parser.nvim", module = "cmd-parser" }, + }, + event = "BufReadPre", + }, +} diff --git a/lua/doom/modules/ranger/binds.lua b/lua/doom/modules/ranger/binds.lua new file mode 100644 index 000000000..702156549 --- /dev/null +++ b/lua/doom/modules/ranger/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "r", "Ranger", name = "Ranger" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/ranger/init.lua b/lua/doom/modules/ranger/init.lua new file mode 100644 index 000000000..ac4a6ae8f --- /dev/null +++ b/lua/doom/modules/ranger/init.lua @@ -0,0 +1,7 @@ +local ranger = {} + +ranger.defaults = {} + +ranger.packer_config = {} + +return ranger diff --git a/lua/doom/modules/ranger/packages.lua b/lua/doom/modules/ranger/packages.lua new file mode 100644 index 000000000..fd0114438 --- /dev/null +++ b/lua/doom/modules/ranger/packages.lua @@ -0,0 +1,16 @@ +return { + ["ranger.vim"] = { + "francoiscabrol/ranger.vim", + commit = "91e82debdf566dfaf47df3aef0a5fd823cedf41c", + requires = { + { "rbgrouleff/bclose.vim", opt = true }, + }, + opt = true, + cmd = { + "Ranger", + "RangerNewTab", + "RangerWorkingDirectory", + "RangerWorkingDirectoryNewTab", + }, + }, +} diff --git a/lua/doom/modules/restclient/binds.lua b/lua/doom/modules/restclient/binds.lua new file mode 100644 index 000000000..bbc81e6c3 --- /dev/null +++ b/lua/doom/modules/restclient/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { "", "RestNvim", name = "Open http client" } + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "h", "RestNvim", name = "Http" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/restclient/init.lua b/lua/doom/modules/restclient/init.lua new file mode 100644 index 000000000..97fdf804a --- /dev/null +++ b/lua/doom/modules/restclient/init.lua @@ -0,0 +1,10 @@ +local restclient = {} + +restclient.defaults = {} + +restclient.packer_config = {} +restclient.packer_config["rest.nvim"] = function() + require("rest-nvim").setup(doom.restclient) +end + +return restclient diff --git a/lua/doom/modules/restclient/packages.lua b/lua/doom/modules/restclient/packages.lua new file mode 100644 index 000000000..41e2e0e75 --- /dev/null +++ b/lua/doom/modules/restclient/packages.lua @@ -0,0 +1,11 @@ +return { + ["rest.nvim"] = { + "NTBBloodbath/rest.nvim", + commit = "e1c34175ee0b2293e8b9c06c11f2fc63f4262918", + cmd = { + "RestNvim", + "RestNvimPreview", + "RestNvimLast", + }, + }, +} diff --git a/lua/doom/modules/show_registers/init.lua b/lua/doom/modules/show_registers/init.lua new file mode 100644 index 000000000..75e2f632c --- /dev/null +++ b/lua/doom/modules/show_registers/init.lua @@ -0,0 +1,7 @@ +local show_registers = {} + +show_registers.defaults = {} + +show_registers.packer_config = {} + +return show_registers diff --git a/lua/doom/modules/show_registers/packages.lua b/lua/doom/modules/show_registers/packages.lua new file mode 100644 index 000000000..a295002de --- /dev/null +++ b/lua/doom/modules/show_registers/packages.lua @@ -0,0 +1,7 @@ +return { + ["registers.nvim"] = { + "tversteeg/registers.nvim", + commit = "4d1f3525c6f9be4297e99e6aed515af3677d7241", + opt = true, + }, +} diff --git a/lua/doom/modules/snippets/binds.lua b/lua/doom/modules/snippets/binds.lua new file mode 100644 index 000000000..87c581247 --- /dev/null +++ b/lua/doom/modules/snippets/binds.lua @@ -0,0 +1,53 @@ +local binds = { + { + "", + [[luasnip#expand_or_jumpable() ? "luasnip-expand-or-jump" : ""]], + name = "Expand snippet", + }, + { + mode = "i", + { + { + "", + function() + require("luasnip").jump(1) + end, + name = "Next snippet section", + }, + }, + }, + { + mode = "s", + { + { + "", + function() + require("luasnip").jump(-1) + end, + name = "Previous snippet section", + }, + }, + }, + { + mode = "i", + { + { + "", + [[luasnip#choice_active() ? "luasnip-next-choice" : ""]], + name = "Next snippet field", + }, + }, + }, + { + mode = "s", + { + { + "", + [[luasnip#choice_active() ? "luasnip-next-choice" : ""]], + name = "Next snippet field", + }, + }, + }, +} + +return binds diff --git a/lua/doom/modules/snippets/init.lua b/lua/doom/modules/snippets/init.lua new file mode 100644 index 000000000..0bbe3fe65 --- /dev/null +++ b/lua/doom/modules/snippets/init.lua @@ -0,0 +1,14 @@ +local snippets = {} + +snippets.defaults = { + history = true, + updateevents = "TextChanged,TextChangedI", +} + +snippets.packer_config = {} +snippets.packer_config["LuaSnip"] = function() + require("luasnip").config.set_config(doom.snippets) + require("luasnip.loaders.from_vscode").load() +end + +return snippets diff --git a/lua/doom/modules/snippets/packages.lua b/lua/doom/modules/snippets/packages.lua new file mode 100644 index 000000000..d5866738d --- /dev/null +++ b/lua/doom/modules/snippets/packages.lua @@ -0,0 +1,8 @@ +return { + ["LuaSnip"] = { + "L3MON4D3/LuaSnip", + commit = "a54b21aee0423dbdce121c858ad6a88a58ef6e0f", + requires = { "rafamadriz/friendly-snippets", opt = true }, + event = "InsertEnter", + }, +} diff --git a/lua/doom/modules/statusline/init.lua b/lua/doom/modules/statusline/init.lua new file mode 100644 index 000000000..812c12628 --- /dev/null +++ b/lua/doom/modules/statusline/init.lua @@ -0,0 +1,328 @@ +local statusline = {} + +statusline.defaults = { + short_line_list = { + "NvimTree", + "packer", + "minimap", + "Outline", + "toggleterm", + "netrw", + }, + on_dashboard = true, + show_file_path = true, + sections = {}, +} + +statusline.packer_config = {} +statusline.packer_config["galaxyline.nvim"] = function() + local utils = require("doom.utils") + local is_plugin_disabled = utils.is_plugin_disabled + + local gl = require("galaxyline") + local colors = require("galaxyline.themes.colors").get_color + local lsp = require("galaxyline.providers.lsp") + local buffer = require("galaxyline.providers.buffer") + local condition = require("galaxyline.condition") + local gls = gl.section + + local function is_dashboard() + local buftype = buffer.get_buffer_filetype() + return buftype == "DASHBOARD" + end + + local function is_not_dashboard() + local buftype = buffer.get_buffer_filetype() + return buftype ~= "DASHBOARD" + end + + gl.short_line_list = doom.statusline.short_line_list + + if not is_plugin_disabled("dashboard") and not doom.statusline.on_dashboard then + table.insert(gl.exclude_filetypes, "dashboard") + end + + local default_sections = { + short_left = { + { + ShortRainbowLeft = { + provider = function() + return "▊ " + end, + highlight = { colors("blue"), colors("bg") }, + }, + }, + { + BufferType = { + provider = "FileTypeName", + condition = is_not_dashboard, + highlight = { colors("fg"), colors("bg") }, + }, + }, + }, + left = { + { + RainbowLeft = { + provider = function() + return "▊ " + end, + highlight = { colors("blue"), colors("bg") }, + }, + }, + { + ViMode = { + provider = function() + -- auto change color according the vim mode + -- TODO: find a less dirty way to set ViMode colors + local mode_color = { + n = colors("red"), + i = colors("green"), + v = colors("blue"), + [""] = colors("blue"), + V = colors("blue"), + c = colors("magenta"), + no = colors("red"), + s = colors("orange"), + S = colors("orange"), + [""] = colors("orange"), + ic = colors("yellow"), + R = colors("magenta"), + Rv = colors("magenta"), + cv = colors("red"), + ce = colors("red"), + r = colors("cyan"), + rm = colors("cyan"), + ["r?"] = colors("cyan"), + ["!"] = colors("red"), + t = colors("red"), + } + vim.api.nvim_command("hi GalaxyViMode guifg=" .. mode_color[vim.fn.mode()]()) + return " " + end, + highlight = { colors("red"), colors("bg"), "bold" }, + }, + }, + { + FileSize = { + provider = "FileSize", + condition = condition.buffer_not_empty and condition.hide_in_width, + highlight = { + colors("fg"), + colors("bg"), + }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + FileIcon = { + provider = "FileIcon", + condition = condition.buffer_not_empty and is_not_dashboard, + highlight = { + require("galaxyline.providers.fileinfo").get_file_icon_color, + colors("bg"), + }, + }, + }, + { + FileName = { + provider = doom.statusline.show_file_path and "FilePath" or "FileName", + condition = condition.buffer_not_empty and is_not_dashboard, + highlight = { colors("fg"), colors("bg"), "bold" }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + LineInfo = { + provider = function() + local line = vim.fn.line(".") + local column = vim.fn.col(".") + return string.format("%3d : %2d ", line, column) + end, + condition = is_not_dashboard, + highlight = { colors("fg_alt"), colors("bg") }, + }, + }, + { + LinePercent = { + provider = "LinePercent", + condition = is_not_dashboard, + highlight = { colors("fg_alt"), colors("bg") }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + }, + short_right = { + { + BufferIcon = { + provider = "BufferIcon", + condition = is_not_dashboard, + highlight = { colors("yellow"), colors("bg") }, + }, + }, + { + ShortRainbowRight = { + provider = function() + return " ▊" + end, + highlight = { colors("blue"), colors("bg") }, + }, + }, + }, + right = { + { + FileFormat = { + provider = "FileFormat", + condition = condition.hide_in_width and is_not_dashboard, + highlight = { colors("fg"), colors("bg") }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + FileEncode = { + provider = "FileEncode", + condition = condition.hide_in_width and is_not_dashboard, + highlight = { colors("fg"), colors("bg") }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + ShowLspClientOrFileType = { + provider = function() + -- Check if there's a LSP client running to avoid redundant + -- statusline elements + if lsp.get_lsp_client() ~= "No Active Lsp" then + return string.format(" %s » %s ", vim.bo.filetype, lsp.get_lsp_client()) + else + -- Use the filetype instead + return string.format(" %s ", vim.bo.filetype) + end + end, + condition = function() + local tbl = { ["dashboard"] = true, [""] = true } + if tbl[vim.bo.filetype] then + return false + end + return true + end, + highlight = { colors("blue"), colors("bg") }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + GitIcon = { + provider = function() + return " " + end, + condition = condition.check_git_workspace, + highlight = { colors("red"), colors("bg") }, + separator = " ", + separator_highlight = { colors("bg"), colors("bg") }, + }, + }, + { + GitBranch = { + provider = "GitBranch", + condition = condition.check_git_workspace, + highlight = { colors("green"), colors("bg"), "bold" }, + }, + }, + { + DiffSeparator = { + provider = function() + return " " + end, + condition = condition.hide_in_width, + highlight = { colors("bg"), colors("bg") }, + }, + }, + { + DiffAdd = { + provider = "DiffAdd", + condition = condition.hide_in_width, + icon = " ", + highlight = { colors("green"), colors("bg") }, + }, + }, + { + DiffModified = { + provider = "DiffModified", + condition = condition.hide_in_width, + icon = " ", + highlight = { colors("orange"), colors("bg") }, + }, + }, + { + DiffRemove = { + provider = "DiffRemove", + condition = condition.hide_in_width, + icon = " ", + highlight = { colors("red"), colors("bg") }, + }, + }, + }, + { + DoomVersion = { + provider = function() + return "DOOM v" .. utils.doom_version .. " " + end, + condition = is_dashboard, + highlight = { colors("blue"), colors("bg"), "bold" }, + separator = " ", + separator_highlight = { + colors("bg"), + colors("bg"), + }, + }, + }, + { + RainbowRight = { + provider = function() + return " ▊" + end, + highlight = { colors("blue"), colors("bg") }, + }, + }, + } + + if not is_plugin_disabled("lsp") then + table.insert(default_sections.left, { + DiagnosticError = { + provider = "DiagnosticError", + condition = is_not_dashboard, + icon = doom.lsp.icons.error .. " ", + highlight = { colors("red"), colors("bg") }, + }, + }) + table.insert(default_sections.left, { + DiagnosticWarn = { + provider = "DiagnosticWarn", + condition = is_not_dashboard, + icon = doom.lsp.icons.warn .. " ", + highlight = { colors("orange"), colors("bg") }, + }, + }) + table.insert(default_sections.left, { + DiagnosticInfo = { + provider = "DiagnosticInfo", + condition = is_not_dashboard, + icon = doom.lsp.icons.hint .. " ", + highlight = { colors("blue"), colors("bg") }, + }, + }) + end + + local merged_sections = vim.tbl_extend("force", default_sections, doom.statusline.sections) + + gls.left = merged_sections.left + gls.right = merged_sections.right + gls.short_line_left = merged_sections.short_left + gls.short_line_right = merged_sections.short_right +end + +return statusline diff --git a/lua/doom/modules/statusline/packages.lua b/lua/doom/modules/statusline/packages.lua new file mode 100644 index 000000000..f19b26055 --- /dev/null +++ b/lua/doom/modules/statusline/packages.lua @@ -0,0 +1,6 @@ +return { + ["galaxyline.nvim"] = { + "NTBBloodbath/galaxyline.nvim", + commit = "7b812cfddfcac7d9031e2f8e03f2b71fe8b2558d", + }, +} diff --git a/lua/doom/modules/suda/binds.lua b/lua/doom/modules/suda/binds.lua new file mode 100644 index 000000000..2df19d333 --- /dev/null +++ b/lua/doom/modules/suda/binds.lua @@ -0,0 +1,23 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "f", + name = "+file", + { + { "R", "SudaRead", name = "Read with sudo" }, + { "W", "SudaWrite", name = "Write with sudo" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/suda/init.lua b/lua/doom/modules/suda/init.lua new file mode 100644 index 000000000..6b10a2a6e --- /dev/null +++ b/lua/doom/modules/suda/init.lua @@ -0,0 +1,7 @@ +local suda = {} + +suda.defaults = {} + +suda.packer_config = {} + +return suda diff --git a/lua/doom/modules/suda/packages.lua b/lua/doom/modules/suda/packages.lua new file mode 100644 index 000000000..59dbab26c --- /dev/null +++ b/lua/doom/modules/suda/packages.lua @@ -0,0 +1,8 @@ +return { + ["suda.vim"] = { + "lambdalisue/suda.vim", + commit = "0290c93c148a14eab2b661a1933003d86436f6ec", + opt = true, + cmd = { "SudaRead", "SudaWrite" }, + }, +} diff --git a/lua/doom/modules/superman/init.lua b/lua/doom/modules/superman/init.lua new file mode 100644 index 000000000..cd30d3648 --- /dev/null +++ b/lua/doom/modules/superman/init.lua @@ -0,0 +1,7 @@ +local superman = {} + +superman.defaults = {} + +superman.packer_config = {} + +return superman diff --git a/lua/doom/modules/superman/packages.lua b/lua/doom/modules/superman/packages.lua new file mode 100644 index 000000000..7b7b7fe81 --- /dev/null +++ b/lua/doom/modules/superman/packages.lua @@ -0,0 +1,8 @@ +return { + ["vim-superman"] = { + "jez/vim-superman", + commit = "19d307446576d9118625c5d9d3c7a4c9bec5571a", + cmd = "SuperMan", + opt = true, + }, +} diff --git a/lua/doom/modules/symbols/binds.lua b/lua/doom/modules/symbols/binds.lua new file mode 100644 index 000000000..cd05e1d2f --- /dev/null +++ b/lua/doom/modules/symbols/binds.lua @@ -0,0 +1,24 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = { + { "", ":SymbolsOutline", name = "Toggle symbols outline" }, +} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "c", "SymbolsOutline", name = "Symbol outline" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/symbols/init.lua b/lua/doom/modules/symbols/init.lua new file mode 100644 index 000000000..dd4eb29aa --- /dev/null +++ b/lua/doom/modules/symbols/init.lua @@ -0,0 +1,24 @@ +local symbols = {} + +symbols.defaults = { + highlight_hovered_item = true, + show_guides = true, + position = "right", + keymaps = { + close = "", + goto_location = "", + focus_location = "o", + hover_symbol = "", + rename_symbol = "r", + code_actions = "a", + }, + lsp_blacklist = {}, + width = 25, +} + +symbols.packer_config = {} +symbols.packer_config["symbols_outline.nvim"] = function() + vim.g.symbols_outline = doom.symbols +end + +return symbols diff --git a/lua/doom/modules/symbols/packages.lua b/lua/doom/modules/symbols/packages.lua new file mode 100644 index 000000000..567bcf82b --- /dev/null +++ b/lua/doom/modules/symbols/packages.lua @@ -0,0 +1,12 @@ +return { + ["symbols-outline.nvim"] = { + "simrat39/symbols-outline.nvim", + commit = "552b67993ed959993279e0b0f8a1da9f3c5e6fc0", + cmd = { + "SymbolsOutline", + "SymbolsOutlineOpen", + "SymbolsOutlineClose", + }, + opt = true, + }, +} diff --git a/lua/doom/modules/tabline/binds.lua b/lua/doom/modules/tabline/binds.lua new file mode 100644 index 000000000..ebad67f3b --- /dev/null +++ b/lua/doom/modules/tabline/binds.lua @@ -0,0 +1,49 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "b", + name = "+buffer", + { + { + "n", + function() + require("bufferline").cycle(1) + end, + name = "Jump to next", + }, + { + "]", + function() + require("bufferline").cycle(1) + end, + name = "Jump to next", + }, + { + "p", + function() + require("bufferline").cycle(-1) + end, + name = "Jump to prev", + }, + { + "[", + function() + require("bufferline").cycle(-1) + end, + name = "Jump to prev", + }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/tabline/init.lua b/lua/doom/modules/tabline/init.lua new file mode 100644 index 000000000..43d1428b0 --- /dev/null +++ b/lua/doom/modules/tabline/init.lua @@ -0,0 +1,147 @@ +local tabline = {} + +local utils_g = require("doom.utils") + +tabline.defaults = { + options = { + numbers = function(opts) + return string.format("%s", opts.id) + end, + indicator_icon = "▎", + buffer_close_icon = "", + modified_icon = "●", + close_icon = "", + left_trunc_marker = "", + right_trunc_marker = "", + max_name_length = 20, + max_prefix_length = 15, -- prefix used when a buffer is de-duplicated + tab_size = 25, + diagnostics = "nvim_lsp", + diagnostics_indicator = function(_, _, diagnostics_dict, _) + local s = " " + for e, n in pairs(diagnostics_dict) do + local sym = e == "error" and "  " or (e == "warning" and "  " or "  ") + s = s .. n .. sym + end + return s + end, + -- NOTE: this will be called a lot so don't do any heavy processing here + custom_filter = function(buf_number) + if vim.bo[buf_number].filetype ~= "dashboard" then + return true + end + end, + groups = { + options = { + toggle_hidden_on_enter = true, -- when you re-enter a hidden group this options re-opens that group so the buffer is visible + }, + items = { + { + name = "Tests", + auto_close = true, + matcher = function(buf) + return buf.filename:match("%_test") or buf.filename:match("%_spec") + end, + }, + { + name = "Docs", + auto_close = true, + matcher = function(buf) + return buf.filename:match("%.md") or buf.filename:match("%.txt") + end, + }, + { + name = "Doom", + auto_close = true, + matcher = function(buf) + if buf.filename:find("doom_") or buf.filename:find("doom-", 1, true) then + return true + end + return false + end, + }, + }, + }, + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + text_align = "center", + }, + { + filetype = "netrw", + text = "File Explorer", + text_align = "center", + }, + { + filetype = "minimap", + text = "Minimap", + text_align = "center", + }, + { + filetype = "Outline", + text = "Symbols", + text_align = "center", + }, + { + filetype = "packer", + text = "Plugins manager", + text_align = "center", + }, + }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = false, + show_tab_indicators = true, + persist_buffer_sort = true, + separator_style = "thick", + enforce_regular_tabs = true, + always_show_bufferline = false, + sort_by = "directory", + custom_areas = { + right = function() + local result = {} + local error = utils_g.get_diagnostic_count(0, [[Error]]) + local warning = utils_g.get_diagnostic_count(0, [[Warning]]) + local info = utils_g.get_diagnostic_count(0, [[Information]]) + local hint = utils_g.get_diagnostic_count(0, [[Hint]]) + + if error ~= 0 then + result[1] = { + text = "  " .. error, + guifg = "#ff6c6b", + } + end + + if warning ~= 0 then + result[2] = { + text = "  " .. warning, + guifg = "#ECBE7B", + } + end + + if hint ~= 0 then + result[3] = { + text = "  " .. hint, + guifg = "#98be65", + } + end + + if info ~= 0 then + result[4] = { + text = "  " .. info, + guifg = "#51afef", + } + end + return result + end, + }, + }, +} + +tabline.packer_config = {} +tabline.packer_config["bufferline.nvim"] = function() + require("bufferline").setup(doom.tabline) +end + +return tabline diff --git a/lua/doom/modules/tabline/packages.lua b/lua/doom/modules/tabline/packages.lua new file mode 100644 index 000000000..a3de53efd --- /dev/null +++ b/lua/doom/modules/tabline/packages.lua @@ -0,0 +1,7 @@ +return { + ["bufferline.nvim"] = { + "akinsho/bufferline.nvim", + commit = "463637a3ac86dcaacbcd47aa608f53aaad749696", + event = "BufAdd", + }, +} diff --git a/lua/doom/modules/telescope/autocmds.lua b/lua/doom/modules/telescope/autocmds.lua new file mode 100644 index 000000000..4a741cb72 --- /dev/null +++ b/lua/doom/modules/telescope/autocmds.lua @@ -0,0 +1,5 @@ +local autocmds = { + { "User", "TelescopePreviewerLoaded", "setlocal wrap" }, +} + +return autocmds diff --git a/lua/doom/modules/telescope/binds.lua b/lua/doom/modules/telescope/binds.lua new file mode 100644 index 000000000..4ce9cc1ae --- /dev/null +++ b/lua/doom/modules/telescope/binds.lua @@ -0,0 +1,98 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "`", + function() + require("telescope.builtin").find_files({ cwd = vim.fn.expand("%:p:n") }) + end, + name = "Browse cwd", + }, + { ".", "Telescope file_browser", name = "Browse project" }, + { ",", "Telescope buffers", name = "Search buffers" }, + { "/", "Telescope live_grep", name = "Search text" }, + { ":", "Telescope command_history", name = "Search recent commands" }, + { + "b", + name = "+buffer", + { + { "f", "Telescope buffers show_all_buffers=true", name = "Find from all" }, + { "s", "Telescope current_buffer_fuzzy_find", name = "Search text" }, + }, + }, + { + "f", + name = "+file", + { + { "f", "Telescope find_files", name = "Find in project" }, + { "r", "Telescope oldfiles", name = "Find recent" }, + }, + }, + { + "h", + name = "+help", + { + { "t", "Telescope help_tags", name = "Find tags" }, + { "k", "Telescope mapper", name = "Open keybindings" }, + }, + }, + { + "g", + name = "+git", + { + { "s", "Telescope git_status", name = "Status" }, + { "b", "Telescope git_branches", name = "Branches" }, + { "c", "Telescope git_commits", name = "Commits" }, + }, + }, + { + "s", + name = "+search", + { + { "t", "Telescope live_grep", name = "Search text" }, + { "b", "Telescope current_buffer_fuzzy_find", name = "Text in buffer" }, + { "h", "Telescope command_history", name = "Recent commands" }, + { "m", "Telescope marks", name = "Marks" }, + }, + }, + { + "t", + name = "+tweak", + { + { + "C", + function() + require("telescope.builtin.internal").colorscheme({ enable_preview = true }) + end, + name = "Switch colorscheme", + }, + }, + }, + }, + }) + + if not is_plugin_disabled("lsp") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "c", + name = "+code", + { + { "s", "Telescope lsp_document_symbols", name = "Lsp symbols" }, + }, + }, + }, + }) + end +end + +return binds diff --git a/lua/doom/modules/telescope/init.lua b/lua/doom/modules/telescope/init.lua new file mode 100644 index 000000000..899c22de3 --- /dev/null +++ b/lua/doom/modules/telescope/init.lua @@ -0,0 +1,85 @@ +local telescope = {} + +telescope.defaults = { + defaults = { + find_command = { + "rg", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + initial_mode = "insert", + selection_strategy = "reset", + sorting_strategy = "descending", + layout_strategy = "horizontal", + prompt_prefix = "  ", + selection_caret = " ", + layout_config = { + width = 0.75, + preview_cutoff = 120, + prompt_position = "bottom", + vertical = { mirror = false }, + horizontal = { + mirror = false, + preview_width = 0.6, + }, + }, + file_ignore_patterns = { "^%.git/", "^node_modules/", "^__pycache__/" }, + winblend = 0, + scroll_strategy = "cycle", + border = {}, + borderchars = { + "─", + "│", + "─", + "│", + "╭", + "╮", + "╯", + "╰", + }, + color_devicons = true, + use_less = true, + set_env = { ["COLORTERM"] = "truecolor" }, -- default = nil, + }, + extensions = { "mapper" }, +} + +telescope.packer_config = {} +telescope.packer_config["telescope.nvim"] = function() + local telescope_package = require("telescope") + local actions = require("telescope.actions") + + telescope_package.setup(vim.tbl_deep_extend("force", { + defaults = { + file_sorter = require("telescope.sorters").get_fuzzy_file, + generic_sorter = require("telescope.sorters").get_generic_fuzzy_sorter, + file_previewer = require("telescope.previewers").vim_buffer_cat.new, + grep_previewer = require("telescope.previewers").vim_buffer_vimgrep.new, + qflist_previewer = require("telescope.previewers").vim_buffer_qflist.new, + buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, + mappings = { + i = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + ["f"] = actions.close, -- works like a toggle, sometimes can be buggy + [""] = actions.select_default + actions.center, + }, + n = { + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + [""] = actions.smart_send_to_qflist + actions.open_qflist, + }, + }, + }, + }, doom.telescope)) + + for _, ext in ipairs(doom.telescope.extensions) do + telescope_package.load_extension(ext) + end +end + +return telescope diff --git a/lua/doom/modules/telescope/packages.lua b/lua/doom/modules/telescope/packages.lua new file mode 100644 index 000000000..4c6ab4950 --- /dev/null +++ b/lua/doom/modules/telescope/packages.lua @@ -0,0 +1,8 @@ +return { + ["telescope.nvim"] = { + "nvim-telescope/telescope.nvim", + commit = "1c57cc6140644695f0d9bd71b63de45feeca6ae7", + cmd = "Telescope", + opt = true, + }, +} diff --git a/lua/doom/modules/terminal/binds.lua b/lua/doom/modules/terminal/binds.lua new file mode 100644 index 000000000..7c898c7ab --- /dev/null +++ b/lua/doom/modules/terminal/binds.lua @@ -0,0 +1,22 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "t", "ToggleTerm", name = "Terminal" }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/terminal/init.lua b/lua/doom/modules/terminal/init.lua new file mode 100644 index 000000000..05749d9e3 --- /dev/null +++ b/lua/doom/modules/terminal/init.lua @@ -0,0 +1,30 @@ +local terminal = {} + +terminal.defaults = { + size = 10, + open_mapping = "", + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = true, + start_in_insert = true, + persist_size = true, + direction = "horizontal", + close_on_exit = true, + float_opts = { + border = "curved", + width = 70, + height = 20, + winblend = 0, + highlights = { + border = "Special", + background = "Normal", + }, + }, +} + +terminal.packer_config = {} +terminal.packer_config["toggleterm.nvim"] = function() + require("toggleterm").setup(doom.terminal) +end + +return terminal diff --git a/lua/doom/modules/terminal/packages.lua b/lua/doom/modules/terminal/packages.lua new file mode 100644 index 000000000..d9f7e1d66 --- /dev/null +++ b/lua/doom/modules/terminal/packages.lua @@ -0,0 +1,8 @@ +return { + ["toggleterm.nvim"] = { + "akinsho/toggleterm.nvim", + commit = "265bbff68fbb8b2a5fb011272ec469850254ec9f", + cmd = { "ToggleTerm", "TermExec" }, + opt = true, + }, +} diff --git a/lua/doom/modules/todo_comments/init.lua b/lua/doom/modules/todo_comments/init.lua new file mode 100644 index 000000000..801df6132 --- /dev/null +++ b/lua/doom/modules/todo_comments/init.lua @@ -0,0 +1,10 @@ +local todo_comments = {} + +todo_comments.defaults = {} + +todo_comments.packer_config = {} +todo_comments.packer_config["todo-comments.nvim"] = function() + require("todo-comments").setup(doom.todo_comments) +end + +return todo_comments diff --git a/lua/doom/modules/todo_comments/packages.lua b/lua/doom/modules/todo_comments/packages.lua new file mode 100644 index 000000000..d7d0e0258 --- /dev/null +++ b/lua/doom/modules/todo_comments/packages.lua @@ -0,0 +1,7 @@ +return { + ["todo-comments.nvim"] = { + "folke/todo-comments.nvim", + commit = "9983edc5ef38c7a035c17c85f60ee13dbd75dcc8", + event = "ColorScheme", + }, +} diff --git a/lua/doom/modules/trouble/binds.lua b/lua/doom/modules/trouble/binds.lua new file mode 100644 index 000000000..f1f19a33f --- /dev/null +++ b/lua/doom/modules/trouble/binds.lua @@ -0,0 +1,36 @@ +local utils = require("doom.utils") +local is_plugin_disabled = utils.is_plugin_disabled + +local binds = {} + +if not is_plugin_disabled("whichkey") then + table.insert(binds, { + "", + name = "+prefix", + { + { + "o", + name = "+open/close", + { + { "T", "TroubleToggle", name = "Trouble" }, + }, + }, + { + "c", + name = "+code", + { + { "e", "TroubleToggle", name = "Open trouble" }, + { + "d", + name = "+diagnostics", + { + { "t", "TroubleToggle", name = "Trouble" }, + }, + }, + }, + }, + }, + }) +end + +return binds diff --git a/lua/doom/modules/trouble/init.lua b/lua/doom/modules/trouble/init.lua new file mode 100644 index 000000000..b23ec7550 --- /dev/null +++ b/lua/doom/modules/trouble/init.lua @@ -0,0 +1,10 @@ +local trouble = {} + +trouble.defaults = {} + +trouble.packer_config = {} +trouble.packer_config["trouble.nvim"] = function() + require("trouble").setup(doom.trouble) +end + +return trouble diff --git a/lua/doom/modules/trouble/packages.lua b/lua/doom/modules/trouble/packages.lua new file mode 100644 index 000000000..b8bbc2f64 --- /dev/null +++ b/lua/doom/modules/trouble/packages.lua @@ -0,0 +1,8 @@ +return { + ["trouble.nvim"] = { + "folke/trouble.nvim", + commit = "756f09de113a775ab16ba6d26c090616b40a999d", + cmd = { "Trouble", "TroubleClose", "TroubleRefresh", "TroubleToggle" }, + opt = true, + }, +} diff --git a/lua/doom/modules/whichkey/init.lua b/lua/doom/modules/whichkey/init.lua new file mode 100644 index 000000000..0d980f005 --- /dev/null +++ b/lua/doom/modules/whichkey/init.lua @@ -0,0 +1,73 @@ +local whichkey = {} + +whichkey.defaults = { + leader = " ", + plugins = { + marks = false, + registers = false, + presets = { + operators = false, + motions = true, + text_objects = true, + windows = true, + nav = true, + z = true, + g = true, + }, + }, + operators = { + d = "Delete", + c = "Change", + y = "Yank (copy)", + ["g~"] = "Toggle case", + ["gu"] = "Lowercase", + ["gU"] = "Uppercase", + [">"] = "Indent right", + [""] = "Indent left", + ["zf"] = "Create fold", + ["!"] = "Filter though external program", + }, + icons = { + breadcrumb = "»", + separator = "➜", + group = "+", + }, + key_labels = { + [""] = "SPC", + [""] = "RET", + [""] = "TAB", + }, + window = { + padding = { 0, 0, 0, 0 }, + border = doom.border_style, + }, + layout = { + height = { min = 1, max = 10 }, + spacing = 3, + align = "left", + }, + ignore_missing = true, + hidden = { + "", + "", + "", + "", + "call", + "lua", + "^:", + "^ ", + }, + show_help = true, + triggers = "auto", +} + +whichkey.packer_config = {} +whichkey.packer_config["which-key.nvim"] = function() + vim.g.mapleader = doom.whichkey.leader + + local wk = require("which-key") + + wk.setup(doom.whichkey) +end + +return whichkey diff --git a/lua/doom/modules/whichkey/packages.lua b/lua/doom/modules/whichkey/packages.lua new file mode 100644 index 000000000..e69de5394 --- /dev/null +++ b/lua/doom/modules/whichkey/packages.lua @@ -0,0 +1,8 @@ +return { + ["which-key.nvim"] = { + "folke/which-key.nvim", + commit = "d3032b6d3e0adb667975170f626cb693bfc66baa", + opt = false, + before = "nest.nvim", + }, +} diff --git a/lua/doom/modules/zen/binds.lua b/lua/doom/modules/zen/binds.lua new file mode 100644 index 000000000..43a2cdfab --- /dev/null +++ b/lua/doom/modules/zen/binds.lua @@ -0,0 +1,5 @@ +local binds = { + { "", ":TZAtaraxis", name = "Enter Nirvana" }, +} + +return binds diff --git a/lua/doom/modules/zen/init.lua b/lua/doom/modules/zen/init.lua new file mode 100644 index 000000000..d07c7edcc --- /dev/null +++ b/lua/doom/modules/zen/init.lua @@ -0,0 +1,56 @@ +local zen = {} + +zen.defaults = { + ui = { + bottom = { + laststatus = 0, + ruler = false, + showmode = false, + showcmd = false, + cmdheight = 1, + }, + top = { + showtabline = 0, + }, + left = { + number = false, + relativenumber = false, + signcolumn = "no", + }, + }, + modes = { + ataraxis = { + left_padding = 30, + right_padding = 30, + top_padding = 0, + bottom_padding = 0, + ideal_writing_area_width = { 0 }, + just_do_it_for_me = true, + keep_default_fold_fillchars = true, + custome_bg = "", + bg_configuration = true, + }, + focus = { + margin_of_error = 5, + focus_method = "experimental", + }, + }, + integrations = { + galaxyline = true, + tmux = true, + gitsigns = true, + nvim_bufferline = true, + }, + misc = { + on_off_commands = false, + ui_elements_commands = false, + cursor_by_mode = false, + }, +} + +zen.packer_config = {} +zen.packer_config["TrueZen.nvim"] = function() + require("true-zen").setup(doom.zen) +end + +return zen diff --git a/lua/doom/modules/zen/packages.lua b/lua/doom/modules/zen/packages.lua new file mode 100644 index 000000000..b827201fb --- /dev/null +++ b/lua/doom/modules/zen/packages.lua @@ -0,0 +1,8 @@ +return { + ["TrueZen.nvim"] = { + "Pocco81/TrueZen.nvim", + commit = "508b977d71650da5c9243698614a9a1416f116d4", + module = "true-zen", + event = "BufWinEnter", + }, +} diff --git a/lua/doom/modules/built-in/async/init.lua b/lua/doom/utils/async.lua similarity index 100% rename from lua/doom/modules/built-in/async/init.lua rename to lua/doom/utils/async.lua diff --git a/lua/doom/utils/fs.lua b/lua/doom/utils/fs.lua index 325e7111a..7d819a419 100644 --- a/lua/doom/utils/fs.lua +++ b/lua/doom/utils/fs.lua @@ -1,9 +1,3 @@ ----[[---------------------------------------]]--- --- fs utils - Doom Nvim fs utilities -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - local fs = {} --- Check if the given file exists diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index 9993219a2..21677017e 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -1,37 +1,178 @@ ----[[---------------------------------------]]--- --- utils - Doom Nvim utilities -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - ---- @class utils local utils = {} local system = require("doom.core.system") +local fs = require("doom.utils.fs") --------------------- HELPERS -------------------- --- Doom Nvim version -utils.doom_version = "3.3.0-alpha1" - --- Check if Neovim version is 0.5, will be used to provide --- backward compatibility for a while before nuking support for 0.5 -utils.nvim_is_05 = vim.version().minor == 5 - ---- For autocommands, extracted from ---- https://github.com/norcalli/nvim_utils ---- @param definitions table> -utils.create_augroups = function(definitions) - for group_name, definition in pairs(definitions) do - vim.api.nvim_command("augroup " .. group_name) - vim.api.nvim_command("autocmd!") - for _, def in ipairs(definition) do - local command = table.concat(vim.tbl_flatten({ "autocmd", def }), " ") - vim.api.nvim_command(command) +utils.doom_version = "4.0.0-alpha1" + +-- Finds `filename` (where it is a doom config file). +utils.find_config = function(filename) + local function get_filepath(dir) + return table.concat({ dir, filename }, system.sep) + end + local path = get_filepath(system.doom_configs_root) + if fs.file_exists(path) then + return path + end + path = get_filepath(system.doom_root) + if fs.file_exists(path) then + return path + end + 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 + -- TODO: Consider copying the default to the user config dir. + -- Can't use log yet, doom doesn't exist. + print(("Error while loading %s: Not found"):format(filename)) + vim.cmd("qa!") +end + +-- If it receives a bool, returns the corresponding number. Otherwise +-- it's an identity function. +-- +-- Useful for setting vim-style boolean options. +utils.bool2num = function(bool_or_num) + if type(bool_or_num) == "boolean" then + return bool_or_num and 1 or 0 + end + return bool_or_num +end + +--- Load the specified Lua modules +--- @param module_path string The path to Lua modules, e.g. 'doom' → 'lua/doom' +--- @param mods table The modules that we want to load +utils.load_modules = function(module_path, mods) + local log = require("doom.utils.logging") + for i = 1, #mods, 1 do + log.debug(string.format("Loading '%s.%s' module", module_path, mods[i])) + local ok, err = xpcall(require, debug.traceback, string.format("%s.%s", module_path, mods[i])) + if not ok then + log.error( + string.format( + "There was an error loading the module '%s.%s'. Traceback:\n%s", + module_path, + mods[i], + err + ) + ) + else + log.debug(string.format("Successfully loaded '%s.%s' module", module_path, mods[i])) end - vim.api.nvim_command("augroup END") end end +--- Helper to attach illuminate on LSP +utils.illuminate_attach = function(client) + require("illuminate").on_attach(client) + -- Set underline highlighting for Lsp references + vim.cmd("hi! LspReferenceText cterm=underline gui=underline") + vim.cmd("hi! LspReferenceWrite cterm=underline gui=underline") + vim.cmd("hi! LspReferenceRead cterm=underline gui=underline") +end + +--- Get LSP capabilities for DOOM +utils.get_capabilities = function() + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.preselectSupport = true + capabilities.textDocument.completion.completionItem.insertReplaceSupport = true + capabilities.textDocument.completion.completionItem.labelDetailsSupport = true + capabilities.textDocument.completion.completionItem.deprecatedSupport = true + capabilities.textDocument.completion.completionItem.commitCharactersSupport = true + capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.textDocument.completion.completionItem.resolveSupport = { + properties = { "documentation", "detail", "additionalTextEdits" }, + } + capabilities.textDocument.codeAction = { + dynamicRegistration = false, + codeActionLiteralSupport = { + codeActionKind = { + valueSet = { + "", + "quickfix", + "refactor", + "refactor.extract", + "refactor.inline", + "refactor.rewrite", + "source", + "source.organizeImports", + }, + }, + }, + } + + return capabilities +end + +utils.make_autocmd = function(event, pattern, action, group, nested, once) + local cmd = "autocmd " + + if group then + cmd = cmd .. group .. " " + end + + cmd = cmd .. event .. " " + cmd = cmd .. pattern .. " " + + if nested then + cmd = cmd .. "++nested " + end + if once then + cmd = cmd .. "++once " + end + + if type(action) == "function" then + if not _G._doom then + _G._doom = {} + end + if not _doom.autocmd_funcs then + _doom.autocmd_funcs = {} + end + -- Nobody is going to need more than a million of these, right? + local unique_number = utils.unique_index() + _doom.autocmd_funcs[unique_number] = action + cmd = cmd .. ("lua _doom.autocmd_funcs[%d]()"):format(unique_number) + else + cmd = cmd .. action + end + + vim.cmd(cmd) +end + +utils.make_augroup = function(group_name, cmds, existing_group) + if not existing_group then + vim.cmd("augroup " .. group_name) + vim.cmd("autocmd!") + end + + for _, cmd in ipairs(cmds) do + utils.make_autocmd(cmd[1], cmd[2], cmd[3], existing_group and group_name, cmd.nested, cmd.once) + end + + if not existing_group then + vim.cmd("augroup END") + end +end + +local index = 1 +utils.unique_index = function() + local ret = index + index = index + 1 + return ret +end + +--- Wraps nvim_replace_termcodes +--- @param str string +--- @return string +function utils.replace_termcodes(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) +end + --- Check if string is empty or if it's nil --- @param str string The string to be checked --- @return boolean @@ -61,19 +202,18 @@ utils.escape_str = function(str) return str:gsub(("([%s])"):format(table.concat(escape_patterns)), "%%%1") end ---- Search if a table have the value we are looking for, ---- useful for plugins management ---- @param tabl table ---- @param val any ---- @return boolean -utils.has_value = function(tabl, val) - for _, value in ipairs(tabl) do - if value == val then - return true - end +--- Wraps the appropriate diagnostics function according to nvim version +--- @param bufnr number The number of desired buffer +--- @param severity string The name of desired severity +--- @return number The count of items +utils.get_diagnostic_count = function(bufnr, severity) + if vim.fn.has("nvim-0.6") == 1 then + return vim.tbl_count(vim.diagnostic.get(bufnr, { + severity = severity, + })) + else + return vim.lsp.diagnostic.get_count(bufnr, severity) end - - return false end --- Search if a table have the key we are looking for, @@ -82,7 +222,7 @@ end --- @param key string --- @return boolean utils.has_key = function(tabl, key) - for _, k in ipairs(vim.tbl_keys(tabl)) do + for k, _ in pairs(tabl) do if k == key then return true end @@ -91,53 +231,20 @@ utils.has_key = function(tabl, key) return false end ---- Executes a git command and gets the output ---- @param command string ---- @param remove_newlines boolean ---- @return string -utils.get_git_output = function(command, remove_newlines) - local git_command_handler = io.popen(system.git_workspace .. command) - -- Read the command output and remove newlines if wanted - local command_output = git_command_handler:read("*a") - if remove_newlines then - command_output = command_output:gsub("[\r\n]", "") - end - -- Close child process - git_command_handler:close() - - return command_output -end - ---- Check if the given plugin is disabled in doom_modules.lua +--- Check if the given plugin is disabled in doom-nvim/modules.lua --- @param plugin string The plugin identifier, e.g. statusline --- @return boolean utils.is_plugin_disabled = function(plugin) local modules = require("doom.core.config.modules").modules -- Iterate over all modules sections (e.g. ui) and their plugins - for _, section in pairs(modules) do - if utils.has_value(section, plugin) then - return false - end + if vim.tbl_contains(modules, plugin) then + return false end return true end --- Check if the given plugin exists --- @param plugin_name string The plugin name, e.g. nvim-tree.lua --- @param path string Where should be searched the plugin in packer's path, defaults to `start` --- @return boolean -utils.check_plugin = function(plugin_name, path) - if not path then - path = "start" - end - - return vim.fn.isdirectory( - vim.fn.stdpath("data") .. "/site/pack/packer/" .. path .. "/" .. plugin_name - ) == 1 -end - --- Rounds a number, optionally to the nearest decimal place --- @param num number - Value to round --- @param decimalplace number|nil - Number of decimal places @@ -156,4 +263,13 @@ utils.find_executable_in_path = function(executables) end, executables)[1] end +--- Returns an iterator over the string str whose next function returns until +--- the next sep is reached. +--- @param str string String to iterate over +--- @param sep string Separator to look for +--- @return fun(string, string),string,string +utils.iter_string_at = function(str, sep) + return string.gmatch(str, "([^" .. sep .. "]+)") +end + return utils diff --git a/lua/doom/extras/logging/init.lua b/lua/doom/utils/logging.lua similarity index 75% rename from lua/doom/extras/logging/init.lua rename to lua/doom/utils/logging.lua index 6107c01fb..0e7c10317 100644 --- a/lua/doom/extras/logging/init.lua +++ b/lua/doom/utils/logging.lua @@ -1,52 +1,18 @@ --- log.lua --- -- Inspired by rxi/log.lua -- Modified by tjdevries and can be found at github.com/tjdevries/vlog.nvim -- -- This library is free software; you can redistribute it and/or modify it -- under the terms of the MIT license. See LICENSE for details. ------ CUSTOM SECTION -------------------------------------- ------------------------------------------------------------ - -local system = require("doom.core.system") local round = require("doom.utils").round --- logging defaults to "info" level -local logging_level = "info" - --- Manually load doom_config.lua to avoid circular dependencies -local ok, ret = xpcall(require, debug.traceback, "doom_config") -if ok then - logging_level = ret.config.doom.logging or logging_level -else - ok, ret = xpcall(dofile, debug.traceback, system.doom_configs_root .. "/doom_config.lua") - if ok then - logging_level = ret.config.doom.logging or logging_level - end -end - ------------------------------------------------------------ ------------------------------------------------------------ --- User configuration section +-- Configuration section local default_config = { - -- Name of the plugin. Prepended to log messages plugin = "doom", - - -- Should print the output to neovim while running use_console = true, - - -- Should highlighting be used in console (using echohl) highlights = true, - - -- Should write to a file use_file = true, - - -- Any messages above this level will be logged. - -- defaults to info - level = logging_level, - - -- Level configuration + level = doom.logging, modes = { { name = "trace", hl = "Comment" }, { name = "debug", hl = "Comment" }, @@ -55,15 +21,13 @@ local default_config = { { name = "error", hl = "ErrorMsg" }, { name = "fatal", hl = "ErrorMsg" }, }, - - -- Can limit the number of decimals places for floats decimal_places = 2, } -- {{{ NO NEED TO CHANGE local log = {} -local unpack = unpack or table.unpack +local unpack = table.unpack --- Sets up self --- @param config table @@ -176,3 +140,5 @@ log.new(default_config, true) -- }}} return log + +-- vim: fdm=marker diff --git a/lua/doom/utils/mappings.lua b/lua/doom/utils/mappings.lua deleted file mode 100644 index 0194f3344..000000000 --- a/lua/doom/utils/mappings.lua +++ /dev/null @@ -1,110 +0,0 @@ ----[[---------------------------------------]]--- --- utils - Doom Nvim utilities -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - ---- @class mappings -local mappings = {} - -local mod_utils = require("doom.utils.modules") - ---- Mappings wrapper, extracted from ---- https://github.com/ojroques/dotfiles/blob/master/nvim/init.lua#L8-L12 ---- https://github.com/lazytanuki/nvim-mapper#prevent-issues-when-module-is-not-installed -if mod_utils.is_module_available("nvim-mapper") then - local mapper = require("nvim-mapper") - - mappings.map = function(mode, lhs, rhs, opts, category, unique_identifier, description) - mapper.map(mode, lhs, rhs, opts, category, unique_identifier, description) - end - mappings.map_buf = function(bufnr, mode, lhs, rhs, opts, category, unique_identifier, description) - mapper.map_buf(bufnr, mode, lhs, rhs, opts, category, unique_identifier, description) - end - mappings.map_virtual = function(mode, lhs, rhs, opts, category, unique_identifier, description) - mapper.map_virtual(mode, lhs, rhs, opts, category, unique_identifier, description) - end - mappings.map_buf_virtual = - function(mode, lhs, rhs, opts, category, unique_identifier, description) - mapper.map_buf_virtual(mode, lhs, rhs, opts, category, unique_identifier, description) - end -else - local config = require("doom.core.config").config - - mappings.map = function(mode, lhs, rhs, opts, _, _, _) - local options = config.doom.allow_default_keymaps_overriding and {} or { noremap = true } - if opts then - options = vim.tbl_extend("force", options, opts) - end - vim.api.nvim_set_keymap(mode, lhs, rhs, options) - end - mappings.map_buf = function(mode, lhs, rhs, opts, _, _, _) - vim.api.nvim_buf_set_keymap(mode, lhs, rhs, opts) - end - mappings.map_virtual = function(_, _, _, _, _, _, _) - return - end - mappings.map_buf_virtual = function(_, _, _, _, _, _, _) - return - end -end - ---- keep functions that we want to call ---- @class functions -mappings.functions = {} - ---- Execute the given lua functions ---- @param id number Index of the function in mappings.functions -mappings.execute = function(id) - local func = mappings.functions[id] - if not func then - require("doom.extras.logging").error("Function doest not exist: " .. id) - end - return func() -end - --- map keybindings to functions and cmds -local function key_map(mode, key, cmd, opts, defaults) - opts = vim.tbl_deep_extend("force", { silent = true }, defaults or {}, opts or {}) - - if type(cmd) == "function" then - table.insert(mappings.functions, cmd) - if opts.expr then - cmd = ([[luaeval('require("doom.utils").execute(%d)')]]):format(#mappings.functions) - else - cmd = ("lua require('doom.utils').execute(%d)"):format(#mappings.functions) - end - end - if opts.buffer ~= nil then - local buffer = opts.buffer - opts.buffer = nil - return vim.api.nvim_buf_set_keymap(buffer, mode, key, cmd, opts) - else - return vim.api.nvim_set_keymap(mode, key, cmd, opts) - end -end - ---- Map termcode keybindings ---- @param str string ---- @return string -mappings.t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - ---- insert mode keybinding ---- @param key string ---- @param cmd string ---- @param opts table -mappings.imap = function(key, cmd, opts) - return key_map("i", key, cmd, opts) -end - ---- substitute mode keybinding ---- @param key string ---- @param cmd string ---- @param opts table -mappings.smap = function(key, cmd, opts) - return key_map("s", key, cmd, opts) -end - -return mappings diff --git a/lua/doom/utils/modules.lua b/lua/doom/utils/modules.lua deleted file mode 100644 index d121a33f4..000000000 --- a/lua/doom/utils/modules.lua +++ /dev/null @@ -1,51 +0,0 @@ ----[[---------------------------------------]]--- --- utils - Doom Nvim utilities -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - ---- @class modules -local modules = {} - ---- Check if a Lua module exists ---- @param mod string The module name, e.g. nvim-treesitter ---- @return boolean -modules.is_module_available = function(mod) - if package.loaded[mod] then - return true - else - for _, searcher in ipairs(package.searchers or package.loaders) do - local loader = searcher(mod) - if type(loader) == "function" then - package.preload[mod] = loader - return true - end - end - return false - end -end - ---- Load the specified Lua modules ---- @param module_path string The path to Lua modules, e.g. 'doom' → 'lua/doom' ---- @param mods table The modules that we want to load -modules.load_modules = function(module_path, mods) - for i = 1, #mods, 1 do - local ok, err = xpcall(require, debug.traceback, string.format("%s.%s", module_path, mods[i])) - if not ok then - require("doom.extras.logging").error( - string.format( - "There was an error loading the module '%s.%s'. Traceback:\n%s", - module_path, - mods[i], - err - ) - ) - else - require("doom.extras.logging").debug( - string.format("Successfully loaded '%s.%s' module", module_path, mods[i]) - ) - end - end -end - -return modules diff --git a/lua/doom/modules/built-in/reloader/init.lua b/lua/doom/utils/reloader.lua similarity index 82% rename from lua/doom/modules/built-in/reloader/init.lua rename to lua/doom/utils/reloader.lua index f72465aa2..04f9cc201 100644 --- a/lua/doom/modules/built-in/reloader/init.lua +++ b/lua/doom/utils/reloader.lua @@ -6,7 +6,7 @@ reloader.has_failed_reload = false local fs = require("doom.utils.fs") local utils = require("doom.utils") -local log = require("doom.extras.logging") +local log = require("doom.utils.logging") local system = require("doom.core.system") --- Paths to reload plugins @@ -21,11 +21,8 @@ local plugins_files_path = string.format( ) local vim_subdirs = { "doc", "after", "syntax", "plugin" } -local installed_plenary, _ = pcall(require, "plenary") -if not installed_plenary then - log.warn("Skipped reloader module loading, requires 'plenary.nvim' plugin to be installed") - return -end +-- Should cause error if plenary is not installed. +xpcall(require, debug.traceback, "plenary") local scan_dir = require("plenary.scandir").scan_dir @@ -137,7 +134,7 @@ reloader.reload_lua_module = function(mod_path, quiet) if type(mod) == "function" then -- Call the loaded module function so the reloading will take effect as expected - local ok, _ = pcall(package.loaded[mod_path]) + local ok, _ = xpcall(package.loaded[mod_path], debug.traceback) if not ok then log.error(string.format("Failed to reload '%s' module", mod_path)) end @@ -162,31 +159,35 @@ reloader.reload_lua_modules = function(quiet) end end ---- Reload the plugins definitions modules like doom_modules.lua to automatically +--- Reload the plugin definitions modules like modules.lua to automatically --- install or uninstall plugins on changes reloader.reload_plugins_definitions = function() + local old_plugins = vim.deepcopy(packer_plugins) + + if _doom and _doom.autocmd_funcs then + _doom.autocmd_funcs = {} + end + -- Silently reload plugins modules + reloader.reload_lua_module("doom.core.config", true) reloader.reload_lua_module("doom.core.config.modules", true) - reloader.reload_lua_module("doom.core.config.userplugins", true) reloader.reload_lua_module("doom.modules", true) + require("doom.core.config"):load() + + -- Redo packer startup + dofile(vim.api.nvim_get_runtime_file("*/doom/modules/init.lua", false)[1]) - -- Cleanup disabled plugins - vim.cmd("PackerClean") - -- Defer the installation of new plugins to avoid a weird bug where packer - -- tries to clean the plugins that are being installed right now vim.defer_fn(function() - vim.cmd("PackerInstall") - end, 200) + vim.cmd("PackerClean") + end, 0) + if not vim.deep_equal(packer_plugins, old_plugins) then + vim.defer_fn(function() + vim.cmd("PackerInstall") + end, 200) + end vim.defer_fn(function() - -- Compile plugins changes and simulate a new Neovim launch - -- to load recently installed plugins - -- NOTE: this won't work to live disable uninstalled plugins, - -- they will keep working until you relaunch Neovim - vim.cmd([[ - PackerCompile - doautocmd VimEnter - ]]) - end, 800) + vim.cmd("PackerCompile") + end, 200) end --- Reload all Neovim configurations @@ -199,8 +200,7 @@ reloader.reload_configs = function() vim.cmd("silent! LspRestart") end - --- Source Doom init - vim.cmd("source $MYVIMRC") + reloader.reload_plugins_definitions() --- Reload all loaded Lua modules reloader.reload_lua_modules(true) @@ -208,7 +208,8 @@ reloader.reload_configs = function() --- Reload start plugins reload_runtime_files() - --- Fix some syntax highlighting issues caused by clearing highlighting + vim.cmd("doautocmd VimEnter") + vim.cmd("doautocmd ColorScheme") vim.cmd("doautocmd Syntax") end @@ -221,12 +222,6 @@ reloader.full_reload = function() --- Reload Neovim configurations reloader.reload_configs() - --- Run VimEnter autocommand to simulate a new Neovim launch - --- and reload all buffers - vim.cmd([[ - doautocmd VimEnter - ]]) - log.info( "Reloaded Doom in " .. vim.fn.printf("%.3f", vim.fn.reltimefloat(vim.fn.reltime(reload_time))) diff --git a/modules.lua b/modules.lua new file mode 100644 index 000000000..b9eaa1e12 --- /dev/null +++ b/modules.lua @@ -0,0 +1,48 @@ +-- modules.lua - Doom nvim module selection +-- +-- modules.lua controls what Doom nvim plugins modules are enabled and +-- what features are being used. +-- +-- Uncomment a plugin to enable it and comment out to disable and uninstall it. + +return { + -- "auto_session", + -- "autopairs", + -- "colorizer", + -- "core", + -- "dap", + -- "dashboard", + -- "doom_themes", + -- "editorconfig", + -- "explorer", + -- "firenvim", + -- "formatter", + -- "gitsigns", + -- "illuminate", + -- "indentlines", + -- "kommentary", + -- "lazygit", + -- "linter", + -- "lsp", + -- "minimap", + -- "neogit", + -- "neorg", + -- "range_highlight", + -- "ranger", + -- "restclient", + -- "show_registers", + -- "snippets", + -- "statusline", + -- "suda", + -- "superman", + -- "symbols", + -- "tabline", + -- "telescope", + -- "terminal", + -- "todo_comments", + -- "trouble", + -- "whichkey", + -- "zen", +} + +-- vim: sw=2 sts=2 ts=2 fdm=indent expandtab