diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 000000000..639332798 --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,115 @@ +{ + "projectName": "doom-nvim", + "projectOwner": "NTBBloodbath", + "repoType": "github", + "repoHost": "https://github.com", + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": true, + "commitConvention": "gitmoji", + "contributors": [ + { + "login": "JohnIrle", + "name": "John Irle", + "avatar_url": "https://avatars.githubusercontent.com/u/11879736?v=4", + "profile": "https://johnirle.com/", + "contributions": [ + "doc" + ] + }, + { + "login": "bketelsen", + "name": "Brian Ketelsen", + "avatar_url": "https://avatars.githubusercontent.com/u/37492?v=4", + "profile": "http://www.brianketelsen.com/", + "contributions": [ + "code", + "bug" + ] + }, + { + "login": "Samantha-uk", + "name": "Samantha-uk", + "avatar_url": "https://avatars.githubusercontent.com/u/45871296?v=4", + "profile": "https://github.com/Samantha-uk", + "contributions": [ + "doc" + ] + }, + { + "login": "rscircus", + "name": "rscircus", + "avatar_url": "https://avatars.githubusercontent.com/u/1167114?v=4", + "profile": "https://rscircus.github.io/", + "contributions": [ + "doc" + ] + }, + { + "login": "bandithedoge", + "name": "bandithedoge", + "avatar_url": "https://avatars.githubusercontent.com/u/26331682?v=4", + "profile": "http://bandithedoge.com/", + "contributions": [ + "doc" + ] + }, + { + "login": "vhyrro", + "name": "vhyrro", + "avatar_url": "https://avatars.githubusercontent.com/u/76052559?v=4", + "profile": "https://github.com/vhyrro", + "contributions": [ + "code" + ] + }, + { + "login": "Mremmalex", + "name": "Ifeanyichukwu Sampson Ebenezer", + "avatar_url": "https://avatars.githubusercontent.com/u/40169444?v=4", + "profile": "https://github.com/Mremmalex", + "contributions": [ + "bug" + ] + }, + { + "login": "GustavoPrietoP", + "name": "Gustavo Prieto", + "avatar_url": "https://avatars.githubusercontent.com/u/70907734?v=4", + "profile": "https://github.com/GustavoPrietoP", + "contributions": [ + "code" + ] + }, + { + "login": "ZeusThundr", + "name": "ZeusThundr", + "avatar_url": "https://avatars.githubusercontent.com/u/76399616?v=4", + "profile": "https://github.com/ZeusThundr", + "contributions": [ + "bug" + ] + }, + { + "login": "leonistor", + "name": "Leo Nistor", + "avatar_url": "https://avatars.githubusercontent.com/u/310468?v=4", + "profile": "https://github.com/leonistor", + "contributions": [ + "bug" + ] + }, + { + "login": "notusknot", + "name": "notusknot", + "avatar_url": "https://avatars.githubusercontent.com/u/69602000?v=4", + "profile": "https://github.com/notusknot", + "contributions": [ + "doc" + ] + } + ], + "contributorsPerLine": 7 +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..16566b0a2 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Use Lua syntax for doomrc file +doomrc linguist-language=lua +doomrc -linguist-detectable diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml new file mode 100644 index 000000000..4d27282ee --- /dev/null +++ b/.github/workflows/format.yml @@ -0,0 +1,30 @@ +name: format + +on: + push: + paths: '**.lua' + branches: [main, develop] + +jobs: + stylua: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup and run stylua + uses: JohnnyMorganz/stylua-action@1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --config-path=stylua.toml -g *.lua -g !doomrc.lua -- . + - name: Commit files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + if [[ ! -z $(git status -s) ]]; then + git add *.lua lua/ + git commit -m "Format lua files" + fi + - name: Push formatted files + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..b8fc5f05c --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,20 @@ +name: lint + +on: + push: + paths: '**.lua' + branches: [main, develop] + pull_request: + paths: '**.lua' + types: [opened, synchronize] + +jobs: + selene: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup and run selene + uses: NTBBloodbath/selene-action@v1.0.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: "." diff --git a/.gitignore b/.gitignore index bd5a3ba5b..ad6100462 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # My temp files -logs/ plugin/ sessions/ -logs/doom.log +time_cost.txt +# Backup files +.doom_releases +.doom_backup_hash diff --git a/CHANGELOG.md b/CHANGELOG.md index 3954c82c7..a3c4d503a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,50 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.0.0] - 2021-07-11 + +### Added + +- `:DoomRollback` command, easily rollback to a previous Doom Nvim version + (main branch, a.k.a stable) or a previous commit (development branch). +- Dynamic statusline colors (WIP) +- More automation, plugins configurations will automatically take effect + and the plugins will be automatically installed or uninstalled too, say bye + to `PackerClean` and `PackerInstall` commands! +- The language servers can be automatically installed now by adding a `+lsp` + flag in the `doomrc` languages field, e.g. for adding `rust` support and adding + `rust-analyzer`: `'rust +lsp'`. +- Plugins: + - Added `neorg`, `range-highlight`, `neogit` and more plugins! + - Added initial built-in plugins for compiling and running your projects, + see [modules](./docs/modules.md) for more information. + +### Changed + +- Our `doom-one` colorscheme have been rewritten and is now pure Lua! +- Reduced average startuptime from 400ms to 40ms (depends on the hardware!) +- Vim macros can be optionally disabled now, see related issue: #31 +- Doom Nvim has been restructured, it's more robust and maintainable now. +- No more non-sense global wrappers around the Neovim Lua API, everything + should have their own scope. +- Our `:DoomUpdate` command is now better, say bye to those annoying merging + issues when there were huge changes. +- New statusline look and feel +- New logging system powered by [vlog](https://github.com/tjdevries/vlog). +- `packer.nvim` bootstrapping is now handled internally. +- Plugins: + - We are now using `bufferline` instead of `barbar.nvim`. + - We are now using `rest.nvim` as our HTTP client instead of `dot-http`. + - We are now using `LuaSnip` + `friendly-snippets` instead of `snippets.nvim`. + +### Deleted + +- LSP kind plugin, the symbols kinds can be managed with the Lua API. + +### Fixed + +- Some issues on first launch related to plugins. + ## [2.3.6] - 2021-07-11 ### Fixed @@ -314,7 +358,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial stable release -[unreleased]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.3.6...develop +[unreleased]: https://github.com/NTBBloodbath/doom-nvim/compare/v3.0.0...develop +[3.0.0]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.3.6...v3.0.0 [2.3.6]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.3.5...v2.3.6 [2.3.5]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.3.4...v2.3.5 [2.3.4]: https://github.com/NTBBloodbath/doom-nvim/compare/v2.3.3...v2.3.4 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3f2111b85..e825e033a 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -17,23 +17,23 @@ diverse, inclusive, and healthy community. Examples of behavior that contributes to a positive environment for our community include: -* Demonstrating empathy and kindness toward other people -* Being respectful of differing opinions, viewpoints, and experiences -* Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the +- Focusing on what is best not just for us as individuals, but for the overall community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or +- The use of sexualized language or imagery, and sexual attention or advances of any kind -* Trolling, insulting or derogatory comments, and personal or political attacks -* Public or private harassment -* Publishing others' private information, such as a physical or email +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a +- Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities @@ -106,7 +106,7 @@ Violating these terms may lead to a permanent ban. ### 4. Permanent Ban **Community Impact**: Demonstrating a pattern of violation of community -standards, including sustained inappropriate behavior, harassment of an +standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. **Consequence**: A permanent ban from any sort of public interaction within diff --git a/README.md b/README.md index e62eb4ab9..5f1f50ddb 100644 --- a/README.md +++ b/README.md @@ -1,97 +1,103 @@
-# Doom Neovim +# Doom Nvim -![License](https://img.shields.io/github/license/NTBBloodbath/doom-nvim?style=flat-square) -[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) -![Latest Release](https://img.shields.io/github/v/release/NTBBloodbath/doom-nvim?include_prereleases&style=flat-square) -![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=flat-square&logo=neovim) +![License](https://img.shields.io/github/license/NTBBloodbath/doom-nvim?style=for-the-badge) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge)](http://makeapullrequest.com) +![Latest Release](https://img.shields.io/github/v/release/NTBBloodbath/doom-nvim?include_prereleases&style=for-the-badge&color=red) +![GitHub last commit (branch)](https://img.shields.io/github/last-commit/NTBBloodbath/doom-nvim/develop?style=for-the-badge) +![Neovim version](https://img.shields.io/badge/Neovim-0.5-57A143?style=for-the-badge&logo=neovim) + + + +[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=for-the-badge)](#contributors) + + [Features](#features) โ€ข [Install](#install) โ€ข [Documentation] โ€ข [Contribute](#contribute) -![Doom Nvim demo](./assets/demo.png) +![Doom Nvim demo](https://i.imgur.com/ejEnlEP.png)
--- -# Introduction +## Introduction -> It is a story as old as time. A barely new vimmer that is afraid to configure -> Neovim and make it work out-of-the-box without problems, that gets the -> solution to his configuration problems. This is his configuration. - -Doom Nvim is a Neovim port of the [doom-emacs](https://github.com/hlissner/doom-emacs) framework. - -As a vimmer, I know that it's difficult to configure Vim/Neovim when you are just starting to use it, -how time consuming it's to customize it to your needs and that's why Doom Nvim exists -_also because I love Doom_. +Doom Nvim is a Neovim port of the [doom-emacs](https://github.com/hlissner/doom-emacs) framework +and adapted to Vim philosophy. Its goal is to give Neovim an initial configuration to start working in a stable and efficient -development environment without spending a lot of time configuring everything, without forgetting +development environment without spending a lot of time configuring everything and without forgetting that we don't all need the same environment. +> As a vimmer, I know that it's difficult to configure Vim/Neovim when you are just starting to use it, +> how time consuming it's to customize it to your needs and that's why Doom Nvim exists +> _also because I love Doom_. + Its design is guided by these mantras: - **Gotta go fast.** Startup and run-time performance are priorities. That is why Doom Nvim uses Lua instead of Vimscript for its configurations - and searches for tiny but powerful plugins. + and lazy-loads _all_ the plugins. - **Your system, your rules.** You know better than a third party what is convenient for you. At least, Doom hopes so! It won't _automatically_ - install system dependencies, plugins that have external dependencies + install system dependencies nor plugins that have external dependencies (and will force plugins not to do so either if they have any external dependencies). - **What does not serve you, you throw away.** Doom Nvim is made up of a moderate number - of plugins (~ 40 plugins as of this writing). You more than anyone know what you need in + of plugins (~40 plugins as of this writing). You more than anyone know what you need in your environment and that's why Doom Nvim allows you to easily disable plugins and add new ones. - Also, Doom Nvim doesn't come with TreeSitter parsers or LSPs by default, - so you can use **only** what you need. - -# 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!). + Also, Doom Nvim doesn't come with TreeSitter parsers or Language Server Protocols configured by default, + so **you can use _only_ what you need**. -# Notices +## Notices +- **2021-07-03**: The `doomrc` has been fragmented and it is not working anymore, + please see [Migrating to 3.0.0](./docs/getting_started.md#migrating-to-300) + for more information. - **2021-05-01**: The `doomrc` is not using Vimscript anymore, please see the new [doomrc](./doomrc) file structure for use it with Lua. -# Features +## Features - Minimalistic good looks inspired by modern code editors. -- Curated and sane defaults for many packages. +- Works out of the box, just install and start editing. - A modular organizational structure for separating concerns in your config. -- A declarative and powerful [package management system] +- Extensible and customizable, everything can be easily modified. +- Curated and sane defaults for many plugins. +- A declarative and powerful [plugins management system](https://github.com/wbthomason/packer.nvim) (powered by `packer.nvim`). - Opt-in LSP integration for many languages by using the new - built-in LSP included on Neovim Nightly. + built-in LSP included on Neovim 0.5. - An Emacs which-key like plugin to manage your `keybindings`, centered around leader prefix key (SPC). -- Per-file indentation style detection and [editorconfig] integration. Let - someone else argue about tabs vs **_spaces_**. -- Project-management tools. -- Project search (and more) utilities, powered by +- Project search _and more_ utilities, powered by [telescope.nvim]. -# Prerequisites +## Prerequisites + +### Installation -- Curl 7.x +- Curl 7.x (for using the installation script) - Git 2.23+ -- Neovim Nightly 0.5.0 (for Neovim 0.4.x see the nvim-0.4 branch _coming soon_) + +### Runtime + +- Neovim 0.5.0 onwards + - GNU `find` -- _OPTIONALS:_ +- _Optionals:_ - [ripgrep] 11.0+ or [fd] 7.3.0+ (improves file indexing performance for some commands) - - `nodejs` and `npm` (required to use the built-in LSP) + - `nodejs` and `npm` (required to use some Language Server Protocols) Doom is comprised of [~40 optional plugins][modules], some of which may have additional dependencies. [Please visit their documentation][modules]. -# Install +## Install Simply run the following command: @@ -99,13 +105,19 @@ Simply run the following command: curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/install.sh | bash ``` +Or if you want to live in the bleeding-edge with the latest features: + +```sh +curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/install.sh | bash -s -- -d +``` + Then [read our Getting Started guide][getting-started] to be walked through installing, configuring and maintaining Doom Nvim. -> NOTE: If you want to see all the available commands in the installation script, then use +> **NOTE**: If you want to see all the available commands in the installation script, then use > bash -s -- -h instead of just bash -# Getting help +## Getting help Neovim is not very difficult. Although you will occasionally run into problems if you are not an advanced vimmer. When you do, here are some places you can look help: @@ -113,24 +125,67 @@ if you are not an advanced vimmer. When you do, here are some places you can loo - [Our documentation][documentation] covers many use cases. - [The Configuration section][configuration] covers how to configure Doom Nvim and its modules. - - [The Package Management section][package-management] covers how to install - and disable modules. + - [The Plugins Management section][plugins-management] covers how to install + and disable plugins. - Search the [Doom Nvim's issue tracker](https://github.com/NTBBloodbath/doom-nvim/issues) before opening a new issue to see if your issue was already been reported and to avoid duplicating issues. -# Contribute +## 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!). +- [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), - but please tell me why (I am new to Lua, I may have some bad practices that can be fixed in code). + but please tell me why. + +## Contributors + +Special thanks to these amazing people for helping improve doom (see [emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + + + + + + + + + + + + + +

Gustavo Prieto

๐Ÿ’ป

vhyrro

๐Ÿ’ป

John Irle

๐Ÿ“–

Brian Ketelsen

๐Ÿ’ป ๐Ÿ›

Samantha-uk

๐Ÿ“–

rscircus

๐Ÿ“–

bandithedoge

๐Ÿ“–

Ifeanyichukwu Sampson Ebenezer

๐Ÿ›

ZeusThundr

๐Ÿ›

Leo Nistor

๐Ÿ›

notusknot

๐Ÿ“–
+ + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + +## License + +Doom Nvim is licensed under [GPLv2](./LICENSE) license. [contribute]: docs/contributing.md [documentation]: docs/README.md [getting-started]: docs/getting_started.md [install]: docs/getting_started.md#install [configuration]: docs/getting_started.md#configuring-doom -[package-management]: docs/getting_started.md#package-management +[plugins-management]: docs/getting_started.md#plugins-management [modules]: docs/modules.md [editorconfig]: http://editorconfig.org/ [fd]: https://github.com/sharkdp/fd diff --git a/assets/demo.png b/assets/demo.png deleted file mode 100644 index b7e8916c8..000000000 Binary files a/assets/demo.png and /dev/null differ diff --git a/autoload/color.vim b/autoload/color.vim deleted file mode 100644 index b5e0e8f68..000000000 --- a/autoload/color.vim +++ /dev/null @@ -1,269 +0,0 @@ -" File: color.vim -" Author: romgrk -" Date: 15 Mar 2016 -" Description: vimscript RGB/HSL color parsing -" This is mostly a transcript from a javascript color parsing module. -" !::exe [so %] -" ================================================================================ -" Definitions: {{{1 -" In function names: -" โ€ข โ€œHexโ€ refers to hexadecimal color format e.g. #599eff -" โ€ข โ€œRGBโ€ refers to an array of numbers [r, g, b] -" where r,g,b โˆˆ [0, 255] -" โ€ข โ€œHSLโ€ refers to an array of floats [h, s, l] -" where h,s,l โˆˆ [0, 1.0] -" }}}1 -" ================================================================================ -" Color-format patterns: -" {{{1 - -let s:patterns = {} - -" 6 hex-numbers, optionnal #-prefix -let s:patterns['hex'] = '\v#?(\x{2})(\x{2})(\x{2})' - -" short version is strict: starting # mandatory -let s:patterns['shortHex'] = '\v#(\x{1})(\x{1})(\x{1})' - -" Disabled -"let s:patterns['rgb'] = '\vrgb\s*\((\d+)\s*,(\d+)\s*,(\d+)\s*)\s*' -"let s:patterns['rgba'] = '\vrgba\s*\((\d+)\s*,(\d+)\s*,(\d+)\s*,(\d+)\s*)\s*' - -" }}}1 -" ================================================================================ -" Functions: -" {{{1 - -" @params String string The string to test -" @returns Boolean [0 or 1] if string matches: rrggbb OR #rrggbb OR #rgb -fu! color#Test (string) - for key in keys(s:patterns) - if a:string =~# s:patterns[key] - return 1 - end - endfor - return 0 -endfu - -" @params (r, g, b) -" @params ([r, g, b]) -" @returns String A RGB color -fu! color#RGBtoHex (...) - let [r, g, b] = ( a:0==1 ? a:1 : a:000 ) - let num = printf('%02x', float2nr(r)) . '' - \ . printf('%02x', float2nr(g)) . '' - \ . printf('%02x', float2nr(b)) . '' - return '#' . num -endfu - -" @param {String|Number} color The color to parse -fu! color#HexToRGB (color) - if type(a:color) == 2 - let color = printf('%x', a:color) - else - let color = a:color | end - - let matches = matchlist(color, s:patterns['hex']) - let factor = 0x1 - - if empty(matches) - let matches = matchlist(color, s:patterns['shortHex']) - let factor = 0x10 - end - - if len(matches) < 4 - throw 'Couldnt parse ' . string(color) . ' ' . string(matches) - end - - let r = str2nr(matches[1], 16) * factor - let g = str2nr(matches[2], 16) * factor - let b = str2nr(matches[3], 16) * factor - - return [r, g, b] -endfu - - -" Converts an HSL color value to RGB. Conversion formula -" adapted from http://en.wikipedia.org/wiki/HSL_color_space. -" Assumes h, s, and l are contained in the set [0, 1] and -" returns r, g, and b in the set [0, 255]. -" @param Number h OR @param Array [h, s, l] -" @param Number s -" @param Number l -" @returns Array [r, g, b] The RGB representation -fu! color#HSLtoRGB(...) " (h, s, l) - let [h, s, l] = ( a:0==1 ? a:1 : a:000 ) - - if (s == 0.0) " achromatic - let r = l - let g = l - let b = l - else - let q = l < 0.5 ? l * (1 + s) : l + s - l * s - let p = 2 * l - q - let r = color#Hue2RGB(p, q, h + 0.33333) - let g = color#Hue2RGB(p, q, h) - let b = color#Hue2RGB(p, q, h - 0.33333) - end - - return [r * 255.0, g * 255.0, b * 255.0] -endfu - - -" @param Number r OR @param Array [r, g, b] -" @param Number g -" @param Number b -" @returns Array [h, s, l] The HSL representation -fu! color#RGBtoHSL(...) - let [r, g, b] = ( a:0==1 ? a:1 : a:000 ) - let max = max([r, g, b]) - let min = min([r, g, b]) - - let r = str2float(r) - let g = str2float(g) - let b = str2float(b) - let max = str2float(max) - let min = str2float(min) - - let max = max / 255 - let min = min / 255 - let r = r / 255 - let g = g / 255 - let b = b / 255 - let h = str2float(0) - let s = str2float(0) - let l = (max + min) / 2 - - if (max == min) - let h = 0 " achromatic - let s = 0 " achromatic - else - let d = max - min - let s = (l > 0.5 ? d / (2 - max - min) - \ : d / (max + min) ) - if (max == r) - let h = (g - b) / d + (g < b ? 6 : 0) - end - if (max == g) - let h = (b - r) / d + 2 - end - if (max == b) - let h = (r - g) / d + 4 - end - let h = h / 6 - end - - return [h, s, l] -endfu - -fu! color#Hue2RGB(...) " (p, q, t) - let [p, q, t] = ( a:0==1 ? a:1 : a:000 ) - - if(t < 0) | let t += 1 | end - if(t > 1) | let t -= 1 | end - - if(t < 1.0/6) | return (p + (q - p) * 6.0 * t) | end - if(t < 1.0/2) | return (q) | end - if(t < 2.0/3) | return (p + (q - p) * (2.0/3 - t) * 6.0) | end - - return p -endfu - -" }}}1 -" ================================================================================ -" Composed functions: -" {{{1 - -fu! color#HexToHSL (color) - let [r, g, b] = color#HexToRGB(a:color) - return color#RGBtoHSL(r, g, b) -endfu - -fu! color#HSLtoHex (...) - let [h, s, l] = ( a:0==1 ? a:1 : a:000 ) - let [r, g, b] = color#HSLtoRGB(h, s, l) - return color#RGBtoHex(r, g, b) -endfu - -" @params String color The color -" @params {Number|String|Float} [amount=5] The percentage of light -fu! color#Lighten(color, ...) - let amount = a:0 ? - \(type(a:1) < 2 ? - \str2float(a:1) : a:1 ) - \: 5.0 - - if(amount < 1.0) - let amount = 1.0 + amount - else - let amount = 1.0 + (amount / 100.0) - end - - let rgb = color#HexToRGB(a:color) - let rgb = map(rgb, 'v:val * amount') - let rgb = map(rgb, 'v:val > 255.0 ? 255.0 : v:val') - let rgb = map(rgb, 'float2nr(v:val)') - let hex = color#RGBtoHex(rgb) - return hex -endfu - -" @params String color The color -" @params {Number|String|Float} [amount=5] The percentage of darkness -fu! color#Darken(color, ...) - let amount = a:0 ? - \(type(a:1) < 2 ? - \str2float(a:1) : a:1 ) - \: 5.0 - - if(amount < 1.0) - let amount = 1.0 - amount - else - let amount = 1.0 - (amount / 100.0) - end - - if(amount < 0.0) - let amount = 0.0 | end - - - let rgb = color#HexToRGB(a:color) - let rgb = map(rgb, 'v:val * amount') - let rgb = map(rgb, 'v:val > 255.0 ? 255.0 : v:val') - let rgb = map(rgb, 'float2nr(v:val)') - let hex = color#RGBtoHex(rgb) - return hex -endfu - -function! color#Decrease (...) - if &background == 'light' - return call(function('color#Lighten'), a:000) - end - return call(function('color#Darken'), a:000) -endfunc - -function! color#Increase (...) - if &background == 'light' - return call(function('color#Darken'), a:000) - end - return call(function('color#Lighten'), a:000) -endfunc - -function! color#Mix (a, b, ...) - let amount = a:0 ? a:1 : 0.5 - - let ca = color#HexToRGB(a:a) - let cb = color#HexToRGB(a:b) - - let r = s:interpolate(ca[0], cb[0], amount) - let g = s:interpolate(ca[1], cb[1], amount) - let b = s:interpolate(ca[2], cb[2], amount) - - return color#RGBtoHex([r, g, b]) -endfunc - -function! s:interpolate (start, end, amount) - let diff = a:end - a:start - return a:start + (diff * a:amount) -endfunc - -" }}}1 - diff --git a/autoload/health/doom.vim b/autoload/health/doom.vim index facf43ddb..c5857f70b 100644 --- a/autoload/health/doom.vim +++ b/autoload/health/doom.vim @@ -5,6 +5,6 @@ "================================================ function! health#doom#check() abort - lua Log_message('+', 'Checking Doom health ...', 2) - lua require('doom.health').checkhealth() + lua require('doom.core.logging').info('Checking Doom health ...') + lua require('doom.core.health').checkhealth() endfunction diff --git a/colors/doom-one.lua b/colors/doom-one.lua new file mode 100644 index 000000000..bc14636ac --- /dev/null +++ b/colors/doom-one.lua @@ -0,0 +1,9 @@ +vim.cmd('hi clear') +if vim.fn.exists('syntax_on') then + vim.cmd('syntax reset') +end + +vim.g['colors_name'] = 'doom-one' + +package.loaded['colors.doom-one'] = nil +require('colors.doom-one') diff --git a/colors/doom-one.vim b/colors/doom-one.vim deleted file mode 100644 index 6ef4e6942..000000000 --- a/colors/doom-one.vim +++ /dev/null @@ -1,545 +0,0 @@ -" !::exe [So] - -if &background != 'dark' - set background=dark -end - -let colors_name = 'doom-one' - -" Highlighting function {{{ -function! s:_ (name, ...) - let fg = '' - let bg = '' - let attr = '' - - if type(a:1) == 3 - let fg = get(a:1, 0, '') - let bg = get(a:1, 1, '') - let attr = get(a:1, 2, '') - else - let fg = get(a:000, 0, '') - let bg = get(a:000, 1, '') - let attr = get(a:000, 2, '') - end - - let has_props = v:false - - let cmd = 'hi! ' . a:name - if !empty(fg) && fg != 'none' - let cmd .= ' guifg=' . fg - let has_props = v:true - end - if !empty(bg) && bg != 'none' - let cmd .= ' guibg=' . bg - let has_props = v:true - end - if !empty(attr) && attr != 'none' - let cmd .= ' gui=' . attr - let has_props = v:true - end - execute 'hi! clear ' a:name - if has_props - execute cmd - end -endfunc - -" }}} -" Colors {{{ - -let s:base0 = '#1B2229' -let s:base1 = '#1c1f24' -let s:base2 = '#202328' -let s:base3 = '#23272e' -let s:base4 = '#3f444a' -let s:base5 = '#5B6268' -let s:base6 = '#73797e' -let s:base7 = '#9ca0a4' -let s:base8 = '#b1b1b1' -let s:base9 = '#E6E6E6' - -let s:grey = s:base4 -let s:red = '#ff6c6b' -let s:orange = '#da8548' -let s:green = '#98be65' -let s:teal = '#4db5bd' -let s:yellow = '#ECBE7B' -let s:blue = '#51afef' -let s:dark_blue = '#2257A0' -let s:magenta = '#c678dd' -let s:violet = '#a9a1e1' -let s:cyan = '#46D9FF' -let s:dark_cyan = '#5699AF' -let s:white = '#efefef' - -let s:green_alt = '#799033' - -let s:bg = '#282c34' -let s:bg_alt = '#21242b' -let s:bg_highlight = '#2E323C' -let s:bg_popup = '#3E4556' -let s:bg_widget = s:bg -let s:bg_statusline = s:bg_popup -let s:bg_visual = color#Lighten(s:base4, 0.3) -let s:bg_selection = s:dark_blue -let s:bg_highlighted = '#4A4A45' - -let s:fg = '#bbc2cf' -let s:fg_alt = '#5B6268' -let s:fg_widget = s:fg -let s:fg_conceal = s:base4 -let s:fg_subtle = s:base7 -let s:fg_highlight = color#Lighten(s:fg, 0.2) -let s:fg_linenr = s:base4 - - -let s:highlight = s:blue -let s:highlight_color = s:base0 - -let s:tag = color#Mix(s:blue, s:cyan) - -let s:diff_info_fg = s:blue -let s:diff_info_bg0 = color#Mix('#D8EEFD', s:bg, 0.6) -let s:diff_info_bg1 = color#Mix('#D8EEFD', s:bg, 0.8) - -let s:diff_add_fg = s:green -let s:diff_add_fg0 = color#Mix(s:green, s:fg, 0.4) -let s:diff_add_bg0 = color#Mix('#506d5b', s:bg, 0.4) -let s:diff_add_bg1 = color#Mix('#acf2bd', s:bg, 0.6) -let s:diff_add_bg2 = color#Mix('#acf2bd', s:bg, 0.8) - -let s:gh_danger_fg = s:red -let s:gh_danger_fg0 = color#Mix(s:red, s:fg, 0.6) -let s:gh_danger_bg0 = color#Mix('#ffdce0', s:bg, 0.6) -let s:gh_danger_bg1 = color#Mix('#ffdce0', s:bg, 0.8) -let s:gh_danger_bg2 = color#Mix('#ffdce0', s:bg, 0.9) - -" }}} -" General UI {{{ - -call s:_('Normal', s:fg, s:bg) -call s:_('EndOfBuffer', s:bg, s:bg) -call s:_('NormalPopup', s:fg_highlight, s:bg_popup) -call s:_('NormalPopover', s:fg_highlight, s:bg_popup) -call s:_('NormalPopupPrompt', s:base7, color#Darken(s:bg_popup, 0.3), 'bold') -call s:_('NormalPopupSubtle', s:base6, s:bg_popup) - -call s:_('Cursor', '', s:base0, 'reverse') -call s:_('SecondaryCursor', '', s:highlight, 'none') - -call s:_('Folded', s:base7, s:bg_highlight, 'none') -call s:_('FoldColumn', s:fg_alt, s:bg_widget, '') -call s:_('SignColumn', '', s:bg_widget, '') -call s:_('ColorColumn', '', s:bg_highlight, '') - -call s:_('CursorLine', '', s:bg_highlight) -call s:_('CursorColumn', '', s:bg_highlight) -call s:_('CursorLineNr', s:highlight, s:bg_highlight, 'none') -call s:_('LineNr', s:fg_linenr, s:bg_widget, 'none') - -call s:_('IndentGuide', s:base4, '', '') -call s:_('IndentGuidesEven', s:base4, '', '') -call s:_('IndentGuidesOdd', s:base4, '', '') - -call s:_('TermCursor', s:fg, 'none', 'reverse') -call s:_('TermCursorNC', s:fg_alt, 'none', 'reverse') -call s:_('TermNormal', s:fg, s:bg, '') -hi! link TermNormalNC TermNormal - - -call s:_('Visual', '', s:bg_visual) -call s:_('VisualBold', '', s:bg_visual, 'bold') - -call s:_('WildMenu', s:fg, s:bg_selection) - -call s:_('StatusLine', s:base8, s:bg_statusline, 'none') -call s:_('StatusLineNC', s:base6, s:bg_statusline, 'none') -call s:_('StatusLinePart', s:base6, s:bg_statusline, 'bold') -call s:_('StatusLinePartNC', s:base6, s:bg_statusline, 'bold') - -call s:_('Separator', s:fg_alt, 'none') -call s:_('VertSplit', s:base4, s:bg, 'none') - -call s:_('Pmenu', s:fg, s:bg_popup) -call s:_('PmenuSel', s:highlight_color, s:highlight) -call s:_('PmenuSelBold', s:highlight_color, s:highlight, 'bold') -call s:_('PmenuSbar', '', s:bg_alt) -call s:_('PmenuThumb', '#666660', '#666660') - -if exists('&pumblend') - set pumblend=20 -end - -let s:bg_current = s:bg -let s:bg_visible = s:bg -let s:bg_other = s:base1 - -call s:_('TabLine', s:base7, s:bg_alt, 'bold') -call s:_('TabLineSel', s:blue, s:bg_current, 'bold') -call s:_('TabLineFill', 'none', s:bg_other, 'bold') - -call s:_('BufferCurrent', s:base9, s:bg_current, 'none') -call s:_('BufferCurrentIndex', s:base6, s:bg_current, 'none') -call s:_('BufferCurrentMod', s:yellow, s:bg_current, 'none') -call s:_('BufferCurrentSign', s:blue, s:bg_current, 'none') -call s:_('BufferCurrentTarget', s:red, s:bg_current, 'bold') - -call s:_('BufferVisible', s:base7, s:bg_visible, 'none') -call s:_('BufferVisibleIndex', s:base9, s:bg_visible, 'none') -call s:_('BufferVisibleMod', s:yellow, s:bg_visible, 'none') -call s:_('BufferVisibleSign', s:base4, s:bg_visible, 'none') -call s:_('BufferVisibleTarget', s:red, s:bg_visible, 'bold') - -call s:_('BufferInactive', s:base6, s:bg_other, 'none') -call s:_('BufferInactiveIndex', s:base6, s:bg_other, 'none') -call s:_('BufferInactiveMod', s:yellow, s:bg_other, 'none') -call s:_('BufferInactiveSign', s:base4, s:bg_other, 'none') -call s:_('BufferInactiveTarget', s:red, s:bg_other, 'bold') - -call s:_('BufferTabpages', s:blue, s:bg_statusline, 'bold') -call s:_('BufferTabpageFill', s:base4, s:bg_other, 'bold') - -call s:_('BufferPart', s:diff_info_fg, s:diff_info_bg0, 'bold') - -" }}} -" Search, Highlight, Conceal, Messages {{{ - -" let s:bg_search = color#Mix(s:bg, s:yellow, 0.2) -let s:bg_search = s:yellow - -call s:_('Search', s:highlight_color, s:bg_search, 'none') -call s:_('IncSearch', s:highlight_color, s:bg_search, 'none') -call s:_('IncSearchCursor', '', '', 'reverse') - -call s:_('Conceal', s:fg_conceal, 'none', '') -call s:_('SpecialKey', s:violet, 'none', 'bold') -call s:_('NonText', s:fg_alt, '', 'bold') -call s:_('MatchParen', s:red, 'none', 'bold') -call s:_('Whitespace', s:base4, '', '') - - -call s:_('Highlight', '', s:bg_highlighted, 'none') -call s:_('HighlightSubtle', '', s:bg_highlighted, 'none') - -call s:_('Question', s:green, '', 'bold') - -call s:_('File', s:fg, '', 'bold') -call s:_('Directory', s:yellow, '', 'bold') -call s:_('Section', s:magenta, '', 'bold') -call s:_('Title', s:violet, '', 'bold') - -call s:_('Bold', '', '', 'bold') -call s:_('Emphasis', s:green, '', 'bold') - -" Text levels {{{ - -let s:text_colors = { -\ 'Normal': s:fg, -\ 'Info': s:blue, -\ 'Success': s:green, -\ 'Warning': s:yellow, -\ 'Debug': s:yellow, -\ 'Error': s:red, -\ 'Special': s:violet, -\ 'Muted': s:base7, -\} -for key in keys(s:text_colors) - call s:_('Text' . key, s:text_colors[key], '', '') - call s:_('Text' . key . 'Bold', s:text_colors[key], '', 'bold') -endfor - -" NOTE/DONE/TODO/FIXME/XXX/DEPRECATED comment highlights - -" }}} - -hi! link Msg TextSuccess -hi! link MoreMsg TextInfo -hi! link WarningMsg TextWarning -hi! link ErrorMsg TextError -hi! link Error TextError -hi! link ModeMsg TextSpecial -hi! link Todo TextWarningBold - - -" }}} -" Main Syntax {{{1 - -call s:_('Tag', s:tag, '', 'underline') -call s:_('Link', s:tag, '', 'underline') -call s:_('URL', s:tag, '', 'underline') -hi! link Underlined URL - -call s:_('Comment', s:base6, '', '') -call s:_('CommentBold', s:base6, '', 'bold') -call s:_('SpecialComment', s:base7, '', 'bold') -hi! link CommentURL URL -hi! link CommentLabel CommentBold -hi! link CommentSection CommentBold -hi! link Noise Comment - -call s:_('Global', s:violet, '', 'bold') -call s:_('PreProc', s:magenta, '', 'none') -call s:_('Macro', s:magenta, '', 'bold') -call s:_('Define', s:magenta, '', 'bold') -call s:_('PreCondit', s:magenta, '', 'bold') -call s:_('Include', s:magenta, '', 'bold') - -call s:_('Repeat', s:blue, '', '') -call s:_('Keyword', s:blue, '', '') -call s:_('Statement', s:blue, '', 'none') -call s:_('Label', s:blue, '', '') - -call s:_('Operator', s:blue, '', '') - -call s:_('Constant', s:violet, '', 'bold') -call s:_('ConstantBuiltin', s:magenta, '', 'bold') - -call s:_('Conditional', s:blue, '', '') - -call s:_('Number', s:orange, '', 'none') -call s:_('Float', s:orange, '', 'none') -call s:_('Boolean', s:orange, '', 'none') -call s:_('Enum', s:orange, '', 'none') - -call s:_('Delimiter', s:blue, '', 'none') -call s:_('DelimiterAlt', s:green_alt, '', 'none') -call s:_('SpecialChar', s:base8, '', 'bold') - -call s:_('String', s:green, '', 'none') -call s:_('StringDelimiter', s:green, '', 'none') - -call s:_('Character', s:green, '', 'bold') - - -call s:_('Special', s:violet, '', 'bold') -call s:_('SpecialBold', s:violet, '', 'bold') - - -call s:_('Identifier', color#Lighten(s:magenta, 0.2), '', 'none') -call s:_('Argument', color#Lighten(s:magenta, 0.2), '', 'none') -call s:_('Variable', color#Lighten(s:magenta, 0.2), '', 'none') -call s:_('VariableBuiltin', color#Lighten(s:magenta, 0.2), '', 'bold') - -call s:_('Function', s:yellow, '', 'none') -call s:_('FunctionBuiltin', s:orange, '', 'bold') -call s:_('Method', s:yellow, '', 'bold') - -call s:_('Symbol', s:magenta, '', 'none') -call s:_('Control', s:magenta, '', 'none') -call s:_('PredefinedIdentifier', s:magenta, '', 'none') -call s:_('Predefined', s:magenta, '', 'none') - -call s:_('StaticFunc', s:cyan, '', 'none') -call s:_('Property', s:magenta, '', 'none') - - -call s:_('Type', s:yellow, '', 'none') -call s:_('TypeBuiltin', s:yellow, '', 'bold') -call s:_('StorageClass', s:blue, '', 'none') -call s:_('Class', s:blue, '', 'none') -call s:_('Structure', s:blue, '', 'none') -call s:_('Typedef', s:blue, '', 'none') - -call s:_('Regexp', '#dd0093', 'none', 'none') -call s:_('RegexpSpecial', '#a40073', 'none', 'none') -call s:_('RegexpDelimiter', '#540063', 'none', 'bold') -call s:_('RegexpKey', '#5f0041', 'none', 'bold') - -" }}} -" Diff {{{ - -call s:_('diffLine', s:base8, s:diff_info_bg1, 'none') -call s:_('diffSubName', s:base8, s:diff_info_bg1, 'none') - -hi! clear DiffAdd -hi! clear DiffChange -hi! clear DiffText -hi! clear DiffDelete - -call s:_('DiffAdd', '', s:diff_add_bg2, 'none') -call s:_('DiffChange', '', s:diff_add_bg2, 'none') -call s:_('DiffText', '', s:diff_add_bg0, 'none') -call s:_('DiffDelete', '', s:gh_danger_bg1, 'none') - -call s:_('DiffAdded', s:diff_add_fg0, s:diff_add_bg2, 'none') -call s:_('DiffModified', s:fg, s:diff_info_bg0, 'none') -call s:_('DiffRemoved', s:gh_danger_fg0, s:gh_danger_bg2, 'none') - -call s:_('DiffAddedGutter', s:diff_add_fg, 'none', 'bold') -call s:_('DiffModifiedGutter', s:diff_info_fg, 'none', 'bold') -call s:_('DiffRemovedGutter', s:gh_danger_fg, 'none', 'bold') - -call s:_('DiffAddedGutterLineNr', s:fg_linenr, 'none', 'none') -call s:_('DiffModifiedGutterLineNr', s:fg_linenr, 'none', 'none') -call s:_('DiffRemovedGutterLineNr', s:fg_linenr, 'none', 'none') - -" Gitgutter - -hi! link GitGutterAdd DiffAddedGutter -hi! link GitGutterChange DiffModifiedGutter -hi! link GitGutterChangeDelete DiffModifiedGutter -hi! link GitGutterDelete DiffRemovedGutter - -hi! link GitGutterAddLineNr DiffAddedGutterLineNr -hi! link GitGutterChangeLineNr DiffModifiedGutterLineNr -hi! link GitGutterChangeDeleteLineNr DiffModifiedGutterLineNr -hi! link GitGutterDeleteLineNr DiffRemovedGutterLineNr - - -" }}} -" Additionnal/Common groups {{{1 - -call s:_('DbgCurrent', '#DEEBFE', '#345FA8', '') -call s:_('DbgBreakPt', '', '#4F0037', '') - -" Jumping around {{{ - -call s:_('JumpTarget', s:red, '', 'bold') - -hi! link EasyMotionTargetDefault JumpTarget -hi! link Sneak JumpTarget -hi! link SneakPluginTarget JumpTarget -hi! link SneakStreakTarget JumpTarget -hi! link SneakStreakMask EasyMotionShadeDefault - -" }}} - -" Languages/Others {{{1 - -" Help {{{2 - -hi! link helpURL URL - -" PHP {{{2 - -hi! link phpFunctions Function -hi! link phpSuperglobal Identifier -hi! link phpQuoteSingle StringDelimiter -hi! link phpQuoteDouble StringDelimiter -hi! link phpBoolean Constant -hi! link phpNull Constant -hi! link phpArrayPair Operator -hi! link phpOperator Normal -hi! link phpRelation Normal -hi! link phpVarSelector Identifier - -" Python {{{2 - -hi! link pythonOperator Operator - -" Ruby {{{2 - -hi! link rubyRegexpDelimiter RegexpDelimiter -hi! link rubyRegexp Regexp -hi! link rubyRegexpSpecial RegexpSpecial -hi! link rubyPredefinedIdentifier PredefinedIdentifier - -hi! link rubyClass Class -hi! link rubyIdentifier Identifier -hi! link rubyInstanceVariable InstanceVariable -hi! link rubySymbol Symbol -hi! link rubyControl Control - -hi! link rubySharpBang Comment -hi! link rubyConstant Type -hi! link rubyFunction Function - -hi! link rubyGlobalVariable rubyInstanceVariable -hi! link rubyModule rubyClass - -hi! link rubyString String -hi! link rubyStringDelimiter StringDelimiter -hi! link rubyInterpolationDelimiter Identifier - - -" Erlang {{{2 - -hi! link erlangAtom rubySymbol -hi! link erlangBIF rubyPredefinedIdentifier -hi! link erlangFunction rubyPredefinedIdentifier -hi! link erlangDirective Statement -hi! link erlangNode Identifier - -" CoffeeScript {{{2 - -hi! link coffeeRegExp rubyRegexp - -" Lua & Moonscript' {{{2 - -hi! link luaOperator Conditional - -hi! link moonObject Type -hi! link moonSpecialOp StringDelimiter -hi! link moonSpecialVar Identifier -hi! link moonObjAssign StorageClass -hi! link moonObjAssign StorageClass -hi! link moonConstant Global - -" Objective-C/Cocoa {{{2 - -hi! link objcClass Type -hi! link cocoaClass objcClass -hi! link objcSubclass objcClass -hi! link objcSuperclass objcClass -hi! link objcDirective rubyClass -hi! link cocoaFunction Function -hi! link objcMethodName Identifier -hi! link objcMethodArg Normal -hi! link objcMessageName Identifier - -" 1}}} - -" 1}}} - -" Neovim Treesitter {{{2 - -hi! link TSAnnotation PreProc -hi! link TSAttribute Macro -hi! link TSBoolean Boolean -hi! link TSCharacter Character -hi! link TSConditional Conditional -hi! link TSConstant Constant -hi! link TSConstBuiltin ConstantBuiltin -hi! link TSConstMacro Macro -hi! link TSConstructor Method -hi! link TSEmphasis Emphasis -hi! link TSError Error -hi! link TSException Error -hi! link TSField Variable -hi! link TSFloat Float -hi! link TSFunction Function -hi! link TSFuncBuiltin FunctionBuiltin -hi! link TSFuncMacro Function -hi! link TSInclude Include -hi! link TSKeyword Keyword -hi! link TSKeywordFunction Keyword -hi! link TSKeywordOperator Operator -hi! link TSLabel Label -hi! link TSLiteral Constant -hi! link TSMethod Method -hi! link TSNamespace Directory -hi! link TSNumber Number -hi! link TSOperator Operator -hi! link TSParameter Argument -hi! link TSParameterReference Argument -hi! link TSProperty Property -hi! link TSPunctBracket Delimiter -hi! link TSPunctDelimiter Delimiter -hi! link TSPunctSpecial DelimiterAlt -hi! link TSRepeat Repeat -hi! link TSString String -hi! link TSStringEscape StringDelimiter -hi! link TSStringRegex Regexp -hi! link TSStrong Bold -hi! link TSStructure Structure -hi! link TSTag Keyword -hi! link TSTagDelimiter Delimiter -hi! link TSText String -hi! link TSTitle Title -hi! link TSType Type -hi! link TSTypeBuiltin TypeBuiltin -hi! link TSUnderline Underlined -hi! link TSURI URL -hi! link TSVariable Variable -hi! link TSVariableBuiltin VariableBuiltin - -" 1}}} diff --git a/doc/doom_nvim.txt b/doc/doom_nvim.txt index 99ba839bb..6096587cb 100644 --- a/doc/doom_nvim.txt +++ b/doc/doom_nvim.txt @@ -25,237 +25,74 @@ ============================================================================= CONTENTS *doom_nvim_contents* 1. Introduction...........................................|doom_nvim_intro| - 2. Options..............................................|doom_nvim_options| - 1. Autocomplete..........................|doom_nvim_options_autocomplete| - 2. Colorscheme............................|doom_nvim_options_colorscheme| - 3. Configuration..................................|doom_nvim_configuration| + 2. Autocomplete..........................|doom_nvim_options_autocomplete| + 3. Colorscheme............................|doom_nvim_options_colorscheme| + 4. Configuration..................................|doom_nvim_configuration| 1. Layout................................|doom_nvim_configuration_layout| 2. File Explorer................|doom_nvim_configuration_layout_explorer| 3. Main Buffer................|doom_nvim_configuration_layout_mainbuffer| - 4. Tagbar.........................|doom_nvim_configuration_layout_tagbar| + 4. Outline.......................|doom_nvim_configuration_layout_outline| 5. Minimap.......................|doom_nvim_configuration_layout_minimap| 6. Terminal.....................|doom_nvim_configuration_layout_terminal| 7. Modules..............................|doom_nvim_configuration_modules| - 1. Enabling modules..........|doom_nvim_configuration_modules_enabling| - 2. Disabling modules........|doom_nvim_configuration_modules_disabling| + 1. Tweaking modules..........|doom_nvim_configuration_modules_tweaking| 8. Custom Plugins................|doom_nvim_configuration_custom_plugins| 9. LSP......................................|doom_nvim_configuration_lsp| - 4. Commands............................................|doom_nvim_commands| + 5. Commands............................................|doom_nvim_commands| 1. Keybindings...........................|doom_nvim_commands_keybindings| - 5. Usage..................................................|doom_nvim_usage| + 6. Usage..................................................|doom_nvim_usage| 1. Moving around..........................|doom_nvim_usage_moving_around| - 6. Known issues..........................................|doom_nvim_issues| - 7. FAQ......................................................|doom_nvim_faq| - 8. Hacking Doom Nvim....................................|doom_nvim_hacking| - 1. Autoload..................................|doom_nvim_hacking_autoload| - 9. Acknowledgements...........................|doom_nvim_acknowledgements| - 10. License.............................................|doom_nvim_license| - 11. Contributing...................................|doom_nvim_contributing| - 12. Changelog.........................................|doom_nvim_changelog| + 7. Known issues..........................................|doom_nvim_issues| + 8. FAQ......................................................|doom_nvim_faq| + 9. Hacking Doom Nvim....................................|doom_nvim_hacking| + 10. Acknowledgements...........................|doom_nvim_acknowledgements| + 11. License.............................................|doom_nvim_license| + 12. Contributing...................................|doom_nvim_contributing| + 13. Changelog.........................................|doom_nvim_changelog| ============================================================================== INTRODUCTION *doom_nvim_intro* -Doom Nvim is a port to Neovim of the Doom Emacs configuration framework for -GNU Emacs adapted for all vimmer who want less framework in their framework -and the performance of a handmade configuration (or better). It can be a base -for your own setup or a resource for Vim enthusiasts to learn more about our -favorite editor and how to do X things on it by using Vimscript/Lua. +Doom Neovim is a Neovim port of the Doom Emacs configuration framework, adapted +for the Neovim user that wants less framework in their framework and the performance +of a hand-made configuration. You can use it as a base for your own setup or as +a learning resource on how to achieve a great Neovim configuration. -Doom Nvim is an opinionated collection of reasonable (and optional) defaults -with a focus on performance (both runtime and startup) and on -abstraction-light, readable code design, so that there is less between you -and Neovim. +Doom Neovim features an opinionated collection of reasonable and optional +defaults, with a focus on runtime and startup performance, and a clean, +readable code base. ============================================================================== -OPTIONS *doom_nvim_options* - -NOTICE: Since version 2.1.0 Doom makes use of Lua for the doomrc instead of -using Vimscript. - -Doom Nvim configuration files resides in the -`$HOME/.config/doom-nvim/lua/doom/config` directory. -Default configurations for Doom Nvim resides in -`$HOME/.config/doom-nvim/lua/doom/config/doomrc.lua`. - -All the options available in the `doomrc.lua` file are global fields. -They all start with `Doom.` followed by a description of ther nature: -`Doom.indent` followed by their value. - - -`Doom.autosave` -default value = false -false : Disable autosave -true : Enable autosave - -`Doom.fmt_on_save` -default value = false -false : Disable format on save -true : Enable format on save - -`Doom.autosave_sessions` -default value = false -This option will also autoload saved sessions -false : Disable session autosave -true : Enable session autosave - -`Doom.autoload_last_session` -default value = false -false : Disable autoload of last unsaved session -true : Enable autoload of last unsaved session - -`Doom.preserve_edit_pos` -default value = false -false : Disable preservation of last editing position -true : Enable preservation of last editing position - -`Doom.indent` -default value = 4 -Specifies the width of tabs and shifttabs - -`Doom.show_indent` -default value = true -Show Indent Lines - -`Doom.expand_tabs` -default value = true -Specifies if spaces or tabs must be used -false : spaces -true : tabs - -`Doom.relative_num` -default value = true -false : Shows absolute number lines -true : Shows relative number lines - -`Doom.max_columns` -default value = 80 -Defines the column to show a vertical marker - -`Doom.enable_guicolors` -default value = true -Enables gui colors on GUI versions of Neovim - -`Doom.sidebar_width` -default value = 25 -Specifies the default width of Tree Explorer and Tagbar - -`Doom.tagbar_left` -default value = true -Sets Tagbar buffer to the left when enabled - -`Doom.show_hidden` -default value = true -Show hidden files with Tree Explorer - -`Doom.colorscheme` -default value = 'doom-one' -Specifies the colorscheme to use - -`Doom.colorscheme_bg` -default value = 'dark' -Specifies the background color -Allowed values: 'dark', 'light' - -`Doom.check_updates` -default value = false -Check updates of plugins on start - -`Doom.auto_install_plugins` -default value = true -Automatically install missing plugins on launch - -`Doom.disabled_plugins` -default value = {'lazygit', 'minimap', 'restclient'} -List of user disabled plugins - -`Doom.disabled_modules` -default value = {'git', 'lsp', 'web'} -List of user disabled modules - -`Doom.custom_plugins` -default value = {} -List of user custom plugins - -`Doom.ts_parsers` -Set the parsers for TreeSitter -default value = {} - -`Doom.terminal_direction` -default value = 'horizontal' -Set the Terminal direction -Available directions: - - vertical - - horizontal - - window - - float - -`Doom.terminal_width` -default value = 70 -Set the Terminal width -Applies only to float direction - -`Doom.terminal_height` -default value = 20 -Set the Terminal height -Applies to all directions except window - -`Doom.conceallevel` -default value = 0 -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 - -`Doom.logging` -default value = 1 -Select the logging level of doomnvim -0: Disables the logging -1: Logs all errors in the `doom.log` file -2: Logs all errors and messages in the `doom.log` file -3: Logs all errors and messages in the `doom.log` file and echoes them - -`Doom_root` -default value = "$HOME/.config/doom-nvim" -Specifies the root directory of Doom Nvim. +AUTOCOMPLETE *doom_nvim_autocomplete* +Doom Neovim uses the built-in LSP as completion engine in Neovim 0.5.0. -============================================================================== -AUTOCOMPLETE *doom_nvim_options_autocomplete* - -Doom Neovim uses the built-in LSP as completion engine on Neovim Nightly. -Use to select the next suggestion. +Use to select the next suggestion and to select the current +suggestion. Autocompletion for parenthesis can be disabled by disabling the autopairs plugin (see |doom_nvim_configuration_modules_disabling| for more information) ============================================================================== -COLORSCHEME *doom_nvim_options_colorscheme* +COLORSCHEME *doom_nvim_colorscheme* -The colorscheme of Doom Nvim. Default is 'doom-one'. There are some -colorschemes listed on `$HOME/.config/doom-nvim/lua/plugins.lua`: - - `sonokai` - - `dogrun` - - `onedark` - - `deus` - - `edge` - - `everforest` +The colorscheme of Doom Nvim. Default is `doom-one`. There are some additional +doom emacs' colorschemes port for Neovim that can be enabled by uncommenting +the `doom-themes` in your `doomrc.lua`. -You can switch between colorschemes by doing tc and then type the name -of the colorscheme you want to use. You can also edit the `BFC` file located -at: `$HOME/.config/doom-nvim/doomrc` (see |doom_nvim_hacking|). +You can switch between colorschemes by doing ds and then type the name +of the colorscheme you want to use. You can also edit the `doom_config.lua` +file located at `$HOME/.config/doom-nvim` (see |doom_nvim_hacking|). ============================================================================== CONFIGURATION *doom_nvim_configuration* -Doom Nvim configuration files resides under the -`$HOME/.config/doom-nvim/config/` directory. See |doom_nvim_hacking| for more +The Doom Neovim configuration files reside under the +`$HOME/.config/doom-nvim/` directory. See |doom_nvim_hacking| for more info. @@ -279,11 +116,11 @@ following layout: -'A' : The tagbar (Plugin: SymbolsOutline) +'A' : The file explorer (Plugin: nvim-tree.lua) 'B' : The main buffer 'C' : The terminal (Plugin: nvim-toggleterm.lua) 'D' : The minimap (Plugin: minimap.vim) -'E' : The file explorer (Plugin: nvim-tree.lua) +'E' : The symbol outline (Plugin: SymbolsOutline) Sections with `*` are not opened by default but can be toggled. See |doom_nvim_commands| for more information. @@ -292,15 +129,15 @@ See |doom_nvim_commands| for more information. ============================================================================== FILE EXPLORER *doom_nvim_configuration_layout_explorer* -Doom Nvim uses `kyazdani42/nvim-tree.lua` plugin as a file explorer when using -Neovim Nightly. It can be toggled by performing the following commands: -te for `FileExplorer` +Doom Neovim uses the `kyazdani42/nvim-tree.lua` plugin as a file explorer. +It can be toggled by running the following commands: +oe for `FileExplorer` for `FileExplorer` To create a new file within the file explorer, do [name_of_file] Append a `/` if you want to create a directory. -Check `nvim-tree.lua` for more info. +Check https://github.com/kyazdani42/nvim-tree.lua for more info. ============================================================================== @@ -309,19 +146,19 @@ MAIN BUFFER *doom_nvim_configuration_layout_mainbuffer* The main buffer is the buffer where the code is opened. To split the main buffer, do w and then select the split method you -want to use horizontally `h`, or vertically `v`. +want to use horizontally (`s`), or vertically (`v`). ============================================================================== -TAGBAR *doom_nvim_configuration_layout_tagbar* +OUTLINE *doom_nvim_configuration_layout_outline* -Tagbar is a plugin that can show the tags and structure of the opened file, -ordered by its scope. For this function, Doom Nvim makes use of +Symbols-Outline is a plugin that can show the tags and structure of the opened +file, ordered by its scope. For this function, Doom Nvim makes use of `simrat39/symbols-outline.nvim`. It can be toggled by performing the following commands: -tS for `Tagbar` - for `Tagbar` +os for `Symbols-Outline` + for `Symbols-Outline` See https://github.com/simrat39/symbols-outline.nvim for more information. @@ -329,9 +166,9 @@ See https://github.com/simrat39/symbols-outline.nvim for more information. ============================================================================== MINIMAP *doom_nvim_configuration_layout_minimap* -Doom Nvim uses `wfxr/minimap.vim` plugin as its minimap when using Neovim -Nightly. It can be toggled by performing the following commands: -tm for `Minimap` +Doom Nvim uses `wfxr/minimap.vim` plugin as its minimap. +It can be toggled by performing the following commands: +om for `Minimap` for `Minimap` @@ -343,96 +180,96 @@ buffer of the terminal is automatically set to `INSERT` mode. The only way to close it is to enter `exit` to close the shell session, or if you just want to toggle it, you can enter in `NORMAL` mode: -tt for `Terminal` +ot for `Terminal` for `Terminal` ============================================================================== MODULES *doom_nvim_configuration_modules* -Doom Nvim consists of around 7 modules and growing. A Doom Nvim Module is a +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. To give a quick summary, the modules are as follows: - - Essentials (package manager, TreeSitter and utilities for using - Lua inside Neovim) - - UI (everything related to UI) - - Git (everything related to Git) - - LSP (for using Language Server Protocols by using the built-in LSP) - - Files (utilities like formatter, commenter, etc) - - Web (for web development) + - UI, everything related to UI + - Doom, neorg and built-in plugins + - Editor, everything related to editing, e.g. tree explorer, git signs, lsp + - Langs, languages support for Doom and language servers + - Utilities, some utility plugins like neogit You can see in a more detailed view the modules and its plugins at https://github.com/NTBBloodbath/doom-nvim/blob/main/docs/modules.md ============================================================================== -ENABLING MODULES *doom_nvim_configuration_modules_enabling* - -To enable a module, you can use the `Doom.disabled_modules` field on your -`doomrc`. +TWEAKING MODULES *doom_nvim_configuration_modules_tweaking* -Example: - To enable all modules except web, just put only 'web' in the disabled - modules array and then reboot Neovim and do `:PackerSync`. +For tweaking a module (enable / disable its plugins) you will only need to +comment or uncomment the desired plugin, e.g. for disabling the tree explorer +you will only need to comment it. - Doom.disabled_modules = { 'web' } - - -============================================================================== -DISABLING MODULES *doom_nvim_configuration_modules_disabling* +`-- Right now the Tree explorer is enabled` +`'explorer',` -To disable a module, you can use the `Doom.disabled_modules` field on -your `doomrc`. +`-- Now the Tree explorer is disabled` +`-- 'explorer',` -Example: - To disable only the web module, just put only 'web' in the disabled - modules array and then reboot Neovim and do `:PackerSync`. - - Doom.disabled_modules = { 'web' } +NOTE: after doing changes to your modules you will only need to restart Neovim +and Doom Nvim will automatically handle your changes on here. ============================================================================== CUSTOM PLUGINS *doom_nvim_configuration_custom_plugins* -To use your own plugins in Doom Nvim you can use the `Doom.custom_plugins` -field on your `doomrc`. +To use your own plugins in Doom Nvim you can use the `plugins.lua` file +located in the Doom Nvim root directory. + +NOTE: if you are familiar with `packer.nvim` (the plugins manager used by Doom +Nvim) then you can see the `plugins.lua` file as a wrapper for it. -To add plugins without extra configurations (e.g., if a plugin does not depends +To add plugins without extra configurations (e.g., if a plugin does not depend on other plugins), you can simply set it as follow: - Doom.custom_plugins = { 'andweeb/presence.nvim' } +` return {` +` 'andweeb/presence.nvim'` +` }` Otherwise, if your plugin depends on other or you do not want to enable it, then you can do it as follow: - Doom.custom_plugins = { - { - ['repo'] = 'andweeb/presence.nvim', - ['enabled'] = true, - ['requires'] = { 'foo', 'bar' } - } - } +` return {` +` {` +` 'andweeb/presence.nvim',` +` requires = { 'john/foo', 'doe/bar' },` +` }` +` }` As you can see, the second way depends on a structure to work. - - repo: the repository where the plugin resides - enabled: if the plugin should be enabled, not required (true by default) - requires: plugin dependencies, not required +All the fields for declaring plugins can be found at +https://github.com/wbthomason/packer.nvim#specifying-plugins ============================================================================== LSP *doom_nvim_configuration_lsp* -To easily install LSPs and without having to do it system-wide or having to -manually configure servers, Doom Nvim makes use of `kabouzeid/nvim-lspinstall`. -You can see a list of currently supported languages at -https://github.com/kabouzeid/nvim-lspinstall#bundled-installers +To easily install language servers and without having to do it system-wide or +having to manually configure servers, Doom Nvim makes use of +`kabouzeid/nvim-lspinstall`. -Usage example: - `:LspInstall python` to install Python LSP - `:LspUninstall python` to uninstall Python LSP +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 `doomrc.lua`, e.g. for enabling Rust support in Doom and install +`rust-analyzer`: + +` local doom = {` +` langs = {` +` 'rust +lsp', -- Let's get rusty!` +` }` +` }` + +NOTE: You can see a list of currently supported languages at +https://github.com/kabouzeid/nvim-lspinstall#bundled-installers ============================================================================== @@ -440,13 +277,15 @@ COMMANDS *doom_nvim_commands* Doom Nvim have its own commands, to make your life easier when developing. -| `:DoomUpdate` | Update Doom Nvim if there are updates. +| `:DoomUpdate` | Update Doom Nvim if there are updates. +| `:DoomRollback` | Rollback Doom Nvim to a previous version. -Doom Nvim also uses `WhichKey` as a command manager, inspired by +Doom Nvim also uses `WhichKey` as a commands manager, inspired by emacs's guide-key. To open it, press and wait for the popup to show, it should not take much time. Each section has a label and is mnemonic. e.g: - `Toggle Terminal` > tt + + `Open Terminal` > ot There are multiple sections for Doom Nvim's commands. Those sections create a path in the decision tree that identifies any command. @@ -470,80 +309,106 @@ KEYBINDINGS *doom_nvim_commands_keybindings* In Doom Nvim, we make use of the keystroke as the map leader. +| <,> | Switch buffer +| <.> | Browse files +| | Search +| <:> | Command history +| <`> | Switch buffer +| | Find file + | uffer -| | <1> First buffer -| | <2> Second buffer -| | <3> Third buffer -| | <4> Fourth buffer -| | <5> Fifth buffer -| | <6> Sixth buffer -| | <7> Seventh buffer -| | <8> Eighth buffer -| | <9> Last buffer +| | <[> Previous buffer +| | <]> Next buffer +| | Switch to other buffer | | Close buffer | | Format buffer +| | Goto buffer | | Next buffer | |

Previous buffer -| |

Pick buffer +| ode +| | Compile project +| | Compile and run project +| | Run rest client on the line that the cursor is +| | Start a REPL +| | Run current file +| | +lsp | oom | | Edit your Doom Nvim configuration -| | Open Doom Nvim docs -| | Create crash reports, useful for debugging +| | Open Doom Nvim documentation +| | Create crash reports, useful for debugging +| | Rollback Doom Nvim version +| | Change colorscheme | | Check Doom Nvim updates | ile -| | Bookmarks -| | Edit your Neovim Configuration -| | Find file -| | Find word -| | Recently opened files +| | Edit Neovim configuration +| | Find files | | New unnamed buffer -| | Re-open an unreadable file with sudo permissions +| | Re-open an unreadable file with sudo permissions +| | Recently opened files | | Help tags | | Write an unwritable file with sudo permissions | it +| | Branches | | Blame line +| | Commits | | Preview hunk | | Reset buffer | | Reset hunk | | Open LazyGit -| |

Pull +| | Pull | |

Push | | Stage hunk | | Status | | Undo stage hunk | sp +| | Code actions | | Show type definition +| | Lsp info | | Show line diagnostics | | Diagnostics into location list -| rder -| | Sort by directory -| | Sort by language -| | Re-order buffer to next -| |

Re-order buffer to previous +| pen +| | Start screen +| | Tree explorer +| | Minimap +| | LSP Symbols +| | Terminal |

lugin | | Clean unused plugins +| | Compile your plugins changes | | Install missing plugins | |

Profile the time taken loading your plugins | | Sync plugins (Clean and Update) -| | Update plugins -| unner -| | Run restclient in the current cursor line -| ession -| | Session switcher/selector -| | Save current session +| | Plugins status +| uit / +| sessions +| | Session switcher +| | Quit | | Restore previously saved session -| oggler -| | Change colorscheme -| | Toggle Tree Explorer -| | Toggle Minimap -| | Toggle Symbols view -| | Toggle Start Screen -| | Toggle Terminal +| | Save current session +| | Save and quit +| earch +| | Buffer +| | Grep +| | Command history +| | Jump to mark +| | Goto symbol | indow -| | Close current window -| | Close all other windows -| | Split horizontally -| | Split vertically +| | <-> Split window below +| | <2> Layout double columns +| | <=> Balance window +| | <|> Split window right +| | Delete window +| | Expand window left +| | Window left +| | Expand window below +| | Window below +| | Expand window up +| | Window up +| | Expand window right +| | Window right +| | Split window below +| | Split window right +| | Other window But there is still more, Doom Nvim knows that you love to use the keyboard but you do not like to be typing so much so it has more keybindings that will make @@ -552,21 +417,30 @@ your life easier! | | Cycle buffers (next buffer) | | Cycle buffers (prev buffer) | | Search highlighting off -| | Toggle Tagbar +| | Toggle Symbols-Outline | | Toggle Tree Explorer | | Toggle Terminal | | Toggle Minimap -| | ToggleZen mode -| | Run restclient -| | Fast exit from Doom Nvim (also dumps `:messages` to logs) +| | Toggle Zen mode +| | Run rest client +| | Fast exit from Doom Nvim +| | Fast exit from `INSERT` mode +| | Comment current line (`NORMAL` mode) | | Comment selected block (`VISUAL` mode) +| | Select window left +| | Select window below +| | Select window up +| | Select window right +| | Resize window up +| | Resize window below +| | Resize window left +| | Resize window right You can modify the default keybindings by modifying the following files: - - `config/keybindings.vim` - general keybindings - - `config/plugins/leader-mapper.vim` - SPC keybindings - - `lua/configs` - lua plugins keybindings + - `lua/doom/core/keybindings/init.lua` - General keybindings + - `lua/doom/modules/config` - Lua plugins keybindings -You can also make your own keybindings by editing your `doomrc` file. +You can also make your own keybindings by editing your `doom_config.lua` file. ============================================================================== @@ -577,8 +451,8 @@ preferred Neovim GUI. By default, if no files were opened, Doom Nvim will show the start menu `dashboard-nvim` where you can select files to edit or if you have a saved -session in the current workspace, Doom will load it automatically -if you want to. +session in the current workspace, Doom will load it automatically if you +want to. ============================================================================== @@ -588,19 +462,18 @@ Doom Nvim uses the default Vim keybindings to move around: `h` `j` `k` `l` and the cursor keys. Use `h` go to left, `j` to go down, `k` to go up, `l` to go right. - ^ - k + ^ + k - < h ยท l > + - j - v + j + v See `Tutor` to know how to use Vim and its keybindings. To move around buffers execute b to select the `buffers` section -and then press the key corresponding to the buffer you want to select (`1-9`) -or press `` to cycle buffers. +and then press the key to select a buffer or press `` to cycle buffers. ============================================================================== @@ -615,19 +488,17 @@ KNOWN ISSUES *doom_nvim_issues* FAQ *doom_nvim_faq* - General - - What type of vimmer is Doom Nvim intended for? + - Who 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 anyone who wants a stable and efficient development environment without spending a lot of time setting everything up. - - Why does Doom Nvim only support Neovim nightly? - -Doom Nvim doesn't support Neovim versions lower than Nightly (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 + - Why does Doom Nvim only support Neovim 0.5.0 (and beyond)? +Doom Nvim relies on lua for the configuration and use of many plugins. Since +lua is not available in neovim 0.4.4 and below, it is not possible to use Doom +Nvim with a neovim version lower than 0.5.0. However, the Doom Nvim installer +automatically installs Neovim 0.5.0 for you! ============================================================================== HACKING DOOM NVIM *doom_nvim_hacking* @@ -636,41 +507,40 @@ Doom Nvim aims to be hackable to suit everyone's needs. Therefore This is the structure of Doom Nvim: -๏„• . # Doom Nvim root -โ”œโ”€โ”€ ๏„• autoload # Files loaded at launch -โ”‚ โ”œโ”€โ”€ ๎˜ซ color.vim # Color utilities, required by `doom-one.vim` -โ”‚ โ””โ”€โ”€ ๏„• health # Doom Nvim health add-ons for `:checkhealth` -โ”œโ”€โ”€ ๏„• colors # Pre-installed colorschemes directory -โ”‚ โ””โ”€โ”€ ๎˜ซ doom-one.vim # `romgrk` doom colorscheme ported to Nvim (`default`) -โ”œโ”€โ”€ ๏„• doc # Doom Nvim documentation to be used inside Nvim -โ”‚ โ””โ”€โ”€ ๏…œ doom_nvim.txt # Doom Nvim help file -โ”œโ”€โ”€ ๏„• docs # Doom Nvim docs meant to be readed on GitHub -โ”œโ”€โ”€ ๏€– doomrc # Doom Nvim user configurations file -โ”œโ”€โ”€ ๎˜  init.lua # init.lua file -โ”œโ”€โ”€ ๏’‰ install.sh # Doom Nvim installer -โ”œโ”€โ”€ ๏€– LICENSE # Doom Nvim License -โ”œโ”€โ”€ ๏„• logs # Location of Doom Nvim logs -โ”‚ โ”œโ”€โ”€ ๏† doom.log # Doom Nvim logs -โ”‚ โ””โ”€โ”€ ๏’Š report.md # Doom Nvim crash reports, does not exists by default -โ”œโ”€โ”€ ๏„• lua # Location of Doom Nvim Lua files -โ”‚ โ”œโ”€โ”€ ๏„• doom # Doom Nvim Lua core -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• autocmds # Doom Nvim autocommands -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• config # Doom Nvim configuration files -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• default # Doom Nvim default Neovim settings -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• functions # Doom Nvim functions -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• health # Doom Nvim health checking -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• keybindings # Doom Nvim keybindings -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• logging # Doom Nvim logging system -โ”‚ โ”‚ โ”œโ”€โ”€ ๏„• system # Doom Nvim system utilities (early stage) -โ”‚ โ”‚ โ””โ”€โ”€ ๏„• utils # Doom Nvim Lua utilities -โ”‚ โ””โ”€โ”€ ๏„• plugins # Location of Doom Nvim plugins -โ”‚ โ”œโ”€โ”€ ๏„• configs # Plugins configurations -โ”‚ โ””โ”€โ”€ ๎˜  init.lua # packer.nvim setup -โ””โ”€โ”€ ๏„• sessions # Location of Neovim workspaces - -Doom Nvim also creates the `BFC`, which serves as the user configuration file +. # Doom Nvim root +โ”œโ”€โ”€ autoload # Files loaded at launch +โ”‚ โ””โ”€โ”€ health # Doom Nvim health add-ons for `:checkhealth` +โ”œโ”€โ”€ colors # Pre-installed colorschemes directory +โ”‚ โ””โ”€โ”€ doom-one.vim # doom-one colorscheme ported to Nvim (`default one`) +โ”œโ”€โ”€ doc # Doom Nvim documentation to be used inside Nvim +โ”‚ โ””โ”€โ”€ doom_nvim.txt # Doom Nvim help file +โ”œโ”€โ”€ docs # Doom Nvim docs meant to be readed on GitHub +โ”œโ”€โ”€ doomrc # Doom Nvim user configurations file +โ”œโ”€โ”€ init.lua # init.lua file +โ”œโ”€โ”€ install.sh # Doom Nvim installer +โ”œโ”€โ”€ LICENSE # Doom Nvim License +โ”œโ”€โ”€ lua # Location of Doom Nvim Lua files +โ”‚ โ”œโ”€โ”€ doom # Doom Nvim Lua core +โ”‚ โ”‚ โ”œโ”€โ”€ core # Doom Nvim core functionality +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ autocmds # Doom Nvim autocommands +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ config # Doom Nvim configuration files +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ default # Doom Nvim default Neovim settings +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ functions # Doom Nvim functions +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ health # Doom Nvim health checking +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ keybindings # Doom Nvim keybindings +โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ logging # Doom Nvim logging system +โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ system # Doom Nvim system utilities (early stage) +โ”‚ โ”‚ โ””โ”€โ”€ utils # Doom Nvim utilities +โ”‚ โ””โ”€โ”€ modules # Location of Doom Nvim plugins +โ”‚ โ”œโ”€โ”€ configs # Plugins configurations +โ”‚ โ”œโ”€โ”€ built-in # Doom Nvim built-in plugins +โ”‚ โ””โ”€โ”€ init.lua # packer.nvim setup +โ””โ”€โ”€ sessions # Location of Neovim workspaces + +Doom Nvim also sets default configurations for the `doomrc.lua` and the +`doom_config.lua` files, which serves as the user configuration file if it is not present on the system. It allows a fine control over the core -functions of Doom Nvim. It is a copy of the doom.vim file. +functions of Doom Nvim. ============================================================================== @@ -698,34 +568,16 @@ ACKNOWLEDGEMENTS *doom_nvim_acknowledgements* Doom Nvim would not have been possible had it not been for - - hlissner : Creator of Doom Emacs - - romgrk : Ported doom-one colorscheme from Doom Emacs to Vim + - hlissner : Creator of Doom Emacs + - romgrk : Ported doom-one colorscheme from Doom Emacs to Vim + - All our contributors ============================================================================== LICENSE *doom_nvim_license* -Doom Nvim is distributed under MIT License. - -Copyright (c) 2021 NTBBloodbath - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +Doom Nvim is distributed under GPLv2 license. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. ============================================================================== CONTRIBUTING *doom_nvim_contributing* @@ -733,151 +585,11 @@ CONTRIBUTING *doom_nvim_contributing* - I really love pull requests and bug reports (please see the Contributing Guidelines on GitHub before contributing) -- Don't hesitate to tell me my Lua coding style sucks, but please tell me why - (I am new to Lua, I may have some bad practices that can be fixed in code). +- Don't hesitate to tell me my Lua coding style sucks, but please tell me why. ============================================================================== CHANGELOG *doom_nvim_changelog* -The format is based on Keep a Changelog (https://keepachangelog.com/en/1.0.0/), -and this project adheres to Semantic Versioning -(https://semver.org/spec/v2.0.0.html). - -- 2.1.5 - - Changed - - Installation script will not install packer anymore, it'll be installed by Doom - when started for the first time - - Fixed - - Now core plugins will be installed at first start -- 2.1.4 - - Fixed - - TreeSitter syntax highlighting and indentation -- 2.1.3 - - Removed - - Unused code in packer setup - - Fixed - - Some bugs in packer setup -- 2.1.2 - - Removed - - `Is_directory` function in `utils/` - - Fixed - - Squashed bugs in `Check_plugin` function - - Installation script will install packer.nvim in `start/` and not in `opt/` -- 2.1.1 - - Fixed - - Squashed a bug in packer setup - - Stop referencing autoload in docs -- 2.1.0 - - Added - - Now the `:messages` are logged automatically on exit, should provide - a better debugging experience - - Plugins - - Configurations - - `devicons` configurations, set proper icons for certain filetypes - (most of them related to web development) - - Changed - - Configurations - - Better defaults - - Breaking changes - - doomrc is not using Vimscript anymore, please see - the new doomrc format - - Plugins - - Replaced - - `indentLine` in favour of `indent-blankline.lua` - - Updated - - New `galaxyline` appearance, should look better now :) - - `WhichKey` configurations, some improvements - - `nvim-toggleterm` configurations, some improvements - - Moved `dashboard` configurations to - `lua/plugins/configs/nvim-dashboard.lua` - - Misc - - Refact Doom Nvim README - - Deleted - - Doom autoload files - (we are already _almost_ completely free from Vimscript!) - - Fixed - - Some typos - - Squashed some bugs - - Lua style (global things to Capitalize), no more warns about that -- 2.0.0 - - Added - - Configurations - - `g:doom_autoload_last_session` variable, see |doom_nvim_options| - - `g:doom_terminal_direction` variable, see |doom_nvim_options| - - `g:doom_terminal_width` variable, see |doom_nvim_options| - - `g:doom_terminal_height` variable, see |doom_nvim_options| - - Plugins - - `auto-session` - - Changed - - Installation script - - Now you can select the branch to use (main, develop) - - Lua migration - - init - - configs - - plugins - - Implemented better custom plugins system, - see |doom_nvim_configuration_custom_plugins| - - Start using TreeSitter based indentation - - Plugins - - Replaced - - `Goyo` in favour of `TrueZen` - - `leader-mapper` in favour of `WhichKey` - - `Vista.vim` in favour of `SymbolsOutline` - - `Neoformat` in favour of `format.nvim` - - `nvim-autopairs` in favour of `pears.nvim` - - Updated - - `nvim-toggleterm` configurations - - Other changes - - `telescope.nvim` cannot be disabled anymore - - Keybindings - - Refact some `` bindings - - Use `:TZAtaraxis` as F6 key bind - - New `:dr` map, easily create crash reports - - Misc - - Cleaned some code hunk - - Formatted all files - - Refact changelog - - Deleted - - Old Vimscript configs codebase - - Plugins - - Deleted `vim-polyglot` in favour of TreeSitter based - syntax highlighting - - Fixed - - Some bugs that I don't really remember - - Squashed bugs on autoload functions -- 1.2.1 - - Added - - New branch `develop` - - Changed - - Improved installation script -- 1.2.0 - - Added - - Configurations - - `g:doom_ts_parsers`, see |doom_nvim_options| - - New key binding for toggle terminal, - see |doom_nvim_commands_keybindings| - - `doomrc` template with the default options values - - Basic implementation for `:checkhealth` command - - Plugins - - `gitsigns` - - `indentLine` - - `nvim-lspinstall` - - Some new colorschemes, see |doom_colorscheme| - - Changed - - Improved `:DoomUpdate` command - - Some minor changes more under the hood - - Plugins - - `signify` in favor of `gitsigns` - - Fixed - - Squashed some bugs -- 1.1.0 - - Added - - `Doom` section to `vim-leader-guide` plugin, - see |doom_nvim_commands_keybindings| - - `:DoomUpdate` command, - see |doom_nvim_commands| - - `g:doom_autosave_sessions`, - see |doom_nvim_options| -- 1.0.0 - - Initial stable release +Please see `$HOME/.config/doom-nvim/CHANGELOG.md` for a full and detailed +changelog. diff --git a/doc/tags b/doc/tags index 591e97f62..eb61b32c5 100644 --- a/doc/tags +++ b/doc/tags @@ -10,7 +10,7 @@ doom_nvim_configuration_layout doom_nvim.txt /*doom_nvim_configuration_layout* doom_nvim_configuration_layout_explorer doom_nvim.txt /*doom_nvim_configuration_layout_explorer* doom_nvim_configuration_layout_mainbuffer doom_nvim.txt /*doom_nvim_configuration_layout_mainbuffer* doom_nvim_configuration_layout_minimap doom_nvim.txt /*doom_nvim_configuration_layout_minimap* -doom_nvim_configuration_layout_tagbar doom_nvim.txt /*doom_nvim_configuration_layout_tagbar* +doom_nvim_configuration_layout_outline doom_nvim.txt /*doom_nvim_configuration_layout_outline* doom_nvim_configuration_layout_terminal doom_nvim.txt /*doom_nvim_configuration_layout_terminal* doom_nvim_configuration_lsp doom_nvim.txt /*doom_nvim_configuration_lsp* doom_nvim_configuration_modules doom_nvim.txt /*doom_nvim_configuration_modules* diff --git a/docs/README.md b/docs/README.md index 3f39a6669..a30c3373b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -4,8 +4,8 @@ Doom Nvim is a port to Neovim of the [Doom Emacs](https://github.com/hlissner/do configuration framework for [GNU Emacs](https://www.gnu.org/software/emacs/) adapted for all vimmer who want less framework in their framework and the performance of a handmade configuration (or better). It can be a base for your own setup or a -resource for Vim enthusiasts to learn more about our favorite editor and how to -do X things on it by using Vimscript/Lua. +resource for Neovim enthusiasts to learn more about our favorite editor and how to +do X things on it by using Lua. Doom Nvim is an opinionated collection of reasonable (and optional) defaults with a focus on performance (both runtime and startup) and on abstraction-light, readable @@ -14,42 +14,32 @@ code design, so that there is less between you and Neovim. > The documentation is designed to be viewed within Doom Nvim. Access it by pressing > `:h doom_nvim`. -# Table of Contents -- [Documentation](#documentation) - - [Getting Started](#getting-started) - - [Modules](#modules) - - [Contributing](#contributing) -- [Community Resources](#community-resources) - - [Asking for help](#asking-for-help) - - [Projects](#projects) +## Documentation -# Documentation - -## Getting Started +### Getting Started - [Install](./getting_started.md#install) - [Update & Rollback](./getting_started.md#update--rollback) - [Configuration](./getting_started.md#configuration) -## Modules +### Modules - [Introduction](./modules.md#introduction) - [Tweaking Doom Nvim Modules](./modules.md#tweaking-doom-nvim-modules) -## Contributing +### Contributing - [Where can I help?](./contributing.md#where-can-i-help) - [Reporting issues](./contributing.md#reporting-issues) - [Suggesting features, keybinds and enhancements](./contributing.md#suggesting-features-keybinds-and-enhancements) - [Contributing code](./contributing.md#contributing-code) +## Community Resources -# Community Resources - -## Asking for help +### Asking for help - [Our issues tracker](https://github.com/NTBBloodbath/doom-nvim/issues) -## Projects +### Projects - [Projects](https://github.com/NTBBloodbath/doom-nvim/projects) diff --git a/docs/contributing.md b/docs/contributing.md index 245aee5f2..1c0dce524 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -11,22 +11,7 @@ and which code style you should use :heart: > **Working on your first Pull Request?** You can learn how from this _free_ series > [How to Contribute to an Open Source Project on GitHub](https://kcd.im/pull-request). -# Table of Contents - -- [Where can I help?](#where-can-i-help) -- [Reporting issues](#reporting-issues) - - [Acquire a backtrace from errors](#acquire-a-backtrace-from-errors) - - [Create a step-by-setp reproduction guide](#create-a-ste-by-step-reproduction-guide) - - [Include information about your Doom Nvim install](include-information-about-your-doom-nvim-install) -- [Suggesting features, keybinds and enhancements](#suggesting-features-keybinds-and-enhancements) -- [Contributing code](#contributing-code) - - [Conventions](#conventions) - - [Code style](#code-style) - - [Commits & PRs](#commits--prs) - - [Keybind conventions](#keybind-conventions) - - [Submitting pull requests](#submitting-pull-requests) - -# Where can I help +## Where can I help - If youโ€™ve encountered a bug, [file a bug report](https://github.com/NTBBloodbath/doom-nvim/issues/new/choose). - Check out our [issue tracker](https://github.com/NTBBloodbath/doom-nvim/issues) @@ -38,56 +23,49 @@ and which code style you should use :heart: so that it works correctly on your environment, you can do it freely since I currently do not have that system to do tests. -# Reporting issues +## Reporting issues -## Acquire a backtrace from errors +### Acquire a backtrace from errors -All the errors ocurred in Doom Nvim are saved into a `doom.log` file inside a `logs/` -directory inside your Doom Nvim root dir (`$HOME/.config/doom-nvim` by default). -If the logs are very long, please paste it using a [gist]. +All the errors ocurred in Doom Nvim are saved into a `doom.log` file inside the +`~/.local/share/nvim/` directory. If the logs are very long, please paste it +using a [gist]. -> **NOTE:** Alternatively you can paste the most recent lines starting with the -> following if the logs are extremely long. -> -> [!] - Errors -> -> [!!!] - Critical errors - -## Create a step-by-step reproduction guide +### Create a step-by-step reproduction guide A step-by-step guide can help considerably to debug the error that occurs and thus reach a solution more quickly. -## Include information about your Doom Nvim install +### Include information about your Doom Nvim install Some important data would be: -- Your Neovim version -- Your custom configuration if you have one (`$HOME/.config/doom-nvim/doomrc`) +- Your custom configuration if you have one + (`doomrc.lua`, `doom_config.lua` and `plugins.lua`) - Which branch of Doom Nvim are you using - Which plugins are you using -# Suggest features, keybinds and enhancements +## Suggest features, keybinds and enhancements -- To request a new feature, please use the prefix `[Feature Request]` in your issue. -- To request a keybind, please use the prefix `[Keybind Request]` in your issue. -- To request an enhancement, please use the prefix `[Enhancement]` in your issue. +- To request a new feature, please use the prefix `Feature request:` in your issue. +- To request a keybind, please use the prefix `Keybind request:` in your issue. +- To request an enhancement, please use the prefix `Enhancement:` in your issue. In this way, it is much easier and more organized to identify the type of issue and handle the requests. -# Contributing code +## Contributing code -## Conventions +### Conventions -### Code style +#### Code style Doom Nvim follows some code style rules like ones the mentioned below: -- Single quotes instead of double quotes. +- Single quotes over double quotes. +- Tabs over spaces. - Variable names in `snake_case`, except in the BASH installation script. -- Function names in `snake_case`, the only exception are the Vimscript functions - which does not are from doom itself, e.g. `function ToggleTerm() ... endfunction`. +- Function names in `snake_case`. - [stylua] is used to format lua files with the following configuration: ```toml @@ -99,20 +77,31 @@ quote_style = "AutoPreferSingle" ``` -### Commits & PRs +> **NOTE:** use `--config-path /path/to/doom/nvim/stylua.toml` to use doom's +> stylua configuration. + +- [selene] is a blazing-fast modern Lua linter written in Rust which is used for + linting doom's source code. We make use of some custom rules so we can be sure + that selene will not raise false errors. + +> **NOTE:** use `selene .` in doom's root dir and selene will automatically +> detect the `selene.toml` and `doom.toml` files. + +#### Commits & PRs - Target `develop` instead of `main`. - the only exception are hotfixes! + The only exception are hotfixes! -### Keybind conventions +#### Keybind conventions -- The keybindings should be declared in [config/keybindings](../lua/doom/keybindings.lua), - except when they are keybindings of [Lua plugins](../lua/plugins/configs). +- The keybindings should be declared in [core/keybindings](../lua/doom/core/keybindings/init.lua), + except when they are keybindings of [Lua plugins](../lua/doom/modules/config). -## Submitting pull requests +### Submitting pull requests -After having made all your changes and having tested them locally to certify that -they work and do not break any of the current code, you can proceed to upload +After having made all your changes **and having tested them locally to certify that** +**they work and do not break any of the current code**, you can proceed to upload your pull request :) [stylua]: https://github.com/JohnnyMorganz/StyLua +[selene]: https://github.com/Kampfkarren/selene diff --git a/docs/faq.md b/docs/faq.md index f74b3966c..3aa43aa24 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -1,20 +1,16 @@ # Frequently Asked Questions -# Table of Contents -- [General](#general) - - [What type of vimmer is Doom Nvim intended for?](#what-type-of-vimmer-is-doom-nvim-intended-for) - - [Why does Doom Nvim only support Neovim nightly?](#why-does-doom-nvim-only-support-neovim-nightly) +## General -# General - -## What type of vimmer is Doom Nvim intended for? +### What type of vimmer is Doom Nvim intended for? Doom Nvim is intended for all types of Vimmer who want a stable and efficient development environment without spending a lot of time setting everything up. -## Why does Doom Nvim only support Neovim nightly? +### 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: -Doom Nvim doesn't support Neovim versions lower than Nightly (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 diff --git a/docs/getting_started.md b/docs/getting_started.md index 730f2943c..3707fa72e 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -1,64 +1,36 @@ # Getting Started -# Table of Contents - -- [Install](#install) - - [Neovim & dependencies](#neovim--dependencies) - - [On Linux](#on-linux) - - [Ubuntu](#ubuntu) - - [Arch Linux](#arch) - - [On MacOS](#on-macos) - - [On Windows](#on-windows) - - [External dependencies](#external-dependencies) - - [On Linux](#on-linux) - - [Ubuntu](#ubuntu) - - [Fedora](#fedora) - - [Arch Linux](#arch) - - [On MacOS](#on-macos) - - [On Windows](#on-windows) - - [Doom Nvim](#doom-nvim) -- [Update & Rollback](#update--rollback) - - [Update Doom Nvim](#update-doom-nvim) - - [Rollback](#rollback) -- [Configuration](#configuration) - - [Modules](#modules) - - [Package Management](#package-management) - - [Installing plugins](#installing-plugins) - - [Disabling plugins](#disabling-plugins) - - [Configuring Doom](#configuring-doom) - - [Configuring settings](#configuring-settings) - - [Configuring plugins](#configuring-plugins) - - [Configuring LSP](#configuring-lsp) - - [Binding keys](#binding-keys) - -# Install +## Install This is what you will have installed by the end of this section: - Git 2.23+ -- Neovim 0.5.0 (Neovim 0.4 not supported, see [faq](https://github.com/NTBBloodbath/doom-nvim/blob/main/docs/faq.md#why-does-doom-nvim-only-support-neovim-nightly) to know why) -- ripgrep 11.0+ +- Neovim 0.5.0+ (Neovim 0.4.x not supported, see [faq](./faq.md#why-does-doom-nvim-only-support-neovim-05) to know why) - GNU Find -- (Optional) fd 7.3.0+ (known as `fd-find` on Debian, Ubuntu & derivates), +- **Optional**: ripgrep 11.0+ +- **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). +- **Optional**: node & npm, required to use LanguageServerProtocols (LSP) and the plugins using LSP, like the symbols-outline plugin. These packages ought to be available through the package managers of your OS; i.e. pacman/aptitude/rpm/etc on the various Linux distributions. -## Neovim & dependencies +### Neovim & dependencies -### On Linux +#### On Linux -Since Neovim 0.5 is a night version, it does not come packaged in the repositories -of your distribution, so you have several options to install it. +Neovim 0.5.0 was recently released as a stable version. +You can check what version your repository has by looking at [this site.](https://repology.org/project/neovim/versions) +If Neovim 0.5.0 is still not available in your repository, you can install it by doing one of the following: 1. Using the Doom Nvim install script to download a Neovim Nightly AppImage from releases (see how by executing the installer with bash -s -- -h). 2. Using extra repositories according to your distribution (PPA/COPR/AUR/etc). -#### Ubuntu +3. Using a Neovim version manager like [nvenv](https://github.com/NTBBloodbath/nvenv). + +##### Ubuntu You can get nightly builds of git master from the [Neovim Unstable PPA](https://launchpad.net/~neovim-ppa/+archive/ubuntu/unstable). @@ -68,19 +40,30 @@ add-apt-repository ppa:neovim-ppa/unstable apt-get update ``` -#### Arch +##### Fedora + +Nightly builds can be installed by using the +[agriffis/neovim-nightly](https://copr.fedorainfracloud.org/coprs/agriffis/neovim-nightly/) +COPR repository. + +```sh +dnf copr enable agriffis/neovim-nightly +dnf update +``` + +##### Arch Neovim Nightly builds can be installed using the PKGBUILD [`neovim-nightly-bin`](https://aur.archlinux.org/packages/neovim-nightly-bin), available on the [AUR](https://wiki.archlinux.org/index.php/Arch_User_Repository). -### On MacOS +#### On MacOS -You can download a prebuilt binary from the [Neovim](https://github.com/neovim/neovim/releases/tag/nightly) nightly releases page. +You can download a prebuilt binary from the [Neovim](https://github.com/neovim/neovim/releases/tag/nightly) releases page. -1. Download: ``` curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim-macos.tar.gz``` -2. Extract: ``` tar xzvf nvim-macos.tar.gz``` -3. Run: ```./nvim-osx64/bin/nvim``` +1. Download: `curl -LO https://github.com/neovim/neovim/releases/download/v0.5.0/nvim-macos.tar.gz` +2. Extract: `tar xzvf nvim-macos.tar.gz` +3. Run: `./nvim-osx64/bin/nvim` You may wish to add it to your PATH using something like: `export PATH="$HOME/nvim-osx64/bin:$PATH"` @@ -89,7 +72,7 @@ Neovim nightly can also be downloaded with [homebrew](https://brew.sh/): `brew install --HEAD neovim` will download the source and build it locally on your machine. -If you already have Neovim v4 installed you may need to unlink it. +If you already have Neovim v0.4 installed you may need to unlink it. ``` brew unlink neovim @@ -97,52 +80,73 @@ brew install neovim --HEAD nvim --version ``` -MacPorts currently only has Neovim v4.4 +MacPorts currently only has Neovim v0.4.4 + + + +#### On Windows + +##### [Chocolatey](https://community.chocolatey.org/) + +``` +choco install neovim --pre +``` +##### [Scoop](https://scoop.sh/) +``` +scoop bucket add versions +scoop install neovim-nightly +``` -### On Windows +##### Manual -If you use Windows, please put the steps to install Neovim Nightly here! +You can also download a prebuilt binary from the [Neovim](https://github.com/neovim/neovim/releases) releases page. -## External dependencies +### External dependencies -### On Linux +#### On Linux -#### Ubuntu +##### Ubuntu ```sh # Required dependencies apt-get install git ripgrep + # (Optional) Improves performance for many file indexing commands apt-get install fd-find -# (Optional) Required by Language Server Protocols + +# (Optional) Required by some Language Server Protocols apt-get install nodejs npm ``` -#### Fedora +##### Fedora ```sh # Required dependencies dnf install git ripgrep + # (Optional) Improves performance for many file indexing commands dnf install fd-find # is 'fd' in Fedora <28 -# (Optional) Required by Language Server Protocols + +# (Optional) Required by some Language Server Protocols dnf install nodejs ``` -#### Arch +##### Arch ```sh # Required dependencies pacman -S git ripgrep + # (Optional) Improves performance for many file indexing commands pacman -S fd -# (Optional) Required by Language Server Protocols + +# (Optional) Required by some Language Server Protocols pacman -S nodejs npm ``` -### On MacOS +#### On MacOS Dependencies can be installed using [homebrew](https://brew.sh/) @@ -156,22 +160,22 @@ brew install node ``` -### On Windows +#### On Windows If you use Windows, please help by posting the steps to install the external dependencies here! -## Doom Nvim +### Doom Nvim -With Neovim Nightly and Doom's dependencies installed, next is to install +With Neovim v0.5.0 and Doom's dependencies installed, next is to install Doom Nvim itself: > **NOTES:** - -1. If you have not installed Neovim Nightly yet, please run the following command - before installing Doom Nvim, it will install Neovim nightly and Doom Nvim. -2. If you want to know all the commands of the installer, run the installer with - bash -s -- -h instead of just bash. +> +> 1. If you have not installed Neovim 0.5.0 yet, please run the following command +> before installing Doom Nvim, it will install Neovim 0.5.0 and Doom Nvim. +> 2. If you want to know all the commands of the installer, run the installer with +> bash -s -- -h instead of just bash. ```sh # Check if you have all the dependencies listed above @@ -179,135 +183,383 @@ curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/install. ``` ```sh -# If you do not have Neovim nightly but you have all the dependencies listed above +# If you do not have Neovim 0.5.0 but you have all the dependencies listed above curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/install.sh | bash -s -- -n ``` ```sh -# If you already have Neovim nightly and all the dependencies listed above +# If you already have Neovim 0.5.0 and all the dependencies listed above curl -sLf https://raw.githubusercontent.com/NTBBloodbath/doom-nvim/main/install.sh | bash ``` The installation script will set up everything for you and will work you through the first-time setup of Doom Nvim. -# Update & Rollback +#### Using cheovim -## Update Doom Nvim +If you're using cheovim as your Neovim configurations manager you can use the +recipe listed in cheovim documentation: + +```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` inside Neovim or run the installation script with bash -s -- -u. -## Rollback +### Rollback + +#### Previous Configurations To uninstall Doom Nvim and go back to your previous setup, simply run the installation script with bash -s -- -x. It will uninstall Doom Nvim and restore the backup of your previous setup. -# Configuration +#### Rolling Back Doom -You can configure Doom Nvim by tweaking the file `doomrc` in your Doom Nvim root -dir (`$HOME/.config/doom-nvim/` by default), please see -:h doom_nvim for more information. +Did the update screwed 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). -## Modules +> **IMPORTANT**: remember to report the issues before just rolling back. In that +> way we can work on fixing them and make doom better! -Doom Nvim consists of around 7 modules and growing. A Doom Nvim Module is a bundle of plugins, -configuration and commands, organized into a unit that can be toggled easily by -tweaking your doomrc (found in `$HOME/.config/doom-nvim`). +## Configuration -Please see [Package Management](#package-management) for more information. +You can configure Doom Nvim by tweaking the `doomrc.lua`, `doom_config.lua` and +the `plugins.lua` files located in your Doom Nvim root directory +(`$HOME/.config/doom-nvim/` by default). -> **IMPORTANT:** any changes to your Doom Nvim Modules won't take effect until -> you run `:PackerSync` inside Neovim. +### doomrc.lua -## Package Management +This file handles all the Doom Nvim modules, its structure is really simple and +easy to understand. -Doom Nvim does not use Vim-Plug in the Neovim Nightly version. Instead, it uses -a declarative and use-package inspired package manager called -[packer.nvim](https://github.com/wbthomason/packer.nvim). +This one will look like that: + +```lua +local doom = { + ui = { + 'dashboard', -- Start screen + -- 'doom-themes', -- Additional doom emacs' colorschemes + 'statusline', -- Statusline + 'tabline', -- Tabline, shows your buffers list at top + -- 'zen', -- Distraction free environment + 'which-key', -- Keybindings popup menu like Emacs' guide-key + -- 'indentlines', -- Show indent lines + }, + doom = { + -- 'neorg', -- Life Organization Tool + -- 'runner', -- Open a REPL for the current language or run the current file + -- 'compiler', -- Compile (and run) your code with just pressing three keys! + }, + editor = { + 'auto-session', -- A small automated session manager for Neovim + -- 'terminal', -- Terminal for Neovim (NOTE: needed for runner and compiler) + 'explorer', -- Tree explorer + 'symbols', -- LSP symbols and tags + -- 'minimap', -- Code minimap, requires github.com/wfxr/code-minimap + 'gitsigns', -- Git signs + 'telescope', -- Highly extendable fuzzy finderover lists + -- 'restclient', -- A fast Neovim http client + 'formatter', -- File formatting + 'autopairs', -- Autopairs + -- 'editorconfig', -- EditorConfig support for Neovim + 'kommentary', -- Comments plugin + 'lsp', -- Language Server Protocols + 'snippets', -- LSP snippets + }, + langs = { + -- To enable the language server for a language justadd the +lsp flag + -- at the end, e.g. 'rust +lsp'. This will install the rust TreeSitter + -- parser and rust-analyzer + -- + -- 'html', -- HTML support + -- 'css', -- CSS support + -- 'javascript', -- JavaScript support + -- 'typescript', -- TypeScript support + -- 'bash', -- The terminal gods language + -- 'python +lsp', -- Python support + lsp + -- 'ruby', -- Look ma, I love the gems! + 'lua', -- Support for our gods language + -- 'elixir', -- Build scalable and maintainablesoftware + -- 'haskell', -- Because Functional programming is fun, isn't it? + + -- 'rust +lsp', -- Let's get rusty! + -- 'go', -- Hello, gopher + -- 'cpp', -- C++ support + -- 'java', -- Java support + + -- 'config', -- Configuration files (JSON, YAML, TOML) + -- 'dockerfile', -- Do you like containers, right? + }, + utilities = { + -- 'suda', -- Write and read files without sudo permissions + -- 'lazygit', -- LazyGit integration for Neovim, requires LazyGit + -- 'neogit', -- Magit for Neovim + -- 'colorizer', -- Fastets colorizer for Neovim + 'range-highlight', -- hightlights ranges you haveentered in commandline + }, +} -Modules and plugins are declared in `lua/plugins/init.lua` file, located in your Doom Nvim root dir. -Read on to learn how to use this system to install your own plugins. +return doom +``` -> **WARNING:** Do not install plugins directly in `lua/plugins/init.lua`. Instead, -> use your `doomrc` to modify them. +And as the `doomrc.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. -### Installing plugins +> **NOTE**: for more information please refer to [modules]. -To install a custom plugin, add it to `custom_plugins` field into the `Doom` table -in your `doomrc`. +### doom_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 --- @default = {} -custom_plugins = { 'plugin_author/plugin_repo' } +local doom = { + -- Here lies all the Doom Nvim configurations +} + +local nvim = { + -- Here lies all the custom Neovim configurations +} + +return { + doom = doom, + nvim = nvim, +} ``` -You can also use other method if the plugin depends on other plugins. +### plugins.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 -custom_plugins = { - 'plugin_author/plugin_repo', +return { { - 'repo': 'plugin_author/second_plugin_repo', - 'enabled': true, -- not required, true by default - 'requires': { 'foo', 'bar' } -- not required if the plugin does not have dependencies + 'iamcco/markdown-preview.nvim', + run = 'cd app && yarn install', + event = 'BufRead', }, } ``` -> **NOTES:** -> -> 1. Do not forget to run `:PackerInstall` to install your new plugins. +And as with the `doomrc.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 `doomrc.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. + +> **WARNING:** Do not install plugins directly in `lua/doom/modules/init.lua`. Instead, +> use your `doomrc.lua` and `plugins.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 -### Disabling 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. -To disable plugins from Doom Nvim Modules or disable a module itself, just use the -`disabled_plugins` and/or `disabled_modules` fields. +Otherwise if you want to configure a plugin declared in your `plugins.lua` you +can use the packer's `config` field, e.g. ```lua --- @default = {} -disabled_plugins = { 'terminal', 'treesitter' } +{ + 'TimUntersberger/neogit', + config = function() + require('neogit').setup() + end, +} +``` + +##### Configuring LSP + +[Language Server Protocols](https://microsoft.github.io/language-server-protocol/) is installed as a plugin. --- @default = { 'git', 'lsp', 'web' } -let g:doom_disabled_modules = { 'web' } +To easily install language servers and without having to do it system-wide or having to +manually configure servers, Doom Nvim makes use of [kabouzeid/nvim-lspinstall](https://github.com/kabouzeid/nvim-lspinstall). + +To enable the language server for a certain programming language and automatically +install it, just append a `+lsp` flag at the end of the language field in your `doomrc.lua`, +e.g. for enabling Rust support in Doom and install `rust-analyzer`: + +```lua +local doom = { + langs = { + 'rust +lsp', -- Let's get rusty! + } +} ``` -> **NOTES:** -> -> 1. Do not forget to run `:PackerSync` or your changes won't take effect. +> **NOTE**: You can see a list of currently supported languages at [bundled installers](https://github.com/kabouzeid/nvim-lspinstall#bundled-installers). + +### Binding keys + +You can modify the default keybindings by modifying the following files: + +- `lua/doom/core/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 + +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: + +### 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 `doomrc.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. + +### 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. +- Added selene linter CI for incoming pull requests and stylua CI for pushes. + Let's get a consistent way to maintain Doom Nvim source! + +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:** > -> 2. You can see a list of the plugins that you can disable on [Modules](./modules.md#list-of-modules). +> 1. Make sure to read everything it does before executing it. > -> 3. You can also see how to enable/disable plugins modules on [Modules](./modules.md). +> 2. If you are using cheovim just remove and clone the doom-nvim repository again. -## Configuring Doom +```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/install.sh | bash -s -- -d +``` -### Configuring settings +This snippet will do the following tasks for you: -You can change Doom's default settings by tweaking your `doomrc`, please see -:h doom_nvim to know how to. +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). -### Configuring plugins +Then you'll only need to start Neovim and start using it as usual! -Do you want to change some configurations of some modules? +#### New configurations -Go to `lua/plugins/configs` dir and you will find the configurations for the plugins. +Since version 3.0.0 the doomrc has been fragmented into some files, but why? -### Configuring LSP +This was done to benefit both contributors and end users as follows: -To easily install LSPs and without having to do it system-wide or having to -manually configure servers, Doom Nvim makes use of [kabouzeid/nvim-lspinstall](https://github.com/kabouzeid/nvim-lspinstall). -You can see a list of currently supported languages at [bundled installers](https://github.com/kabouzeid/nvim-lspinstall#bundled-installers). +- 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. -> Usage example: +And now, how can I start using the new configuration files? -- `:LspInstall python` to install Python LSP -- `:LspUninstall python` to uninstall Python LSP +I'm going to explain you in a short way because the new configuration files has +a rich documentation inside them. -## Binding keys +- `doomrc.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. +- `plugins.lua`, this file handles the user-defined plugins, it is the + replacement for the `custom_plugins` field in the old doomrc. -You can modify the default keybindings by modifying the following files: +> 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. -- `lua/doom/keybindings/init.lua` - General and SPC keybindings -- `lua/plugins/configs` - lua plugins keybindings +[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 915e27a8e..1b7b5003e 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -1,222 +1,254 @@ # Doom Nvim Modules -# Table of Contents - -- [Introduction](#introduction) -- [Tweaking Doom Nvim Modules](#tweaking-doom-nvim-modules) - - [List of modules](#list-of-modules) - - [Essentials](#essentials) - - [UI](#ui) - - [Fuzzy](#fuzzy) - - [Git](#git) - - [LSP](#lsp) - - [Files](#files) - - [Web](#web) - - [Managing modules](#managing-modules) - - [Enabling modules](#enabling-modules) - - [Enabling module plugins](#enabling-module-plugins) - - [Disabling modules](#disabling-modules) - - [Disabling module plugins](#disabling-module-plugins) - -# Introduction - -Doom Nvim consists of around 7 modules and growing. A Doom Nvim Module is a bundle of plugins, -configuration and commands, organized into a unit that can be toggled easily. - -# Tweaking Doom Nvim Modules - -You can easily tweak Doom Nvim Modules by tweaking your doomrc -(found in `$HOME/.config/doom-nvim`). +## Introduction -## List of modules - -First of all, we must know which modules we can enable and disable, -including their plugins individually. +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. -### Essentials +> **NOTE**: Doom Nvim uses [packer.nvim] as its plugins manager. -- [x] Enabled by default -- [ ] Can be disabled -- Plugins inside - - [ ] [packer.nvim] - A use-package inspired plugin manager for Neovim. - - [ ] [vimpeccable] - Helpers for Lua configs. - - [x] [treesitter] - Nvim Treesitter configurations and abstraction layer. - - Use `treesitter` to disable it +## Tweaking Doom Nvim Modules -### UI +You can easily tweak Doom Nvim Modules by tweaking your `doomrc.lua` file +(found in `~/.config/doom-nvim`). -- [x] Enabled by default -- [ ] Can be disabled -- Plugins inside - - [ ] [dashboard-nvim] - Vim dashboard. - - [x] colorschemes - Obviously, colorschemes. - - Use `colorschemes` to disable it - - [x] [nvim-tree.lua] - A file explorer tree for neovim written in lua. - - Use `tree` to disable it - - [x] [galaxyline.nvim] - galaxyline is a light-weight and Super Fast statusline plugin. - - Use `statusline` to disable it - - [x] [barbar.nvim] - Tabs, as understood by any other editor. - - Use `tabline` to disable it - - [x] [nvim-toggleterm.lua] - A neovim plugin to persist and toggle multiple terminals during an editing session - - Use `terminal` to disable it - - [x] [symbols-outline.nvim] - A tree like view for symbols in Neovim using the Language Server Protocol. - - Use `tagbar` to disable it - - [x] [minimap.vim] - Blazing fast minimap / scrollbar for vim, powered by code-minimap written in Rust. - - Use `minimap` to disable it - - **Depends on** [wfxr/code-minimap](htps://github.com/wfxr/code-minimap) **to work!** - - [ ] [which-key.nvim] - WhichKey is a lua plugin for Neovim 0.5 that displays a popup with possible keybindings of the command you started typing. - - [x] [TrueZen.nvim] - Clean and elegant distraction-free writing for NeoVim. - - Use `zen` to disable it - -### Fuzzy - -- [x] Enabled by default -- [ ] Can be disabled -- Plugins inside - - [ ] [telescope.nvim] - Find, Filter, Preview, Pick. All lua, all the time. - -### Git - -- [ ] Enabled by default -- [x] Can be disabled - - Use `git` to disable the entire module -- Plugins inside - - [x] [gitsigns.nvim] - Git signs written in pure lua - - Use `gitsigns` to disable it - - [x] [lazygit.nvim] - Plugin for calling lazygit from within neovim. - - Use `lazygit` to disable it - - **Depends on** [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) **to work!** - -### LSP - -- [ ] Enabled by default -- [x] Can be disabled - - Use `lsp` to disable the entire module -- Plugins inside - - [x] [nvim-lspconfig] - Quickstart configurations for the Nvim LSP client - - Use `lspconfig` to disable it - - **NOTE:** do not disable it if you are going to use LSP! - - [x] [nvim-compe] - Auto completion plugin for nvim that written in Lua. - - Use `compe` to disable it - -### Files - -- [x] Enabled by default -- [x] Can be disabled - - Use `files` to disable the entire module -- Plugins inside - - [x] [suda.vim] - suda is a plugin to read or write files with sudo command. - - Use `suda` to disable it - - [x] [format.nvim] - Neovim lua plugin to format the current buffer with external executables. - - Use `formatter` to disable it - - [x] [pears.nvim] - Auto pair plugin for neovim - - Use `autopairs` to disable it - - [x] [indentLine] - A vim plugin to display the indention levels with thin vertical lines - - Use `indentlines` to disable it - - [x] [editorconfig-vim] - EditorConfig support - - Use `editorconfig` to disable it - - [x] [kommentary] - Neovim commenting plugin, written in lua. - - Use `kommentary` to disable it - -### Web - -- [ ] Enabled by default -- [x] Can be disabled - - Use `web` to disable the entire module -- Plugins inside - - [x] [nvim-colorizer.lua] - A high-performance color highlighter for Neovim which has no external dependencies written in performant Luajit. - - Use `colorizer` to disable it - - [x] [vim-dot-http] - Rest HTTP Client - - Use `restclient` to disable it - - **Depends on** [bayne/dot-http](https://github/bayne/dot-http) **to work!** - - [x] [emmet-vim] - Emmet for Vim - - Use `emmet` to disable it +## List of modules -## Managing modules +First of all, we must know which modules are there and their plugins. -### Enabling modules +> **NOTE:** all plugins can be disabled, including the UI ones. -To enable a module, you can use the `disabled_modules` field in the `Doom` table -on your `doomrc`. +### Essentials -```lua --- To enable all modules except web, just put only 'web' in the disabled modules --- array and then, reboot Neovim and do :PackerSync --- --- @default = { 'git', 'lsp', 'web' } -disabled_modules = { 'web' } -``` +This ones are implicit plugins so the end user cannot disable them. But why? -### Enabling module plugins +That is because these plugins are the core of Doom so in fact, things can break +without them. These plugins are the following: -All the module plugins will be enabled by default unless the entire module is disabled. +- [packer.nvim] + - A use-package inspired plugin manager for Neovim. +- [treesitter] + - An incremental parsing system for programming tools. -> If you want to use custom plugins, please refer to -> [Installing plugins](./getting_started.md#installing-plugins). +### UI -### Disabling modules +- [dashboard] + - Vim dashboard (start screen). +- [doom-themes] + - Additional doom emacs' colorschemes. +- [statusline] + - Neovim statusline. +- [tabline] + - Tabline, shows your buffers list at top. +- [zen] + - Distraction free environment. +- [which-key] + - Keybindings popup like Emacs' guide-key. +- [indentlines] + - Show indent lines. + +### Doom + +- [neorg] + - Life Organization Tool. +- [runner] (built-in) + - A code runner for your interpreted code. +- [compiler] (built-in) + - Compile _and run_ your projects with only a few keystrokes. + +### Editor + +- [auto-session] + - A small automated session manager for Neovim. +- [terminal] + - Terminal for Neovim. +- [explorer] + - Tree explorer. +- [symbols] + - LSP symbols and tags. +- [minimap] + - Code minimap, requires [wfxr/code-minimap](https://github.com/wfxr/code-minimap). +- [gitsigns] + - Git signs. +- [telescope] + - Highly extendable fuzzy finder over lists. +- [restclient] + - A fast Neovim http client. +- [formatter] + - File formatting. +- [autopairs] + - Autopairs. +- [editorconfig] + - EditorConfig support for Neovim, let other argue about tabs vs spaces. +- [kommentary] + - Comments plugin. +- [lsp] + - Language Server Protocols ([compe] + [lspsaga] + [lspinstall]). +- snippets + - Code snippets ([LuaSnip] + [friendly-snippets]). + +### 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 TreeSitter parser for getting + syntax highlighting for Rust and will also install `rust-analyzer`. + +#### Web development + +- **html** + - HTML support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **css** + - CSS support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **javascript** + - JavaScript support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes, by using TSServer. +- **typescript** + - TypeScript support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. + +#### Scripting + +- **bash** + - BASH support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **python** + - Python support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **ruby** + - Ruby support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **lua** + - Lua support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **elixir** + - Elixir support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. + +#### Compiled + +- **haskell** + - Haskell support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **rust** + - Rust support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **go** + - Golang support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **cpp** + - CPP support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. +- **java** + - Java support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. + +#### Configs & DevOps + +- **config** + - Configuration languages support (JSON, YAML, TOML). + - TreeSitter based syntax highlighting: yes. + - LSP: not yet. +- **dockerfile** + - Docker support. + - TreeSitter based syntax highlighting: yes. + - LSP: yes. + +> **NOTE**: this group requires the `lsp` installed for the `+lsp` flags. + +### Utilities + +- [suda] + - Write and read files without sudo permissions. +- [lazygit] + - LazyGit integration for neovim, requires LazyGit. +- [neogit] + - Magit for Neovim. +- [colorizer] + - Fastest colorizer for Neovim. +- [range-highlight] + - Highlights ranges you have entered in commandline -To disable a module, you can use the `disabled_modules` field in the `Doom` table -on your `doomrc`. +## Managing modules -```lua --- To disable only the web module, just put only 'web' in the disabled modules --- array and then, reboot Neovim and do :PackerSync --- --- @default = { 'git', 'lsp', 'web' } -disabled_modules = { 'web' } -``` +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! -### Disabling module plugins +So by example, if you want to disable the tree explorer you can simply comment it. -To disable a module plugin, you can use the `disabled_plugins` field in the `Doom` table -on your `doomrc`. +```lua +-- Before, the plugin is enabled +'explorer', -- Tree explorer -```vim --- @default = {} -disabled_plugins = { 'emmet' } +-- 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! + + [packer.nvim]: https://github.com/wbthomason/packer.nvim -[vimpeccable]: https://github.com/svermeulen/vimpeccable [treesitter]: https://github.com/nvim-treesitter/nvim-treesitter - - -[dashboard-nvim]: https://github.com/glepnir/dashboard-nvim -[nvim-tree.lua]: https://github.com/kyazdani42/nvim-tree.lua -[galaxyline.nvim]: https://github.com/glepnir/galaxyline.nvim -[barbar.nvim]: https://github.com/romgrk/barbar.nvim -[nvim-toggleterm.lua]: https://github.com/akinsho/nvim-toggleterm.lua -[symbols-outline.nvim]: https://github.com/simrat39/symbols-outline.nvim -[minimap.vim]: https://github.com/wfxr/minimap.vim -[which-key.nvim]: https://github.com/folke/which-key.nvim -[truezen.nvim]: https://github.com/kdav5758/TrueZen.nvim - - - -[telescope.nvim]: https://github.com/nvim-telescope/telescope.nvim - - - -[gitsigns.nvim]: https://github.com/lewis6991/gitsigns.nvim -[lazygit.nvim]: https://github.com/kdheepak/lazygit.nvim - - - -[nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig -[nvim-compe]: -[suda.vim]: https://github.com/lambdalisue/suda.vim -[format.nvim]: https://github.com/lukas-reineke/format.nvim -[pears.nvim]: https://github.com/steelsojka/pears.nvim -[indentline]: https://github.com/Yggdroot/indentLine -[editorconfig-vim]: https://github.com/editorconfig/editorconfig-vim +[auto-session]: https://github.com/rmagatti/auto-session +[dashboard]: https://github.com/glepnir/dashboard-nvim +[explorer]: https://github.com/kyazdani42/nvim-tree.lua +[statusline]: https://github.com/glepnir/galaxyline.nvim +[tabline]: https://github.com/akinsho/nvim-bufferline.lua +[terminal]: https://github.com/akinsho/nvim-toggleterm.lua +[symbols]: https://github.com/simrat39/symbols-outline.nvim +[minimap]: https://github.com/wfxr/minimap.vim +[which-key]: https://github.com/folke/which-key.nvim +[zen]: https://github.com/kdav5758/TrueZen.nvim +[telescope]: https://github.com/nvim-telescope/telescope.nvim +[doom-themes]: https://github.com/GustavoPrietoP/doom-themes.nvim + +[gitsigns]: https://github.com/lewis6991/gitsigns.nvim +[lazygit]: https://github.com/kdheepak/lazygit.nvim +[neogit]: https://github.com/TimUntersberger/neogit +[neorg]: https://github.com/vhyrro/neorg + +[lsp]: https://github.com/neovim/nvim-lspconfig +[compe]: https://github.com/hrsh7th/nvim-compe +[lspsaga]: https://github.com/glepnir/lspsaga.nvim +[lspinstall]: https://github.com/kabouzeid/nvim-lspinstall +[LuaSnip]: https://github.com/L3MON4D3/LuaSnip +[friendly-snippets]: https://github.com/rafamadriz/friendly-snippets + +[suda]: https://github.com/lambdalisue/suda.vim +[formatter]: https://github.com/lukas-reineke/format.nvim +[autopairs]: https://github.com/windwp/nvim-autopairs +[indentlines]: https://github.com/lukas-reineke/indent-blankline.nvim +[editorconfig]: https://github.com/editorconfig/editorconfig-vim [kommentary]: https://github.com/b3nj5m1n/kommentary - +[restclient]: https://github.com/NTBBloodbath/rest.nvim +[colorizer]: https://github.com/norcalli/nvim-colorizer.lua +[range-highlight]: https://github.com/winston0410/range-highlight.nvim -[nvim-colorizer.lua]: https://github.com/norcalli/nvim-colorizer.lua -[vim-dot-http]: https://github.com/bayne/vim-dot-http -[emmet-vim]: https://github.com/mattn/emmet-vim +[runner]: ../lua/doom/modules/built-in/runner/README.md +[compiler]: ../lua/doom/modules/built-in/compiler/README.md diff --git a/doom.toml b/doom.toml new file mode 100644 index 000000000..51799f4a3 --- /dev/null +++ b/doom.toml @@ -0,0 +1,11 @@ +[selene] +base = 'lua51' +name = 'doom' + +# for Neovim development +[vim] +any = true + +# for LuaJIT +[jit] +any = true diff --git a/doom_config.lua b/doom_config.lua new file mode 100644 index 000000000..c5c7277b9 --- /dev/null +++ b/doom_config.lua @@ -0,0 +1,363 @@ +-- 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 + +-- {{{ Doom +local 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 + backup = 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) + + -- 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, + + -- 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) + -- @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 : Shows absolute number lines + -- true : Shows relative number lines + -- @default = true + relative_num = true, + + -- 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, + + -- 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_warning = '๏ฑ', + lsp_hint = '๏ช', + lsp_information = '๏š', + lsp_virtual_text = '๏ŒŒ ', + + -- 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 +local nvim = { + -- Set custom Neovim global variables + -- @default = {} + -- example: + -- { ['sonokai_style'] = 'andromeda' } + global_variables = {}, + + -- Set custom autocommands + -- @default = {} + -- example: + -- augroup_name = { + -- { 'BufNewFile,BufRead', 'doomrc', 'set ft=lua'} + -- } + autocmds = {}, + + -- Set custom key bindings + -- @default = {} + -- example: + -- { + -- {'n', 'ca', ':Lspsaga code_action'} + -- } + -- + -- where + -- 'n' is the map scope + -- 'ca' is the map activator + -- ':Lspsaga ...' is the command to be executed + 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 + -- } + functions = {}, +} +-- }}} + +return { + doom = doom, + nvim = nvim, +} + +-- vim: fdm=marker diff --git a/doomrc b/doomrc deleted file mode 100644 index 235a4cd9a..000000000 --- a/doomrc +++ /dev/null @@ -1,332 +0,0 @@ ----[[--------------------------------------------------]]--- --- doomrc - Doom Nvim configurations -- --- For more information, see `:h doom_nvim_options` -- ----[[--------------------------------------------------]]--- - -Doom = { - ---[[--------------------------------------------------]]--- - -- Boolean Options -- - ---[[--------------------------------------------------]]--- - - -- 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, - - -- 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 - backup = 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) - - -- 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, - - -- 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) - -- @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 : Shows absolute number lines - -- true : Shows relative number lines - -- @default = true - relative_num = true, - - -- 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, - - -- Tagbar left - -- Sets Tagbar buffer to the left when enabled - -- @default = false - tagbar_left = 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, - - ---[[--------------------------------------------------]]--- - -- Number Options -- - ---[[--------------------------------------------------]]--- - - -- 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, - - -- Logging level - -- 0 : No logging - -- 1 : All errors, no echo (default) - -- 2 : All errors and messages, no echo - -- 3 : All errors and messages, echo - -- @default = 1 - logging = 1, - - -- 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, - - ---[[--------------------------------------------------]]--- - -- String Options -- - ---[[--------------------------------------------------]]--- - - -- 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', - - -- 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_warning = '๏ฑ', - lsp_hint = '๏ช', - lsp_information = '๏š', - lsp_virtual_text = '๏ŒŒ ', - - -- Set your dashboard custom colors below - -- @default = doom emacs' default dashboard colors - dashboard_custom_colors = { - header_color = '#586268', - center_color = '#51afef', - shortcut_color = '#9788b9', - footer_color = '#586268', - }, - - -- Disabled plugins - -- @default = {'lazygit', 'minimap', 'restclient', 'doom-themes'} - -- example: - -- disabled_plugins = {'emmet-vim'} - disabled_plugins = { 'lazygit', 'minimap', 'restclient', 'doom-themes'}, - - -- Disabled plugins modules - -- @default = {'git', 'lsp', 'web'} - -- example: - -- disabled_modules = {'web'} - disabled_modules = { 'git', 'lsp', 'web' }, - - -- Install custom plugins - -- @default = {} - -- examples: - -- plugins without options: - -- custom_plugins = {'andweeb/presence.nvim'} - -- plugins with options: - -- custom_plugins = { - -- { - -- ['repo'] = 'andweeb/presence.nvim', - -- ['enabled'] = true, - -- } - -- } - custom_plugins = {}, - - -- Set the parsers for TreeSitter - -- @default = {} - -- example: - -- ts_parsers = {'python', 'javascript'} - ts_parsers = {}, - - -- Set your custom dashboard header below - -- @default = doom emacs' default dashboard header - dashboard_custom_header = { - '================= =============== =============== ======== ========', - '\\\\ . . . . . . .\\\\ //. . . . . . .\\\\ //. . . . . . .\\\\ \\\\. . .\\\\// . . //', - '||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||', - '|| . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||', - '||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||', - '|| . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\\ . . . . ||', - "||. . || ||-' || || `-|| || . .|| ||. . || ||-' || || `|\\_ . .|. .||", - '|| . _|| || || || || ||_ . || || . _|| || || || |\\ `-_/| . ||', - "||_-' || .|/ || || \\|. || `-_|| ||_-' || .|/ || || | \\ / |-_.||", - "|| ||_-' || || `-_|| || || ||_-' || || | \\ / | `||", - "|| `' || || `' || || `' || || | \\ / | ||", - "|| .===' `===. .==='.`===. .===' /==. | \\/ | ||", - "|| .==' \\_|-_ `===. .===' _|_ `===. .===' _-|/ `== \\/ | ||", - "|| .==' _-' `-_ `=' _-' `-_ `=' _-' `-_ /| \\/ | ||", - "|| .==' _-' `-__\\._-' `-_./__-' `' |. /| | ||", - "||.==' _-' `' | /==.||", - "==' _-' N E O V I M \\/ `==", - "\\ _-' `-_ /", - " `'' ``' ", - ' ', - }, -} diff --git a/doomrc.lua b/doomrc.lua new file mode 100644 index 000000000..b9351ae04 --- /dev/null +++ b/doomrc.lua @@ -0,0 +1,78 @@ +-- doomrc - Doom nvim configurations file +-- +-- The doomrc 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 doom = { + ui = { + 'dashboard', -- Start screen + -- 'doom-themes', -- Additional doom emacs' colorschemes + 'statusline', -- Statusline + 'tabline', -- Tabline, shows your buffers list at top + -- 'zen', -- Distraction free environment + 'which-key', -- Keybindings popup menu like Emacs' guide-key + -- 'indentlines', -- Show indent lines + }, + doom = { + -- 'neorg', -- Life Organization Tool + -- 'runner', -- Open a REPL for the current language or run the current file + -- 'compiler', -- Compile (and run) your code with just pressing three keys! + }, + editor = { + 'auto-session', -- A small automated session manager for Neovim + -- 'terminal', -- Terminal for Neovim (NOTE: needed for runner and compiler) + 'explorer', -- Tree explorer + 'symbols', -- LSP symbols and tags + -- 'minimap', -- Code minimap, requires github.com/wfxr/code-minimap + 'gitsigns', -- Git signs + 'telescope', -- Highly extendable fuzzy finder over lists + -- 'restclient', -- A fast Neovim http client + 'formatter', -- File formatting + 'autopairs', -- Autopairs + -- 'editorconfig', -- EditorConfig support for Neovim + 'kommentary', -- Comments plugin + 'lsp', -- Language Server Protocols + 'snippets', -- LSP snippets + }, + 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 + -- + -- 'html', -- HTML support + -- 'css', -- CSS support + -- 'javascript', -- JavaScript support + -- 'typescript', -- TypeScript support + -- 'bash', -- The terminal gods language + -- 'python +lsp', -- Python support + lsp + -- 'ruby', -- Look ma, I love the gems! + 'lua', -- Support for our gods language + -- 'elixir', -- Build scalable and maintainable software + -- 'haskell', -- Because Functional programming is fun, isn't it? + + -- 'rust +lsp', -- Let's get rusty! + -- 'go', -- Hello, gopher + -- 'cpp', -- C++ support + -- 'java', -- Java support + + -- 'config', -- Configuration files (JSON, YAML, TOML) + -- 'dockerfile', -- Do you like containers, right? + }, + utilities = { + -- 'suda', -- Write and read files without sudo permissions + -- 'lazygit', -- LazyGit integration for Neovim, requires LazyGit + -- 'neogit', -- Magit for Neovim + -- 'colorizer', -- Fastets colorizer for Neovim + 'range-highlight', -- hightlights ranges you have entered in commandline + }, +} + +return doom diff --git a/init.lua b/init.lua index 9e9371f59..51214ce11 100644 --- a/init.lua +++ b/init.lua @@ -4,25 +4,65 @@ -- License: GPLv2 -- ---[[---------------------------------------]]--- --- Utility functions -require('doom.utils') +---- Doom Utilities ----------------------------- +------------------------------------------------- +-- Store startup time in seconds +vim.g.start_time = vim.fn.reltime() --- Load default settings -require('doom.default') +-- Disable these for very fast startup time +vim.cmd([[ + syntax off + filetype off + filetype plugin indent off +]]) --- Logging -require('doom.logging') +-- Temporarily disable shada file to improve performance +vim.opt.shadafile = 'NONE' +-- Disable some unused built-in Neovim plugins +vim.g.loaded_man = false +vim.g.loaded_gzip = false +vim.g.loaded_netrwPlugin = false +vim.g.loaded_tarPlugin = false +vim.g.loaded_zipPlugin = false +vim.g.loaded_2html_plugin = false +vim.g.loaded_remote_plugins = false --- Load configurations -require('doom.config.doomrc') +local async --- Core modules -require('doom.system') -require('doom.functions') -require('doom.config.doomrc') +async = vim.loop.new_async(vim.schedule_wrap(function() + ---- Doom Configurations ------------------------ + ------------------------------------------------- + vim.defer_fn(function() + -- Load Doom core + require('doom.core') --- Main configurations -require('doom.config') -require('doom.config.ui') -require('doom.autocmds') -require('doom.keybindings') + -- If the dashboard plugin is already installed and the packer_compiled.lua + -- file exists so we can make sure that the dashboard have been loaded + local compiled_plugins_path = vim.fn.expand( + '$HOME/.config/doom-nvim/plugin/packer_compiled.lua' + ) + if vim.fn.filereadable(compiled_plugins_path) > 0 then + -- If the current buffer name is empty then trigger Dashboard + if vim.api.nvim_buf_get_name(0):len() == 0 then + vim.cmd('Dashboard') + end + end + + vim.opt.shadafile = '' + vim.defer_fn(function() + vim.cmd([[ + rshada! + doautocmd BufRead + syntax on + filetype on + filetype plugin indent on + PackerLoad nvim-treesitter + silent! bufdo e + ]]) + end, 15) + end, 0) + + async:close() +end)) + +async:send() diff --git a/install.sh b/install.sh index e205066ba..fc0d3512e 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# #================================================ # install.sh - Doom Nvim Installation Script # Author: NTBBloodbath @@ -12,6 +13,7 @@ Color_reset='\033[0m' # Reset ## Normal colors Black='\033[0;30m' # Black +Gray='\033[0;90m' # Gray White='\033[0;37m' # White Red='\033[0;31m' # Red Blue='\033[0;34m' # Blue @@ -22,6 +24,7 @@ Yellow='\033[0;33m' # Yellow ## Bold colors BBlack='\033[1;30m' # Black +BGray='\033[1;90m' # Gray BWhite='\033[1;37m' # White BRed='\033[1;31m' # Red BBlue='\033[1;34m' # Blue @@ -32,7 +35,7 @@ BYellow='\033[1;33m' # Yellow # }}} # Doom Nvim version -DoomNvimVersion='2.3.5' +DoomNvimVersion='3.0.0' # System OS System="$(uname -s)" @@ -84,12 +87,13 @@ check_cmd() { check_all() { # Install Doom Nvim (see also git) need_cmd 'curl' + sleep 1 # Clone repositories and install Doom Nvim need_cmd 'git' - # Generate help tags - check_cmd 'ctags' + sleep 1 # Install Language Server Protocols check_cmd 'npm' + sleep 1 check_cmd 'node' } @@ -103,6 +107,7 @@ check_requirements() { else log_warn "Check requirements : git" fi + sleep 1 # Checks if neovim is installed if hash "nvim" &>/dev/null; then @@ -110,6 +115,7 @@ check_requirements() { else log_warn "Check requirements : nvim" fi + sleep 1 # Check if nodejs and npm are installed again, # we do not check only nodejs because some Linux distributions @@ -119,6 +125,7 @@ check_requirements() { else log_warn "Check requirements : node (optional, required to use LSP)" fi + sleep 1 if hash "npm" &>/dev/null; then log_success "Check requirements : npm" else @@ -172,30 +179,22 @@ update_repo() { fi } -install_nvim_nightly() { - log_info "Installing Neovim Nightly AppImage ..." +install_nvim_appimage() { + log_info "Installing Neovim 0.5 AppImage ..." - curl -LO https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage + curl -LO https://github.com/neovim/neovim/releases/download/v0.5.0/nvim.appimage chmod u+x nvim.appimage mkdir -p $HOME/.local/bin mv nvim.appimage $HOME/.local/bin/ + log_info "Creating an alias for the Neovim AppImage ..." if [ -f "$HOME/.zshrc" ]; then echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >>$HOME/.zshrc else echo "alias 'nvim'=$HOME/.local/bin/nvim.appimage" >>$HOME/.bashrc fi - log_success "Successfully installed Neovim Nightly under $HOME/.local/bin/ directory" -} - -install_packer() { - if [[ ! -d "$HOME/.local/share/nvim/site/pack/packer/start/packer.nvim" ]]; then - log_info "Installing packer plugin manager ..." - # NOTE: stop installing that branch when merged into the main branch - git clone -q -b fix/premature-display-opening https://github.com/wbthomason/packer.nvim \ - $HOME/.local/share/nvim/site/pack/packer/start/packer.nvim - fi + log_success "Successfully installed Neovim 0.5.0 under $HOME/.local/bin/ directory" } install_fonts() { @@ -203,19 +202,21 @@ install_fonts() { mkdir -p $HOME/.local/share/fonts fi - download_font "Fira Code Regular Nerd Font Complete Mono.ttf" - log_info "Updating font cache, please wait ..." - if [ $System == "Darwin" ]; then - if [ ! -e "$HOME/Library/Fonts" ]; then - mkdir "$HOME/Library/Fonts" + if [[ ! -f "$HOME/.local/share/fonts/Fira Code Regular Nerd Font Complete Mono.ttf" ]]; then + download_font "Fira Code Regular Nerd Font Complete Mono.ttf" + log_info "Updating font cache, please wait ..." + if [ "$System" == "Darwin" ]; then + if [ ! -e "$HOME/Library/Fonts" ]; then + mkdir "$HOME/Library/Fonts" + fi + cp $HOME/.local/share/fonts/* $HOME/Library/Fonts/ + else + fc-cache -fv >/dev/null + mkfontdir "$HOME/.local/share/fonts" >/dev/null + mkfontscale "$HOME/.local/share/fonts" >/dev/null fi - cp $HOME/.local/share/fonts/* $HOME/Library/Fonts/ - else - fc-cache -fv >/dev/null - mkfontdir "$HOME/.local/share/fonts" >/dev/null - mkfontscale "$HOME/.local/share/fonts" >/dev/null + log_success "Font cache done" fi - log_success "Font cache done" } download_font() { @@ -241,8 +242,8 @@ install_done() { pretty_echo ${Green} " You are almost done. Start neovim to install " pretty_echo ${Green} " the plugins and kill some demons. " pretty_echo ${Green} " " - pretty_echo ${Green} " Thanks for installing Doom Nvim, if you have any " - pretty_echo ${Green} " issue, please report it :) " + pretty_echo ${Green} " Thanks for installing Doom Nvim. If you have any " + pretty_echo ${Green} " issue, please report it :) " pretty_echo ${Green} "==================================================" } # }}} @@ -273,26 +274,26 @@ uninstall() { # =========== # {{{ welcome() { - pretty_echo ${BRed} " ================= =============== =============== ======== ========" - pretty_echo ${BRed} " \\\\\ . . . . . . .\\\\\ //. . . . . . .\\\\\ //. . . . . . .\\\\\ \\\\\. . .\\\\\// . . //" - pretty_echo ${BRed} " ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||" - pretty_echo ${BRed} " || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||" - pretty_echo ${BRed} " ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||" - pretty_echo ${BRed} " || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||" - pretty_echo ${BYellow} " ||. . || ||-' || || \`-|| || . .|| ||. . || ||-' || || \`|\_ . .|. .||" - pretty_echo ${BYellow} " || . _|| || || || || ||_ . || || . _|| || || || |\ \`-_/| . ||" - pretty_echo ${BYellow} " ||_-' || .|/ || || \|. || \`-_|| ||_-' || .|/ || || | \ / |-_.||" - pretty_echo ${BYellow} " || ||_-' || || \`-_|| || || ||_-' || || | \ / | \`||" - pretty_echo ${BYellow} " || \`' || || \`' || || \`' || || | \ / | ||" - pretty_echo ${BYellow} " || .===' \`===. .==='.\`===. .===' /==. | \/ | ||" - pretty_echo ${BYellow} " || .==' \_|-_ \`===. .===' _|_ \`===. .===' _-|/ \`== \/ | ||" - pretty_echo ${BYellow} " || .==' _-' \`-_ \`=' _-' \`-_ \`=' _-' \`-_ /| \/ | ||" - pretty_echo ${BYellow} " || .==' _-' '-__\._-' '-_./__-' \`' |. /| | ||" - pretty_echo ${BYellow} " ||.==' _-' \`' | /==.||" - pretty_echo ${BRed} " ==' _-' \/ \`==" - pretty_echo ${BRed} " \ _-' N e o v i m \`-_ /" - pretty_echo ${BRed} " \`'' \`\`' " - pretty_echo ${BYellow} " Version : ${DoomNvimVersion} By : NTBBloodbath " + pretty_echo ${Gray} " ================= =============== =============== ======== ========" + pretty_echo ${Gray} " \\\\\ . . . . . . .\\\\\ //. . . . . . .\\\\\ //. . . . . . .\\\\\ \\\\\. . .\\\\\// . . //" + pretty_echo ${Gray} " ||. . ._____. . .|| ||. . ._____. . .|| ||. . ._____. . .|| || . . .\\/ . . .||" + pretty_echo ${Gray} " || . .|| ||. . || || . .|| ||. . || || . .|| ||. . || ||. . . . . . . ||" + pretty_echo ${Gray} " ||. . || || . .|| ||. . || || . .|| ||. . || || . .|| || . | . . . . .||" + pretty_echo ${Gray} " || . .|| ||. _-|| ||-_ .|| ||. . || || . .|| ||. _-|| ||-_.|\ . . . . ||" + pretty_echo ${Gray} " ||. . || ||-' || || \`-|| || . .|| ||. . || ||-' || || \`|\_ . .|. .||" + pretty_echo ${Gray} " || . _|| || || || || ||_ . || || . _|| || || || |\ \`-_/| . ||" + pretty_echo ${Gray} " ||_-' || .|/ || || \|. || \`-_|| ||_-' || .|/ || || | \ / |-_.||" + pretty_echo ${Gray} " || ||_-' || || \`-_|| || || ||_-' || || | \ / | \`||" + pretty_echo ${Gray} " || \`' || || \`' || || \`' || || | \ / | ||" + pretty_echo ${Gray} " || .===' \`===. .==='.\`===. .===' /==. | \/ | ||" + pretty_echo ${Gray} " || .==' \_|-_ \`===. .===' _|_ \`===. .===' _-|/ \`== \/ | ||" + pretty_echo ${Gray} " || .==' _-' \`-_ \`=' _-' \`-_ \`=' _-' \`-_ /| \/ | ||" + pretty_echo ${Gray} " || .==' _-' '-__\._-' '-_./__-' \`' |. /| | ||" + pretty_echo ${Gray} " ||.==' _-' \`' | /==.||" + pretty_echo ${Gray} " ==' _-' \/ \`==" + pretty_echo ${Gray} " \ _-' N E O V I M \`-_ /" + pretty_echo ${Gray} " \`'' \`\`' " + pretty_echo ${BBlue} " Version : ${DoomNvimVersion} By : NTBBloodbath " echo "" } # }}} @@ -303,88 +304,85 @@ welcome() { helper() { welcome echo "" - pretty_echo ${BRed} " Usage ./install.sh [OPTION]" + pretty_echo ${BGreen} " Usage: ./install.sh [OPTION]" echo "" - pretty_echo ${BRed} " OPTIONS:" - pretty_echo ${Yellow} " -h --help Displays this message" - pretty_echo ${Yellow} " -c --check-requirements Check Doom Nvim requirements" - pretty_echo ${Yellow} " -i --install Install Doom Nvim" - pretty_echo ${Yellow} " -d --install-dev Install Development version of Doom Nvim" - pretty_echo ${Yellow} " -n --nightly Install Neovim Nightly and Doom Nvim" - pretty_echo ${Yellow} " -u --update Update Doom Nvim" - pretty_echo ${Yellow} " -v --version Echo Doom Nvim version" - pretty_echo ${Yellow} " -x --uninstall Uninstall Doom Nvim" + pretty_echo ${BGreen} " Options:" + pretty_echo " -h --help\t\t\t\tDisplays this message" + pretty_echo " -c --check-requirements\t\tCheck Doom Nvim requirements" + pretty_echo " -i --install\t\t\tInstall Doom Nvim" + pretty_echo " -d --install-dev\t\t\tInstall Development version of Doom Nvim" + pretty_echo " -n --install-nvim\t\t\tInstall Neovim 0.5.0 and Doom Nvim" + pretty_echo " -u --update\t\t\t\tUpdate Doom Nvim" + pretty_echo " -v --version\t\t\tEcho Doom Nvim version" + pretty_echo " -x --uninstall\t\t\tUninstall Doom Nvim" } main() { if [ $# -gt 0 ]; then case $1 in - --check-requirements | -c) - welcome - check_requirements - exit 0 - ;; - --update | -u) - welcome - update_repo - exit 0 - ;; - --install | -i) - welcome - check_all - update_repo "main" - install_packer - install_fonts - backup_neovim - install_done - exit 0 - ;; - --install-dev | -d) - welcome - check_all - update_repo "develop" - install_packer - install_fonts - backup_neovim - install_done - exit 0 - ;; - --nvim-nightly | -n) - welcome - check_all - update_repo "main" - install_packer - backup_neovim - install_nvim_nightly - install_done - exit 0 - ;; - --help | -h) - helper - exit 0 - ;; - --version | -v) - log "Doom Nvim v${DoomNvimVersion}" - exit 0 - ;; - --uninstall | -x) - welcome - log_info "Uninstalling Doom Nvim ..." - uninstall - pretty_echo ${Green} "Thanks for using Doom Nvim, there are no more demons!" - exit 0 - ;; + --check-requirements | -c) + welcome + check_requirements + exit 0 + ;; + --update | -u) + welcome + update_repo + exit 0 + ;; + --install | -i) + welcome + check_all + update_repo "main" + install_fonts + backup_neovim + install_done + exit 0 + ;; + --install-dev | -d) + welcome + check_all + update_repo "develop" + install_fonts + backup_neovim + install_done + exit 0 + ;; + --install-nvim | -n) + welcome + check_all + update_repo "main" + backup_neovim + install_nvim_appimage + install_done + exit 0 + ;; + --help | -h) + helper + exit 0 + ;; + --version | -v) + log "Doom Nvim v${DoomNvimVersion}" + exit 0 + ;; + --uninstall | -x) + welcome + log_info "Uninstalling Doom Nvim ..." + uninstall + pretty_echo ${Green} "Thanks for using Doom Nvim, there are no more demons!" + exit 0 + ;; esac else # Run normal commands welcome check_all update_repo "main" - install_packer backup_neovim install_fonts check_requirements install_done + exit 0 fi } diff --git a/lua/colors/README.md b/lua/colors/README.md new file mode 100644 index 000000000..36efdbbb8 --- /dev/null +++ b/lua/colors/README.md @@ -0,0 +1,59 @@ +# Colors + +This module contains the embedded colorschemes for Doom Nvim and the utils +module required by those colorschemes. + +Actually the embedded colorschemes are the following: + +- doom-one (dark and light variant) + +## utils + +The utils module contains a few utilities for easily port Doom Emacs colorschemes +to Lua colorschemes. These utilities are the following: + +- `Lighten` - lighten the provided HEX color in X percentage (5 by default). +- `Darken` - darken the provided HEX color in X percentage (5 by default). +- `Mix` - mix two provided HEX colors in X percentage (0 by default) + +## Contributing + +### Write colorschemes + +If you want to write colorschemes for Doom Nvim you will need to follow some +requirements. + +- The colorscheme should be a Doom Emacs colorscheme, see [emacs-doom-themes]. +- The colorscheme should be written in pure Lua **without using helpers like lush**, + you can take a look at [doom-one] source or use it as a template (highly recommended). + +### Update embedded colorschemes + +If you want to update the embedded colorschemes like [doom-one] you'll need to +copy the doom-one files to the proper locations and change a few lines to match +Doom Nvim structure. + +- Changes in `colors/doom-one.lua`: + +```lua +--- FROM: +package.loaded['doom-one'] = nil +require('doom-one') + +--- TO: +package.loaded['colors.doom-one'] = nil +require('colors.doom-one') +``` + +- Changes in `doom-one/init.lua`: + +```lua +--- FROM: +local utils = require('utils') + +--- TO: +local utils = require('colors.utils') +``` + +[doom-one]: https://github.com/NTBBloodbath/doom-one.nvim +[emacs-doom-themes]: https://github.com/hlissner/emacs-doom-themes diff --git a/lua/colors/doom-one/init.lua b/lua/colors/doom-one/init.lua new file mode 100644 index 000000000..d608c4796 --- /dev/null +++ b/lua/colors/doom-one/init.lua @@ -0,0 +1,743 @@ +-- vim:fdm=marker +-- Vim Color File +-- Name: doom-one +-- Maintainer: http//github.com/NTBBloodbath +-- License: The MIT License (MIT) +-- Based On: http//github.com/romgrk/doom-one.vim and the original Doom Emacs one + +-- Helpers {{{ + +local utils = require('colors.utils') + +-- }}} + +-- Customization variables {{{ + +-- Set default values for doom_one variables if they don't exists +if vim.g.doom_one_cursor_coloring == nil then + vim.g.doom_one_cursor_coloring = false +end +if vim.g.doom_one_terminal_colors == nil then + vim.g.doom_one_terminal_colors = false +end +if vim.g.doom_one_enable_treesitter == nil then + vim.g.doom_one_enable_treesitter = true +end +if vim.g.doom_one_transparent_background == nil then + vim.g.doom_one_transparent_background = false +end +if vim.g.doom_one_italic_comments == nil then + vim.g.doom_one_italic_comments = false +end +if vim.g.doom_one_telescope_highlights == nil then + vim.g.doom_one_telescope_highlights = true +end + +local transparent_bg = vim.g.doom_one_transparent_background + +-- }}} + +-- Highlight Functions and Color definitions {{{ + +local function high_clear(group) + vim.api.nvim_command('hi! clear ' .. group) +end + +local function high_link(group, link) + vim.api.nvim_command('hi! link ' .. group .. ' ' .. link) +end + +local function highlight(group, styles) + local bg = styles.bg and 'guibg=' .. styles.bg or 'guibg=NONE' + local fg = styles.fg and 'guifg=' .. styles.fg or 'guifg=NONE' + local sp = styles.sp and 'guisp=' .. styles.sp or 'guisp=NONE' + local gui = styles.gui and 'gui=' .. styles.gui or 'gui=NONE' + + vim.api.nvim_command( + 'hi! ' .. group .. ' ' .. bg .. ' ' .. fg .. ' ' .. sp .. ' ' .. gui + ) +end + +local function apply_highlight(groups) + for group, styles in pairs(groups) do + highlight(group, styles) + end +end + +-- Change the colorscheme colors depending on the current background, defaults to +-- doom-one dark variant colors +local current_bg = vim.opt.background:get() +local light_bg = false + +local base0 = '#1B2229' +local base1 = '#1c1f24' +local base2 = '#202328' +local base3 = '#23272e' +local base4 = '#3f444a' +local base5 = '#5B6268' +local base6 = '#73797e' +local base7 = '#9ca0a4' +local base8 = '#DFDFDF' +local base9 = '#E6E6E6' + +local grey = base4 +local red = '#ff6c6b' +local orange = '#da8548' +local green = '#98be65' +local yellow = '#ECBE7B' +local blue = '#51afef' +local dark_blue = '#2257A0' +local magenta = '#c678dd' +local light_magenta = utils.Lighten(magenta, 0.4) +local violet = '#a9a1e1' +local cyan = '#46D9FF' +local white = '#efefef' + +local bg = '#282c34' +local bg_alt = '#21242b' +local bg_highlight = '#21252a' +local bg_popup = '#3E4556' +local bg_statusline = bg_popup +local bg_highlighted = '#4A4A45' + +local fg = '#bbc2cf' +local fg_alt = '#5B6268' +local fg_highlight = utils.Lighten(fg, 0.2) + +local tag = utils.Mix(blue, cyan, 0.5) + +local diff_info_fg = orange +local diff_info_bg0 = utils.Mix('#D8EEFD', bg, 0.6) +local diff_info_bg1 = utils.Mix('#D8EEFD', bg, 0.8) + +local diff_add_fg = green +local diff_add_fg0 = utils.Mix(green, fg, 0.4) +local diff_add_bg0 = utils.Mix('#506d5b', bg, 0.6) +local diff_add_bg1 = utils.Mix('#acf2bd', bg, 0.8) + +local gh_danger_fg = red +local gh_danger_fg0 = utils.Mix(red, fg, 0.6) +local gh_danger_bg0 = utils.Mix('#ffdce0', bg, 0.6) +local gh_danger_bg1 = utils.Mix('#ffdce0', bg, 0.8) + +if current_bg == 'light' then + light_bg = true + + base0 = '#f0f0f0' + base1 = '#e7e7e7' + base2 = '#dfdfdf' + base3 = '#c6c7c7' + base4 = '#9ca0a4' + base5 = '#383a42' + base6 = '#202328' + base7 = '#23272e' + base8 = '#1c1f24' + base9 = '#1B2229' + + grey = base4 + red = '#e45649' + orange = '#da8548' + green = '#50a14f' + yellow = '#986801' + blue = '#4078f2' + dark_blue = '#a0bcf8' + magenta = '#a626a4' + light_magenta = utils.Darken(magenta, 0.36) + violet = '#b751b6' + cyan = '#0184bc' + white = '#efefef' + + bg = '#fafafa' + bg_alt = '#f0f0f0' + bg_highlight = utils.Darken(bg, 0.3) + bg_popup = bg_alt + bg_statusline = bg_popup + + fg = base5 + fg_alt = base3 + fg_highlight = utils.Lighten(fg, 0.2) + + tag = utils.Mix(blue, cyan, 0.5) + + diff_info_fg = orange + diff_info_bg0 = utils.Mix('#D8EEFD', bg, 0.6) + diff_info_bg1 = utils.Mix('#D8EEFD', bg, 0.8) + + diff_add_fg = green + diff_add_fg0 = utils.Mix(green, fg, 0.4) + diff_add_bg0 = utils.Mix('#506d5b', bg, 0.4) + diff_add_bg1 = utils.Mix('#acf2bd', bg, 0.8) + + gh_danger_fg = red + gh_danger_fg0 = utils.Mix(red, fg, 0.6) + gh_danger_bg0 = utils.Mix('#ffdce0', bg, 0.8) + gh_danger_bg1 = utils.Mix('#ffdce0', bg, 0.9) +end + +if vim.g.doom_one_cursor_coloring then + vim.opt.guicursor = + 'n-v-c:block-Cursor,i-ci-ve:ver25-Cursor,r-cr-o:hor25-Cursor' +end + +-- }}} + +-- General UI {{{ + +local general_ui = { + Normal = { fg = fg, bg = transparent_bg and 'NONE' or bg }, + NormalPopup = { + fg = fg_highlight, + bg = transparent_bg and 'NONE' or bg_popup, + }, + NormalPopover = { + fg = fg_highlight, + bg = transparent_bg and 'NONE' or bg_popup, + }, + NormalPopupPrompt = { + fg = base7, + bg = transparent_bg and 'NONE' or utils.Darken(bg_popup, 0.3), + gui = 'bold', + }, + NormalPopupSubtle = { + fg = base6, + bg = transparent_bg and 'NONE' or bg_popup, + }, + EndOfBuffer = { fg = bg, bg = transparent_bg and 'NONE' or bg }, + + Visual = { bg = dark_blue }, + VisualBold = { bg = dark_blue, gui = 'bold' }, + + LineNr = { fg = grey, bg = transparent_bg and 'NONE' or bg }, + Cursor = { bg = blue }, + CursorLine = { bg = bg_highlight }, + CursorLineNr = { fg = fg, bg = bg_highlight }, + CursorColumn = { bg = bg_highlight }, + + Folded = { fg = base5, bg = bg_highlight }, + FoldColumn = { fg = fg_alt, bg = bg }, + SignColumn = { bg = transparent_bg and 'NONE' or bg }, + ColorColumn = { bg = bg_highlight }, + + IndentGuide = { fg = grey }, + IndentGuideEven = { fg = grey }, + IndentGuideOdd = { fg = grey }, + + TermCursor = { fg = fg, gui = 'reverse' }, + TermCursorNC = { fg = fg_alt, gui = 'reverse' }, + TermNormal = { fg = fg, bg = bg }, + TermNormalNC = { fg = fg, bg = bg }, + + WildMenu = { fg = fg, bg = dark_blue }, + Separator = { fg = fg_alt }, + VertSplit = { fg = grey, bg = bg }, + + TabLine = { + fg = base7, + bg = transparent_bg and 'NONE' or bg_alt, + gui = 'bold', + }, + TabLineSel = { fg = blue, bg = bg, gui = 'bold' }, + TabLineFill = { bg = transparent_bg and 'NONE' or base1, gui = 'bold' }, + + StatusLine = { fg = base8, bg = base3 }, + StatusLineNC = { fg = base6, bg = bg_popup }, + StatusLinePart = { fg = base6, bg = bg_popup, gui = 'bold' }, + StatusLinePartNC = { fg = base6, bg = bg_popup, gui = 'bold' }, + + Pmenu = { fg = fg, bg = bg_highlight }, + PmenuSel = { fg = base0, bg = blue }, + PmenuSelBold = { fg = base0, bg = blue, gui = 'bold' }, + PmenuSbar = { bg = bg_alt }, + PmenuThumb = { bg = fg }, +} + +if vim.opt.pumblend == 1 then + vim.opt.pumblend = 20 +end + +apply_highlight(general_ui) + +-- }}} + +-- Search, Highlight. Conceal, Messages {{{ + +local search_high_ui = { + Search = { fg = fg, bg = dark_blue, gui = 'bold' }, + Substitute = { fg = red, gui = 'strikethrough,bold' }, + IncSearch = { fg = fg, bg = dark_blue, gui = 'bold' }, + IncSearchCursor = { gui = 'reverse' }, + + Conceal = { fg = grey, gui = 'none' }, + SpecialKey = { fg = violet, gui = 'bold' }, + NonText = { fg = fg_alt, gui = 'bold' }, + MatchParen = { fg = red, gui = 'bold' }, + Whitespace = { fg = grey }, + + Highlight = { bg = bg_highlighted }, + HighlightSubtle = { bg = bg_highlighted }, + + Question = { fg = green, gui = 'bold' }, + + File = { fg = fg }, + Directory = { fg = violet, gui = 'bold' }, + Title = { fg = violet, gui = 'bold' }, + + Bold = { gui = 'bold' }, + Emphasis = { fg = green, gui = 'bold' }, +} + +apply_highlight(search_high_ui) + +-- }}} + +-- Text levels {{{ + +local text_colors = { + Normal = fg, + Info = blue, + Success = green, + Warning = yellow, + Debug = yellow, + Error = red, + Special = violet, + Muted = base7, +} + +for key, _ in pairs(text_colors) do + apply_highlight({ + ['Text' .. key] = { + fg = text_colors[key], + }, + }) + apply_highlight({ + ['Text' .. key .. 'Bold'] = { + fg = text_colors[key], + gui = 'bold', + }, + }) +end + +high_link('Msg', 'TextSuccess') +high_link('MoreMsg', 'TextInfo') +high_link('WarningMsg', 'TextWarning') +high_link('Error', 'TextError') +high_link('ErrorMsg', 'TextError') +high_link('ModeMsg', 'TextSpecial') +high_link('Todo', 'TextWarningBold') + +-- }}} + +-- Main Syntax {{{ + +local main_syntax = { + Tag = { fg = tag, gui = 'bold' }, + Link = { fg = tag, gui = 'undercurl' }, + URL = { fg = tag, gui = 'undercurl' }, + Underlined = { fg = tag, gui = 'underline' }, + + Comment = { + fg = fg_alt, + gui = vim.g.doom_one_italic_comments and 'italic' or 'NONE', + }, + CommentBold = { fg = fg_alt, gui = 'bold' }, + SpecialComment = { fg = base7, gui = 'bold' }, + + Macro = { fg = violet }, + Define = { fg = violet, gui = 'bold' }, + Include = { fg = violet, gui = 'bold' }, + PreProc = { fg = violet, gui = 'bold' }, + PreCondit = { fg = violet, gui = 'bold' }, + + Label = { fg = light_bg and orange or blue }, + Repeat = { fg = light_bg and orange or blue }, + Keyword = { fg = light_bg and orange or blue }, + Operator = { fg = light_bg and orange or blue }, + Delimiter = { fg = light_bg and orange or blue }, + Statement = { fg = light_bg and orange or blue }, + Exception = { fg = light_bg and orange or blue }, + Conditional = { fg = light_bg and orange or blue }, + + Variable = { fg = '#8B93E6' }, + VariableBuiltin = { fg = '#8B93E6', gui = 'bold' }, + Constant = { fg = violet, gui = 'bold' }, + + Number = { fg = light_bg and yellow or orange }, + Float = { fg = light_bg and yellow or orange }, + Boolean = { fg = light_bg and yellow or orange, gui = 'bold' }, + Enum = { fg = light_bg and yellow or orange }, + + Character = { fg = violet, gui = 'bold' }, + SpecialChar = { fg = base8, gui = 'bold' }, + + String = { fg = green }, + StringDelimiter = { fg = green }, + + Special = { fg = violet }, + SpecialBold = { fg = violet, gui = 'bold' }, + + Field = { fg = violet }, + Argument = { fg = light_magenta }, + Attribute = { fg = light_magenta }, + Identifier = { fg = light_magenta }, + Property = { fg = magenta }, + Function = { fg = magenta }, + FunctionBuiltin = { fg = light_magenta, gui = 'bold' }, + KeywordFunction = { fg = light_bg and orange or blue }, + Method = { fg = violet }, + + Type = { fg = yellow }, + TypeBuiltin = { fg = yellow, gui = 'bold' }, + StorageClass = { fg = light_bg and orange or blue }, + Class = { fg = light_bg and orange or blue }, + Structure = { fg = light_bg and orange or blue }, + Typedef = { fg = light_bg and orange or blue }, + + Regexp = { fg = '#dd0093' }, + RegexpSpecial = { fg = '#a40073' }, + RegexpDelimiter = { fg = '#540063', gui = 'bold' }, + RegexpKey = { fg = '#5f0041', gui = 'bold' }, +} + +apply_highlight(main_syntax) +high_link('CommentURL', 'URL') +high_link('CommentLabel', 'CommentBold') +high_link('CommentSection', 'CommentBold') +high_link('Noise', 'Comment') + +-- }}} + +-- Diff {{{ + +local diff = { + diffLine = { fg = base8, bg = diff_info_bg1 }, + diffSubName = { fg = base8, bg = diff_info_bg1 }, + + DiffAdd = { bg = diff_add_bg1 }, + DiffChange = { bg = diff_add_bg1 }, + DiffText = { bg = diff_add_bg0 }, + DiffDelete = { bg = gh_danger_bg0 }, + + DiffAdded = { fg = diff_add_fg0, bg = diff_add_bg1 }, + DiffModified = { fg = fg, bg = diff_info_bg0 }, + DiffRemoved = { fg = gh_danger_fg0, bg = gh_danger_bg1 }, + + DiffAddedGutter = { fg = diff_add_fg, gui = 'bold' }, + DiffModifiedGutter = { fg = diff_info_fg, gui = 'bold' }, + DiffRemovedGutter = { fg = gh_danger_fg, gui = 'bold' }, + + DiffAddedGutterLineNr = { fg = grey }, + DiffModifiedGutterLineNr = { fg = grey }, + DiffRemovedGutterLineNr = { fg = grey }, +} + +high_clear('DiffAdd') +high_clear('DiffChange') +high_clear('DiffText') +high_clear('DiffDelete') +apply_highlight(diff) + +-- }}} + +-- Markdown {{{ +local markdown = { + markdownCode = { bg = bg_highlight }, + markdownCodeBlock = { bg = bg_highlight }, + markdownH1 = { gui = 'bold' }, + markdownH2 = { gui = 'bold' }, + markdownLinkText = { gui = 'underline' }, +} + +apply_highlight(markdown) +--}}} + +-- Plugins {{{ + +-- barbar.nvim {{{ + +local barbar = { + BufferCurrent = { fg = base9, bg = bg }, + BufferCurrentIndex = { fg = base6, bg = bg }, + BufferCurrentMod = { fg = yellow, bg = bg }, + BufferCurrentSign = { fg = blue, bg = bg }, + BufferCurrentTarget = { fg = red, bg = bg, gui = 'bold' }, + + BufferVisible = { fg = base7, bg = bg }, + BufferVisibleIndex = { fg = base9, bg = bg }, + BufferVisibleMod = { fg = yellow, bg = bg }, + BufferVisibleSign = { fg = base4, bg = bg }, + BufferVisibleTarget = { fg = red, bg = bg, gui = 'bold' }, + + BufferInactive = { fg = base6, bg = base1 }, + BufferInactiveIndex = { fg = base6, bg = base1 }, + BufferInactiveMod = { fg = yellow, bg = base1 }, + BufferInactiveSign = { fg = base4, bg = base1 }, + BufferInactiveTarget = { fg = red, bg = base1, gui = 'bold' }, + + BufferTabpages = { fg = blue, bg = bg_statusline, gui = 'bold' }, + BufferTabpageFill = { fg = base4, bg = base1, gui = 'bold' }, + + BufferPart = { fg = diff_info_fg, bg = diff_info_bg0, gui = 'bold' }, +} + +apply_highlight(barbar) + +-- }}} + +-- Gitgutter {{{ + +high_link('GitGutterAdd', 'DiffAddedGutter') +high_link('GitGutterChange', 'DiffModifiedGutter') +high_link('GitGutterDelete', 'DiffRemovedGutter') +high_link('GitGutterChangeDelete', 'DiffModifiedGutter') + +high_link('GitGutterAddLineNr', 'DiffAddedGutterLineNr') +high_link('GitGutterChangeLineNr', 'DiffModifiedGutterLineNr') +high_link('GitGutterDeleteLineNr', 'DiffRemovedGutterLineNr') +high_link('GitGutterChangeDeleteLineNr', 'DiffModifiedGutterLineNr') + +-- }}} + +-- Gitsigns {{{ + +high_link('GitSignsAdd', 'DiffAddedGutter') +high_link('GitSignsChange', 'DiffModifiedGutter') +high_link('GitSignsDelete', 'DiffRemovedGutter') +high_link('GitSignsChangeDelete', 'DiffModifiedGutter') + +-- }}} + +-- Telescope {{{ + +if vim.g.doom_one_telescope_highlights then + local telescope = { + TelescopeSelection = { fg = yellow, gui = 'bold' }, + TelescopeSelectionCaret = { fg = light_bg and orange or blue }, + TelescopeMultiSelection = { fg = grey }, + TelescopeNormal = { fg = fg }, + TelescopeMatching = { fg = green, gui = 'bold' }, + TelescopePromptPrefix = { fg = light_bg and orange or blue }, + TelescopeBorder = { fg = light_bg and orange or blue }, + TelescopePromptBorder = { fg = light_bg and orange or blue }, + TelescopeResultsBorder = { fg = light_bg and orange or blue }, + TelescopePreviewBorder = { fg = light_bg and orange or blue }, + } + + apply_highlight(telescope) + high_link('TelescopePrompt', 'TelescopeNormal') +end + +-- }}} + +-- NvimTree {{{ + +local nvim_tree = { + NvimTreeFolderName = { fg = light_bg and base9 or blue, gui = 'bold' }, + NvimTreeRootFolder = { fg = green }, + NvimTreeEmptyFolderName = { fg = fg_alt, gui = 'bold' }, + NvimTreeSymlink = { fg = fg, gui = 'underline' }, + NvimTreeExecFile = { fg = green, gui = 'bold' }, + NvimTreeImageFile = { fg = light_bg and orange or blue }, + NvimTreeOpenedFile = { fg = fg_alt }, + NvimTreeSpecialFile = { fg = fg, gui = 'underline' }, + NvimTreeMarkdownFile = { fg = fg, gui = 'underline' }, +} + +apply_highlight(nvim_tree) +high_link('NvimTreeGitDirty', 'DiffModifiedGutter') +high_link('NvimTreeGitStaged', 'DiffModifiedGutter') +high_link('NvimTreeGitMerge', 'DiffModifiedGutter') +high_link('NvimTreeGitRenamed', 'DiffModifiedGutter') +high_link('NvimTreeGitNew', 'DiffAddedGutter') +high_link('NvimTreeGitDeleted', 'DiffRemovedGutter') + +high_link('NvimTreeIndentMarker', 'IndentGuide') +high_link('NvimTreeOpenedFolderName', 'NvimTreeFolderName') + +-- }}} + +-- Dashboard {{{ + +local dashboard = { + dashboardHeader = { fg = '#586268' }, + dashboardCenter = { fg = light_bg and orange or blue }, + dashboardShortcut = { fg = '#9788b9' }, +} + +apply_highlight(dashboard) +high_link('dashboardFooter', 'dashboardHeader') + +-- }}} + +-- WhichKey {{{ + +local whichkey = { + WhichKey = { fg = light_bg and orange or blue }, + WhichKeyGroup = { fg = magenta }, + WhichKeyDesc = { fg = magenta }, + WhichKeySeparator = { fg = base5 }, + WhichKeyFloat = { bg = base2 }, + WhichKeyValue = { fg = grey }, +} + +apply_highlight(whichkey) + +-- }}} + +-- }}} + +-- LSP {{{ + +local msg_underline = { + ErrorMsgUnderline = { fg = red, gui = 'undercurl' }, + WarningMsgUnderline = { fg = yellow, gui = 'undercurl' }, + MoreMsgUnderline = { fg = blue, gui = 'undercurl' }, + MsgUnderline = { fg = green, gui = 'undercurl' }, +} + +apply_highlight(msg_underline) +high_link('LspDiagnosticsFloatingError', 'ErrorMsg') +high_link('LspDiagnosticsFloatingWarning', 'Warning') +high_link('LspDiagnosticsFloatingInformation', 'MoreMsg') +high_link('LspDiagnosticsFloatingHint', 'Msg') +high_link('LspDiagnosticsDefaultError', 'ErrorMsg') +high_link('LspDiagnosticsDefaultWarning', 'WarningMsg') +high_link('LspDiagnosticsDefaultInformation', 'MoreMsg') +high_link('LspDiagnosticsDefaultHint', 'Msg') +high_link('LspDiagnosticsVirtualTextError', 'ErrorMsg') +high_link('LspDiagnosticsVirtualTextWarning', 'WarningMsg') +high_link('LspDiagnosticsVirtualTextInformation', 'MoreMsg') +high_link('LspDiagnosticsVirtualTextHint', 'Msg') +high_link('LspDiagnosticsUnderlineError', 'ErrorMsgUnderline') +high_link('LspDiagnosticsUnderlineWarning', 'WarningMsgUnderline') +high_link('LspDiagnosticsUnderlineInformation', 'MoreMsgUnderline') +high_link('LspDiagnosticsUnderlineHint', 'MsgUnderline') +high_link('LspDiagnosticsSignError', 'ErrorMsg') +high_link('LspDiagnosticsSignWarning', 'WarningMsg') +high_link('LspDiagnosticsSignInformation', 'MoreMsg') +high_link('LspDiagnosticsSignHint', 'Msg') +high_link('LspReferenceText', 'Bold') +high_link('LspReferenceRead', 'Bold') +high_link('LspReferenceWrite', 'Bold') +high_link('TermCursor', 'Cursor') +high_link('healthError', 'ErrorMsg') +high_link('healthSuccess', 'Msg') +high_link('healthWarning', 'WarningMsg') + +-- LspSaga {{{ + +local lspsaga = { + SagaShadow = { bg = bg }, + LspSagaDiagnosticHeader = { fg = red }, +} + +apply_highlight(lspsaga) +high_link('LspSagaDiagnosticBorder', 'Normal') +high_link('LspSagaDiagnosticTruncateLine', 'Normal') +high_link('LspFloatWinBorder', 'Normal') +high_link('LspSagaBorderTitle', 'Title') +high_link('TargetWord', 'Error') +high_link('ReferencesCount', 'Title') +high_link('ReferencesIcon', 'Special') +high_link('DefinitionCount', 'Title') +high_link('TargetFileName', 'Comment') +high_link('DefinitionIcon', 'Special') +high_link('ProviderTruncateLine', 'Normal') +high_link('LspSagaFinderSelection', 'Search') +high_link('DiagnosticTruncateLine', 'Normal') +high_link('DiagnosticError', 'LspDiagnosticsDefaultError') +high_link('DiagnosticWarning', 'LspDiagnosticsDefaultWarning') +high_link('DiagnosticInformation', 'LspDiagnosticsDefaultInformation') +high_link('DiagnosticHint', 'LspDiagnosticsDefaultHint') +high_link('DefinitionPreviewTitle', 'Title') +high_link('LspSagaShTruncateLine', 'Normal') +high_link('LspSagaDocTruncateLine', 'Normal') +high_link('LineDiagTuncateLine', 'Normal') +high_link('LspSagaCodeActionTitle', 'Title') +high_link('LspSagaCodeActionTruncateLine', 'Normal') +high_link('LspSagaCodeActionContent', 'Normal') +high_link('LspSagaRenamePromptPrefix', 'Normal') +high_link('LspSagaRenameBorder', 'Bold') +high_link('LspSagaHoverBorder', 'Bold') +high_link('LspSagaSignatureHelpBorder', 'Bold') +high_link('LspSagaCodeActionBorder', 'Bold') +high_link('LspSagaDefPreviewBorder', 'Bold') +high_link('LspLinesDiagBorder', 'Bold') + +-- }}} + +-- }}} + +-- TreeSitter {{{ + +if vim.g.doom_one_enable_treesitter then + high_link('TSException', 'Exception') + high_link('TSAnnotation', 'PreProc') + high_link('TSAttribute', 'Attribute') + high_link('TSConditional', 'Conditional') + high_link('TSComment', 'Comment') + high_link('TSConstructor', 'Structure') + high_link('TSConstant', 'Constant') + high_link('TSConstBuiltin', 'Constant') + high_link('TSConstMacro', 'Macro') + high_link('TSError', 'Error') + high_link('TSField', 'Field') + high_link('TSFloat', 'Float') + high_link('TSFunction', 'Function') + high_link('TSFuncBuiltin', 'FunctionBuiltin') + high_link('TSFuncMacro', 'Macro') + high_link('TSInclude', 'Include') + high_link('TSKeyword', 'Keyword') + high_link('TSKeywordFunction', 'KeywordFunction') + high_link('TSLabel', 'Label') + high_link('TSMethod', 'Method') + high_link('TSNamespace', 'Directory') + high_link('TSNumber', 'Number') + high_link('TSOperator', 'Operator') + high_link('TSParameter', 'Argument') + high_link('TSParameterReference', 'Argument') + high_link('TSProperty', 'Property') + high_link('TSPunctDelimiter', 'Delimiter') + high_link('TSPunctBracket', 'Delimiter') + high_link('TSPunctSpecial', 'Delimiter') + high_link('TSRepeat', 'Repeat') + high_link('TSString', 'String') + high_link('TSStringRegex', 'StringDelimiter') + high_link('TSStringEscape', 'StringDelimiter') + high_link('TSTag', 'Tag') + high_link('TSTagDelimiter', 'Delimiter') + high_link('TSStrong', 'Bold') + high_link('TSURI', 'URL') + high_link('TSWarning', 'Warning') + high_link('TSDanger', 'Error') + high_link('TSType', 'Type') + high_link('TSTypeBuiltin', 'TypeBuiltin') + high_link('TSVariable', 'None') + high_link('TSVariableBuiltin', 'VariableBuiltin') +end + +-- }}} + +-- Neovim Terminal Colors {{{ + +if vim.g.doom_one_terminal_colors then + vim.g.terminal_color_0 = bg + vim.g.terminal_color_1 = red + vim.g.terminal_color_2 = green + vim.g.terminal_color_3 = yellow + vim.g.terminal_color_4 = blue + vim.g.terminal_color_5 = violet + vim.g.terminal_color_6 = cyan + vim.g.terminal_color_7 = fg + vim.g.terminal_color_8 = grey + vim.g.terminal_color_9 = red + vim.g.terminal_color_10 = green + vim.g.terminal_color_11 = orange + vim.g.terminal_color_12 = blue + vim.g.terminal_color_13 = violet + vim.g.terminal_color_14 = cyan + vim.g.terminal_color_15 = white + vim.g.terminal_color_background = bg_alt + vim.g.terminal_color_foreground = fg_alt +end + +-- }}} diff --git a/lua/colors/utils/init.lua b/lua/colors/utils/init.lua new file mode 100644 index 000000000..111c0e7c4 --- /dev/null +++ b/lua/colors/utils/init.lua @@ -0,0 +1,109 @@ +---[[------------------------]]--- +-- COLOR UTILITIES -- +---]]------------------------[[--- + +local M = {} + +------------------------------------------------------------------------------- +-- Functions {{{ + +-- Convert RGB to Hex color. +-- @param r Red value +-- @param g Green value +-- @param b Blue value +-- @return HEX color, e.g. '#1E1E1E' +local function RGB_to_Hex(r, g, b) + return '#' .. string.format('%02X%02X%02X', r, g, b) +end + +-- Convert Hex to RGB color. +-- @param color HEX color +-- @return RGB color, e.g. {30, 30, 30} +local function Hex_to_RGB(color) + color = color:gsub('#', '') + return { + tonumber('0x' .. string.sub(color, 1, 2)), + tonumber('0x' .. string.sub(color, 3, 4)), + tonumber('0x' .. string.sub(color, 5, 6)), + } +end + +-- }}} +------------------------------------------------------------------------------- +-- Composed functions {{{ + +M.Lighten = function(color, percentage) + local amount = percentage == nil and 5.0 or percentage + + if amount < 1.0 then + amount = 1.0 + amount + else + amount = 1.0 + (amount / 100.0) + end + + -- Let's pass amount variable to Neovim so we can use + -- the Neovim map function + vim.g.amount = amount + + local rgb = Hex_to_RGB(color) + rgb = vim.fn.map(rgb, 'v:val * amount') + -- Let's delete the g:amount variable since we don't need it anymore + vim.cmd('unlet g:amount') + + rgb = vim.fn.map(rgb, 'v:val > 255.0 ? 255.0 : v:val') + rgb = vim.fn.map(rgb, 'float2nr(v:val)') + local hex = RGB_to_Hex(rgb[1], rgb[2], rgb[3]) + + return hex +end + +M.Darken = function(color, percentage) + local amount = percentage == nil and 5.0 or percentage + + if amount < 1.0 then + amount = 1.0 - amount + else + amount = 1.0 - (amount / 100.0) + end + if amount < 0.0 then + amount = 0.0 + end + + -- Let's pass amount variable to Neovim so we can use + -- the Neovim map function + vim.g.amount = amount + + local rgb = Hex_to_RGB(color) + rgb = vim.fn.map(rgb, 'v:val * amount') + -- Let's delete the g:amount variable since we don't need it anymore + vim.cmd('unlet g:amount') + + rgb = vim.fn.map(rgb, 'v:val > 255.0 ? 255.0 : v:val') + rgb = vim.fn.map(rgb, 'float2nr(v:val)') + local hex = RGB_to_Hex(rgb[1], rgb[2], rgb[3]) + + return hex +end + +local function interpolate(start, _end, amount) + local diff = _end - start + return start + (diff * amount) +end + +M.Mix = function(first, second, percentage) + local amount = percentage == nil and 0.0 or percentage + + local first_rgb = Hex_to_RGB(first) + local second_rgb = Hex_to_RGB(second) + + local r = interpolate(first_rgb[1], second_rgb[1], amount) + local g = interpolate(first_rgb[2], second_rgb[2], amount) + local b = interpolate(first_rgb[3], second_rgb[3], amount) + + 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 new file mode 100644 index 000000000..f6231b13e --- /dev/null +++ b/lua/doom/README.md @@ -0,0 +1,11 @@ +# Doom + +This is the entry point module for Doom Nvim. Herein lies the core of Doom +divided into three different sub-modules. + +- [core](./core/README.md) - The Doom core, herein lies the entire Doom core, + e.g. configurations, keybindings. +- [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. diff --git a/lua/doom/config/doomrc.lua b/lua/doom/config/doomrc.lua deleted file mode 100644 index 1c9ac4653..000000000 --- a/lua/doom/config/doomrc.lua +++ /dev/null @@ -1,193 +0,0 @@ ----[[---------------------------------------]]--- --- doomrc.lua - Load Doom Nvim doomrc -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -function Check_BFC() - -- /home/user/.config/doom-nvim/doomrc - if Fn.filereadable(Doom_root .. '/doomrc') then - Doom_bfc = true - else - Doom_bfc = false - end -end - -local function default_BFC_values() - 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, - - -- Autosave sessions - -- false : Disable session autosave - -- true : Enable session autosave - -- @default = false - autosave_sessions = false, - - -- Autoload sessions - -- false : Disable session autoload - -- true : Enable session autosave - -- @default = false - autoload_last_session = false, - - -- Preserve last editing position - -- false : Disable preservation of last editing position - -- true : Enable preservation of last editing position - -- @default = false - preserve_edit_pos = false, - - -- Default indent size - -- @default = 4 - indent = 4, - - -- 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 : Shows absolute number lines - -- true : Shows relative number lines - -- @default = true - relative_num = true, - - -- Set max cols - -- Defines the column to show a vertical marker - -- @default = 80 - max_columns = 80, - - -- Enable guicolors - -- Enables gui colors on GUI versions of Neovim - -- @default = true - enable_guicolors = true, - - -- Sidebar sizing - -- Specifies the default width of Tree Explorer and Tagbar - -- @default = 25 - sidebar_width = 25, - - -- Tagbar left - -- Sets Tagbar buffer to the left when enabled - -- @default = true - tagbar_left = true, - - -- Show hidden files - -- @default = true - show_hidden = true, - - -- Default colorscheme - -- @default = doom-one - colorscheme = 'doom-one', - - -- Background color - -- @default = dark - colorscheme_bg = 'dark', - - -- Checkupdates on start - -- @default = false - check_updates = false, - - -- Disabled plugins - -- @default = {'lazygit', 'minimap', 'restclient'} - -- example: - -- disabled_plugins = {'emmet-vim'} - disabled_plugins = { 'lazygit', 'minimap', 'restclient' }, - - -- Disabled plugins modules - -- @default = {'git', 'lsp', 'web'} - -- example: - -- disabled_modules = {'web'} - disabled_modules = { 'git', 'lsp', 'web' }, - - -- Install custom plugins - -- @default = {} - -- examples: - -- plugins without options: - -- custom_plugins = {'andweeb/presence.nvim'} - -- plugins with options: - -- custom_plugins = { - -- { - -- 'repo': 'andweeb/presence.nvim', - -- 'enabled': true, - -- } - -- } - custom_plugins = {}, - - -- Set the parsers for TreeSitter - -- @default = {} - -- example: - -- ts_parsers = {'python', 'javascript'} - ts_parsers = {}, - - -- Set the Terminal direction - -- Available directions: - -- - vertical - -- - horizontal - -- - window - -- - float - -- @default = 'horizontal' - terminal_direction = 'horizontal', - - -- 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 - -- 0 : No logging - -- 1 : All errors, no echo (default) - -- 2 : All errors and messages, no echo - -- 3 : All errors and messages, echo - -- @default = 1 - logging = 3, - } -end - -function Load_BFC() - -- /home/user/.config/doom-nvim/doomrc - if Fn.filereadable(Doom_root .. '/doomrc') then - Try({ - function() - Cmd('luafile ' .. Doom_root .. '/doomrc') - Log_message('+', 'Loading the BFC ...', 2) - end, - Catch({ - function(_) - Log_message('!', 'Error while loading the BFC', 1) - end, - }), - }) - else - Log_message('+', 'No BFC file found, falling to defaults', 2) - default_BFC_values() - end -end diff --git a/lua/doom/config/init.lua b/lua/doom/config/init.lua deleted file mode 100644 index 924970a1b..000000000 --- a/lua/doom/config/init.lua +++ /dev/null @@ -1,52 +0,0 @@ ----[[---------------------------------------]]--- --- config - Core of Doom Nvim -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- --- Doom Nvim version -Doom_version = '2.3.5' - --- Check if running Neovim or Vim and fails if: --- 1. Running Vim instead of Neovim --- 2. Running Neovim 0.4 or below -if Fn.has('nvim') then - if Fn.has('nvim-0.5') ~= 1 then - Log_message('!!!', 'Doom Nvim requires Neovim 0.5.0', 2) - end -else - Log_message( - '!!!', - 'Doom Nvim does not have support for Vim, please use it with Neovim instead', - 2 - ) -end - --- Set some configs on load -if Fn.has('vim_starting') then - -- Set encoding - Opt('o', 'encoding', 'utf-8') - -- Required to use some colorschemes and improve colors - Opt('o', 'termguicolors', true) -end - ------ Start Doom and run packer.nvim --- Search for a configuration file (doomrc) -Check_BFC() -if Doom_bfc then - Load_BFC() -end --- Set which separator should be used for paths -Which_os() --- Load the default Neovim settings, e.g. tabs width -Default_options() - --- Load packer.nvim and load plugins settings -require('plugins') -require('doom.config.load_plugins') - --- Load the user-defined settings (global variables, autocmds, mappings) -Custom_commands() - -if Doom.check_updates then - Check_updates() -end diff --git a/lua/doom/config/load_plugins/init.lua b/lua/doom/config/load_plugins/init.lua deleted file mode 100644 index b97839354..000000000 --- a/lua/doom/config/load_plugins/init.lua +++ /dev/null @@ -1,61 +0,0 @@ ----[[---------------------------------------]]--- --- load_plugins - Load Doom Nvim Plugins -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - --- /home/user/.config/doom-nvim/lua/plugins/init.lua --- /home/user/.config/doom-nvim/lua/plugins/configs/*.lua --- Don't load plugin config if the plugin is disabled to improve performance - --- Defines the list of plugins to conditionally load -local conditional_plugins = { - - -- Format: ['file-to-require'] = 'plugin-to-check' OR ['file-to-require'] = { 'plugins', 'to', 'check' } - ['autopairs'] = 'nvim-autopairs', - ['lsp'] = { 'nvim-lspconfig', 'nvim-lspinstall' }, - ['nvim-compe'] = 'nvim-compe', - ['nvim-colorizer'] = 'nvim-colorizer.lua', - ['nvim-telescope'] = 'telescope.nvim', - ['nvim-toggleterm'] = 'nvim-toggleterm.lua', - ['nvim-tree'] = 'nvim-tree.lua', - ['statusline'] = 'galaxyline.nvim', - ['tree-sitter'] = 'nvim-treesitter', - ['nvim-gitsigns'] = 'gitsigns.nvim', - ['which-key'] = 'which-key.nvim', - ['symbols'] = 'symbols-outline.nvim', - ['auto-session'] = 'auto-session', - ['nvim-format'] = 'format.nvim', - ['nvim-devicons'] = 'nvim-web-devicons', - ['nvim-dashboard'] = 'dashboard-nvim', - ['blankline'] = 'indent-blankline.nvim' - -} - --- Loop through all conditional plugins and see whether we need to load them -for file_to_require, plugins_to_check in pairs(conditional_plugins) do - - -- The plugins_to_check value can be either an array of strings or a single string - local type_of_plugin = type(plugins_to_check) - - if type_of_plugin == 'string' then - if Check_plugin(plugins_to_check) then - require('plugins.configs.' .. file_to_require) - end - elseif type_of_plugin == 'table' then - - -- If we're dealing with a table then loop through it and see if all plugins want to be loaded - local success = true - - for _, plugin in ipairs(plugins_to_check) do - if not Check_plugin(plugin) then -- If even one of those plugins isn't wanted do not load our file - success = false - break - end - end - - if success then - require('plugins.configs.' .. file_to_require) - end - end -end diff --git a/lua/doom/config/ui.lua b/lua/doom/config/ui.lua deleted file mode 100644 index 7d0acc4a0..000000000 --- a/lua/doom/config/ui.lua +++ /dev/null @@ -1,33 +0,0 @@ ----[[---------------------------------------]]--- --- ui.lua - Doom Nvim UI settings -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - --- If no colorscheme was established then fallback to defauls -if not Is_empty(Doom.colorscheme) then - Try({ - function() - Execute('set background=' .. Doom.colorscheme_bg) - Execute('colorscheme ' .. Doom.colorscheme) - end, - Catch({ - function(_) - Log_message('!', 'Colorscheme not found', 1) - Execute('colorscheme ' .. Doom.colorscheme) - end, - }), - }) -else - Log_message('!', 'Forced default Doom colorscheme', 1) - Execute('colorscheme doom-one') -end - --- Set colors based on environment (GUI, TUI) -if Doom.enable_guicolors then - if Fn.exists('+termguicolors') then - Opt('o', 'termguicolors', true) - elseif Fn.exists('+guicolors') then - Opt('o', 'guicolors', true) - end -end diff --git a/lua/doom/core/README.md b/lua/doom/core/README.md new file mode 100644 index 000000000..45b4d3be5 --- /dev/null +++ b/lua/doom/core/README.md @@ -0,0 +1,15 @@ +# 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. +- config - Doom configurations, handles doomrc file and UI settings. +- default - Doom configurations for Neovim, e.g. `tabwidth`, `showmode`. +- functions - Doom core functions, e.g. `create_report`. +- health - Doom health add-on. +- keybindings - Doom keybindings. +- logging - Doom logging system. +- system - Doom system detection (unused at the moment). diff --git a/lua/doom/autocmds/init.lua b/lua/doom/core/autocmds/init.lua similarity index 52% rename from lua/doom/autocmds/init.lua rename to lua/doom/core/autocmds/init.lua index 391848832..a3c75ff20 100644 --- a/lua/doom/autocmds/init.lua +++ b/lua/doom/core/autocmds/init.lua @@ -4,44 +4,35 @@ -- License: GPLv2 -- ---[[---------------------------------------]]--- +local utils = require('doom.utils') +local log = require('doom.core.logging') +local config = require('doom.core.config').load_config() + +log.debug('Loading Doom autocmds module ...') + local autocmds = { doom_core = { - -- Set proper syntax highlight for our doomrc - { 'BufNewFile,BufRead', 'doomrc', 'set ft=lua' }, - -- Ensure every file does full syntax highlight - { 'BufEnter', '*', ':syntax sync fromstart' }, - { 'BufEnter', '*', ':set signcolumn=yes' }, - { - 'BufEnter', - '*', - ':set pumblend=' .. Doom.complete_transparency, - }, -- Compile new plugins changes at save { 'BufWritePost', - 'init.lua,doomrc', + '*/doom-*.lua,doomrc.lua,plugins.lua', 'PackerCompile profile=true', }, }, doom_extras = { -- Set up vim_buffer_previewer in telescope.nvim { 'User', 'TelescopePreviewerLoaded', 'setlocal wrap' }, - -- Disable tabline on Dashboard - { - 'FileType', - 'dashboard', - 'set showtabline=0 | autocmd WinLeave set showtabline=2', - }, }, } -- Set relative numbers -if Doom.relative_num 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'], { 'BufLeave,WinEnter', '*', @@ -50,36 +41,47 @@ if Doom.relative_num then end -- Install plugins on launch -if Doom.auto_install_plugins then - table.insert(autocmds['doom_core'], { - 'VimEnter', - '*', - 'PackerInstall', - }) +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') + -- Install the plugins + vim.cmd('PackerInstall') + end + end, 200) end -- Set autosave -if Doom.autosave then +if config.doom.autosave then table.insert(autocmds['doom_core'], { - 'TextChanged,TextChangedI', + 'TextChanged,InsertLeave', '', 'silent! write', }) end -- Enable auto comment -if not Doom.auto_comment then - table.insert(autocmds['doom_core'], { - { - 'BufWinEnter', - '*', - 'setlocal formatoptions-=c formatoptions-=r formatoptions-=o', - }, - }) +if not config.doom.auto_comment then + vim.opt.formatoptions:remove({ 'c', 'r', 'o' }) end -- Enable highlight on yank -if Doom.highlight_yank then +if config.doom.highlight_yank then table.insert(autocmds['doom_core'], { { 'TextYankPost', @@ -91,7 +93,7 @@ end -- Format on save -- NOTE: Requires formatter to be enabled! -if Doom.fmt_on_save then +if config.doom.fmt_on_save then table.insert(autocmds['doom_core'], { 'BufWritePost', '*', @@ -100,26 +102,17 @@ if Doom.fmt_on_save then end -- Preserve last editing position -if Doom.preserve_edit_pos then +if config.doom.preserve_edit_pos then table.insert(autocmds['doom_core'], { 'BufReadPost', '*', [[ - if line("'\"") > 1 && line("'\"") <= line("$") | - exe "normal! g'\"" | - endif + if line("'\"") > 1 && line("'\"") <= line("$") | + exe "normal! g'\"" | + endif ]], }) end --- If logging level is greater than 0 then dump :messages to doom.log on exit -if Doom.logging >= 1 then - table.insert(autocmds['doom_core'], { - 'VimLeave', - '*', - ':lua Dump_messages()', - }) -end - -- Create augroups -Create_augroups(autocmds) +utils.create_augroups(autocmds) diff --git a/lua/doom/core/config/doomrc.lua b/lua/doom/core/config/doomrc.lua new file mode 100644 index 000000000..1dfd51a60 --- /dev/null +++ b/lua/doom/core/config/doomrc.lua @@ -0,0 +1,105 @@ +---[[---------------------------------------]]--- +-- doomrc.lua - Load Doom Nvim doomrc -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local utils = require('doom.utils') +local log = require('doom.core.logging') + +local M = {} + +log.debug('Loading Doom doomrc module ...') + +-- default_doomrc_values loads the default doomrc values +-- @return table +local function default_doomrc_values() + return { + ui = { + 'dashboard', -- Start screen + -- 'doom-themes', -- Additional doom emacs' colorschemes + 'statusline', -- Statusline + 'tabline', -- Tabline, shows your buffers list at top + -- 'zen', -- Distraction free environment + 'which-key', -- Keybindings popup menu like Emacs' guide-key + -- 'indentlines', -- Show indent lines + }, + doom = { + -- 'neorg', -- Life Organization Tool + -- 'runner', -- Open a REPL for the current language or run the current file + -- 'compiler', -- Compile (and run) your code with just pressing three keys! + }, + editor = { + 'auto-session', -- A small automated session manager for Neovim + -- 'terminal', -- Terminal for Neovim (NOTE: needed for runner and compiler) + 'explorer', -- Tree explorer + 'symbols', -- LSP symbols and tags + -- 'minimap', -- Code minimap, requires github.com/wfxr/code-minimap + 'gitsigns', -- Git signs + 'telescope', -- Highly extendable fuzzy finder over lists + -- 'restclient', -- A fast Neovim http client + 'formatter', -- File formatting + 'autopairs', -- Autopairs + -- 'editorconfig', -- EditorConfig support for Neovim + 'kommentary', -- Comments plugin + 'lsp', -- Language Server Protocols + 'snippets', -- LSP snippets + }, + 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 + -- + -- 'html', -- HTML support + -- 'css', -- CSS support + -- 'javascript', -- JavaScript support + -- 'typescript', -- TypeScript support + -- 'bash', -- The terminal gods language + -- 'python +lsp', -- Python support + lsp + -- 'ruby', -- Look ma, I love the gems! + 'lua', -- Support for our gods language + -- 'elixir', -- Build scalable and maintainable software + -- 'haskell', -- Because Functional programming is fun, isn't it? + + -- 'rust +lsp', -- Let's get rusty! + -- 'go', -- Hello, gopher + -- 'cpp', -- C++ support + -- 'java', -- Java support + + -- 'config', -- Configuration files (JSON, YAML, TOML) + -- 'dockerfile', -- Do you like containers, right? + }, + utilities = { + -- 'suda', -- Write and read files without sudo permissions + -- 'lazygit', -- LazyGit integration for Neovim, requires LazyGit + -- 'neogit', -- Magit for Neovim + -- 'colorizer', -- Fastets colorizer for Neovim + 'range-highlight', -- hightlights ranges you have entered in commandline + }, + } +end + +-- load_doomrc Loads the doomrc if it exists, otherwise it'll fallback to doom +-- default configs. +M.load_doomrc = function() + local config + + -- /home/user/.config/doom-nvim/doomrc + if vim.fn.filereadable(utils.doom_root .. '/doomrc.lua') == 1 then + local loaded_doomrc, err = pcall(function() + log.debug('Loading the doomrc file ...') + config = dofile(utils.doom_root .. '/doomrc.lua') + end) + + if not loaded_doomrc then + log.error('Error while loading the doomrc. Traceback:\n' .. err) + end + else + log.warn('No doomrc.lua file found, falling to defaults') + config = default_doomrc_values() + end + + return config +end + +return M diff --git a/lua/doom/core/config/init.lua b/lua/doom/core/config/init.lua new file mode 100644 index 000000000..2d631abd9 --- /dev/null +++ b/lua/doom/core/config/init.lua @@ -0,0 +1,456 @@ +---[[------------------------------]]--- +-- config - Core of Doom Nvim -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[------------------------------]]--- + +local M = {} + +local log = require('doom.core.logging') +local utils = require('doom.utils') + +log.debug('Loading Doom core 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' + ) +end + +-- {{{ Default doom_config values + +-- default_doom_config_values loads the default doom_config values +-- @return table +local function default_doom_config_values() + -- {{{ Doom + local 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 = true + disable_macros = 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, + + -- 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) + -- @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 : Shows absolute number lines + -- true : Shows relative number lines + -- @default = true + relative_num = true, + + -- 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, + + -- 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 thepath: ~/.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_warning = '๏ฑ', + lsp_hint = '๏ช', + lsp_information = '๏š', + lsp_virtual_text = '๏ŒŒ ', + + -- 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 + local nvim = { + -- Set custom Neovim global variables + -- @default = {} + -- example: + -- { ['sonokai_style'] = 'andromeda' } + global_variables = {}, + + -- Set custom autocommands + -- @default = {} + -- example: + -- augroup_name = { + -- { 'BufNewFile,BufRead', 'doomrc', 'set ft=lua'} + -- } + autocmds = {}, + + -- Set custom key bindings + -- @default = {} + -- example: + -- { + -- {'n', 'ca', ':Lspsaga code_action'} + -- } + -- + -- where + -- 'n' is the map scope + -- 'ca' is the map activator + -- ':Lspsaga ...' is the command to be executed + 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 + -- } + functions = {}, + } + -- }}} + + return { + doom = doom, + nvim = nvim, + } +end + +-- }}} + +-- load_config Loads the doom_config.lua file if it exists +-- @return table +M.load_config = function() + local config = { + doom = {}, + nvim = {}, + } + + -- /home/user/.config/doom-nvim/doomrc + if vim.fn.filereadable(utils.doom_root .. '/doom_config.lua') == 1 then + local loaded_doomrc, err = pcall(function() + config = dofile(utils.doom_root .. '/doom_config.lua') + end) + + if not loaded_doomrc then + log.error( + 'Error while loading the doom_config file. Traceback:\n' .. err + ) + end + else + log.warn('No doom_config.lua file found, falling to defaults') + default_doom_config_values() + end + + return config +end + +-- install_servers will install the language servers for the languages with +-- the +lsp flag. +-- +-- @param langs The list of languages in the doomrc +M.install_servers = function(langs) + local lspinstall = require('lspinstall') + local installed_servers = lspinstall.installed_servers() + local available_servers = lspinstall.available_servers() + + for _, lang in ipairs(langs) do + local lang_str = lang + lang = lang:gsub('%s+%+lsp', '') + + -- If the +lsp flag exists and the language server is not installed yet + if + lang_str:find('%+lsp') + and (not utils.has_value(installed_servers, lang)) + then + -- Try to install the server only if there is a server available for + -- the language, oterwise raise a warning + if utils.has_value(available_servers, lang) then + lspinstall.install_server(lang) + else + log.warn( + 'The language ' + .. lang + .. ' does not have a server, please remove the "+lsp" flag' + ) + end + end + end +end + +-- Check plugins updates on start if enabled +if M.load_config().doom.check_updates then + require('doom.core.functions').check_updates() +end + +return M + +-- vim: fdm=marker diff --git a/lua/doom/core/config/ui.lua b/lua/doom/core/config/ui.lua new file mode 100644 index 000000000..fb2a07d59 --- /dev/null +++ b/lua/doom/core/config/ui.lua @@ -0,0 +1,45 @@ +---[[---------------------------------------]]--- +-- ui.lua - Doom Nvim UI settings -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local utils = require('doom.utils') +local log = require('doom.core.logging') +local config = require('doom.core.config').load_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 = pcall(function() + vim.opt.background = config.doom.colorscheme_bg + vim.api.nvim_command('colorscheme ' .. config.doom.colorscheme) + end) + + if not loaded_colorscheme then + log.error('Colorscheme not found, falling to doom-one') + vim.api.nvim_command('colorscheme ' .. config.doom.colorscheme) + 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 doom-one colorscheme settings +vim.g.doom_one_cursor_coloring = config.doom.doom_one.cursor_coloring +vim.g.doom_one_enable_treesitter = config.doom.doom_one.enable_treesitter +vim.g.doom_one_italic_comments = config.doom.doom_one.italic_comments +vim.g.doom_one_telescope_highlights = config.doom.doom_one.telescope_highlights +vim.g.doom_one_terminal_colors = config.doom.doom_one.terminal_colors +vim.g.doom_one_transparent_background = + config.doom.doom_one.transparent_background diff --git a/lua/doom/core/default/init.lua b/lua/doom/core/default/init.lua new file mode 100644 index 000000000..edc3c1203 --- /dev/null +++ b/lua/doom/core/default/init.lua @@ -0,0 +1,157 @@ +---[[---------------------------------------]]--- +-- default - Doom Nvim defaults -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local functions = require('doom.core.functions') +local log = require('doom.core.logging') +local config = require('doom.core.config').load_config() + +local M = {} + +log.debug('Loading Doom defaults module ...') + +-- load_default_options sets and loads default Doom options based on doomrc values +M.load_default_options = function() + ----- Default Neovim configurations + -- Set colorscheme + vim.cmd('colorscheme ' .. config.doom.colorscheme) + vim.opt.background = config.doom.colorscheme_bg + vim.cmd('highlight WhichKeyFloat guibg=' .. config.doom.whichkey_bg) + + -- 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 = 'yes' + + -- 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 config.doom.relative_num then + vim.opt.number = true + vim.opt.relativenumber = true + else + vim.opt.number = true + 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('config') .. config.doom.undo_dir + if config.doom.backup and vim.fn.empty(vim.fn.glob(undo_dir)) > 0 then + vim.api.nvim_command('!mkdir ' .. undo_dir .. ' -p') + 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 +end + +-- Custom Doom Nvim commands +M.custom_options = 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()' + ) + + -- Load user-defined settings from the Neovim field in the doomrc file + functions.load_custom_settings(config.nvim.autocmds, 'autocmds') + functions.load_custom_settings(config.nvim.commands, 'commands') + functions.load_custom_settings(config.nvim.functions, 'functions') + functions.load_custom_settings(config.nvim.mappings, 'mappings') + functions.load_custom_settings(config.nvim.global_variables, 'variables') +end + +return M diff --git a/lua/doom/core/functions/init.lua b/lua/doom/core/functions/init.lua new file mode 100644 index 000000000..a93947111 --- /dev/null +++ b/lua/doom/core/functions/init.lua @@ -0,0 +1,446 @@ +---[[---------------------------------------]]--- +-- functions - Doom Nvim Functions -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local utils = require('doom.utils') +local log = require('doom.core.logging') +local config = require('doom.core.config').load_config() + +local M = {} + +log.debug('Loading Doom functions module ...') + +-- check_plugin checks if the given plugin exists +-- @tparam string plugin_name The plugin name, e.g. nvim-tree.lua +-- @tparam string path Where should be searched the plugin in packer's path, defaults to `start` +-- @return bool +M.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 + +-- is_plugin_disabled checks if the given plugin is disabled in doomrc +-- @tparam string plugin The plugin identifier, e.g. statusline +-- @return bool +M.is_plugin_disabled = function(plugin) + local doomrc = require('doom.core.config.doomrc').load_doomrc() + + -- Iterate over all doomrc sections (e.g. ui) and their plugins + for _, section in pairs(doomrc) do + if utils.has_value(section, plugin) then + return false + end + end + + return true +end + +-- Load user-defined settings from the Neovim field in the doomrc +-- @param settings_tbl The settings table to iterate over +-- @param scope The settings scope, e.g. autocmds +M.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 == 'autocmds' then + utils.create_augroups(settings_tbl) + elseif scope == 'commands' then + for _, cmd in ipairs(settings_tbl) do + vim.cmd(cmd) + end + elseif scope == 'functions' then + for _, func_body in pairs(settings_tbl) do + func_body() + end + elseif scope == 'mappings' then + local opts = { silent = true } + for _, map in ipairs(settings_tbl) do + -- scope, lhs, rhs, options + map(map[1], map[2], map[3], opts) + end + elseif scope == 'variables' then + for var, val in pairs(settings_tbl) do + vim.g[var] = val + end + end + end +end + +-- Quit Neovim and change the colorscheme at doomrc if the colorscheme is not the same, +-- dump all messages to doom.log file +-- @tparam bool write If doom should save before exiting +-- @tparam bool force If doom should force the exiting +M.quit_doom = function(write, force) + local changed_colorscheme, err = pcall(function() + log.info('Checking if the colorscheme or background were changed ...') + local target_colorscheme = vim.g.colors_name + local target_background = vim.opt.background:get() + + if target_colorscheme ~= config.doom.colorscheme then + vim.cmd( + 'silent !sed -i "s/\'' + .. config.doom.colorscheme + .. "'/'" + .. target_colorscheme + .. '\'/" $HOME/.config/doom-nvim/doom_config.lua' + ) + log.info( + 'Colorscheme successfully changed to ' .. target_colorscheme + ) + end + if target_background ~= config.doom.colorscheme_bg then + vim.cmd( + 'silent !sed -i "s/\'' + .. config.doom.colorscheme_bg + .. "'/'" + .. target_background + .. '\'/" $HOME/.config/doom-nvim/doom_config.lua' + ) + log.info('Background successfully changed to ' .. target_background) + end + end) + + if not changed_colorscheme then + log.error('Unable to write to the doomrc. Traceback:\n' .. err) + end + + local quit_cmd = '' + + -- Save current session if enabled + if config.doom.autosave_sessions then + vim.cmd('SaveSession') + end + + if write then + quit_cmd = 'wa | ' + end + if force then + vim.cmd(quit_cmd .. 'qa!') + else + vim.cmd(quit_cmd .. 'q!') + end +end + +-- check_updates checks for plugins updates +M.check_updates = function() + local updated_plugins, err = pcall(function() + log.info('Updating the outdated plugins ...') + vim.cmd('PackerSync') + end) + + if not updated_plugins then + log.error('Unable to update plugins. Traceback:\n' .. err) + end +end + +-- create_report creates a markdown report. It's meant to be used when a bug +-- occurs, useful for debugging issues. +M.create_report = function() + local date = os.date('%Y-%m-%d %H:%M:%S') + + local created_report, err = pcall(function() + vim.cmd( + 'silent !echo "' + .. vim.fn.fnameescape('#') + .. ' doom crash report" >> ' + .. utils.doom_report + ) + vim.cmd( + 'silent !echo "Report date: ' + .. date + .. '" >> ' + .. utils.doom_report + ) + vim.cmd( + 'silent !echo "' + .. vim.fn.fnameescape('##') + .. ' Begin log dump" >> ' + .. utils.doom_report + ) + vim.cmd( + 'silent !cat ' + .. utils.doom_logs + .. ' | grep "$(date +%a %d %b %Y)" >> ' + .. utils.doom_report + ) + vim.cmd( + 'silent !echo "' + .. vim.fn.fnameescape('##') + .. ' End log dump" >> ' + .. utils.doom_report + ) + log.info('Report created at ' .. utils.doom_report) + end) + + if not created_report then + log.error('Error while writing report. Traceback:\n' .. err) + end +end + +-- save_backup_hashes saves the commits or releases SHA for future rollbacks +local function save_backup_hashes() + -- Check for the current branch + local branch_handler = io.popen( + utils.git_workspace .. 'branch --show-current' + ) + local git_branch = branch_handler:read('a'):gsub('[\r\n]', '') + branch_handler:close() + + if git_branch == 'main' then + local releases_database_path = string.format( + '%s/.doom_releases', + utils.doom_root + ) + + -- Fetch for a file containing the releases tags + log.info('Saving the Doom releases for future rollbacks ...') + local saved_releases, releases_err = pcall(function() + -- Get the releases + log.debug( + 'Executing "' .. utils.git_workspace .. 'show-ref --tags"' + ) + local releases_handler = io.popen( + utils.git_workspace .. 'show-ref --tags' + ) + local doom_releases = releases_handler:read('a') + releases_handler:close() + + -- Put all the releases into a table so we can sort them later + local releases = {} + for release in doom_releases:gmatch('[^\r\n]+') do + table.insert(releases, release) + end + -- Sort the releases table + local sorted_releases = {} + for idx, release in ipairs(releases) do + sorted_releases[#releases + 1 - idx] = release:gsub( + 'refs/tags/', + '' + ) + end + + -- Check if the database already exists so we can check if the + -- database is up-to-date or if we should override it. + -- + -- If the database does not exist yet then we will create it + if vim.fn.filereadable(releases_database_path) == 1 then + local current_releases = utils.read_file(releases_database_path) + if current_releases ~= doom_releases then + -- Write the first release in the list with 'w+' so the + -- actual content will be overwritten by this one + utils.write_file( + releases_database_path, + sorted_releases[1] .. '\n', + 'w+' + ) + -- Write the rest of the releases + for idx, release in ipairs(sorted_releases) do + -- Exclude the first release because we have already + -- written it in the database file + if idx ~= 1 then + utils.write_file( + releases_database_path, + release .. '\n', + 'a+' + ) + end + end + end + else + for _, release in ipairs(sorted_releases) do + utils.write_file( + releases_database_path, + release .. '\n', + 'a+' + ) + end + end + end) + + if not saved_releases then + log.error( + 'Error while saving the Doom releases. Traceback:\n' + .. releases_err + ) + end + else + -- Get the current commit SHA and store it into a hidden file + log.info('Saving the current commit SHA for future rollbacks ...') + local saved_backup_hash, backup_err = pcall(function() + os.execute( + utils.git_workspace + .. 'rev-parse --short HEAD > ' + .. utils.doom_root + .. '/.doom_backup_hash' + ) + end) + + if not saved_backup_hash then + log.error( + 'Error while saving the backup commit hash. Traceback:\n' + .. backup_err + ) + end + end +end + +-- update_doom saves the current commit/release hash into a file for future +-- restore if needed and then updates Doom. +M.update_doom = function() + save_backup_hashes() + + log.info('Pulling Doom remote changes ...') + local updated_doom, update_err = pcall(function() + os.execute(utils.git_workspace .. 'pull -q') + end) + + if not updated_doom then + log.error('Error while updating Doom. Traceback:\n' .. update_err) + end + -- Run syntax_on event to fix UI if it's broke after the git pull + vim.cmd('syntax on') + + log.info('Successfully updated Doom, please restart') +end + +-- rollback_doom will rollback the local doom version to an older one +-- in case that the local one is broken +M.rollback_doom = function() + -- Backup file for main (stable) branch + local releases_database_path = string.format( + '%s/.doom_releases', + utils.doom_root + ) + -- Backup file for development branch + local rolling_backup = string.format( + '%s/.doom_backup_hash', + utils.doom_root + ) + + -- Check if there's a rollback file and sets the rollback type + if vim.fn.filereadable(releases_database_path) == 1 then + -- Get the releases database and split it into a table + local doom_releases = utils.read_file(releases_database_path) + + -- Put all the releases into a table so we can sort them later + local releases = {} + for release in doom_releases:gmatch('[^\r\n]+') do + table.insert(releases, release) + end + -- Sort the releases table + local sorted_releases = {} + for idx, release in ipairs(releases) do + sorted_releases[#releases + 1 - idx] = release:gsub( + 'refs/tags/', + '' + ) + end + + -- Check the current commit hash and compare it with the ones in the + -- releases table + local current_version + local commit_handler = io.popen(utils.git_workspace .. 'rev-parse HEAD') + local current_commit = commit_handler:read('a'):gsub('[\r\n]', '') + commit_handler:close() + for _, version_info in ipairs(sorted_releases) do + for release_hash, version in version_info:gmatch('(%w+)%s(%w+%W+%w+%W+%w+)') do + if release_hash == current_commit then + current_version = version + end + end + end + -- If the current_version variable is still nil then + -- fallback to latest version + if not current_version then + -- next => index, SHA vX.Y.Z + local _, release_info = next(releases, nil) + -- split => { SHA, vX.Y.Z }, [2] => vX.Y.Z + current_version = vim.split(release_info, ' ')[2] + end + + local rollback_sha, rollback_version + local break_loop = false + for _, version_info in ipairs(releases) do + for commit_hash, release in version_info:gmatch('(%w+)%s(%w+%W+%w+%W+%w+)') do + if release:gsub('v', '') < current_version:gsub('v', '') then + rollback_sha = commit_hash + rollback_version = release + break_loop = true + break + end + end + if break_loop then + break + end + end + + log.info( + 'Reverting back to version ' + .. rollback_version + .. ' (' + .. rollback_sha + .. ') ...' + ) + local rolled_back, rolled_err = pcall(function() + os.execute(utils.git_workspace .. 'checkout ' .. rollback_sha) + end) + + if not rolled_back then + log.error( + 'Error while rolling back to version ' + .. rollback_version + .. ' (' + .. rollback_sha + .. '). Traceback:\n' + .. rolled_err + ) + end + + log.info( + 'Successfully rolled back Doom to version ' + .. rollback_version + .. ' (' + .. rollback_sha + .. '), please restart' + ) + elseif vim.fn.filereadable(rolling_backup) == 1 then + local backup_commit = utils.read_file(rolling_backup):gsub( + '[\r\n]+', + '' + ) + log.info('Reverting back to commit ' .. backup_commit .. ' ...') + local rolled_back, rolled_err = pcall(function() + os.execute(utils.git_workspace .. 'checkout ' .. backup_commit) + end) + + if not rolled_back then + log.error( + 'Error while rolling back to commit ' + .. backup_commit + .. '. Traceback:\n' + .. rolled_err + ) + end + + log.info( + 'Successfully rolled back Doom to commit ' + .. backup_commit + .. ', please restart' + ) + else + log.error('There are no backup files to rollback') + end +end + +return M diff --git a/lua/doom/health/init.lua b/lua/doom/core/health/init.lua similarity index 79% rename from lua/doom/health/init.lua rename to lua/doom/core/health/init.lua index c5d0c63d9..e5b3e5b7a 100644 --- a/lua/doom/health/init.lua +++ b/lua/doom/core/health/init.lua @@ -4,14 +4,18 @@ -- License: GPLv2 -- ---[[---------------------------------------]]--- --- Health status -local health_start = Fn['health#report_start'] -local health_ok = Fn['health#report_ok'] -local health_error = Fn['health#report_error'] -local health_warn = Fn['health#report_warn'] +local log = require('doom.core.logging') local M = {} +log.debug('Loading Doom health module ...') + +-- Health status +local health_start = vim.fn['health#report_start'] +local health_ok = vim.fn['health#report_ok'] +local health_error = vim.fn['health#report_error'] +local health_warn = vim.fn['health#report_warn'] + -- Installation health local function install_health() health_start('Installation') @@ -20,7 +24,7 @@ local function install_health() -- REQUIRED DEPENDENCIES -- ---]]-----------------------[[--- -- Check Git - if Fn.executable('git') == 0 then + if vim.fn.executable('git') == 0 then health_error('`git` executable not found.', { 'Install it with your package manager.', 'Check that your `$PATH` is set correctly.', @@ -33,7 +37,7 @@ local function install_health() -- OPTIONAL DEPENDENCIES -- ---]]-----------------------[[--- -- Ripgrep and fd - if Fn.executable('rg') == 0 then + if vim.fn.executable('rg') == 0 then health_warn('`rg` executable not found.', { 'Required to improve file indexing performance for some commands', 'Ignore this message if you have `fd` installed.', @@ -41,7 +45,7 @@ local function install_health() else health_ok('`rg` executable found.') end - if Fn.executable('fd') == 0 then + if vim.fn.executable('fd') == 0 then health_warn('`fd` executable not found.', { 'Required to improve file indexing performance for some commands', 'Ignore this message if you have `rg` installed.', @@ -51,14 +55,14 @@ local function install_health() end -- Check NodeJS and NPM - if Fn.executable('node') == 0 then + if vim.fn.executable('node') == 0 then health_warn('`node` executable not found.', { 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', }) else health_ok('`node` executable found.') end - if Fn.executable('npm') == 0 then + if vim.fn.executable('npm') == 0 then health_warn('`npm` executable not found.', { 'Required by the built-in LSP to work, you should need to install it if you want to use LSP.', 'If node is installed but npm is not, you should need to install it with your package manager', diff --git a/lua/doom/core/init.lua b/lua/doom/core/init.lua new file mode 100644 index 000000000..d4fde7f68 --- /dev/null +++ b/lua/doom/core/init.lua @@ -0,0 +1,22 @@ +--- Main Doom configuration file +--- This file loads all doom core components +--- (ui, options, doomrc, modules, packer, ect) + +-- Doom core configurations +require('doom.core.config') +require('doom.core.config.ui') +-- Neovim configurations, e.g. shiftwidth +require('doom.core.default').load_default_options() +-- User-defined settings (global variables, mappings, ect) +require('doom.core.default').custom_options() +-- Doom modules (packer and plugins) +require('doom.modules') +-- Doom keybindings +require('doom.core.keybindings') +-- Doom autocommands +require('doom.core.autocmds') + +-- Automatically install language servers +require('doom.core.config').install_servers( + require('doom.core.config.doomrc').load_doomrc().langs +) diff --git a/lua/doom/core/keybindings/init.lua b/lua/doom/core/keybindings/init.lua new file mode 100644 index 000000000..d0f61fed6 --- /dev/null +++ b/lua/doom/core/keybindings/init.lua @@ -0,0 +1,405 @@ +---[[---------------------------------------]]--- +-- keybindings - Doom Nvim keybindings -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local utils = require('doom.utils') +local log = require('doom.core.logging') +local config = require('doom.core.config').load_config() +local functions = require('doom.core.functions') + +log.debug('Loading Doom keybindings module ...') + +-- Additional options for mappings +local opts = { silent = true } + +-- selene: allow(undefined_variable) +if packer_plugins and not packer_plugins['which-key.nvim'] then + utils.map('n', '', '', opts) + vim.g.mapleader = ' ' +end + +-- Map WhichKey popup menu +utils.map('n', '', ':WhichKey ', opts) + +------------------------------------------------- + +---[[---------------------------------]]--- +-- Custom Key mappings -- +-- -- +-- b = Buffer Menu -- +-- f = File Menu -- +-- g = Git Menu -- +-- p = Plugin Menu -- +-- r = Runner Menu -- +-- s = Session Menu -- +-- t = Toggle Menu -- +-- w = Window Menu -- +-- -- +-- 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 -- +---]]---------------------------------[[--- + +------------------------------------------------- + +---[[-----------------]]--- +-- LSP Keybindings -- +---]]-----------------[[--- + +local lsp_opts = vim.tbl_extend('force', opts, { expr = true }) + +-- If the LSP is not disabled and compe is installed then set its mappings. +if functions.check_plugin('nvim-compe', 'opt') then + -- https://github.com/hrsh7th/nvim-compe#mappings + utils.map('i', '', 'compe#complete()', lsp_opts) + utils.map('i', '', 'compe#confirm("")', lsp_opts) + utils.map('i', '', 'compe#close("")', lsp_opts) + utils.map('i', '', 'compe#scroll({ "delta": +4 })', lsp_opts) + utils.map('i', '', 'compe#scroll({ "delta": -4 })', lsp_opts) + utils.map('n', 'gd', ':lua vim.lsp.buf.definition()', opts) -- gd: jump to definition + utils.map('n', 'gr', ':lua vim.lsp.buf.references()', opts) -- gr: go to reference + utils.map('n', 'gi', ':lua vim.lsp.buf.implementation()', opts) -- gi: buf implementation + utils.map('n', 'ca', ':Lspsaga code_action', opts) -- ca: code actions + utils.map('n', 'K', ':Lspsaga hover_doc', opts) -- K: hover doc + utils.map('n', '', ':Lspsaga diagnostic_jump_prev', opts) -- Control+p: Jump to previous diagnostic + utils.map('n', '', ':Lspsaga diagnostic_jump_next', opts) -- Control+n: Jump to next diagnostic + utils.map( + 'n', + '', + ':lua require("lspsaga.action").smart_scroll_with_saga(1)', + opts + ) -- Control+f: Scroll down documents + utils.map( + 'n', + '', + ":lua require('lspsaga.action').smart_scroll_with_saga(-1)", + opts + ) -- Control+b: Scroll up documents + vim.cmd( + 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()' + ) +end + +-- LuaSnip mappings +utils.map( + 'n', + '', + 'luasnip#expand_or_jumpable() ? "luasnip-expand-or-jump" : ""', + lsp_opts +) +utils.map('i', '', 'lua require("luasnip").jump(-1)', opts) + +utils.map('s', '', 'lua require("luasnip").jump(1)', opts) +utils.map('s', '', 'lua require("luasnip").jump(-1)', opts) + +utils.map( + 'i', + '', + 'luasnip#choice_active() ? "luasnip-next-choice" : ""', + lsp_opts +) +utils.map( + 's', + '', + 'luasnip#choice_active() ? "luasnip-next-choice" : ""', + lsp_opts +) + +if config.doom.new_file_split then + utils.map('n', 'fn', ':new', opts) +else + utils.map('n', 'fn', ':enew', opts) +end + +-- TAB to cycle buffers too, why not? +utils.map('n', '', ':bnext', opts) +utils.map('n', '', ':bprevious', opts) + +-- ESC to turn off search highlighting +utils.map('n', '', ':noh', opts) + +--- F keybindings +if not functions.is_plugin_disabled('symbols') then + utils.map('n', '', ':SymbolsOutline', opts) +end +if not functions.is_plugin_disabled('explorer') then + utils.map('n', '', ':NvimTreeToggle', opts) +end +if not functions.is_plugin_disabled('minimap') then + utils.map('n', '', ':MinimapToggle', opts) +end +if not functions.is_plugin_disabled('zen') then + utils.map('n', '', ':TZAtaraxis', opts) +end +if not functions.is_plugin_disabled('restclient') then + utils.map('n', '', ':RestNvim', opts) +end + +---[[------------------------------]]--- +-- Window Movements keys -- +---]]------------------------------]]--- +utils.map('n', '', 'h', opts) +utils.map('n', '', 'j', opts) +utils.map('n', '', 'k', opts) +utils.map('n', '', 'l', opts) + +---[[-----------------]]--- +-- Escape Remaps -- +---]]-----------------[[--- +utils.map('i', 'jk', '', opts) + +---[[-----------------]]--- +-- Select Movement -- +---]]-----------------[[--- +utils.map('x', 'K', ":move '<-2gv-gv", opts) +utils.map('x', 'J', ":move '>+1gv-gv", opts) + +-- get out of terminal insert mode into normal mode with Esc +vim.cmd('tnoremap ') + +---[[-----------------]]--- +-- Resizing Splits -- +---]]-----------------[[--- +vim.cmd([[ + nnoremap :resize +2 + nnoremap :resize -2 + nnoremap :vertical resize -2 + nnoremap :vertical resize +2 +]]) + +---[[-----------------]]--- +-- Disable keys -- +---]]-----------------[[--- +-- Disable accidentally pressing ctrl-z and suspending +utils.map('n', '', '', opts) + +-- Disable ex mode +utils.map('n', 'Q', '', opts) + +-- Disable recording macros +if config.doom.disable_macros then + utils.map('n', 'q', '', opts) +end + +-- Fast exit from Doom Nvim and write messages to logs +utils.map( + 'n', + 'ZZ', + ':lua require("doom.core.functions").quit_doom(true, true)', + opts +) + +---[[-----------------]]--- +-- WhichKey binds -- +---]]-----------------[[--- + +-- Misc +utils.map('n', '`', 'e #', opts) +utils.map('n', '', 'Telescope find_files', opts) +utils.map('n', '.', 'Telescope file_browser', opts) +utils.map( + 'n', + ',', + 'Telescope buffers show_all_buffers=true', + opts +) +utils.map('n', '/', 'Telescope live_grep', opts) +utils.map('n', ':', 'Telescope command_history', opts) + +-- Buffers +utils.map( + 'n', + 'bc', + 'lua require("bufferline").handle_close_buffer(vim.fn.bufnr("%"))', + opts +) +utils.map('n', 'bb', 'e #', opts) +utils.map( + 'n', + 'b]', + 'lua require("bufferline").cycle(1)', + opts +) +utils.map( + 'n', + 'bn', + 'lua require("bufferline").cycle(1)', + opts +) +utils.map( + 'n', + 'bg', + 'lua require("bufferline").pick_buffer()', + opts +) +utils.map( + 'n', + 'b[', + 'lua require("bufferline").cycle(-1)', + opts +) +utils.map( + 'n', + 'bp', + 'lua require("bufferline").cycle(-1)', + opts +) +utils.map('n', 'bf', 'FormatWrite', opts) + +-- Doom +utils.map( + 'n', + 'dc', + 'e ~/.config/doom-nvim/doom_config.lua', + opts +) +utils.map('n', 'dd', 'help doom_nvim', opts) +utils.map('n', 'du', 'DoomUpdate', opts) +utils.map('n', 'dr', 'DoomRollback', opts) +utils.map( + 'n', + 'dR', + 'lua require("doom.core.functions").create_report()', + opts +) +utils.map('n', 'ds', 'Telescope colorscheme', opts) + +-- Plugins +utils.map('n', 'ps', 'PackerSync', opts) +utils.map('n', 'pi', 'PackerInstall', opts) +utils.map('n', 'pc', 'PackerClean', opts) +utils.map('n', 'pC', 'PackerCompile', opts) +utils.map('n', 'pS', 'PackerStatus', opts) +utils.map('n', 'pp', 'PackerProfile', opts) + +-- files +utils.map('n', 'fc', 'e $MYVIMRC', opts) +utils.map('n', 'ff', 'Telescope find_files', opts) + +utils.map('n', 'fr', 'Telescope oldfiles', opts) +utils.map('n', 'ft', 'Telescope help_tags', opts) +utils.map('n', 'fR', 'SudaRead', opts) +utils.map('n', 'fw', 'SudaWrite', opts) + +-- search +utils.map('n', 'sg', 'Telescope live_grep', opts) +utils.map( + 'n', + 'sb', + 'Telescope current_buffer_fuzzy_find', + opts +) +utils.map('n', 'ss', 'Telescope lsp_document_symbols', opts) +utils.map('n', 'sh', 'Telescope command_history', opts) +utils.map('n', 'sm', 'Telescope marks', opts) + +-- windows +utils.map('n', 'ww', 'p', opts) +utils.map('n', 'wd', 'c', opts) +utils.map('n', 'w-', 's', opts) +utils.map('n', 'w|', 'v', opts) +utils.map('n', 'w2', 'v', opts) +utils.map('n', 'wh', 'h', opts) +utils.map('n', 'wj', 'j', opts) +utils.map('n', 'wl', 'l', opts) +utils.map('n', 'wk', 'k', opts) +utils.map('n', 'wH', '5<', opts) +utils.map('n', 'wJ', 'resize +5', opts) +utils.map('n', 'wL', '5>', opts) +utils.map('n', 'wK', 'resize -5', opts) +utils.map('n', 'w=', '=', opts) +utils.map('n', 'ws', 's', opts) +utils.map('n', 'wv', 'v', opts) + +-- quit / sessions +utils.map( + 'n', + 'qq', + 'lua require("doom.core.functions").quit_doom()', + opts +) +utils.map( + 'n', + 'qw', + 'lua require("doom.core.functions").quit_doom(true, true)', + opts +) +utils.map('n', 'qs', 'SaveSession', opts) +utils.map('n', 'qr', 'RestoreSession', opts) +utils.map( + 'n', + 'ql', + 'Telescope session-lens search_session', + opts +) + +-- toggle +utils.map('n', 'od', 'Dashboard', opts) +utils.map('n', 'oe', 'NvimTreeToggle', opts) +utils.map('n', 'om', 'MinimapToggle', opts) +utils.map('n', 'os', 'SymbolsOutline', opts) +utils.map('n', 'ot', 'ToggleTerm', opts) + +-- git +utils.map('n', 'go', 'LazyGit', opts) +utils.map('n', 'gl', 'TermExec cmd="git pull"', opts) +utils.map('n', 'gp', 'TermExec cmd="git push"', opts) +utils.map('n', 'gs', 'Telescope git_status', opts) +utils.map('n', 'gB', 'Telescope git_branches', opts) +utils.map('n', 'gc', 'Telescope git_commits', opts) + +-- code +utils.map('n', 'ch', 'RestNvim', opts) +utils.map( + 'n', + 'ci', + 'lua require("doom.modules.built-in.runner").start_repl()', + opts +) +utils.map( + 'n', + 'cr', + 'lua require("doom.modules.built-in.runner").run_code()', + opts +) +utils.map( + 'n', + 'cb', + 'lua require("doom.modules.built-in.compiler").compile()', + opts +) +utils.map( + 'n', + 'cc', + 'lua require("doom.modules.built-in.compiler").compile_and_run()', + opts +) + +-- lsp +utils.map('n', 'cli', 'LspInfo', opts) +utils.map('n', 'cla', 'Lspsaga code_action', opts) +utils.map( + 'n', + 'cld', + 'lua vim.lsp.buf.type_definition()', + opts +) +utils.map( + 'n', + 'cll', + 'lua vim.lsp.diagnostic.show_line_diagnostics()', + opts +) +utils.map( + 'n', + 'clL', + 'lua vim.lsp.diagnostic.set_loclist()', + opts +) diff --git a/lua/doom/core/logging/init.lua b/lua/doom/core/logging/init.lua new file mode 100644 index 000000000..041bc8a24 --- /dev/null +++ b/lua/doom/core/logging/init.lua @@ -0,0 +1,190 @@ +-- 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 utils = require('doom.utils') +local doom_config = dofile(utils.doom_root .. '/doom_config.lua') + +----------------------------------------------------------- +----------------------------------------------------------- + +-- User 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 = ( + doom_config.doom.logging == nil and 'info' + or doom_config.doom.logging + ), + + -- Level configuration + modes = { + { name = 'trace', hl = 'Comment' }, + { name = 'debug', hl = 'Comment' }, + { name = 'info', hl = 'None' }, + { name = 'warn', hl = 'WarningMsg' }, + { name = 'error', hl = 'ErrorMsg' }, + { name = 'fatal', hl = 'ErrorMsg' }, + }, + + -- Can limit the number of decimals displayed for floats + float_precision = 0.01, +} + +-- {{{ NO NEED TO CHANGE +local log = {} + +-- selene: allow(incorrect_standard_library_use) +local unpack = unpack or table.unpack + +log.new = function(config, standalone) + config = vim.tbl_deep_extend('force', default_config, config) + + local outfile = string.format( + '%s/%s.log', + vim.api.nvim_call_function('stdpath', { 'data' }), + config.plugin + ) + + local obj + if standalone then + obj = log + else + obj = {} + end + + local levels = {} + for i, v in ipairs(config.modes) do + levels[v.name] = i + end + + local round = function(x, increment) + increment = increment or 1 + x = x / increment + return (x > 0 and math.floor(x + 0.5) or math.ceil(x - 0.5)) * increment + end + + local make_string = function(...) + local t = {} + for i = 1, select('#', ...) do + local x = select(i, ...) + + if type(x) == 'number' and config.float_precision then + x = tostring(round(x, config.float_precision)) + elseif type(x) == 'table' then + x = vim.inspect(x) + else + x = tostring(x) + end + + t[#t + 1] = x + end + return table.concat(t, ' ') + end + + local console_output = vim.schedule_wrap( + function(level_config, info, nameupper, msg) + local console_lineinfo = vim.fn.fnamemodify(info.short_src, ':t') + .. ':' + .. info.currentline + local console_string = string.format( + '[%-6s%s] %s: %s', + nameupper, + os.date('%H:%M:%S'), + console_lineinfo, + msg + ) + + if config.highlights and level_config.hl then + vim.cmd(string.format('echohl %s', level_config.hl)) + end + + local split_console = vim.split(console_string, '\n') + for _, v in ipairs(split_console) do + vim.cmd( + string.format( + [[echom "[%s] %s"]], + config.plugin, + vim.fn.escape(v, '"') + ) + ) + end + + if config.highlights and level_config.hl then + vim.cmd('echohl NONE') + end + end + ) + + local log_at_level = function(level, level_config, message_maker, ...) + -- Return early if we're below the config.level + if level < levels[config.level] then + return + end + local nameupper = level_config.name:upper() + + local msg = message_maker(...) + local info = debug.getinfo(2, 'Sl') + local lineinfo = info.short_src .. ':' .. info.currentline + + -- Output to console + if config.use_console then + console_output(level_config, info, nameupper, msg) + end + + -- Output to log file + if config.use_file then + local fp = io.open(outfile, 'a') + local str = string.format( + '[%-6s%s] %s: %s\n', + nameupper, + os.date(), + lineinfo, + msg + ) + fp:write(str) + fp:close() + end + end + + for i, x in ipairs(config.modes) do + obj[x.name] = function(...) + return log_at_level(i, x, make_string, ...) + end + + obj[('fmt_%s'):format(x.name)] = function() + return log_at_level(i, x, function(...) + local passed = { ... } + local fmt = table.remove(passed, 1) + local inspected = {} + for _, v in ipairs(passed) do + table.insert(inspected, vim.inspect(v)) + end + return string.format(fmt, unpack(inspected)) + end) + end + end +end + +log.new(default_config, true) +-- }}} + +return log diff --git a/lua/doom/core/system/init.lua b/lua/doom/core/system/init.lua new file mode 100644 index 000000000..097ad21c9 --- /dev/null +++ b/lua/doom/core/system/init.lua @@ -0,0 +1,31 @@ +---[[---------------------------------------]]--- +-- system - Doom Nvim system utilities -- +-- Author: NTBBloodbath -- +-- License: GPLv2 -- +---[[---------------------------------------]]--- + +local utils = require('doom.utils') +local log = require('doom.core.logging') + +local M = {} + +log.debug('Loading doom system module ...') + +-- which_os identifies the current OS to determine which separator should be used +-- and then return it +-- @return string +M.which_os = function() + log.debug('Checking OS ...') + + local doom_os = utils.get_os() + if doom_os == 'Windows' then + return '\\' + elseif doom_os == 'Linux' or doom_os == 'OSX' then + return '/' + else + log.warn('OS not recognized, falling to Unix separator') + return '/' + end +end + +return M diff --git a/lua/doom/default/init.lua b/lua/doom/default/init.lua deleted file mode 100644 index 5040822af..000000000 --- a/lua/doom/default/init.lua +++ /dev/null @@ -1,143 +0,0 @@ ----[[---------------------------------------]]--- --- default - Doom Nvim defaults -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- --- Set and load default options -function Default_options() - local o = vim.o - ----- Default Neovim configurations - -- Set colorscheme - Cmd('colorscheme ' .. Doom.colorscheme) - Cmd('set background=' .. Doom.colorscheme_bg) - Cmd('highlight WhichKeyFloat guibg='..Doom.whichkey_bg) - - -- Set default options - Cmd('syntax on') - Cmd('filetype plugin indent on') - Opt('o', 'encoding', 'utf-8') - - -- Global options - Opt('o', 'wildmenu', true) - Opt('o', 'autoread', true) - Opt('o', 'smarttab', true) - Opt('o', 'hidden', true) - Opt('o', 'hlsearch', true) - Opt('o', 'laststatus', 2) - Opt('o', 'backspace', 'indent,eol,start') - Opt('o', 'updatetime', 100) - Opt('o', 'timeoutlen', 200) - Opt( - 'o', - 'completeopt', - 'menu,menuone,preview,noinsert,noselect' - ) - Cmd('set shortmess += "atsc"') - Opt('o', 'inccommand', 'split') - Opt('o', 'path', '**') - --Cmd('set signcolumn=yes') - - -- Buffer options - Opt('b', 'autoindent', true) - Opt('b', 'smartindent', true) - - Cmd('set pumheight='..Doom.complete_size) - - -- set Gui Fonts - --Opt('o', 'guifont='..Doom.guifont..':h'..Doom.guifont_size) - o.guifont = Doom.guifont..':h'..Doom.guifont_size - - -- Use clipboard outside vim - if Doom.clipboard then - Opt('o', 'clipboard', 'unnamedplus') - end - - if Doom.line_highlight then - Cmd('set cursorline') - else - Cmd('set nocursorline') - end - - -- Automatic split locations - if Doom.split_right then - Opt('o', 'splitright', true) - else - Opt('o', 'splitright', false) - end - - if Doom.split_below then - Opt('o', 'splitbelow', true) - else - Opt('o', 'splitbelow', false) - end - - -- Enable scroll off - if Doom.scrolloff then - Opt('o', 'scrolloff', Doom.scrolloff_amount ) - end - - -- Enable showmode - if not Doom.show_mode then - Cmd('set noshowmode') - else - Cmd('set showmode') - end - - -- Enable mouse input - if Doom.mouse then - Opt('o', 'mouse', 'a') - end - - -- Enable wrapping - if not Doom.line_wrap then - Cmd('set nowrap') - else - Cmd('set wrap') - end - - -- Enable swap files - if not Doom.swap_files then - Cmd('set noswapfile') - else - Cmd('set swapfile') - end - - -- Set numbering - if Doom.relative_num then - Cmd('set nu rnu') - else - Cmd('set nu') - end - - -- Checks to see if undo_dir does not exist. If it doesn't, it will create a undo folder - local undo_dir = Fn.stdpath('config') ..Doom.undo_dir - if Doom.backup and Fn.empty(Fn.glob(undo_dir)) > 0 then - Execute('!mkdir '..undo_dir..' -p') - Cmd('set undofile') - end - - -- If backup is false but `undo_dir` still exists then it will delete it. - if not Doom.backup and Fn.empty(Fn.glob(undo_dir)) == 0 then - Execute('!rm -rf '..undo_dir) - Cmd('set noundofile') - end - - -- Set local-buffer options - if Doom.expand_tabs then - Execute('let &expandtab = 1') - else - Execute('let &expandtab = 0') - end - Execute('let &tabstop = ' .. Doom.indent) - Execute('let &shiftwidth = ' .. Doom.indent) - Execute('let &softtabstop = ' .. Doom.indent) - Execute('let &colorcolumn = ' .. Doom.max_columns) - Execute('let &conceallevel = ' .. Doom.conceallevel) -end - --- Custom Doom Nvim commands -function Custom_commands() - -- Set a custom command to update Doom Nvim - -- can be called by using :DoomUpdate - Cmd('command! DoomUpdate !git -C ~/.config/doom-nvim/ stash -q && git -C ~/.config/doom-nvim/ pull && git -C ~/.config/doom-nvim/ stash pop -q') -end diff --git a/lua/doom/functions/init.lua b/lua/doom/functions/init.lua deleted file mode 100644 index cb99b2a05..000000000 --- a/lua/doom/functions/init.lua +++ /dev/null @@ -1,120 +0,0 @@ ----[[---------------------------------------]]--- --- functions - Doom Nvim Functions -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - --- Check if the given plugin exists -function Check_plugin(plugin_path) - return Fn.isdirectory(Fn.expand('$HOME/.local/share/nvim/site/pack/packer/start/' .. plugin_path)) == 1 -end - --- Quit Neovim and change the colorscheme at doomrc if the colorscheme is not the same, --- dump all messages to doom.log file -function Quit_doom(write, force) - Try({ - function() - Log_message( - '*', - 'Checking if the colorscheme was changed ...', - 2 - ) - local target = G.colors_name - if target ~= Doom.colorscheme then - Cmd( - '!sed -i "s/\'' - .. Doom.colorscheme - .. "'/'" - .. target - .. '\'/" $HOME/.config/doom-nvim/doomrc' - ) - Log_message( - '*', - 'Colorscheme successfully changed to ' .. target, - 2 - ) - else - Log_message( - '*', - 'No need to write colors (same colorscheme)', - 2 - ) - end - end, - Catch({ - function(_) - Log_message('!', 'Unable to write to the doomrc', 1) - end, - }), - }) - - Cmd( - 'silent !echo "[---] - Dumping :messages" >> ' .. Doom_logs - ) - Cmd('redir >> ' .. Doom_logs) - Cmd('silent messages') - Cmd('redir END') - Cmd('silent !echo " " >> ' .. Doom_logs) - Cmd('silent !echo "[---] - End of dump" >> ' .. Doom_logs) - - local quit_cmd = '' - - -- Save current session if enabled - if Doom.autosave_sessions then - Cmd('SaveSession') - end - - if write then - quit_cmd = 'wa | ' - end - if force == false then - Cmd(quit_cmd .. 'q!') - else - Cmd(quit_cmd .. 'qa!') - end -end - --- Check for plugins updates -function Check_updates() - Try({ - function() - Log_message('+', 'Updating the outdated plugins ...', 2) - Cmd('PackerSync') - Log_message('+', 'Done', 2) - end, - Catch({ - function(_) - Log_message('!', 'Unable to update plugins', 1) - end, - }), - }) -end - --- Create a markdown report to use when a bug occurs, --- useful for debugging issues. -function Create_report() - local today = os.date('%Y-%m-%d %H:%M:%S') - - Cmd( - 'silent !echo "' - .. Fn.fnameescape('#') .. ' doom crash report" >> ' - .. Doom_report - ) - Cmd( - 'silent !echo "Report date: ' .. today .. '" >> ' .. Doom_report - ) - Cmd( - 'silent !echo "' - .. Fn.fnameescape('##') .. ' Begin log dump" >> ' - .. Doom_report - ) - Cmd( - 'silent !echo | cat ' .. Doom_logs .. ' >> ' .. Doom_report - ) - Cmd( - 'silent !echo "' - .. Fn.fnameescape('##') .. ' End log dump" >> ' - .. Doom_report - ) - print('Report created at ' .. Doom_report) -end diff --git a/lua/doom/keybindings/init.lua b/lua/doom/keybindings/init.lua deleted file mode 100644 index 0ec9e1666..000000000 --- a/lua/doom/keybindings/init.lua +++ /dev/null @@ -1,367 +0,0 @@ ----[[---------------------------------------]]--- --- keybindings - Doom Nvim keybindings -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -local wk = require('which-key') - --- Define leader key to space --- and call leader mapper -Map('n', '', '') -Api.nvim_set_var('mapleader', ' ') - -------------------------------------------------- - ----[[-------------------------------]]--- --- Custom Key Mappings -- --- -- --- b = Buffer Menu -- --- f = File Menu -- --- g = Git Menu -- --- p = Plugin Menu -- --- r = Runner Menu -- --- s = Session Menu -- --- t = Toggle Menu -- --- w = Window Menu -- --- -- --- TAB = Cycle buffers -- --- ESC = Search highlight off -- --- F2 = Toggle Tagbar -- --- F3 = Toggle Tree Explorer -- --- F4 = Toggle Terminal -- --- F5 = Toggle Minimap -- --- F6 = Toggle Zen Mode -- --- F7 = Run restclient -- ----]]-------------------------------[[--- - -------------------------------------------------- - --- Additional options for mappings -local opts = { silent = true } - ----[[-----------------]]--- --- LSP Keybindings -- ----]]-----------------[[--- --- If the LSP group is not disabled or the nvim-compe plugin is not disabled --- then set its mappings. -if - not Has_value(Doom.disabled_modules, 'lsp') - and (not Has_value(Doom.disabled_plugins, 'compe')) - and Check_plugin('nvim-compe') -then - local compe_opts = { silent = true, expr = true } - -- https://github.com/hrsh7th/nvim-compe#mappings - Map('i', '', 'compe#complete("")', compe_opts) - Map('i', '', 'compe#confirm("")', compe_opts) - Map('i', '', 'compe#close("")', compe_opts) - Map('i', '', 'compe#scroll({ "delta": +4 })', compe_opts) - Map('i', '', 'compe#scroll({ "delta": -4 })', compe_opts) - Map('n', 'gd', ':lua vim.lsp.buf.definition()', opts) -- gd: jump to definitionA - Map('n', 'gr', ':lua vim.lsp.buf.references()', opts) -- gr: go to reference - Map('n', 'gi', ':lua vim.lsp.buf.implementation()', opts) -- gi: buf implementation - Map('n', 'ca', ':Lspsaga code_action', opts) -- ca: code actions - Map('n', 'K', ':Lspsaga hover_doc', opts) -- K: hover doc - Map('n', '', ':Lspsaga diagnostic_jump_prev', opts) -- Control+p: Jump to previous diagnostic - Map('n', '', ':Lspsaga diagnostic_jump_next', opts) -- Control+n: Jump to next diagnostic - Map( - 'n', - '', - ':lua require("lspsaga.action").smart_scroll_with_saga(1)', - opts - ) -- Control+f: Scroll down documents - Map( - 'n', - '', - "lua require('lspsaga.action').smart_scroll_with_saga(-1)" - ) -- Control+b: Scroll up documents - Cmd( - 'command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()' - ) -end - -if Doom.new_file_split then - Map('n', 'fn', ':new', opts) -else - Map('n', 'fn', ':enew', opts) -end - --- TAB to cycle buffers too, why not? -Map('n', '', ':bnext', opts) -Map('n', '', ':bprevious', opts) - --- ESC to turn off search highlighting -Map('n', '', ':noh', opts) - ---- F keybindings -if not Has_value(Doom.disabled_plugins, 'tagbar') then - Map('n', '', ':SymbolsOutline') -end -if not Has_value(Doom.disabled_plugins, 'tree') then - Map('n', '', ':NvimTreeToggle') -end -if not Has_value(Doom.disabled_plugins, 'terminal') then - Map('n', '', ':ToggleTerm') -end -if not Has_value(Doom.disabled_plugins, 'minimap') then - Map('n', '', ':MinimapToggle') -end -if not Has_value(Doom.disabled_plugins, 'zen') then - Map('n', '', ':TZAtaraxis') -end -if - not Has_value(Doom.disabled_modules, 'web') - and (not Has_value(Doom.disabled_plugins, 'restclient')) -then - Map('n', '', ':DotHttp') -end ----[[------------------------------]] --- Window Movements keys -- ----]]------------------------------]] - -Map('n', '', 'h', opts) -Map('n', '', 'j', opts) -Map('n', '', 'k', opts) -Map('n', '', 'l', opts) - ----[[-----------------]]--- --- Escape Remaps -- ----]]-----------------[[--- -Map('i', 'jk', '', opts) - ----[[-----------------]]--- --- Select Movement -- ----]]-----------------[[--- -Map('x', 'K', ":move '<-2gv-gv", opts) -Map('x', 'J', ":move '>+1gv-gv", opts) - -Cmd('tnoremap ') -- get out of terminal insert mode into normal mode with Esc - ----[[-----------------]]--- --- Resizing Splits -- ----]]-----------------[[--- -Cmd([[ - nnoremap :resize -2 - nnoremap :resize +2 - nnoremap :vertical resize -2 - nnoremap :vertical resize +2 -]]) - ----[[-----------------]]--- --- Disable keys -- ----]]-----------------[[--- --- Disable accidentally pressing ctrl-z and suspending -Map('n', '', '') - --- Disable ex mode -Map('n', 'Q', '') - --- Disable recording -Map('n', 'q', '') - --- Fast exit from Doom Nvim and write messages to logs -Map('n', 'ZZ', ':lua Quit_doom(1, 1)') - ----[[-----------------]]--- --- Leader keys -- ----]]-----------------[[--- --- Buffers -wk.register({ - [''] = { - b = { - name = '+buffer', - ['1'] = { ':BufferGoto 1', 'Buffer 1' }, - ['2'] = { ':BufferGoto 2', 'Buffer 2' }, - ['3'] = { ':BufferGoto 3', 'Buffer 3' }, - ['4'] = { ':BufferGoto 4', 'Buffer 4' }, - ['5'] = { ':BufferGoto 5', 'Buffer 5' }, - ['6'] = { ':BufferGoto 6', 'Buffer 6' }, - ['7'] = { ':BufferGoto 7', 'Buffer 7' }, - ['8'] = { ':BufferGoto 8', 'Buffer 8' }, - ['9'] = { ':BufferLast', 'Last buffer' }, - c = { ':BufferClose', 'Close buffer' }, - f = { ':FormatWrite', 'Format buffer' }, - n = { ':BufferNext', 'Next buffer' }, - P = { ':BufferPick', 'Pick buffer' }, - p = { ':BufferPrevious', 'Previous buffer' }, - }, - }, -}) - --- Plugins -wk.register({ - [''] = { - p = { - name = '+plugins', - c = { ':PackerClean', 'Clean disabled or unused plugins' }, - i = { ':PackerInstall', 'Install missing plugins' }, - p = { - ':PackerProfile', - 'Profile the time taken loading your plugins', - }, - s = { - ':PackerSync', - 'Performs PackerClean and then PackerUpdate', - }, - u = { ':PackerUpdate', 'Update your plugins' }, - }, - }, -}) - --- Order -wk.register({ - [''] = { - o = { - name = '+order', - d = { ':BufferOrderByDirectory', 'Sort by directory' }, - l = { ':BufferOrderByLanguage', 'Sort by language' }, - n = { ':BufferMoveNext', 'Re-order buffer to next' }, - p = { ':BufferMovePrevious', 'Re-order buffer to previous' }, - }, - }, -}) - --- File -wk.register({ - [''] = { - f = { - name = '+file', - c = { ':e $MYVIMRC', 'Edit Neovim configuration' }, - n = { 'Create a new unnamed buffer' }, - f = { ':Telescope find_files', 'Find files' }, - b = { ':Telescope marks', 'Bookmarks' }, - W = { ':Telescope live_grep', 'Find word' }, - t = { ':Telescope help_tags', 'Help tags' }, - h = { ':Telescope oldfiles', 'Recently opened files' }, - w = { ':SudaWrite', 'Write file with sudo permissions' }, - r = { ':SudaRead', 'Re-open file with sudo permissions' }, - }, - }, -}) - --- Window -wk.register({ - [''] = { - w = { - name = '+window', - C = { ':only', 'Close all other windows' }, - c = { ':close', 'Close current window' }, - h = { ':split', 'Split horizontally' }, - v = { ':vsplit', 'Split vertically' }, - }, - }, -}) - --- Sessions -wk.register({ - [''] = { - s = { - name = '+sessions', - s = { ':SaveSession', 'Save current session' }, - r = { ':RestoreSession', 'Restore previously saved session' }, - l = { - ':Telescope session-lens search_session', - 'Session switcher', - }, - }, - }, -}) - --- Doom Menu -wk.register({ - [''] = { - d = { - name = '+doom', - c = { - ':e ~/.config/doom-nvim/doomrc', - 'Edit your Doom Nvim configuration', - }, - d = { ':help doom_nvim', 'Open Doom Nvim documentation' }, - u = { ':DoomUpdate', 'Check Doom Nvim udpates' }, - r = { - ':lua Create_report()', - 'Create crash report', - }, - }, - }, -}) - --- Toggler -wk.register({ - [''] = { - t = { - name = '+toggle', - s = { ':Dashboard', 'Open start screen' }, - c = { ':DashboardChangeColorscheme', 'Change colorscheme' }, - e = { ':NvimTreeToggle', 'Toggle Tree Explorer' }, - m = { ':MinimapToggle', 'Toggle Minimap' }, - S = { ':SymbolsOutline', 'Toggle Symbols view' }, - t = { ':ToggleTerm', 'Toggle terminal' }, - }, - }, -}) - --- If web is enabled and restclient is enabled too -if - not Has_value(Doom.disabled_modules, 'web') - and (not Has_value(Doom.disabled_plugins, 'restclient')) -then - wk.register({ - [''] = { - r = { - name = '+runner', - r = { - ':DotHttp', - 'Run restclient on the line that the cursor is currently on', - }, - }, - }, - }) -end - --- If LSP is enabled -if - not Has_value(Doom.disabled_modules, 'lsp') - and (not Has_value(Doom.disabled_plugins, 'compe')) -then - wk.register({ - [''] = { - l = { - name = '+lsp', - d = { - 'lua vim.lsp.buf.type_definition()', - 'Show type definition', - }, - l = { - 'lua vim.lsp.diagnostic.show_line_diagnostics()', - 'Show line diagnostics', - }, - L = { - 'lua vim.lsp.diagnostic.set_loclist()', - 'Diagnostics into location list', - }, - }, - }, - }) -end - --- If Git is enabled -if not Has_value(Doom.disabled_modules, 'git') then - wk.register({ - [''] = { - g = { - name = '+git', - o = { ':LazyGit', 'Open LazyGit' }, - P = { ':TermExec cmd="git pull"', 'Pull' }, - p = { ':TermExec cmd="git push"', 'Push' }, - S = { 'Stage hunk' }, - s = { ':TermExec cmd="git status"', 'Status' }, - u = { 'Undo stage hunk' }, - R = { 'Reset buffer' }, - r = { 'Reset hunk' }, - h = { 'Preview hunk' }, - b = { 'Blame line' }, - }, - }, - }) -end diff --git a/lua/doom/logging/init.lua b/lua/doom/logging/init.lua deleted file mode 100644 index 4ec6642eb..000000000 --- a/lua/doom/logging/init.lua +++ /dev/null @@ -1,96 +0,0 @@ ----[[---------------------------------------]]--- --- logging - Doom Nvim logging system -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -function Log_init() - if Doom.logging ~= 0 then - local today = os.date('%Y-%m-%d %H:%M:%S') - local boot_msg = '[' - .. today - .. '] - Starting Doom Nvim ' - .. Doom.version - .. ' ...' - Try({ - function() - if Doom.logging == 3 then - print(boot_msg) - end - Cmd('silent !echo " " >> ' .. Doom_logs) - Cmd( - 'silent !echo "' .. boot_msg .. '" >> ' .. Doom_logs - ) - end, - Catch({ - function(_) - print('Cannot write on_start log message') - Cmd('!touch ' .. Doom_logs) - end, - }), - }) - end -end - -function Log_message(msg_type, msg, level) - --[[ - + : Doom Nvim internal - * : External command - ? : Prompt - ! : Error - !!! : CRITICAL - --]] - local output = '' - if Doom.logging ~= 0 then - -- Generate log message - if msg_type == '!' then - output = '[!] - ' .. msg - elseif msg_type == '+' then - output = '[+] - ' .. msg - elseif msg_type == '*' then - output = '[*] - ' .. msg - elseif msg_type == '?' then - output = '[?] - ' .. msg - elseif msg_type == '!!!' then - output = '[!!!] - ' .. msg - end - - Try({ - function() - if Doom.logging >= level then - if Doom.logging == 3 then - print(output) - end - Cmd( - 'silent !echo "' .. output .. '" >> ' .. Doom_logs - ) - end - end, - Catch({ - function(_) - local err_msg = '[!] - Cannot save: ' .. msg .. '' - print(err_msg) - Cmd( - 'silent !echo "' .. err_msg .. '" >> ' .. Doom_logs - ) - end, - }), - }) - end -end - --- Dump messages to doom.log file -function Dump_messages() - if Doom.logging ~= 0 then - Cmd( - 'silent !echo "[---] - Dumping :messages" >> ' .. Doom_logs - ) - Cmd('redir >> ' .. Doom_logs) - Cmd('silent messages') - Cmd('redir END') - Cmd('silent !echo " " >> ' .. Doom_logs) - Cmd( - 'silent !echo "[---] - End of dump" >> ' .. Doom_logs - ) - end -end diff --git a/lua/doom/modules/README.md b/lua/doom/modules/README.md new file mode 100644 index 000000000..f4040bfb3 --- /dev/null +++ b/lua/doom/modules/README.md @@ -0,0 +1,6 @@ +# Modules + +Herein lies all the Doom plugins and their configurations. + +Refer to [List of modules](../../../docs/modules.md#list-of-modules) for more +information about what's inside this module. diff --git a/lua/doom/modules/built-in/README.md b/lua/doom/modules/built-in/README.md new file mode 100644 index 000000000..75f30f3d0 --- /dev/null +++ b/lua/doom/modules/built-in/README.md @@ -0,0 +1,31 @@ +# 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 new file mode 100644 index 000000000..9adba99d4 --- /dev/null +++ b/lua/doom/modules/built-in/compiler/README.md @@ -0,0 +1,33 @@ +# 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 new file mode 100644 index 000000000..dd4e423cc --- /dev/null +++ b/lua/doom/modules/built-in/compiler/init.lua @@ -0,0 +1,93 @@ +local log = require('doom.core.logging') + +-- selene: allow(undefined_variable) +if packer_plugins and not packer_plugins['nvim-toggleterm.lua'] then + log.error( + "Doom compiler needs toggleterm plugin, please uncomment the 'terminal' entry in your doomrc" + ) +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 = pcall(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 + require('toggleterm').exec_command( + string.format('cmd="%s"', compiler_cmd), + 1 + ) + else + log.error( + 'The filetype ' + .. filetype + .. ' is not yet supported in the Doom compiler plugin' + ) + end + end) + + 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 = pcall(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 + require('toggleterm').exec_command( + string.format('cmd="%s"', compiler_cmd), + 1 + ) + else + log.error( + 'The filetype ' + .. filetype + .. ' is not yet supported in the Doom compiler plugin' + ) + end + end) + + 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/runner/README.md b/lua/doom/modules/built-in/runner/README.md new file mode 100644 index 000000000..59982c5f0 --- /dev/null +++ b/lua/doom/modules/built-in/runner/README.md @@ -0,0 +1,34 @@ +# 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 new file mode 100644 index 000000000..ecdbd032f --- /dev/null +++ b/lua/doom/modules/built-in/runner/init.lua @@ -0,0 +1,79 @@ +local log = require('doom.core.logging') +local term + +-- selene: allow(undefined_variable) +if packer_plugins and packer_plugins['nvim-toggleterm.lua'] then + term = require('toggleterm.terminal').Terminal +else + log.error( + "Doom runner needs toggleterm plugin, please uncomment the 'terminal' entry in your doomrc" + ) +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 = pcall(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) + + 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 = pcall(function() + if lang_bin then + require('toggleterm').exec_command('cmd="' .. lang_bin .. ' %"', 1) + else + log.error( + 'There is no available executable for ' + .. filetype + .. '. Maybe it is not yet supported in the Doom runner plugin?' + ) + end + end) + + 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/config/doom-autopairs.lua b/lua/doom/modules/config/doom-autopairs.lua new file mode 100644 index 000000000..f257ce31c --- /dev/null +++ b/lua/doom/modules/config/doom-autopairs.lua @@ -0,0 +1,9 @@ +return function() + local is_plugin_disabled = require('doom.core.functions').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-autosession.lua b/lua/doom/modules/config/doom-autosession.lua new file mode 100644 index 000000000..ef320b450 --- /dev/null +++ b/lua/doom/modules/config/doom-autosession.lua @@ -0,0 +1,13 @@ +return function() + local config = require('doom.core.config').load_config() + require('auto-session').setup({ + -- Sets the log level of the plugin (debug, info, error) + logLevel = 'info', + -- Root dir where sessions will be stored (/home/user/.config/nvim/sessions/) + auto_session_root_dir = vim.fn.stdpath('data') .. '/sessions/', + -- Enables/disables auto save/restore + auto_session_enabled = config.doom.autosave_sessions, + -- Enable keeping track and loading of the last session + auto_session_enable_last_session = config.doom.autoload_last_session, + }) +end diff --git a/lua/doom/modules/config/doom-blankline.lua b/lua/doom/modules/config/doom-blankline.lua new file mode 100644 index 000000000..aa71fca42 --- /dev/null +++ b/lua/doom/modules/config/doom-blankline.lua @@ -0,0 +1,18 @@ +return function() + local config = require('doom.core.config').load_config() + + vim.g.indent_blankline_enabled = config.doom.show_indent + + vim.g.indent_blankline_char_list = { '|', 'ยฆ', 'โ”†', 'โ”Š' } + + -- If treesitter plugin is enabled then use its indentation + if + require('doom.core.functions').check_plugin('nvim-treesitter', 'opt') + then + vim.g.indent_blankline_use_treesitter = true + end + vim.g.indent_blankline_show_first_indent_level = false + + vim.g.indent_blankline_filetype_exclude = { 'dashboard' } + vim.g.indent_blankline_buftype_exclude = { 'terminal' } +end diff --git a/lua/doom/modules/config/doom-bufferline.lua b/lua/doom/modules/config/doom-bufferline.lua new file mode 100644 index 000000000..1039d8f7f --- /dev/null +++ b/lua/doom/modules/config/doom-bufferline.lua @@ -0,0 +1,106 @@ +return function() + require('bufferline').setup({ + options = { + numbers = 'buffer_id', + number_style = 'none', + mappings = false, + 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, + offsets = { + { + filetype = 'NvimTree', + 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 = true, + sort_by = 'directory', + custom_areas = { + right = function() + local result = {} + local error = vim.lsp.diagnostic.get_count(0, [[Error]]) + local warning = vim.lsp.diagnostic.get_count(0, [[Warning]]) + local info = vim.lsp.diagnostic.get_count( + 0, + [[Information]] + ) + local hint = vim.lsp.diagnostic.get_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, + }, + }, + }) +end diff --git a/lua/doom/modules/config/doom-colorizer.lua b/lua/doom/modules/config/doom-colorizer.lua new file mode 100644 index 000000000..4a085d1c5 --- /dev/null +++ b/lua/doom/modules/config/doom-colorizer.lua @@ -0,0 +1,8 @@ +-- 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-compe.lua b/lua/doom/modules/config/doom-compe.lua new file mode 100644 index 000000000..f2763c07d --- /dev/null +++ b/lua/doom/modules/config/doom-compe.lua @@ -0,0 +1,91 @@ +--# selene: allow(global_usage) + +--- nvim-compe configuration +-- https://github.com/hrsh7th/nvim-compe#lua-config +return function() + require('compe').setup({ + enabled = true, + autocomplete = true, + debug = false, + min_length = 4, + preselect = 'enable', + throttle_time = 80, + source_timeout = 200, + incomplete_delay = 400, + max_abbr_width = 100, + max_kind_width = 100, + max_menu_width = 100, + documentation = true, + + source = { + path = true, + buffer = true, + calc = false, + vsnip = false, + nvim_lsp = true, + nvim_lua = true, + spell = false, + tags = true, + snippets_nvim = false, + treesitter = true, + }, + }) + local t = function(str) + return vim.api.nvim_replace_termcodes(str, true, true, true) + end + + local check_back_space = function() + local col = vim.fn.col('.') - 1 + if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + return true + else + return false + end + end + + -- Use (s-)tab to: + --- move to prev/next item in completion menuone + --- jump to prev/next snippet's placeholder + _G.tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t('') + elseif check_back_space() then + return t('') + else + return vim.fn['compe#complete']() + end + end + + _G.s_tab_complete = function() + if vim.fn.pumvisible() == 1 then + return t('') + else + return t('') + end + end + + vim.api.nvim_set_keymap( + 'i', + '', + 'v:lua.tab_complete()', + { expr = true } + ) + vim.api.nvim_set_keymap( + 's', + '', + 'v:lua.tab_complete()', + { expr = true } + ) + vim.api.nvim_set_keymap( + 'i', + '', + 'v:lua.s_tab_complete()', + { expr = true } + ) + vim.api.nvim_set_keymap( + 's', + '', + 'v:lua.s_tab_complete()', + { expr = true } + ) +end diff --git a/lua/doom/modules/config/doom-dashboard.lua b/lua/doom/modules/config/doom-dashboard.lua new file mode 100644 index 000000000..0404405e1 --- /dev/null +++ b/lua/doom/modules/config/doom-dashboard.lua @@ -0,0 +1,91 @@ +return function() + local config = require('doom.core.config').load_config() + + vim.g.dashboard_session_directory = require('doom.utils').doom_root + .. '/sessions' + vim.g.dashboard_default_executive = 'telescope' + + vim.g.dashboard_custom_section = { + a = { + description = { '๏‘ค Reload Last Session SPC s r' }, + command = 'SessionLoad', + }, + b = { + description = { '๏ƒถ Recently Opened Files SPC f h' }, + command = 'Telescope oldfiles', + }, + c = { + description = { '๏‘ก Jump to Bookmark SPC f b' }, + command = 'Telescope marks', + }, + d = { + description = { '๏ƒ… Find File SPC f f' }, + command = 'Telescope find_files', + }, + e = { + description = { '๏‡‚ Find Word SPC f g' }, + command = 'Telescope live_grep', + }, + f = { + description = { '๏ฅ Open Private Configuration SPC d c' }, + command = ':e ~/.config/doom-nvim/doomrc', + }, + g = { + description = { '๏… Open Documentation SPC d d' }, + command = ':h doom_nvim', + }, + } + + vim.g.dashboard_custom_footer = { + 'Doom Nvim loaded in ' .. vim.fn.printf( + '%.3f', + vim.fn.reltimefloat(vim.fn.reltime(vim.g.start_time)) + ) .. ' seconds.', + } + + if not config.doom.dashboard_statline then + vim.g.dashboard_disable_statusline = 1 + end + + 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 new file mode 100644 index 000000000..fb2942f9d --- /dev/null +++ b/lua/doom/modules/config/doom-devicons.lua @@ -0,0 +1,81 @@ +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 new file mode 100644 index 000000000..7fb9a606e --- /dev/null +++ b/lua/doom/modules/config/doom-eviline.lua @@ -0,0 +1,366 @@ +return function() + local utils = require('doom.utils') + local config = require('doom.core.config').load_config() + + local bo = vim.bo + local gl = require('galaxyline') + local lsp = require('galaxyline.provider_lsp') + local buffer = require('galaxyline.provider_buffer') + local condition = require('galaxyline.condition') + + local gls = gl.section + + gl.short_line_list = { + 'NvimTree', + 'packer', + 'minimap', + 'Outline', + 'toggleterm', + } + + -- {{{ Utility functions + -- Dynamically change statusline colors, + -- defaults to doom-one dark variant colors. + -- + -- @tparam string name The color name to be returned + -- @return string + local function get_color(name) + return function() + local colors = { + bg = '#23272e', + fg = '#bbc2cf', + section_bg = '#5B6268', + yellow = '#ECBE7B', + cyan = '#46D9FF', + green = '#98be65', + orange = '#da8548', + magenta = '#c678dd', + blue = '#51afef', + red = '#ff6c6b', + } + + if + vim.g.colors_name == 'doom-one' + and vim.opt.background:get() == 'light' + then + colors = { + bg = '#c6c7c7', + fg = '#383a42', + fg_alt = '#9ca0a4', + yellow = '#986801', + cyan = '#0184bc', + green = '#50a14f', + orange = '#da8548', + magenta = '#a626a4', + blue = '#4078f2', + red = '#e45649', + } + elseif vim.g.colors_name:find('gruvbox') then + colors = { + bg = '#32302f', + fg = '#d4be98', + fg_alt = '#ddc7a1', + yellow = '#d8a657', + cyan = '#89b482', + green = '#a9b665', + orange = '#e78a4e', + magenta = '#d3869b', + blue = '#7daea3', + red = '#ea6962', + } + end + return colors[name] + end + end + + local function is_dashboard() + local buftype = buffer.get_buffer_filetype() + if buftype == 'DASHBOARD' then + return true + end + end + + local function is_not_dashboard() + local buftype = buffer.get_buffer_filetype() + if buftype ~= 'DASHBOARD' then + return true + end + end + -- }}} + + -- Left side + gls.left[1] = { + RainbowLeft = { + provider = function() + return 'โ–Š ' + end, + highlight = { get_color('blue'), get_color('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 = get_color('red')(), + i = get_color('green')(), + v = get_color('blue')(), + [''] = get_color('blue')(), + V = get_color('blue')(), + c = get_color('magenta')(), + no = get_color('red')(), + s = get_color('orange')(), + S = get_color('orange')(), + [''] = get_color('orange')(), + ic = get_color('yellow')(), + R = get_color('magenta')(), + Rv = get_color('magenta')(), + cv = get_color('red')(), + ce = get_color('red')(), + r = get_color('cyan')(), + rm = get_color('cyan')(), + ['r?'] = get_color('cyan')(), + ['!'] = get_color('red')(), + t = get_color('red')(), + } + vim.api.nvim_command( + 'hi GalaxyViMode guifg=' .. mode_color[vim.fn.mode()] + ) + return '๏ŒŒ ' + end, + highlight = { get_color('red'), get_color('bg'), 'bold' }, + }, + } + gls.left[3] = { + FileSize = { + provider = 'FileSize', + condition = condition.buffer_not_empty and is_not_dashboard, + highlight = { + get_color('fg'), + get_color('bg'), + }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.left[4] = { + FileIcon = { + provider = 'FileIcon', + condition = condition.buffer_not_empty and is_not_dashboard, + highlight = { + require('galaxyline.provider_fileinfo').get_file_icon_color, + get_color('bg'), + }, + }, + } + gls.left[5] = { + FileName = { + provider = 'FileName', + condition = condition.buffer_not_empty and is_not_dashboard, + highlight = { get_color('fg'), get_color('bg'), 'bold' }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('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 = { get_color('fg_alt'), get_color('bg') }, + }, + } + gls.left[7] = { + LinePercent = { + provider = 'LinePercent', + condition = is_not_dashboard, + highlight = { get_color('fg_alt'), get_color('bg') }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.left[8] = { + DiagnosticError = { + provider = 'DiagnosticError', + condition = is_not_dashboard, + icon = config.doom.lsp_error, + highlight = { get_color('red'), get_color('bg') }, + }, + } + gls.left[9] = { + DiagnosticWarn = { + provider = 'DiagnosticWarn', + condition = is_not_dashboard, + icon = config.doom.lsp_warning, + highlight = { get_color('orange'), get_color('bg') }, + }, + } + gls.left[10] = { + DiagnosticInfo = { + provider = 'DiagnosticInfo', + condition = is_not_dashboard, + icon = config.doom.lsp_hint, + highlight = { get_color('blue'), get_color('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 = { get_color('fg'), get_color('bg') }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.right[2] = { + FileEncode = { + provider = 'FileEncode', + condition = condition.hide_in_width and is_not_dashboard, + highlight = { get_color('fg'), get_color('bg') }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('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 '๎˜ ' + .. lsp.get_lsp_client():gsub('^%l', string.upper) + else + -- Use the filetype instead and capitalize it + return '๏ ' .. (vim.bo.filetype:gsub('^%l', string.upper)) + end + end, + condition = function() + local tbl = { ['dashboard'] = true, [''] = true } + if tbl[bo.filetype] then + return false + end + return true + end, + highlight = { get_color('blue'), get_color('bg') }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.right[4] = { + GitIcon = { + provider = function() + return ' ๏žก ' + end, + condition = condition.check_git_workspace, + highlight = { get_color('red'), get_color('bg') }, + separator = ' ', + separator_highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.right[5] = { + GitBranch = { + provider = 'GitBranch', + condition = condition.check_git_workspace, + highlight = { get_color('green'), get_color('bg'), 'bold' }, + }, + } + gls.right[6] = { + DiffSeparator = { + provider = function() + return ' ' + end, + condition = is_not_dashboard, + highlight = { get_color('bg'), get_color('bg') }, + }, + } + gls.right[7] = { + DiffAdd = { + provider = 'DiffAdd', + condition = condition.hide_in_width and is_not_dashboard, + icon = '๏‘— ', + highlight = { get_color('green'), get_color('bg') }, + }, + } + gls.right[8] = { + DiffModified = { + provider = 'DiffModified', + condition = condition.hide_in_width and is_not_dashboard, + icon = '๏‘™ ', + highlight = { get_color('orange'), get_color('bg') }, + }, + } + gls.right[9] = { + DiffRemove = { + provider = 'DiffRemove', + condition = condition.hide_in_width and is_not_dashboard, + icon = '๏‘˜ ', + highlight = { get_color('red'), get_color('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 = { get_color('blue'), get_color('bg'), 'bold' }, + separator = ' ', + separator_highlight = { + get_color('bg'), + get_color('bg'), + }, + }, + } + end + gls.right[11] = { + RainbowRight = { + provider = function() + return ' โ–Š' + end, + highlight = { get_color('blue'), get_color('bg') }, + }, + } + + -- Short status line + gls.short_line_left[1] = { + ShortRainbowLeft = { + provider = function() + return 'โ–Š ' + end, + highlight = { get_color('blue'), get_color('bg') }, + }, + } + gls.short_line_left[2] = { + BufferType = { + provider = 'FileTypeName', + condition = is_not_dashboard, + highlight = { get_color('fg'), get_color('bg') }, + }, + } + + gls.short_line_right[1] = { + BufferIcon = { + provider = 'BufferIcon', + condition = is_not_dashboard, + highlight = { get_color('yellow'), get_color('bg') }, + }, + } + gls.short_line_right[2] = { + ShortRainbowRight = { + provider = function() + return ' โ–Š' + end, + highlight = { get_color('blue'), get_color('bg') }, + }, + } +end diff --git a/lua/doom/modules/config/doom-format.lua b/lua/doom/modules/config/doom-format.lua new file mode 100644 index 000000000..a1e482933 --- /dev/null +++ b/lua/doom/modules/config/doom-format.lua @@ -0,0 +1,121 @@ +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 new file mode 100644 index 000000000..0e360b36d --- /dev/null +++ b/lua/doom/modules/config/doom-gitsigns.lua @@ -0,0 +1,69 @@ +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_index = { interval = 1000 }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + use_decoration_api = true, + use_internal_diff = true, -- If luajit is present + }) +end diff --git a/lua/doom/modules/config/doom-lsp-signature.lua b/lua/doom/modules/config/doom-lsp-signature.lua new file mode 100644 index 000000000..bfe41d7c2 --- /dev/null +++ b/lua/doom/modules/config/doom-lsp-signature.lua @@ -0,0 +1,4 @@ +return function() + -- Signature help + require('lsp_signature').on_attach() +end diff --git a/lua/doom/modules/config/doom-lspconfig.lua b/lua/doom/modules/config/doom-lspconfig.lua new file mode 100644 index 000000000..be166bf71 --- /dev/null +++ b/lua/doom/modules/config/doom-lspconfig.lua @@ -0,0 +1,66 @@ +return function() + local config = require('doom.core.config').load_config() + + -- Snippets support + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + + -- Lsp Symbols + vim.fn.sign_define('LspDiagnosticsSignError', { + texthl = 'LspDiagnosticsSignError', + text = config.doom.lsp_error, + numhl = 'LspDiagnosticsSignError', + }) + vim.fn.sign_define('LspDiagnosticsSignWarning', { + texthl = 'LspDiagnosticsSignWarning', + text = config.doom.lsp_warning, + numhl = 'LspDiagnosticsSignWarning', + }) + vim.fn.sign_define('LspDiagnosticsSignHint', { + texthl = 'LspDiagnosticsSignHint', + text = config.doom.lsp_hint, + numhl = 'LspDiagnosticsSignHint', + }) + vim.fn.sign_define('LspDiagnosticsSignInformation', { + texthl = 'LspDiagnosticsSignInformation', + text = config.doom.lsp_information, + numhl = 'LspDiagnosticsSignInformation', + }) + + vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, + { + virtual_text = { + prefix = config.doom.lsp_virtual_text, -- change this to whatever you want your diagnostic icons to be + }, + } + ) + -- symbols for autocomplete + vim.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)', + } +end diff --git a/lua/doom/modules/config/doom-lspinstall.lua b/lua/doom/modules/config/doom-lspinstall.lua new file mode 100644 index 000000000..7efe6123d --- /dev/null +++ b/lua/doom/modules/config/doom-lspinstall.lua @@ -0,0 +1,59 @@ +return function() + local nvim_lsp = require('lspconfig') + + --[[-----------------]] + -- + -- LSP Setup -- + --]]-----------------[[-- + -- https://github.com/kabouzeid/nvim-lspinstall#advanced-configuration-recommended + local function setup_servers() + -- Provide the missing :LspInstall + require('lspinstall').setup() + local servers = require('lspinstall').installed_servers() + for _, server in pairs(servers) do + -- Configure sumneko for neovim lua development + if server == 'lua' then + local lua_path = vim.split(package.path, ';') + table.insert(lua_path, 'lua/?.lua') + table.insert(lua_path, 'lua/?/init.lua') + + nvim_lsp[server].setup({ + settings = { + Lua = { + awakened = { cat = true }, + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + -- Setup your lua path + path = lua_path, + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = { 'vim' }, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = {}, + maxPreload = 2000, + preloadFileSize = 150, + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { enable = false }, + }, + }, + }) + else + -- Use default settings for all the other language servers + nvim_lsp[server].setup({}) + end + end + end + + setup_servers() + + -- Automatically reload after `:LspInstall ` so we don't have to restart neovim + require('lspinstall').post_install_hook = function() + setup_servers() -- reload installed servers + vim.cmd('bufdo e') -- this triggers the FileType autocmd that starts the server + end +end diff --git a/lua/doom/modules/config/doom-neorg.lua b/lua/doom/modules/config/doom-neorg.lua new file mode 100644 index 000000000..799866ed2 --- /dev/null +++ b/lua/doom/modules/config/doom-neorg.lua @@ -0,0 +1,23 @@ +return function() + -- 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', + }, + }, + }, + }, + }) +end diff --git a/lua/doom/modules/config/doom-symbols.lua b/lua/doom/modules/config/doom-symbols.lua new file mode 100644 index 000000000..0346e8b43 --- /dev/null +++ b/lua/doom/modules/config/doom-symbols.lua @@ -0,0 +1,18 @@ +return function() + local config = require('doom.core.config').load_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 new file mode 100644 index 000000000..1cbef6902 --- /dev/null +++ b/lua/doom/modules/config/doom-telescope.lua @@ -0,0 +1,72 @@ +-- 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 = '> ', + layout_config = { + prompt_position = 'bottom', + horizontal = { + mirror = false, + preview_width = 0.6, + }, + }, + file_sorter = require('telescope.sorters').get_fuzzy_file, + file_ignore_patterns = {}, + 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, + }, + }, + }, + }) +end diff --git a/lua/doom/modules/config/doom-toggleterm.lua b/lua/doom/modules/config/doom-toggleterm.lua new file mode 100644 index 000000000..d2551b152 --- /dev/null +++ b/lua/doom/modules/config/doom-toggleterm.lua @@ -0,0 +1,25 @@ +return function() + local config = require('doom.core.config').load_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 new file mode 100644 index 000000000..518b90ea1 --- /dev/null +++ b/lua/doom/modules/config/doom-tree.lua @@ -0,0 +1,97 @@ +return function() + local config = require('doom.core.config').load_config() + local tree_cb = require('nvim-tree.config').nvim_tree_callback + + -- Empty by default + vim.g.nvim_tree_ignore = { '.git', 'node_modules', '.cache', '__pycache__' } + -- False by default, opens the tree when typing `vim $DIR` or `vim` + vim.g.nvim_tree_auto_open = 0 + -- False by default, closes the tree when it is the last window + vim.g.nvim_tree_auto_close = 0 + -- False by default, closes the tree when you open a file + vim.g.nvim_tree_quit_on_open = 1 + -- False by default, this option allows the cursor to be updated when entering a buffer + vim.g.nvim_tree_follow = 1 + -- 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 + -- Set tree width + vim.g.nvim_tree_width = config.doom.sidebar_width + -- False by default, will enable file highlight for git attributes (can be used without the icons). + vim.g.nvim_tree_git_hl = 1 + -- This is the default. See :help filename-modifiers for more options + vim.g.nvim_tree_root_folder_modifier = ':~' + -- False by default, will open the tree when entering a new tab and the tree was previously open + vim.g.nvim_tree_tab_open = 1 + -- False by default, will not resize the tree when opening a file + vim.g.nvim_tree_width_allow_resize = 1 + -- 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 + --- Tree icons + -- 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 } + if config.doom.explorer_right then + vim.g.nvim_tree_side = 'right' + end + -- You can edit keybindings be defining this variable + -- You don't have to define all keys. + -- NOTE: the 'edit' key will wrap/unwrap a folder and open a file + vim.g.nvim_tree_bindings = { + -- default mappings + { key = 'o', cb = tree_cb('edit') }, + { key = '<2-LeftMouse>', cb = tree_cb('edit') }, + { key = '', cb = tree_cb('cd') }, + { key = '<2-RightMouse>', cb = tree_cb('cd') }, + { key = '', 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') }, + } + + -- 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 = 'โ˜…', + }, + folder = { + default = '๎—ฟ', + open = '๎—พ', + empty = '๏„”', + empty_open = '๏„•', + symlink = '๏’‚', + symlink_open = '๎—พ', + }, + } + + -- 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 new file mode 100644 index 000000000..c9b611611 --- /dev/null +++ b/lua/doom/modules/config/doom-treesitter.lua @@ -0,0 +1,45 @@ +return function() + local doomrc = require('doom.core.config.doomrc').load_doomrc() + local functions = require('doom.core.functions') + + 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', '') + table.insert(langs, lang) + end + 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/vhyrro/tree-sitter-norg', + files = { 'src/parser.c' }, + branch = 'main', + }, + } + -- selene: allow(undefined_variable) + if packer_plugins and packer_plugins['neorg'] then + table.insert(doomrc.langs, 'norg') + end + + require('nvim-treesitter.configs').setup({ + ensure_installed = get_ts_parsers(doomrc.langs), + highlight = { enable = true }, + autopairs = { + enable = functions.is_plugin_disabled('autopairs') and false or true, + }, + indent = { enable = true }, + }) +end diff --git a/lua/doom/modules/config/doom-whichkey.lua b/lua/doom/modules/config/doom-whichkey.lua new file mode 100644 index 000000000..c97ef970a --- /dev/null +++ b/lua/doom/modules/config/doom-whichkey.lua @@ -0,0 +1,194 @@ +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] + }, + 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 = { + ['`'] = { 'Switch buffer' }, + [' '] = { 'Find file' }, + ['.'] = { 'Browse files' }, + [','] = { 'Switch buffer' }, + ['/'] = { 'Search a word' }, + [':'] = { 'Command history' }, + ['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', + }, + ['l'] = { + name = '+lsp', + ['a'] = { 'Code actions' }, + ['i'] = { 'Lsp info' }, + ['d'] = { 'Show type definition' }, + ['l'] = { 'Show line diagnostics' }, + ['L'] = { 'Diagnostics into location list' }, + }, + }, + ['d'] = { + name = '+doom', + ['c'] = { 'Edit your Doom Nvim configuration' }, + ['d'] = { 'Open Doom Nvim documentation' }, + ['u'] = { 'Update Doom Nvim' }, + ['r'] = { 'Rollback Doom Nvim version' }, + ['R'] = { 'Create crash report' }, + ['s'] = { 'Change colorscheme' }, + }, + ['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' }, + ['s'] = { 'Save current session' }, + ['r'] = { 'Restore previously saved session' }, + ['l'] = { 'Session switcher' }, + }, + ['s'] = { + name = '+search', + ['g'] = { 'Grep' }, + ['b'] = { 'Buffer' }, + ['s'] = { 'Goto symbol' }, + ['h'] = { 'Command history' }, + ['m'] = { 'Jump to mark' }, + }, + ['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', + ['d'] = { 'Start screen' }, + ['e'] = { 'Tree Explorer' }, + ['m'] = { 'Minimap' }, + ['s'] = { 'Symbols' }, + ['t'] = { 'Terminal' }, + }, + } + + wk.register(mappings, { prefix = '' }) +end diff --git a/lua/doom/modules/config/doom-zen.lua b/lua/doom/modules/config/doom-zen.lua new file mode 100644 index 000000000..a32e7476e --- /dev/null +++ b/lua/doom/modules/config/doom-zen.lua @@ -0,0 +1,70 @@ +return function() + require('true-zen').setup({ + true_false_commands = false, + cursor_by_mode = false, + bottom = { + hidden_laststatus = 0, + hidden_ruler = true, + hidden_showmode = true, + hidden_showcmd = true, + hidden_cmdheight = 1, + + shown_laststatus = 2, + shown_ruler = false, + shown_showmode = false, + shown_showcmd = false, + shown_cmdheight = 1, + }, + top = { + hidden_showtabline = 0, + + shown_showtabline = 2, + }, + left = { + hidden_number = false, + hidden_relativenumber = false, + hidden_signcolumn = 'no', + + shown_number = true, + shown_relativenumber = false, + shown_signcolumn = 'no', + }, + ataraxis = { + ideal_writing_area_width = 0, + just_do_it_for_me = true, + left_padding = 40, + right_padding = 40, + top_padding = 0, + bottom_padding = 0, + custome_bg = '', + disable_bg_configuration = false, + disable_fillchars_configuration = false, + keep_default_fold_fillchars = true, + force_when_plus_one_window = false, + force_hide_statusline = true, + quit_untoggles_ataraxis = true, + }, + focus = { + margin_of_error = 5, + focus_method = 'experimental', + }, + minimalist = { + store_and_restore_settings = true, + }, + events = { + before_minimalist_mode_shown = false, + before_minimalist_mode_hidden = false, + after_minimalist_mode_shown = false, + after_minimalist_mode_hidden = false, + + before_focus_mode_focuses = false, + before_focus_mode_unfocuses = false, + after_focus_mode_focuses = false, + after_focus_mode_unfocuses = false, + }, + integrations = { + integration_galaxyline = true, + integration_gitsigns = true, + }, + }) +end diff --git a/lua/doom/modules/init.lua b/lua/doom/modules/init.lua new file mode 100644 index 000000000..2493da703 --- /dev/null +++ b/lua/doom/modules/init.lua @@ -0,0 +1,412 @@ +-- 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 functions = require('doom.core.functions') + +---- Packer Bootstrap --------------------------- +------------------------------------------------- +local packer_path = vim.fn.stdpath('data') + .. '/site/pack/packer/opt/packer.nvim' + +if vim.fn.empty(vim.fn.glob(packer_path)) > 0 then + vim.fn.system({ + 'git', + 'clone', + 'https://github.com/wbthomason/packer.nvim', + packer_path, + }) +end + +-- Load packer +vim.cmd([[ packadd packer.nvim ]]) +local packer = require('packer') + +-- Change some defaults +packer.init({ + git = { + clone_timeout = 300, -- 5 mins + }, + profile = { + enable = true, + }, +}) + +packer.startup(function(use) + -----[[------------]]----- + --- Essentials --- + -----]]------------[[----- + -- Plugins manager + use({ + 'wbthomason/packer.nvim', + opt = true, + }) + + -- Tree-Sitter + use({ + 'nvim-treesitter/nvim-treesitter', + opt = true, + run = ':TSUpdate', + config = require('doom.modules.config.doom-treesitter'), + }) + + -- Neorg + local disabled_neorg = functions.is_plugin_disabled('neorg') + use({ + 'vhyrro/neorg', + branch = 'unstable', + config = require('doom.modules.config.doom-neorg'), + disable = disabled_neorg, + after = { 'nvim-treesitter' }, + }) + + -- Sessions + local disabled_sessions = functions.is_plugin_disabled('auto-session') + use({ + 'rmagatti/auto-session', + config = require('doom.modules.config.doom-autosession'), + requires = { { 'rmagatti/session-lens', after = 'telescope.nvim' } }, + cmd = { 'SaveSession', 'RestoreSession', 'DeleteSession' }, + event = 'TabNewEntered', + disable = disabled_sessions, + }) + + -----[[------------]]----- + --- UI Related --- + -----]]------------[[----- + -- Fancy start screen + local disabled_dashboard = functions.is_plugin_disabled('dashboard') + use({ + 'glepnir/dashboard-nvim', + config = require('doom.modules.config.doom-dashboard'), + cmd = 'Dashboard', + disable = disabled_dashboard, + }) + + -- Doom Colorschemes + local disabled_doom_themes = functions.is_plugin_disabled('doom-themes') + use({ + 'GustavoPrietoP/doom-themes.nvim', + disable = disabled_doom_themes, + event = 'TabNewEntered', + }) + + -- Development icons + use({ + 'kyazdani42/nvim-web-devicons', + module = 'nvim-web-devicons', + }) + + -- File tree + local disabled_tree = functions.is_plugin_disabled('explorer') + use({ + 'kyazdani42/nvim-tree.lua', + requires = 'nvim-web-devicons', + config = require('doom.modules.config.doom-tree'), + disable = disabled_tree, + cmd = { + 'NvimTreeClipboard', + 'NvimTreeClose', + 'NvimTreeFindFile', + 'NvimTreeOpen', + 'NvimTreeRefresh', + 'NvimTreeToggle', + }, + }) + + -- Statusline + -- can be disabled to use your own statusline + local disabled_statusline = functions.is_plugin_disabled('statusline') + use({ + 'glepnir/galaxyline.nvim', + config = require('doom.modules.config.doom-eviline'), + disable = disabled_statusline, + event = 'ColorScheme', + }) + + -- Tabline + -- can be disabled to use your own tabline + local disabled_tabline = functions.is_plugin_disabled('tabline') + use({ + 'akinsho/nvim-bufferline.lua', + config = require('doom.modules.config.doom-bufferline'), + disable = disabled_tabline, + event = 'ColorScheme', + }) + + -- Better terminal + -- can be disabled to use your own terminal plugin + local disabled_terminal = functions.is_plugin_disabled('terminal') + use({ + 'akinsho/nvim-toggleterm.lua', + 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 = functions.is_plugin_disabled('symbols') + use({ + 'simrat39/symbols-outline.nvim', + 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 = functions.is_plugin_disabled('minimap') + use({ + 'wfxr/minimap.vim', + disable = disabled_minimap, + cmd = { + 'Minimap', + 'MinimapClose', + 'MinimapToggle', + 'MinimapRefresh', + 'MinimapUpdateHighlight', + }, + }) + + -- Keybindings menu like Emacs's guide-key + local disabled_whichkey = functions.is_plugin_disabled('which-key') + use({ + 'folke/which-key.nvim', + config = require('doom.modules.config.doom-whichkey'), + event = 'BufWinEnter', + disable = disabled_whichkey, + }) + + -- Distraction free environment + local disabled_zen = functions.is_plugin_disabled('zen') + use({ + 'kdav5758/TrueZen.nvim', + config = require('doom.modules.config.doom-zen'), + disable = disabled_zen, + module = 'true-zen', + event = 'TabNewEntered', + }) + + -----[[--------------]]----- + --- Fuzzy Search --- + -----]]--------------[[----- + use({ + 'nvim-lua/plenary.nvim', + module = 'plenary', + }) + use({ + 'nvim-lua/popup.nvim', + module = 'popup', + }) + + local disabled_telescope = functions.is_plugin_disabled('telescope') + use({ + 'nvim-telescope/telescope.nvim', + cmd = 'Telescope', + module = 'telescope', + requires = { + 'popup.nvim', + 'plenary.nvim', + }, + config = require('doom.modules.config.doom-telescope'), + 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 = functions.is_plugin_disabled('gitsigns') + use({ + 'lewis6991/gitsigns.nvim', + config = require('doom.modules.config.doom-gitsigns'), + disable = disabled_gitsigns, + requires = 'plenary.nvim', + event = 'BufRead', + }) + + -- LazyGit integration + local disabled_lazygit = functions.is_plugin_disabled('lazygit') + use({ + 'kdheepak/lazygit.nvim', + requires = 'plenary.nvim', + disable = disabled_lazygit, + cmd = { 'LazyGit', 'LazyGitConfig' }, + }) + + -----[[------------]]----- + --- Completion --- + -----]]------------[[----- + local disabled_lsp = functions.is_plugin_disabled('lsp') + -- Built-in LSP Config + use({ + 'neovim/nvim-lspconfig', + opt = true, + config = require('doom.modules.config.doom-lspconfig'), + disable = disabled_lsp, + event = 'ColorScheme', + }) + + -- Completion plugin + -- can be disabled to use your own completion plugin + use({ + 'hrsh7th/nvim-compe', + requires = { + { + 'ray-x/lsp_signature.nvim', + config = require('doom.modules.config.doom-lsp-signature'), + }, + }, + config = require('doom.modules.config.doom-compe'), + disable = disabled_lsp, + opt = true, + after = 'nvim-lspconfig', + }) + + -- Snippets + local disabled_snippets = functions.is_plugin_disabled('snippets') + use({ + 'L3MON4D3/LuaSnip', + disable = (disabled_lsp and true or disabled_snippets), + opt = true, + after = 'nvim-compe', + }) + use({ + 'rafamadriz/friendly-snippets', + disable = (disabled_lsp and true or disabled_snippets), + opt = true, + after = 'nvim-compe', + }) + + -- install lsp saga + use({ + 'glepnir/lspsaga.nvim', + disable = disabled_lsp, + opt = true, + after = 'nvim-lspconfig', + }) + + -- provides the missing `:LspInstall` for `nvim-lspconfig`. + use({ + 'kabouzeid/nvim-lspinstall', + config = require('doom.modules.config.doom-lspinstall'), + disable = disabled_lsp, + after = 'nvim-lspconfig', + }) + + -----[[--------------]]----- + --- File Related --- + -----]]--------------[[----- + -- Write / Read files without permissions (e.vim.g. /etc files) without having + -- to use `sudo nvim /path/to/file` + local disabled_suda = functions.is_plugin_disabled('suda') + use({ + 'lambdalisue/suda.vim', + disable = disabled_suda, + cmd = { 'SudaRead', 'SudaWrite' }, + }) + + -- File formatting + -- can be disabled to use your own file formatter + local disabled_formatter = functions.is_plugin_disabled('formatter') + use({ + 'lukas-reineke/format.nvim', + config = require('doom.modules.config.doom-format'), + disable = disabled_formatter, + cmd = { 'Format', 'FormatWrite' }, + }) + + -- Autopairs + -- can be disabled to use your own autopairs + local disabled_autopairs = functions.is_plugin_disabled('autopairs') + use({ + 'windwp/nvim-autopairs', + config = require('doom.modules.config.doom-autopairs'), + disable = disabled_autopairs, + event = 'InsertEnter', + }) + + -- Indent Lines + local disabled_indent_lines = functions.is_plugin_disabled('indentlines') + use({ + 'lukas-reineke/indent-blankline.nvim', + config = require('doom.modules.config.doom-blankline'), + disable = disabled_indent_lines, + event = 'ColorScheme', + }) + + -- EditorConfig support + local disabled_editorconfig = functions.is_plugin_disabled('editorconfig') + use({ + 'editorconfig/editorconfig-vim', + disable = disabled_editorconfig, + event = 'TabNewEntered', + }) + + -- Comments + -- can be disabled to use your own comments plugin + local disabled_kommentary = functions.is_plugin_disabled('kommentary') + use({ + 'b3nj5m1n/kommentary', + disable = disabled_kommentary, + event = 'BufEnter', + }) + + -----[[-------------]]----- + --- Web Related --- + -----]]-------------[[----- + -- Fastest colorizer without external dependencies! + local disabled_colorizer = functions.is_plugin_disabled('colorizer') + use({ + 'norcalli/nvim-colorizer.lua', + 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 = functions.is_plugin_disabled('restclient') + use({ + 'NTBBloodbath/rest.nvim', + requires = 'plenary.nvim', + config = function() + require('rest-nvim').setup() + end, + disable = disabled_restclient, + event = 'BufEnter', + }) + + local disabled_range_highlight = functions.is_plugin_disabled( + 'range-highlight' + ) + use({ + 'winston0410/range-highlight.nvim', + requires = { + { 'winston0410/cmd-parser.nvim', opt = true, module = 'cmd-parser' }, + }, + config = function() + require('range-highlight').setup() + end, + disable = disabled_range_highlight, + event = 'BufRead', + }) + + -----[[----------------]]----- + --- Custom Plugins --- + -----]]----------------[[----- + -- If there are custom plugins then also require them + local custom_plugins = dofile(utils.doom_root .. '/plugins.lua') + for _, plug in pairs(custom_plugins) do + packer.use(plug) + end +end) diff --git a/lua/doom/system/init.lua b/lua/doom/system/init.lua deleted file mode 100644 index 76d2036f3..000000000 --- a/lua/doom/system/init.lua +++ /dev/null @@ -1,18 +0,0 @@ ----[[---------------------------------------]]--- --- system - Doom Nvim system utilities -- --- Author: NTBBloodbath -- --- License: GPLv2 -- ----[[---------------------------------------]]--- - -function Which_os() - Log_message('+', 'Checking OS ...', 2) - - local doom_os = Get_OS() - if doom_os == 'Windows' then - Doom.separator = '\\' - elseif doom_os == 'Linux' or doom_os == 'OSX' then - Doom.separator = '/' - else - Log_message('!', 'OS not recognized', 1) - end -end diff --git a/lua/doom/utils/README.md b/lua/doom/utils/README.md new file mode 100644 index 000000000..16a0a7de3 --- /dev/null +++ b/lua/doom/utils/README.md @@ -0,0 +1,21 @@ +# Utils + +Herein lies all the Doom utility functions and variables. + +## Variables + +- `doom_version` - Doom Nvim version. +- `doom_root` - Doom Nvim root directory. +- `doom_logs` - Doom Nvim logs file path. +- `doom_report` - Doom Nvim crash report path. +- `git_workspace` - Doom Nvim workspace for Git commands. + +## Functions + +- `map` - Wrapper for `nvim_set_keymap`. +- `create_augroups` - Autocommands wrapper for Lua. +- `is_empty` - Check if a string is empty or nil. +- `has_value` - Search if a table have a value. +- `get_os` - Get the current OS using LuaJIT. +- `read_file` - returns the content of the given file. +- `write_file` - writes the given string into given file. diff --git a/lua/doom/utils/init.lua b/lua/doom/utils/init.lua index 57c6847ec..f0c254f4c 100644 --- a/lua/doom/utils/init.lua +++ b/lua/doom/utils/init.lua @@ -4,61 +4,55 @@ -- License: GPLv2 -- ---[[---------------------------------------]]--- ---- Require packer so we can use `packer.use` function in `custom_plugins` function -local packer = require('packer') +local M = {} -------------------- HELPERS -------------------- -Api, Cmd, Fn = vim.api, vim.cmd, vim.fn -Keymap, Execute, G = Api.nvim_set_keymap, Api.nvim_command, vim.g -Scopes = { o = vim.o, b = vim.bo, w = vim.wo } +-- Doom Nvim version +M.doom_version = '3.0.0' -- Local files -Doom_root = Fn.expand('$HOME/.config/doom-nvim') -Doom_logs = Doom_root .. '/logs/doom.log' -Doom_report = Doom_root .. '/logs/report.md' +M.doom_root = vim.fn.expand('$HOME/.config/doom-nvim') +M.doom_logs = vim.fn.stdpath('data') .. '/doom.log' +M.doom_report = vim.fn.stdpath('data') .. '/doom_report.md' --- Mappings wrapper, extracted from +M.git_workspace = string.format('git -C %s ', M.doom_root) + +-- mappings wrapper, extracted from -- https://github.com/ojroques/dotfiles/blob/master/nvim/init.lua#L8-L12 -function Map(mode, lhs, rhs, opts) +M.map = function(mode, lhs, rhs, opts) local options = { noremap = true } if opts then options = vim.tbl_extend('force', options, opts) end - Keymap(mode, lhs, rhs, options) -end - --- Options wrapper, extracted from --- https://github.com/ojroques/dotfiles/blob/master/nvim/init.lua#L14-L17 -function Opt(scope, key, value) - Scopes[scope][key] = value - if scope ~= 'o' then - Scopes['o'][key] = value - end + vim.api.nvim_set_keymap(mode, lhs, rhs, options) end -- For autocommands, extracted from -- https://github.com/norcalli/nvim_utils -function Create_augroups(definitions) +M.create_augroups = function(definitions) for group_name, definition in pairs(definitions) do - Execute('augroup ' .. group_name) - Execute('autocmd!') + 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 }), ' ') - Execute(command) + local command = table.concat( + vim.tbl_flatten({ 'autocmd', def }), + ' ' + ) + vim.api.nvim_command(command) end - Execute('augroup END') + vim.api.nvim_command('augroup END') end end -- Check if string is empty or if it's nil -function Is_empty(str) +-- @return bool +M.is_empty = function(str) return str == '' or str == nil end -- Search if a table have the value we are looking for, -- useful for plugins management -function Has_value(tabl, val) +M.has_value = function(tabl, val) for _, value in ipairs(tabl) do if value == val then return true @@ -68,62 +62,8 @@ function Has_value(tabl, val) return false end --- try/catch statements, see --- https://gist.github.com/cwarden/1207556 -function Catch(err) - return err[1] -end - -function Try(block) - local status, result = pcall(block[1]) - if not status then - block[2](result) - end - return result -end - --- A better and less primitive implementation of custom plugins in Doom Nvim -function Custom_plugins(plugins) - -- if a plugin have some configs like enabled or requires then we will - -- store them in that table - local plugin_with_configs = {} - - if type(plugins) ~= 'string' then - for idx, val in pairs(plugins) do - -- Create the correct plugin structure to packer - -- use { - -- url, - -- enabled, - -- requires - -- } - if idx == 'repo' then - table.insert(plugin_with_configs, val) - end - - if idx == 'enabled' then - if val then - plugin_with_configs['disable'] = false - else - plugin_with_configs['disable'] = true - end - end - - if idx == 'requires' then - plugin_with_configs['requires'] = val - end - end - -- Send the configured plugin to packer - packer.use(plugin_with_configs) - else - -- Send the simple plugins, e.G. those who have not declared with configs - -- 'user/repo' โ† simple plugin - -- { 'user/repo', opts } โ† configured plugin - packer.use(plugins) - end -end - -- Get current OS, returns 'Other' if the current OS is not recognized -function Get_OS() +M.get_os = function() --[[ -- Target OS names: -- - Windows @@ -137,3 +77,33 @@ function Get_OS() -- We make use of JIT because LuaJIT is bundled in Neovim return jit.os end + +-- read_file returns the content of the given file +-- @tparam string path The path of the file +-- @return string +M.read_file = function(path) + local fd = vim.loop.fs_open(path, 'r', 438) + local stat = vim.loop.fs_fstat(fd) + local data = vim.loop.fs_read(fd, stat.size, 0) + vim.loop.fs_close(fd) + + return data +end + +-- write_file writes the given string into given file +-- @tparam string path The path of the file +-- @tparam string content The content to be written in the file +-- @tparam string mode The mode for opening the file, e.g. 'w+' +M.write_file = function(path, content, mode) + -- 644 sets read and write permissions for the owner, and it sets read-only + -- mode for the group and others. + vim.loop.fs_open(path, mode, tonumber('644', 8), function(err, fd) + if not err then + local fpipe = vim.loop.new_pipe(false) + vim.loop.pipe_open(fpipe, fd) + vim.loop.write(fpipe, content) + end + end) +end + +return M diff --git a/lua/plugins/configs/auto-session.lua b/lua/plugins/configs/auto-session.lua deleted file mode 100644 index 962c8739a..000000000 --- a/lua/plugins/configs/auto-session.lua +++ /dev/null @@ -1,10 +0,0 @@ -require('auto-session').setup({ - -- Sets the log level of the plugin (debug, info, error) - logLevel = 'info', - -- Root dir where sessions will be stored (/home/user/.config/nvim/sessions/) - auto_session_root_dir = Fn.stdpath('data') .. '/sessions/', - -- Enables/disables auto save/restore - auto_session_enabled = Doom.autosave_sessions, - -- Enable keeping track and loading of the last session - auto_session_enable_last_session = Doom.autoload_last_session, -}) diff --git a/lua/plugins/configs/autopairs.lua b/lua/plugins/configs/autopairs.lua deleted file mode 100644 index 0f775736f..000000000 --- a/lua/plugins/configs/autopairs.lua +++ /dev/null @@ -1 +0,0 @@ -require('nvim-autopairs').setup() diff --git a/lua/plugins/configs/blankline.lua b/lua/plugins/configs/blankline.lua deleted file mode 100644 index 13d20bd40..000000000 --- a/lua/plugins/configs/blankline.lua +++ /dev/null @@ -1,12 +0,0 @@ -G.indent_blankline_enabled = Doom.show_indent - -G.indent_blankline_char_list = { '|', 'ยฆ', 'โ”†', 'โ”Š' } - --- If treesitter plugin is enabled then use its indentation -if Check_plugin('nvim-treesitter') then - G.indent_blankline_use_treesitter = true -end -G.indent_blankline_show_first_indent_level = false - -G.indent_blankline_filetype_exclude = { 'dashboard' } -G.indent_blankline_buftype_exclude = { 'terminal' } diff --git a/lua/plugins/configs/lsp.lua b/lua/plugins/configs/lsp.lua deleted file mode 100644 index b9ce4b000..000000000 --- a/lua/plugins/configs/lsp.lua +++ /dev/null @@ -1,206 +0,0 @@ --- taken from https://github.com/neovim/nvim-lspconfig#keybindings-and-completion -local nvim_lsp = require('lspconfig') --- Snippets support -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - --- Lsp Symbols -Fn.sign_define( - "LspDiagnosticsSignError", - {texthl = "LspDiagnosticsSignError", text = Doom.lsp_error, numhl = "LspDiagnosticsSignError"} -) -Fn.sign_define( - "LspDiagnosticsSignWarning", - {texthl = "LspDiagnosticsSignWarning", text = Doom.lsp_warning, numhl = "LspDiagnosticsSignWarning"} -) -Fn.sign_define( - "LspDiagnosticsSignHint", - {texthl = "LspDiagnosticsSignHint", text = Doom.lsp_hint, numhl = "LspDiagnosticsSignHint"} -) -Fn.sign_define( - "LspDiagnosticsSignInformation", - {texthl = "LspDiagnosticsSignInformation", text = Doom.lsp_information, numhl = "LspDiagnosticsSignInformation"} -) - -vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = { - prefix = Doom.lsp_virtual_text, -- change this to whatever you want your diagnostic icons to be - }, - } -) - --- Signature help -require('lsp_signature').on_attach() - --- Vscode-like pictograms on completion -require('lspkind').init({ - with_text = true, - symbol_map = { - Text = '๎˜’', - Method = 'ฦ’', - Function = '๏‚š', - Constructor = '๎ˆ', - Variable = '๎ž›', - Class = '๎ƒ', - Interface = '๏ฐฎ', - Module = '๏ฃ–', - Property = '๎˜ค', - Unit = '๏‘ต', - Value = '๏ขŸ', - Enum = 'ไบ†', - Keyword = '๏ …', - Snippet = '๏ฌŒ', - Color = '๎ˆซ', - File = '๏…›', - Folder = '๏„•', - EnumMember = '๏…', - Constant = '๎ˆฌ', - Struct = '๏ƒŠ', - }, -}) - -local on_attach = function(client, bufnr) - local function buf_set_option(...) - Api.nvim_buf_set_option(bufnr, ...) - end - - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - -- Mappings. - local opts = { silent = true } - Map( - 'n', - 'ga', - 'lua vim.lsp.buf.code_action()', - opts - ) - Map( - 'n', - 'gD', - 'lua vim.lsp.buf.declaration()', - opts - ) - Map('n', 'gd', 'lua vim.lsp.buf.definition()', opts) - Map('n', 'K', 'lua vim.lsp.buf.hover()', opts) - Map( - 'n', - 'gi', - 'lua vim.lsp.buf.implementation()', - opts - ) - Map( - 'n', - '', - 'lua vim.lsp.buf.signature_help()', - opts - ) - Map( - 'n', - 'wa', - 'lua vim.lsp.buf.add_workspace_folder()', - opts - ) - Map( - 'n', - 'wr', - 'lua vim.lsp.buf.remove_workspace_folder()', - opts - ) - Map( - 'n', - 'wl', - 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', - opts - ) - Map( - 'n', - 'D', - 'lua vim.lsp.buf.type_definition()', - opts - ) - Map( - 'n', - 'rn', - 'lua vim.lsp.buf.rename()', - opts - ) - Map('n', 'gr', 'lua vim.lsp.buf.references()', opts) - Map( - 'n', - 'e', - 'lua vim.lsp.diagnostic.show_line_diagnostics()', - opts - ) - Map( - 'n', - '[d', - 'lua vim.lsp.diagnostic.goto_prev()', - opts - ) - Map( - 'n', - ']d', - 'lua vim.lsp.diagnostic.goto_next()', - opts - ) - Map( - 'n', - 'q', - 'lua vim.lsp.diagnostic.set_loclist()', - opts - ) - -- Set some keybinds conditional on server capabilities - if client.resolved_capabilities.document_formatting then - Map( - 'n', - 'f', - 'lua vim.lsp.buf.formatting()', - opts - ) - elseif client.resolved_capabilities.document_range_formatting then - Map( - 'n', - 'f', - 'lua vim.lsp.buf.range_formatting()', - opts - ) - end - -- Set autocommands conditional on server_capabilities - if client.resolved_capabilities.document_highlight then - Api.nvim_exec( - [[ - hi LspReferenceRead ctermbg=237 guibg=LightYellow - hi LspReferenceText ctermbg=237 guibg=LightYellow - hi LspReferenceWrite ctermbg=237 guibg=LightYellow - augroup lsp_document_highlight - autocmd! * - autocmd CursorHold lua vim.lsp.buf.document_highlight() - autocmd CursorMoved lua vim.lsp.buf.clear_references() - augroup END - ]], - false - ) - end -end - ---[[-----------------]] --- --- LSP Setup -- ---]]-----------------[[-- --- https://github.com/kabouzeid/nvim-lspinstall#advanced-configuration-recommended -local function setup_servers() - -- Provide the missing :LspInstall - require('lspinstall').setup() - local servers = require('lspinstall').installed_servers() - for _, server in pairs(servers) do - nvim_lsp[server].setup({}) - end -end - -setup_servers() - --- Automatically reload after `:LspInstall ` so we don't have to restart neovim -require('lspinstall').post_install_hook = function() - setup_servers() -- reload installed servers - Cmd('bufdo e') -- this triggers the FileType autocmd that starts the server -end diff --git a/lua/plugins/configs/nvim-colorizer.lua b/lua/plugins/configs/nvim-colorizer.lua deleted file mode 100644 index 803caeb9f..000000000 --- a/lua/plugins/configs/nvim-colorizer.lua +++ /dev/null @@ -1,6 +0,0 @@ --- https://github.com/norcalli/nvim-colorizer.lua#customization -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 -}) diff --git a/lua/plugins/configs/nvim-compe.lua b/lua/plugins/configs/nvim-compe.lua deleted file mode 100644 index bcc3d96e5..000000000 --- a/lua/plugins/configs/nvim-compe.lua +++ /dev/null @@ -1,67 +0,0 @@ ---- nvim-compe configuration --- https://github.com/hrsh7th/nvim-compe#lua-config -require('compe').setup({ - enabled = true, - autocomplete = true, - debug = false, - min_length = 2, - preselect = 'enable', - throttle_time = 80, - source_timeout = 200, - incomplete_delay = 400, - max_abbr_width = 100, - max_kind_width = 100, - max_menu_width = 100, - documentation = true, - - source = { - path = true, - buffer = true, - calc = true, - vsnip = true, - nvim_lsp = true, - nvim_lua = true, - spell = true, - tags = true, - snippets_nvim = true, - treesitter = true, - }, - -}) -local t = function(str) - return vim.api.nvim_replace_termcodes(str, true, true, true) -end - -local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then - return true - else - return false - end -end - --- Use (s-)tab to: ---- move to prev/next item in completion menuone ---- jump to prev/next snippet's placeholder -_G.tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - elseif check_back_space() then - return t "" - else - return vim.fn['compe#complete']() - end -end -_G.s_tab_complete = function() - if vim.fn.pumvisible() == 1 then - return t "" - else - return t "" - end -end - -vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) -vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) diff --git a/lua/plugins/configs/nvim-dashboard.lua b/lua/plugins/configs/nvim-dashboard.lua deleted file mode 100644 index 6eb97b3d7..000000000 --- a/lua/plugins/configs/nvim-dashboard.lua +++ /dev/null @@ -1,31 +0,0 @@ -local plugins_count = - Fn.len(Fn.globpath('~/.local/share/nvim/site/pack/packer/start', '*', 0, 1)) - -G.dashboard_session_directory = Doom_root .. '/sessions' -G.dashboard_default_executive = 'telescope' - -G.dashboard_custom_section = { - a = {description = {'๏‘ค Reload Last Session SPC s r'}, command = 'SessionLoad'}, - b = {description = {'๏ƒถ Recently Opened Files SPC f h'}, command = 'Telescope oldfiles'}, - c = {description = {'๏‘ก Jump to Bookmark SPC f b'}, command = 'Telescope marks'}, - d = {description = {'๏ƒ… Find File SPC f f'}, command = 'Telescope find_files'}, - e = {description = {'๏‡‚ Find Word SPC f g'}, command = 'Telescope live_grep'}, - f = {description = {'๏ฅ Open Private Configuration SPC d c'}, command = ':e ~/.config/nvim/doomrc'}, - g = {description = {'๏… Open Documentation SPC d d'}, command = ':h doom_nvim'}, -} - -G.dashboard_custom_footer = { - 'Doom Nvim loaded ' .. plugins_count .. ' plugins', -} - -if not Doom.dashboard_statline then - G.dashboard_disable_statusline = 1 -end - -G.dashboard_custom_header = Doom.dashboard_custom_header, - --- Header color -Cmd('hi! dashboardHeader guifg='..Doom.dashboard_custom_colors.header_color) -Cmd('hi! dashboardCenter guifg='..Doom.dashboard_custom_colors.center_color) -Cmd('hi! dashboardShortcut guifg='..Doom.dashboard_custom_colors.shortcut_color) -Cmd('hi! dashboardFooter guifg='..Doom.dashboard_custom_colors.footer_color) diff --git a/lua/plugins/configs/nvim-devicons.lua b/lua/plugins/configs/nvim-devicons.lua deleted file mode 100644 index d0deb306f..000000000 --- a/lua/plugins/configs/nvim-devicons.lua +++ /dev/null @@ -1,79 +0,0 @@ -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', - }, - }, -}) diff --git a/lua/plugins/configs/nvim-format.lua b/lua/plugins/configs/nvim-format.lua deleted file mode 100644 index 426e96789..000000000 --- a/lua/plugins/configs/nvim-format.lua +++ /dev/null @@ -1,115 +0,0 @@ -require('format').setup({ - ['*'] = { - -- remove trailing whitespaces - { - cmd = { - "sed -i 's/[ \t]*$//'", - }, - }, - }, - vim = { - { - cmd = { - function(file) - return string.format( - '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 string.format( - 'stylua --config-path ~/.config/stylua/stylua.toml %s', - file - ) - end, - }, - }, - }, - python = { - { - cmd = { - 'yapf -i', - }, - }, - }, - 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' }, - }, - }, -}) diff --git a/lua/plugins/configs/nvim-gitsigns.lua b/lua/plugins/configs/nvim-gitsigns.lua deleted file mode 100644 index 12d8e4324..000000000 --- a/lua/plugins/configs/nvim-gitsigns.lua +++ /dev/null @@ -1,67 +0,0 @@ -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_index = { interval = 1000 }, - sign_priority = 6, - update_debounce = 100, - status_formatter = nil, -- Use default - use_decoration_api = true, - use_internal_diff = true, -- If luajit is present -}) diff --git a/lua/plugins/configs/nvim-telescope.lua b/lua/plugins/configs/nvim-telescope.lua deleted file mode 100644 index b91eebe2a..000000000 --- a/lua/plugins/configs/nvim-telescope.lua +++ /dev/null @@ -1,52 +0,0 @@ --- https://github.com/nvim-telescope/telescope.nvim#telescope-defaults --- Required to close with ESC in insert mode -local actions = require('telescope.actions') -local telescope = require('telescope') - -telescope.setup({ - defaults = { - find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, - prompt_prefix = '> ', - initial_mode = 'insert', - selection_strategy = 'reset', - sorting_strategy = 'descending', - layout_strategy = 'horizontal', - layout_config = { - prompt_position = 'bottom', - horizontal = { - mirror = false, - preview_width = 0.6, - }, - }, - file_sorter = require('telescope.sorters').get_fuzzy_file, - file_ignore_patterns = {}, - 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, - } - } - }, -}) diff --git a/lua/plugins/configs/nvim-toggleterm.lua b/lua/plugins/configs/nvim-toggleterm.lua deleted file mode 100644 index fd4c410ea..000000000 --- a/lua/plugins/configs/nvim-toggleterm.lua +++ /dev/null @@ -1,21 +0,0 @@ -require('toggleterm').setup({ - size = Doom.terminal_height, - open_mapping = [[]], - hide_numbers = true, - shade_filetypes = {}, - shade_terminals = true, - start_in_insert = true, - persist_size = true, - direction = Doom.terminal_direction, - close_on_exit = true, - float_opts = { - border = 'curved', - width = Doom.terminal_width, - height = Doom.terminal_height, - winblend = 0, - highlights = { - border = 'Special', - background = 'Normal', - }, - }, -}) diff --git a/lua/plugins/configs/nvim-tree.lua b/lua/plugins/configs/nvim-tree.lua deleted file mode 100644 index e1a681edf..000000000 --- a/lua/plugins/configs/nvim-tree.lua +++ /dev/null @@ -1,93 +0,0 @@ -local tree_cb = require('nvim-tree.config').nvim_tree_callback - --- Empty by default -G.nvim_tree_ignore = { '.git', 'node_modules', '.cache', '__pycache__' } --- False by default, opens the tree when typing `vim $DIR` or `vim` -G.nvim_tree_auto_open = 0 --- False by default, closes the tree when it is the last window -G.nvim_tree_auto_close = 0 --- False by default, closes the tree when you open a file -G.nvim_tree_quit_on_open = 1 --- False by default, this option allows the cursor to be updated when entering a buffer -G.nvim_tree_follow = 1 --- False by default, this option shows indent markers when folders are open -G.nvim_tree_indent_markers = 1 --- Show hidden files -G.nvim_tree_hide_dotfiles = Doom.show_hidden --- Set tree width -G.nvim_tree_width = Doom.sidebar_width --- False by default, will enable file highlight for git attributes (can be used without the icons). -G.nvim_tree_git_hl = 1 --- This is the default. See :help filename-modifiers for more options -G.nvim_tree_root_folder_modifier = ':~' --- False by default, will open the tree when entering a new tab and the tree was previously open -G.nvim_tree_tab_open = 1 --- False by default, will not resize the tree when opening a file -G.nvim_tree_width_allow_resize = 1 --- False by default, append a trailing slash to folder names -G.nvim_tree_add_trailing = 1 --- False by default, compact folders that only contain a single folder into one node in the file tree -G.nvim_tree_group_empty = 1 ---- Tree icons --- 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 -G.nvim_tree_show_icons = { git = 1, folders = 1, files = 1 } --- If the tagbar is set to left then set tree side to right and vice versa. --- left by default -if Doom.tagbar_left then - G.nvim_tree_side = 'right' -end --- You can edit keybindings be defining this variable --- You don't have to define all keys. --- NOTE: the 'edit' key will wrap/unwrap a folder and open a file -G.nvim_tree_bindings = { - -- default mappings - { key = 'o', cb = tree_cb('edit') }, - { key = '<2-LeftMouse>', cb = tree_cb('edit') }, - { key = '', cb = tree_cb('cd') }, - { key = '<2-RightMouse>', cb = tree_cb('cd') }, - { key = '', 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') }, -} - --- default will show icon by default if no icon is provided --- default shows no icon by default -G.nvim_tree_icons = { - default = '๎˜’', - symlink = '๏’', - git = { - unstaged = 'โœ—', - staged = 'โœ“', - unmerged = '๎œง', - renamed = 'โžœ', - untracked = 'โ˜…', - }, - folder = { - default = '๎—ฟ', - open = '๎—พ', - empty = '๏„”', - empty_open = '๏„•', - symlink = '๏’‚', - symlink_open = '๎—พ', - }, -} diff --git a/lua/plugins/configs/nvim-zen.lua b/lua/plugins/configs/nvim-zen.lua deleted file mode 100644 index 922a7853b..000000000 --- a/lua/plugins/configs/nvim-zen.lua +++ /dev/null @@ -1,42 +0,0 @@ -require('true-zen').setup({ - true_false_commands = false, - cursor_by_mode = false, - before_minimalist_mode_shown = false, - before_minimalist_mode_hidden = false, - after_minimalist_mode_shown = false, - after_minimalist_mode_hidden = false, - bottom = { - hidden_laststatus = 0, - hidden_ruler = false, - hidden_showmode = false, - hidden_showcmd = false, - hidden_cmdheight = 1, - - shown_laststatus = 2, - shown_ruler = true, - shown_showmode = false, - shown_showcmd = false, - shown_cmdheight = 1, - }, - top = { hidden_showtabline = 0, shown_showtabline = 2 }, - left = { - hidden_number = false, - hidden_relativenumber = false, - hidden_signcolumn = 'no', - - shown_number = true, - shown_relativenumber = false, - shown_signcolumn = 'no', - }, - ataraxis = { - just_do_it_for_me = true, - left_padding = 40, - right_padding = 40, - top_padding = 0, - bottom_padding = 0, - custome_bg = '', - disable_bg_configuration = true, - }, - focus = { margin_of_error = 5 }, - integrations = { integration_galaxyline = true }, -}) diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua deleted file mode 100644 index 16a6bebd7..000000000 --- a/lua/plugins/configs/statusline.lua +++ /dev/null @@ -1,300 +0,0 @@ -local bo = vim.bo -local gl = require('galaxyline') -local buffer = require('galaxyline.provider_buffer') -local condition = require('galaxyline.condition') - -local gls = gl.section - -gl.short_line_list = { 'NvimTree', 'packer', 'minimap', 'Outline' } - -local colors = { - bg = '#282c34', - fg = '#bbc2cf', - section_bg = '#3E4556', - yellow = '#ECBE7B', - cyan = '#46D9FF', - green = '#98be65', - orange = '#da8548', - magenta = '#c678dd', - blue = '#51afef', - red = '#ff6c6b', -} - --- TODO: merge dashboard functions to get only one function for both cases - --- If current buffer is not a dashboard -local function is_not_dashboard() - local buftype = buffer.get_buffer_filetype() - if buftype == 'DASHBOARD' then - return false - else - return true - end -end - --- If current buffer is a dashboard -local function is_dashboard() - local buftype = buffer.get_buffer_filetype() - if buftype == 'DASHBOARD' then - return true - else - return false - end -end - --- Left side -gls.left[1] = { - RainbowRed = { - provider = function() - return 'โ–Š ' - end, - highlight = { colors.blue, colors.bg }, - }, -} -gls.left[2] = { - ViMode = { - provider = function() - -- auto change color according the vim mode - 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, - } - Execute( - 'hi GalaxyViMode guifg=' .. mode_color[Fn.mode()] - ) - return '๏ŒŒ Doom ' - end, - highlight = { colors.red, colors.bg, 'bold' }, - }, -} -gls.left[3] = { - Separator = { - provider = function() - return '๎‚ธ ' - end, - condition = condition.buffer_not_empty and is_not_dashboard, - highlight = { colors.bg, colors.section_bg }, - }, -} -gls.left[4] = { - FileIcon = { - provider = 'FileIcon', - condition = condition.buffer_not_empty and is_not_dashboard, - highlight = { - require('galaxyline.provider_fileinfo').get_file_icon_color, - colors.section_bg, - }, - }, -} -gls.left[5] = { - FileName = { - provider = 'FileName', - condition = condition.buffer_not_empty and is_not_dashboard, - highlight = { colors.fg, colors.section_bg }, - separator = '๎‚ธ', - separator_highlight = { colors.section_bg, colors.bg }, - }, -} -gls.left[6] = { - GitIcon = { - provider = function() - return ' ๏žก ' - end, - condition = condition.check_git_workspace and is_not_dashboard, - highlight = { colors.red, colors.bg }, - }, -} -gls.left[7] = { - GitBranch = { - provider = 'GitBranch', - condition = condition.check_git_workspace and is_not_dashboard, - highlight = { colors.fg, colors.bg }, - separator = ' ', - }, -} -gls.left[8] = { - DiffAdd = { - provider = 'DiffAdd', - condition = condition.hide_in_width and is_not_dashboard, - icon = '๏‘— ', - highlight = { colors.green, colors.bg }, - }, -} -gls.left[9] = { - DiffModified = { - provider = 'DiffModified', - condition = condition.hide_in_width and is_not_dashboard, - icon = '๏‘™ ', - highlight = { colors.orange, colors.bg }, - }, -} -gls.left[10] = { - DiffRemove = { - provider = 'DiffRemove', - condition = condition.hide_in_width and is_not_dashboard, - icon = '๏‘˜ ', - highlight = { colors.red, colors.bg }, - }, -} -gls.left[11] = { - LeftEnd = { - provider = function() - return '๎‚บ' - end, - condition = is_not_dashboard, - highlight = { colors.section_bg, colors.bg }, - }, -} -gls.left[12] = { - DiagnosticError = { - provider = 'DiagnosticError', - condition = is_not_dashboard, - icon = ' ๏— ', - highlight = { colors.red, colors.section_bg }, - }, -} -gls.left[13] = { - DiagnosticWarn = { - provider = 'DiagnosticWarn', - condition = is_not_dashboard, - icon = ' ๏ฑ ', - highlight = { colors.orange, colors.section_bg }, - }, -} -gls.left[14] = { - DiagnosticInfo = { - provider = 'DiagnosticInfo', - condition = is_not_dashboard, - icon = ' ๏š ', - highlight = { colors.blue, colors.section_bg }, - separator = '๎‚ธ', - separator_highlight = { colors.section_bg, colors.bg }, - }, -} - --- Right side --- alternate separator colors if the current buffer is a dashboard -gls.right[1] = { - RightStart = { - provider = function() - return '๎‚บ' - end, - condition = is_not_dashboard, - highlight = { colors.section_bg, colors.bg }, - }, -} -gls.right[2] = { - FileFormat = { - provider = function() - return bo.filetype - end, - condition = is_not_dashboard, - highlight = { colors.fg, colors.section_bg }, - separator = ' ', - separator_highlight = { colors.bg, colors.section_bg }, - }, -} -gls.right[3] = { - ShowLspClient = { - provider = 'GetLspClient', - condition = function() - local tbl = { ['dashboard'] = true, [''] = true } - if tbl[bo.filetype] then - return false - end - return true - end, - icon = 'LSP: ', - highlight = { colors.fg, colors.section_bg }, - separator = ' | ', - separator_highlight = { colors.bg, colors.section_bg }, - }, -} -gls.right[4] = { - FileEncode = { - provider = 'FileEncode', - condition = condition.hide_in_width and is_not_dashboard, - highlight = { colors.fg, colors.section_bg }, - separator = ' |', - separator_highlight = { colors.bg, colors.section_bg }, - }, -} -gls.right[5] = { - LineInfo = { - provider = 'LineColumn', - condition = is_not_dashboard, - highlight = { colors.fg, colors.section_bg }, - separator = ' | ', - separator_highlight = { colors.bg, colors.section_bg }, - }, -} --- If the current buffer is the dashboard then show Doom Nvim version -if is_dashboard then - gls.right[6] = { - DoomVersion = { - provider = function() - return 'DOOM v' .. Doom_version - end, - condition = is_dashboard, - highlight = { colors.blue, colors.bg, 'bold' }, - separator = ' ', - separator_highlight = { colors.section_bg, colors.bg }, - }, - } - gls.right[7] = { - Space = { - provider = function() - return ' ' - end, - condition = is_dashboard, - highlight = { colors.section_bg, colors.bg }, - }, - } -end -gls.right[8] = { - RainbowBlue = { - provider = function() - return ' โ–Š' - end, - highlight = { colors.blue, colors.bg }, - }, -} - --- Short status line -gls.short_line_left[1] = { - BufferType = { - provider = 'FileTypeName', - condition = is_not_dashboard, - highlight = { colors.fg, colors.section_bg }, - separator = '๎‚ธ', - separator_highlight = { colors.section_bg, colors.bg }, - }, -} - -gls.short_line_right[1] = { - BufferIcon = { - provider = 'BufferIcon', - condition = is_not_dashboard, - highlight = { colors.yellow, colors.section_bg }, - separator = '๎‚บ', - separator_highlight = { colors.section_bg, colors.bg }, - }, -} diff --git a/lua/plugins/configs/symbols.lua b/lua/plugins/configs/symbols.lua deleted file mode 100644 index 041cc9210..000000000 --- a/lua/plugins/configs/symbols.lua +++ /dev/null @@ -1,14 +0,0 @@ -G.symbols_outline = { - highlight_hovered_item = true, - show_guides = true, - position = Doom.tagbar_left, - keymaps = { - close = '', - goto_location = '', - focus_location = 'o', - hover_symbol = '', - rename_symbol = 'r', - code_actions = 'a', - }, - lsp_blacklist = {}, -} diff --git a/lua/plugins/configs/tree-sitter.lua b/lua/plugins/configs/tree-sitter.lua deleted file mode 100644 index dc677c90d..000000000 --- a/lua/plugins/configs/tree-sitter.lua +++ /dev/null @@ -1,12 +0,0 @@ -local ts = require('nvim-treesitter.configs') ---[[ - Here you can use the maintained value which indicates that we wish to use all - maintained languages modules instead of a list of languages. You also need to - set highlight to true, otherwise the plugin will be disabled. ---]] -ts.setup({ - -- NOTE: Place your languages here! - ensure_installed = Doom.ts_parsers, - highlight = { enable = true }, - indent = { enable = true }, -}) diff --git a/lua/plugins/configs/which-key.lua b/lua/plugins/configs/which-key.lua deleted file mode 100644 index 226926948..000000000 --- a/lua/plugins/configs/which-key.lua +++ /dev/null @@ -1,46 +0,0 @@ -require('which-key').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', - -- ['v'] = 'Visual Character Mode', - gc = 'Comments', - }, - 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 - }, - window = { - padding = { 0, 0, 0, 0 }, -- extra window padding [top, right, bottom, left] - }, - layout = { - height = { min = 1, max = 10 }, -- min and max height of the columns - }, - hidden = { '', '^:', '^ ' }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - triggers = {""}, -- automatically setup triggers - -- triggers = {""} -- or specifiy a list manually -}) ---Cmd('highlight WhichKeyFloat guibg='..Doom.whichkey_bg') - diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua deleted file mode 100644 index d36adc229..000000000 --- a/lua/plugins/init.lua +++ /dev/null @@ -1,267 +0,0 @@ ------ Plugins modules --- Essentials / (Plugin manager, vimpeccable, treesitter, sessions) --- UI Related / (All look-and-feel plugins) --- Fuzzy Search ! (Fuzzy searching) --- Git Integration + (Some git plugins like LazyGit) --- Completion + (Built-in LSP configurations) --- File-related + (EditorConfig, formatting, Tree-sitter, etc) --- Web-related + (Colorizer, emmet, rest client) --- --- Legend: --- ! : The group and its plugins cannot be disabled --- / : The group cannot be disabled but some of its plugins can be --- + : The group and its plugins can be disabled --- --- NOTES: --- 1. You can disable an entire group or just some or their plugins based on --- the legend, please refer to our documentation to learn how to do it. --- 2. We do not provide other LSP integration like coc.nvim, --- please refer to our FAQ to see why. - ---- Disabled modules -local disabled_git = Has_value(Doom.disabled_modules, 'git') -local disabled_lsp = Has_value(Doom.disabled_modules, 'lsp') -local disabled_files = Has_value(Doom.disabled_modules, 'files') -local disabled_web = Has_value(Doom.disabled_modules, 'web') - -local packer = require('packer') -return packer.startup(function() - -----[[------------]]----- - --- Essentials --- - -----]]------------[[----- - -- Plugins manager - use({ - 'wbthomason/packer.nvim', - }) - - -- Tree-Sitter - local disabled_treesitter = - Has_value(Doom.disabled_plugins, 'treesitter') - use({ - 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', - disable = (disabled_files and true or disabled_treesitter), - }) - - -- Sessions - use({ - 'rmagatti/auto-session', - requires = { 'rmagatti/session-lens' }, - }) - - -----[[------------]]----- - --- UI Related --- - -----]]------------[[----- - -- Fancy start screen - -- cannot be disabled - use({ 'glepnir/dashboard-nvim', disable = false }) - - -- Colorschemes - local disabled_theme = Has_value(Doom.disabled_plugins, 'doom-themes') - use({ - 'GustavoPrietoP/doom-themes.nvim', - disable = disabled_theme, - }) - - -- File tree - local disabled_tree = Has_value(Doom.disabled_plugins, 'tree') - use({ - 'kyazdani42/nvim-tree.lua', - requires = { 'kyazdani42/nvim-web-devicons' }, - disable = disabled_tree, - }) - - -- Statusline - -- can be disabled to use your own statusline - local disabled_statusline = - Has_value(Doom.disabled_plugins, 'statusline') - use({ - 'glepnir/galaxyline.nvim', - disable = disabled_statusline, - }) - - -- Tabline - -- can be disabled to use your own tabline - local disabled_tabline = Has_value(Doom.disabled_plugins, 'tabline') - use({ 'romgrk/barbar.nvim', disable = disabled_tabline }) - - -- Better terminal - -- can be disabled to use your own terminal plugin - local disabled_terminal = Has_value(Doom.disabled_plugins, 'terminal') - use({ - 'akinsho/nvim-toggleterm.lua', - disable = disabled_terminal, - }) - - -- Viewer & finder for LSP symbols and tags - local disabled_outline = Has_value(Doom.disabled_plugins, 'outline') - use({ - 'simrat39/symbols-outline.nvim', - disable = disabled_outline, - }) - - -- Minimap - -- Depends on wfxr/code-minimap to work! - local disabled_minimap = Has_value(Doom.disabled_plugins, 'minimap') - use({ 'wfxr/minimap.vim', disable = disabled_minimap }) - - -- Keybindings menu like Emacs's guide-key - -- cannot be disabled - use({ 'folke/which-key.nvim', disable = false }) - - -- Distraction free environment - local disabled_zen = Has_value(Doom.disabled_plugins, 'zen') - use({ 'kdav5758/TrueZen.nvim', disable = disabled_zen }) - - -----[[--------------]]----- - --- Fuzzy Search --- - -----]]--------------[[----- - use({ - 'nvim-telescope/telescope.nvim', - requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } }, - disable = false, - }) - - -----[[-------------]]----- - --- GIT RELATED --- - -----]]-------------[[----- - -- Git gutter better alternative, written in Lua - -- can be disabled to use your own git gutter plugin - local disabled_gitsigns = Has_value(Doom.disabled_plugins, 'gitsigns') - use({ - 'lewis6991/gitsigns.nvim', - disable = (disabled_git and true or disabled_gitsigns), - }) - - -- LazyGit integration - local disabled_lazygit = Has_value(Doom.disabled_plugins, 'lazygit') - use({ - 'kdheepak/lazygit.nvim', - requires = { 'nvim-lua/plenary.nvim' }, - disable = (disabled_git and true or disabled_lazygit), - }) - - -----[[------------]]----- - --- Completion --- - -----]]------------[[----- - -- Built-in LSP Config - -- NOTE: It should not be disabled if you are going to use LSP! - local disabled_lspconfig = Has_value(Doom.disabled_plugins, 'lspconfig') - use({ - 'neovim/nvim-lspconfig', - disable = (disabled_lsp and true or disabled_lspconfig), - }) - -- Completion plugin - -- can be disabled to use your own completion plugin - local disabled_compe = Has_value(Doom.disabled_plugins, 'compe') - use({ - 'hrsh7th/nvim-compe', - requires = { - { 'ray-x/lsp_signature.nvim' }, - { 'onsails/lspkind-nvim' }, - { 'norcalli/snippets.nvim' }, - }, - disable = (disabled_lsp and true or disabled_compe), - }) - - -- install lsp saga - local disabled_lspsaga = Has_value(Doom.disabled_plugins, 'lspsaga') - use({ - 'glepnir/lspsaga.nvim', - disable = (disabled_lsp and true or disabled_lspsaga), - }) - - -- provides the missing `:LspInstall` for `nvim-lspconfig`. - local disabled_lspinstall = - Has_value(Doom.disabled_plugins, 'lspinstall') - use({ - 'kabouzeid/nvim-lspinstall', - disable = (disabled_lsp and true or disabled_lspinstall), - }) - - -----[[--------------]]----- - --- File Related --- - -----]]--------------[[----- - -- Write / Read files without permissions (e.G. /etc files) without having - -- to use `sudo nvim /path/to/file` - local disabled_suda = Has_value(Doom.disabled_plugins, 'suda') - use({ - 'lambdalisue/suda.vim', - disable = (disabled_files and true or disabled_suda), - }) - - -- File formatting - -- can be disabled to use your own file formatter - local disabled_formatter = Has_value(Doom.disabled_plugins, 'formatter') - use({ - 'lukas-reineke/format.nvim', - disable = (disabled_files and true or disabled_formatter), - }) - - -- Autopairs - -- can be disabled to use your own autopairs - local disabled_autopairs = Has_value(Doom.disabled_plugins, 'autopairs') - use({ - 'windwp/nvim-autopairs', - disable = (disabled_files and true or disabled_autopairs), - }) - - -- Indent Lines - local disabled_indent_lines = - Has_value(Doom.disabled_plugins, 'indentlines') - use({ - 'lukas-reineke/indent-blankline.nvim', - disable = (disabled_files and true or disabled_indent_lines), - }) - - -- EditorConfig support - local disabled_editorconfig = - Has_value(Doom.disabled_plugins, 'editorconfig') - use({ - 'editorconfig/editorconfig-vim', - disable = (disabled_files and true or disabled_editorconfig), - }) - - -- Comments - -- can be disabled to use your own comments plugin - local disabled_kommentary = - Has_value(Doom.disabled_plugins, 'kommentary') - use({ - 'b3nj5m1n/kommentary', - disable = (disabled_files and true or disabled_kommentary), - }) - - -----[[-------------]]----- - --- Web Related --- - -----]]-------------[[----- - -- Fastest colorizer without external dependencies! - local disabled_colorizer = Has_value(Doom.disabled_plugins, 'colorizer') - use({ - 'norcalli/nvim-colorizer.lua', - disable = (disabled_web and true or disabled_colorizer), - }) - - -- HTTP Client support - -- Depends on bayne/dot-http to work! - local disabled_restclient = - Has_value(Doom.disabled_plugins, 'restclient') - use({ - 'bayne/vim-dot-http', - disable = (disabled_web and true or disabled_restclient), - }) - - -- Emmet plugin - local disabled_emmet = Has_value(Doom.disabled_plugins, 'emmet') - use({ - 'mattn/emmet-vim', - disable = (disabled_web and true or disabled_emmet), - }) - - -----[[----------------]]----- - --- Custom Plugins --- - -----]]----------------[[----- - -- If there are custom plugins then also require them - for _, plug in pairs(Doom.custom_plugins) do - Custom_plugins(plug) - end -end) diff --git a/plugins.lua b/plugins.lua new file mode 100644 index 000000000..1412a966c --- /dev/null +++ b/plugins.lua @@ -0,0 +1,15 @@ +-- plugins - 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: +-- return { +-- { +-- 'user/repository', +-- requires = { 'nvim-lua/telescope.nvim' }, +-- }, +-- } + +return {} diff --git a/selene.toml b/selene.toml new file mode 100644 index 000000000..b861c202a --- /dev/null +++ b/selene.toml @@ -0,0 +1 @@ +std = "doom" diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 000000000..c6015eb76 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,5 @@ +column_width = 80 +line_endings = "Unix" +indent_type = "Tabs" +indent_width = 4 +quote_style = "AutoPreferSingle"