1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -0,0 +1,70 @@
---
name: Bug Report
about: Report a problem in lualine
title: 'Bug: '
labels: bug
---
<!--
Before reporting: search existing issues and
ensure you are running neovim >= 0.5 and the
latest version of lualine.
-->
### Self Checks
<!-- Check these boxes by placing an X in the middle -->
- [ ] I'm using the latest lualine.
- [ ] I didn't find the issue in existing issues or PRs.
### How to reproduce the problem
<!-- Add steps to reproduce with minimal config from below -->
### Expected behaviour
### Actual behaviour
### Minimal config to reproduce the issue
<!--
=================
### IMPORTANT ###
=================
You need to provide a way to reproduce the issue without influence
of other plugins.
Issues without proper format and a proper way to
reproduce might be ignored and closed without any reply.
This script can help you with that.
https://github.com/nvim-lualine/lualine.nvim/blob/master/scripts/nvim_isolated_conf.sh
Create an isolated config directory with:
`nvim_isolated_conf.sh -c DirectoryName`
Then modify the DirectoryName/.config/nvim/init.vim
so you can reproduce the issue .
`nvim_isolated_conf.sh -e DirectoryName`
will open DirectoryName/.config/nvim/init.vim in neovim.
the init.vim will have instructions on how and where to place
your config don't worry if you don't know viml you can get away
with lua even in a vim file.
Then you can load the config in an isolated environment to see
if the issue is occurring with
`nvim_isolated_conf.sh -l DirectoryName`
Paste the DirectoryName/.config/init.vim below
-->
### Additional information

View File

@ -0,0 +1,19 @@
---
name: Feature Request
about: Request a feature for lualine
title: "Feat: "
labels: new feature
---
<!--
Before creating a new request: search existing issues and prs
and ensure it hasn't been already requested.
-->
### Requested feature
<!-- Describe the feature with details. -->
### Motivation
<!-- Explain why you think it should be included in lualine.-->

View File

@ -0,0 +1,6 @@
generatedFiles:
- path: "doc/lualine.txt"
message: "`lualine.txt` is generated from README.md. Make changes there instead."
ignoreAuthors:
- 'github-actions[bot]'
- 'shadmansaleh'

View File

@ -0,0 +1,22 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- upstream
- help wanted
- wip
- good first issue
- discuss
- pin
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View File

@ -0,0 +1,44 @@
name: autogen
on:
push:
branches: [master]
paths:
- "lua/**.lua"
- "examples/**.lua"
- ".stylua.toml"
- "README.md"
# Cancel any in-progress CI runs for a PR if it is updated
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
autogen:
name: "(vimdoc|formating)"
runs-on: ubuntu-20.04
timeout-minutes: 10
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- name: Generate docs with panvimdoc
uses: kdheepak/panvimdoc@v2.7.1
with:
vimdoc: lualine
description: fast and easy to configure statusline plugin for neovim
- name: Apply stylua
uses: JohnnyMorganz/stylua-action@1.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --config-path=.stylua.toml lua/ examples/
version: 0.14.1
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
commit_message: "chore: autogen (vimdocs+formating)"
branch: ${{ github.head_ref }}
file_pattern: lua/ examples/ doc/lualine.txt

View File

@ -0,0 +1,68 @@
name: Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
# Cancel any in-progress CI runs for a PR if it is updated
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
jobs:
tests:
name: ${{ matrix.os }} ${{ matrix.flavor }}
strategy:
fail-fast: false
matrix:
include:
- flavor: nvim-0.7
runner: ubuntu-20.04
os: linux
nvim_version: v0.7.0
- flavor: nvim-0.8
runner: ubuntu-20.04
os: linux
nvim_version: v0.8.0
- flavor: nvim-0.9
runner: ubuntu-20.04
os: linux
nvim_version: v0.9.0
- flavor: nvim-nightly
runner: ubuntu-20.04
os: linux
nvim_version: nightly
runs-on: ${{ matrix.runner }}
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Setup Test Environment
run: |
mkdir -p ./tmp_home/nvim/pack/vendor/start
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ./tmp_home/nvim/pack/vendor/start/plenary.nvim
git clone --depth 1 https://github.com/nvim-tree/nvim-web-devicons ./tmp_home/nvim/pack/vendor/start/nvim-web-devicons
ln -s $(pwd) ./tmp_home/nvim/pack/vendor/start
- name: Setup neovim ${{matrix.nvim_version}}
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{matrix.nvim_version}}
- name: Run tests
run: |
make test
lint:
runs-on: ubuntu-20.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
- name: Setup linters
run: |
sudo apt-get update
sudo apt-get install luarocks
sudo luarocks install luacheck
- name: Run luacheck
run: |
make lint

View File

@ -0,0 +1,58 @@
# Compiled Lua sources
luac.out
# luarocks build files
*.src.rock
*.zip
*.tar.gz
# Object files
*.o
*.os
*.ko
*.obj
*.elf
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# ctags
tags
# helptags
/doc/tags
# panvimdoc
/panvimdoc/
# luacov
/luacov.report
/luacov.report.index
/luacov.stats
# tests
/tmp_home/
.luarc.json

View File

@ -0,0 +1,15 @@
globals = {
"vim",
"assert"
}
-- Don't report unused self arguments of methods.
self = false
-- Rerun tests only if their modification time changed.
cache = true
ignore = {
"631", -- max_line_length
"212/_.*", -- unused argument, for vars with "_" prefix
}

View File

@ -0,0 +1,20 @@
return {
include = {
"lua/lualine$",
"lua/lualine_require$",
"lua/lualine%/.+$",
},
exclude = {
"lua/lualine/themes%/.+$",
"lua/lualine/extensions%/.+$",
},
modules = {
["lualine"] = "lua/lualine.lua",
["lualine_require"] = "lua/lualine_require.lua",
["lualine.*"] = "lua/",
},
statsfile = 'luacov.stats',
reportfile = 'luacov.report',
-- includeuntestedfiles = true,
}
-- vim:ft=lua

View File

@ -0,0 +1,5 @@
indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
call_parentheses = "NoSingleTable"
collapse_simple_statement = "Never"

View File

@ -0,0 +1,50 @@
# Contributing to lualine.nvim
Thanks for considering to contribute.
### Getting started
If you're not sure where to help? You can try these:
- You can look at the currently open [issues](https://github.com/nvim-lualine/lualine.nvim/issues)
to see if some bug needs fixing or for cool feature ideas.<br>
You should also look at currently open PRs ([Pull requests](https://github.com/nvim-lualine/lualine.nvim/pulls)) to see if some abandoned PR interests you.<br>
*We could really use some help with tests & docs they are currently lacking :)*
- You can add an exciting new component, extension or theme.
Note: Currently we aren't adding regular colorscheme based themes.
We think they make more sense with colorschemes as they tend not to get
updated once added here. But if you have some unique themes idea like [auto](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#auto) or [pywal](https://github.com/nvim-lualine/lualine.nvim/blob/master/THEMES.md#pywal) feel free to open an PR or issue.
- Feel free to open issues or unfinished PRs for help.
I'd actually recommend you to open an issue first for bigger PRs to discuss
the feature with a maintainer beforehand. That way you can know if the
feature is likely to be accepted or not before you get started.
You'll get recommendation and help with implementation specially if you show
willingness to implement it yourself.
- Do add tests and docs for your changes.
Good luck!
### Developer tools
*Let's introduce you to the tools we use.*
- Your PR needs to pass tests & linter. We lint our codebase with [luacheck](https://github.com/mpeterv/luacheck)
and run tests with [plenary-test][plenary.nvim] these will be run on CI. If you want you can run tests & linter
locally with `make test` & `make lint` respectively. Or `make check` to run both linter & tests. For running
tests you'll have to make sure lualine.nvim, [plenary.nvim][plenary.nvim] and
[nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) are in same directory.
- Lua codebase gets formatted with [stylua](https://github.com/JohnnyMorganz/StyLua) in CI.
So you can ignore formatting. But if you want to submit formatted
PR you can run formatter locally with `make format`.
- VimDocs are auto generated with [panvimdoc](https://github.com/kdheepak/panvimdoc) from README.md.
So don't make changes to doc/lualine.txt . Instead add your docs to README or Wiki.
The docgen in ran by CI too. If you want to run it locally you can do so
with `make docgen`. Note: you'll need to have [pandoc](https://github.com/jgm/pandoc) installed.
- `make precommit_check` can come quite handy it'll run all the above mentioned tools
- You can check our test coverage with `make testcov`.
You'll need to have [luacov](https://github.com/keplerproject/luacov)
& [luacov-console](https://github.com/spacewander/luacov-console) installed for that.
If you want luacov's detailed report files, run the command with the `NOCLEAN` env set.
For example `NOCLEAN=1 make testcov`
[plenary.nvim]: https://github.com/nvim-lua/plenary.nvim

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 hoob3rt
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.
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.

View File

@ -0,0 +1,38 @@
.DEFAULT_GOAL = check
lint:
@luacheck lua/lualine/
@luacheck tests/
@luacheck examples/
format:
@stylua --config-path=.stylua.toml lua/ examples/
test:
@mkdir -p tmp_home
@export XDG_DATA_HOME='./tmp_home' && \
export XDG_CONFIG_HOME='./tmp_home' && \
bash ./scripts/test_runner.sh
@rm -rf tmp_home
# Install luacov & luacov-console from luarocks
testcov:
@mkdir -p ./tmp_home/data/nvim
@mkdir -p ./tmp_home/config/nvim
@export XDG_DATA_HOME=$(realpath './tmp_home/data') && \
export XDG_CONFIG_HOME=$(realpath './tmp_home/config') && \
export TEST_COV=true && \
bash ./scripts/test_runner.sh
@luacov-console lua/
@luacov-console -s
ifeq ($(NOCLEAN), )
@rm luacov.*
endif
@rm -rf tmp_home
docgen:
@sh ./scripts/docgen.sh
precommit_check: docgen format test lint
check: lint test

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,361 @@
# Available themes
All available themes are only best effort ports by myself/ other users. If you find a theme to be weird/ wrong please open an issue/ pr.
### auto
auto is a special theme. It will automatically load theme for your colorscheme.
If there's no theme available for your colorscheme then
it'll try it's best to generate one.
### 16color
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648240-02d2ae00-74bb-11eb-9ac1-495849621366.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648219-f77f8280-74ba-11eb-84e4-978bf918c21f.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648263-141bba80-74bb-11eb-84e0-ff48ae6f927a.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648270-1a119b80-74bb-11eb-8fff-00984243846f.png'/>
</p>
### ayu_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648314-357ca680-74bb-11eb-83de-ec94c3a75d99.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648329-3e6d7800-74bb-11eb-901b-41e1f01315f0.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648342-44fbef80-74bb-11eb-8262-a6f615e5fcfb.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648367-52b17500-74bb-11eb-8ec5-dbb59db60d98.png'/>
</p>
### ayu_light
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648508-b5a30c00-74bb-11eb-80f7-0bce969d35ea.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648511-b89dfc80-74bb-11eb-9868-f63d7752fe83.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648514-bb98ed00-74bb-11eb-87f4-6b24de56f86c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648518-bd62b080-74bb-11eb-8cbe-869ed12d16dc.png'/>
</p>
### ayu_mirage
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648535-c6538200-74bb-11eb-815b-53f4b3274602.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648537-c784af00-74bb-11eb-8da5-d91bfc61a967.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648539-ca7f9f80-74bb-11eb-840a-5e0d9ba98bb8.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648541-cbb0cc80-74bb-11eb-843f-19c4c58b1d91.png'/>
</p>
### ayu
It's a combination of ayu_light, ayu_dark & ayu_mirage. If `g:ayucolor` exists,
it loads one of these based on your `g:ayucolor` option. Otherwise, it will
load ayu_light when background=light and ayu_dark when background=dark
But if `g:ayuprefermirage` exists, it will load ayu_mirage instead when
`background=dark`.
### base16
This theme will automatically use colors defined by your colorscheme using [tinted-theming/base16-vim](https://github.com/tinted-theming/base16-vim) or [RRethy/nvim-base16](https://github.com/RRethy/nvim-base16)] plugin.
The following example is using the `tomorrow-night` colorscheme:
<p>
<img width='700' src='https://user-images.githubusercontent.com/11501572/156889654-3dedc9a1-e7a5-4cbe-b219-2a97499cf1d2.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11501572/156889648-93bf3ce8-064d-4ac0-8415-20d6ef87c60b.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11501572/156889624-c97fc3ae-d642-41ba-b39a-f9a72ff8b15e.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11501572/156889566-17066e95-7f85-4bfd-8178-c4a34beab453.png'/>
</p>
### codedark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648568-dff4c980-74bb-11eb-9d16-b68ac68f2ab2.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648569-e125f680-74bb-11eb-8782-db9a6c2a3153.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648578-e6834100-74bb-11eb-819c-fb66d7d5118c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648582-e8e59b00-74bb-11eb-9239-edcc8e9c2c18.png'/>
</p>
### dracula
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648594-f0a53f80-74bb-11eb-9018-9ee12260750e.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648600-f26f0300-74bb-11eb-82a4-f732b3e7eeff.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648606-f4d15d00-74bb-11eb-8327-a35e97533617.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648619-fe5ac500-74bb-11eb-8952-cc5c81fd0b2b.png'/>
</p>
### everforest
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648663-1cc0c080-74bc-11eb-8cc1-36266a0385e3.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648667-1df1ed80-74bc-11eb-9ef8-dfd2e8401f0c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648671-21857480-74bc-11eb-996e-a5cf212e98bd.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648675-22b6a180-74bc-11eb-9b8e-45e64a03e062.png'/>
</p>
### gruvbox_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648685-2b0edc80-74bc-11eb-9ec9-9aac3677df43.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648693-2ea26380-74bc-11eb-831a-9ebbe4f3dd83.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648700-319d5400-74bc-11eb-90fa-72eccbda8242.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648716-382bcb80-74bc-11eb-824a-aaca67035073.png'/>
</p>
### gruvbox_light
<p>
<img width='700' src='https://user-images.githubusercontent.com/34294427/118757012-5d9b5c00-b896-11eb-8e4f-c0c28f774cf6.png'/>
<img width='700' src='https://user-images.githubusercontent.com/34294427/118757009-5bd19880-b896-11eb-9846-d02b16653ab0.png'/>
<img width='700' src='https://user-images.githubusercontent.com/34294427/118757023-612ee300-b896-11eb-8673-a39a0fbce619.png'/>
<img width='700' src='https://user-images.githubusercontent.com/34294427/118757020-5ffdb600-b896-11eb-95e7-dbf1f08e063d.png'/>
</p>
### gruvbox
It's a combination of gruvbox_light and gruvbox_dark. It loads either of
them based you your `background` option.
### gruvbox-material
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648725-3f52d980-74bc-11eb-8fa5-a77b0a21cdea.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648728-41b53380-74bc-11eb-99cf-001eab6cc51b.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648742-4a0d6e80-74bc-11eb-9685-8e0cba1eb3c3.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648744-4d085f00-74bc-11eb-8aaa-05a7ca46adec.png'/>
</p>
### horizon
<p>
<img width='700' src='https://user-images.githubusercontent.com/69089176/118903813-70527700-b910-11eb-9d45-1785790ce8e8.png'/>
<img width='700' src='https://user-images.githubusercontent.com/69089176/118902058-bc9bb800-b90c-11eb-99b8-3b98cbdd01d7.png'/>
<img width='700' src='https://user-images.githubusercontent.com/69089176/118903506-dab6e780-b90f-11eb-85db-c6227a8caf0c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/69089176/118902070-c2919900-b90c-11eb-9296-145a99ce52ce.png'/>
</p>
### iceberg_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648796-614c5c00-74bc-11eb-8398-cde120ec7746.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648813-64474c80-74bc-11eb-986b-432498dd6245.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648822-66a9a680-74bc-11eb-8b2b-416cd359c30d.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648829-6ad5c400-74bc-11eb-9af4-670968934931.png'/>
</p>
### iceberg_light
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648848-71fcd200-74bc-11eb-8910-e12ae9ce619f.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648849-73c69580-74bc-11eb-93f9-d6f75a2bdd97.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648851-7628ef80-74bc-11eb-8a4b-c7f44c89ac93.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648862-7aeda380-74bc-11eb-808c-1b12dde45f3d.png'/>
</p>
### iceberg
It's a combination of iceberg_light and iceberg_dark. It loads either of
them based you your `background` option.
### jellybeans
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648882-82ad4800-74bc-11eb-91e8-4d38fcdec134.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648883-850fa200-74bc-11eb-8d9b-54116accd2f8.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648900-8d67dd00-74bc-11eb-9600-13cd48fa2bde.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648902-8f31a080-74bc-11eb-9d8e-37a3f41d4c7a.png'/>
</p>
### material
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648925-9e185300-74bc-11eb-9263-842fe2d56ba8.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648927-9f498000-74bc-11eb-8a15-4ba68403037a.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648930-a1134380-74bc-11eb-8a24-f203bf05cfb3.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648935-a2dd0700-74bc-11eb-9a4b-72eb1e2ab79e.png'/>
</p>
### modus-vivendi
<p>
<img width='700' src='https://user-images.githubusercontent.com/9327361/114389966-58176b80-9b9e-11eb-944e-1e0079527d74.png'/>
<img width='700' src='https://user-images.githubusercontent.com/9327361/114390000-606fa680-9b9e-11eb-97dd-ef5bbc23049a.png'/>
<img width='700' src='https://user-images.githubusercontent.com/9327361/114390024-6796b480-9b9e-11eb-8be2-ca4cc893fbb2.png'/>
<img width='700' src='https://user-images.githubusercontent.com/9327361/114390052-6d8c9580-9b9e-11eb-8dcb-469290a4c655.png'/>
</p>
### molokai
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648944-ab354200-74bc-11eb-85fd-71a40102384b.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648946-acff0580-74bc-11eb-9aae-36a869b855e5.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648953-af615f80-74bc-11eb-8897-f2945fc34c09.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648958-b12b2300-74bc-11eb-8232-550949cbbfb3.png'/>
</p>
### moonfly
<p>
<img width='700' src='https://user-images.githubusercontent.com/11382509/129304429-cd2af22d-3b88-4c17-bf99-99f7608576d4.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11382509/129304441-81a6c88e-364c-476a-9050-0ada4cae1e3b.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11382509/129304453-2b18900a-13a9-4476-9977-3875e55aabaf.png'/>
<img width='700' src='https://user-images.githubusercontent.com/11382509/129304469-37fb0168-0484-406b-8b2e-d309232612ab.png'/>
</p>
### nightfly
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648974-b9835e00-74bc-11eb-9c52-c5187aa3ff2c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648977-bab48b00-74bc-11eb-96b3-7f51fc73d8e8.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648980-bc7e4e80-74bc-11eb-9b12-3182a112f968.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648981-bdaf7b80-74bc-11eb-86d4-6c44c3764a70.png'/>
</p>
### nord
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649007-cbfd9780-74bc-11eb-87be-a9edc714e57a.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649010-cd2ec480-74bc-11eb-9d9b-54fadee2abef.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649019-cef88800-74bc-11eb-97eb-054d78427442.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649021-cf911e80-74bc-11eb-8b4a-9f9eb61c7973.png'/>
</p>
### OceanicNext
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649039-d7e95980-74bc-11eb-9a33-df413936c645.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649043-d91a8680-74bc-11eb-9b1b-9c2e88ede3aa.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649052-db7ce080-74bc-11eb-8d9b-05c4c21a7e53.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649056-dcae0d80-74bc-11eb-91a0-ee0d98f3525d.png'/>
</p>
### onedark
<p>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150810955-ef6bf575-4a96-439c-a708-37dd25c63a47.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150811104-31fbc04c-1500-4779-a079-98bd1e56701d.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150811324-d1169232-a7b6-4f79-a104-031ea7972a32.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150811517-f90a406d-a4b9-4bd5-913c-ec1ae547c400.png'/>
</p>
### onelight
<p>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150809518-b596f9bc-c351-4e71-9dec-e1856efaff8a.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150809979-237c6414-4278-447d-a00f-0a32e2770195.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150810292-afeecfce-3b53-468d-aed9-1bb5ea9ed46f.png'/>
<img width='700' src='https://user-images.githubusercontent.com/8293386/150810514-81024b2c-3b80-466f-85ce-914e191bb4f9.png'/>
</p>
### palenight
<p>
<img width='700' src='https://user-images.githubusercontent.com/7190144/109406548-3e1d2300-797a-11eb-8fdb-c3882ae08625.png'/>
<img width='700' src='https://user-images.githubusercontent.com/7190144/109406547-3e1d2300-797a-11eb-9b72-43ba7145355d.png'/>
<img width='700' src='https://user-images.githubusercontent.com/7190144/109406545-3cebf600-797a-11eb-8e2e-992e98d8120e.png'/>
<img width='700' src='https://user-images.githubusercontent.com/7190144/109406546-3d848c80-797a-11eb-9069-04caf383275d.png'/>
</p>
### papercolor_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649104-fd766300-74bc-11eb-8c5c-40e7191a81f7.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649106-fe0ef980-74bc-11eb-93f7-f98e0b89d5c9.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649108-ff402680-74bc-11eb-93da-bb96d51c39f0.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649112-00715380-74bd-11eb-8125-2c108da5123e.png'/>
</p>
### papercolor_light
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649126-07986180-74bd-11eb-9a25-c6ce762d37d2.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649129-08c98e80-74bd-11eb-93d4-5bc109ac9ee9.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649132-0b2be880-74bd-11eb-8ed2-afab3e974b4e.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649137-0cf5ac00-74bd-11eb-8764-765bead5de6e.png'/>
</p>
### PaperColor
It's a combination of papercolor_light and papercolor_dark. It loads either of
them based you your `background` option.
### powerline
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649147-14b55080-74bd-11eb-9670-713185342eb2.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649150-15e67d80-74bd-11eb-8815-194c51d96016.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649155-17b04100-74bd-11eb-8e41-017eb9a837b5.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649158-18e16e00-74bd-11eb-8687-65b0ecbf20d2.png'/>
</p>
### powerline_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/59497618/131224416-851aedd4-27bb-47fd-a9a6-5332aa42ce60.png'/>
<img width='700' src='https://user-images.githubusercontent.com/59497618/131224418-7bec491b-1183-4ec7-8089-3dbe460cc1e4.png'/>
<img width='700' src='https://user-images.githubusercontent.com/59497618/131224419-adab4f88-aaf8-449e-9988-ae002333d131.png'/>
<img width='700' src='https://user-images.githubusercontent.com/59497618/131224421-3b175d7a-fb14-424c-ad53-03d2c3b2ab71.png'/>
</p>
### pywal
pywal is another special theme. It will load the colors from your current [pywal](https://github.com/dylanaraps/pywal) cache, specifically `~/.cache/wal/colors.sh` and generate a theme.
#### `wal --theme ashes`
<img width='700' src='https://user-images.githubusercontent.com/36740602/132101614-8aa90169-a1ed-4911-b09f-31b5bae56cbf.png'/>
#### `wal --theme -l github`
<img width='700' src='https://user-images.githubusercontent.com/36740602/132101617-f3ff65eb-8051-4294-9a55-e6caa9605006.png'/>
#### `wal --theme vscode`
<img width='700' src='https://user-images.githubusercontent.com/36740602/132101619-7d04d748-d478-45a2-983a-f2a93f3c5714.png'/>
#### `wal --theme zenburn`
<img width='700' src='https://user-images.githubusercontent.com/36740602/132101621-505e5bb6-d18a-434c-a0f8-a3904a5c71f2.png'/>
### seoul256
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649194-2c8cd480-74bd-11eb-8fbc-935d7e0fe921.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649198-2d256b00-74bd-11eb-9894-7ffdead0297c.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649202-2eef2e80-74bd-11eb-9627-38f834ce4aec.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649205-2f87c500-74bd-11eb-9da6-5253dcff2c82.png'/>
</p>
### solarized_dark
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649216-37476980-74bd-11eb-8f3b-2a7fc368388d.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649217-38789680-74bd-11eb-8337-5e3005c5e261.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649223-3c0c1d80-74bd-11eb-953b-72c614aa9638.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649227-3d3d4a80-74bd-11eb-8251-d7788db36060.png'/>
</p>
### solarized_light
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649246-44645880-74bd-11eb-92c9-120798dc0452.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649251-462e1c00-74bd-11eb-953d-2857296997cc.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649255-475f4900-74bd-11eb-8a75-7ca266d56009.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649258-48907600-74bd-11eb-9bba-8e82b56777d9.png'/>
</p>
### Tomorrow
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649275-51814780-74bd-11eb-881b-1e137a0cbfe0.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649297-59d98280-74bd-11eb-92a5-a8c4af150106.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649317-5e9e3680-74bd-11eb-95a4-fc018cb4a528.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649321-6067fa00-74bd-11eb-83bb-b1de7f5e62d6.png'/>
</p>
### wombat
<p>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649337-65c54480-74bd-11eb-9ea1-fab2e679c56b.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649411-8db4a800-74bd-11eb-962a-8b73f9fb7124.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649349-6cec5280-74bd-11eb-9ada-8f1cb8b48ec1.png'/>
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649358-6fe74300-74bd-11eb-9fe2-a955f964e3ce.png'/>
</p>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
-- Bubbles config for lualine
-- Author: lokesh-krishna
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
blue = '#80a0ff',
cyan = '#79dac8',
black = '#080808',
white = '#c6c6c6',
red = '#ff5189',
violet = '#d183e8',
grey = '#303030',
}
local bubbles_theme = {
normal = {
a = { fg = colors.black, bg = colors.violet },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.white },
},
insert = { a = { fg = colors.black, bg = colors.blue } },
visual = { a = { fg = colors.black, bg = colors.cyan } },
replace = { a = { fg = colors.black, bg = colors.red } },
inactive = {
a = { fg = colors.white, bg = colors.black },
b = { fg = colors.white, bg = colors.black },
c = { fg = colors.white },
},
}
require('lualine').setup {
options = {
theme = bubbles_theme,
component_separators = '',
section_separators = { left = '', right = '' },
},
sections = {
lualine_a = { { 'mode', separator = { left = '' }, right_padding = 2 } },
lualine_b = { 'filename', 'branch' },
lualine_c = {
'%=', --[[ add your center compoentnts here in place of this comment ]]
},
lualine_x = {},
lualine_y = { 'filetype', 'progress' },
lualine_z = {
{ 'location', separator = { right = '' }, left_padding = 2 },
},
},
inactive_sections = {
lualine_a = { 'filename' },
lualine_b = {},
lualine_c = {},
lualine_x = {},
lualine_y = {},
lualine_z = { 'location' },
},
tabline = {},
extensions = {},
}

View File

@ -0,0 +1,221 @@
-- Eviline config for lualine
-- Author: shadmansaleh
-- Credit: glepnir
local lualine = require('lualine')
-- Color table for highlights
-- stylua: ignore
local colors = {
bg = '#202328',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
end,
hide_in_width = function()
return vim.fn.winwidth(0) > 80
end,
check_git_workspace = function()
local filepath = vim.fn.expand('%:p:h')
local gitdir = vim.fn.finddir('.git', filepath .. ';')
return gitdir and #gitdir > 0 and #gitdir < #filepath
end,
}
-- Config
local config = {
options = {
-- Disable sections and component separators
component_separators = '',
section_separators = '',
theme = {
-- We are going to use lualine_c an lualine_x as left and
-- right section. Both are highlighted by c theme . So we
-- are just setting default looks o statusline
normal = { c = { fg = colors.fg, bg = colors.bg } },
inactive = { c = { fg = colors.fg, bg = colors.bg } },
},
},
sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
-- These will be filled later
lualine_c = {},
lualine_x = {},
},
inactive_sections = {
-- these are to remove the defaults
lualine_a = {},
lualine_b = {},
lualine_y = {},
lualine_z = {},
lualine_c = {},
lualine_x = {},
},
}
-- Inserts a component in lualine_c at left section
local function ins_left(component)
table.insert(config.sections.lualine_c, component)
end
-- Inserts a component in lualine_x at right section
local function ins_right(component)
table.insert(config.sections.lualine_x, component)
end
ins_left {
function()
return ''
end,
color = { fg = colors.blue }, -- Sets highlighting of component
padding = { left = 0, right = 1 }, -- We don't need space before this
}
ins_left {
-- mode component
function()
return ''
end,
color = function()
-- auto change color according to neovims 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.violet,
Rv = colors.violet,
cv = colors.red,
ce = colors.red,
r = colors.cyan,
rm = colors.cyan,
['r?'] = colors.cyan,
['!'] = colors.red,
t = colors.red,
}
return { fg = mode_color[vim.fn.mode()] }
end,
padding = { right = 1 },
}
ins_left {
-- filesize component
'filesize',
cond = conditions.buffer_not_empty,
}
ins_left {
'filename',
cond = conditions.buffer_not_empty,
color = { fg = colors.magenta, gui = 'bold' },
}
ins_left { 'location' }
ins_left { 'progress', color = { fg = colors.fg, gui = 'bold' } }
ins_left {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = { error = '', warn = '', info = '' },
diagnostics_color = {
color_error = { fg = colors.red },
color_warn = { fg = colors.yellow },
color_info = { fg = colors.cyan },
},
}
-- Insert mid section. You can make any number of sections in neovim :)
-- for lualine it's any number greater then 2
ins_left {
function()
return '%='
end,
}
ins_left {
-- Lsp server name .
function()
local msg = 'No Active Lsp'
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end,
icon = ' LSP:',
color = { fg = '#ffffff', gui = 'bold' },
}
-- Add components to right sections
ins_right {
'o:encoding', -- option component same as &encoding in viml
fmt = string.upper, -- I'm not sure why it's upper case either ;)
cond = conditions.hide_in_width,
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'fileformat',
fmt = string.upper,
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
color = { fg = colors.green, gui = 'bold' },
}
ins_right {
'branch',
icon = '',
color = { fg = colors.violet, gui = 'bold' },
}
ins_right {
'diff',
-- Is it me or the symbol for modified us really weird
symbols = { added = '', modified = '󰝤 ', removed = '' },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.orange },
removed = { fg = colors.red },
},
cond = conditions.hide_in_width,
}
ins_right {
function()
return ''
end,
color = { fg = colors.blue },
padding = { left = 1 },
}
-- Now don't forget to initialize lualine
lualine.setup(config)

View File

@ -0,0 +1,124 @@
local colors = {
red = '#ca1243',
grey = '#a0a1a7',
black = '#383a42',
white = '#f3f3f3',
light_green = '#83a598',
orange = '#fe8019',
green = '#8ec07c',
}
local theme = {
normal = {
a = { fg = colors.white, bg = colors.black },
b = { fg = colors.white, bg = colors.grey },
c = { fg = colors.black, bg = colors.white },
z = { fg = colors.white, bg = colors.black },
},
insert = { a = { fg = colors.black, bg = colors.light_green } },
visual = { a = { fg = colors.black, bg = colors.orange } },
replace = { a = { fg = colors.black, bg = colors.green } },
}
local empty = require('lualine.component'):extend()
function empty:draw(default_highlight)
self.status = ''
self.applied_separator = ''
self:apply_highlights(default_highlight)
self:apply_section_separators()
return self.status
end
-- Put proper separators and gaps between components in sections
local function process_sections(sections)
for name, section in pairs(sections) do
local left = name:sub(9, 10) < 'x'
for pos = 1, name ~= 'lualine_z' and #section or #section - 1 do
table.insert(section, pos * 2, { empty, color = { fg = colors.white, bg = colors.white } })
end
for id, comp in ipairs(section) do
if type(comp) ~= 'table' then
comp = { comp }
section[id] = comp
end
comp.separator = left and { right = '' } or { left = '' }
end
end
return sections
end
local function search_result()
if vim.v.hlsearch == 0 then
return ''
end
local last_search = vim.fn.getreg('/')
if not last_search or last_search == '' then
return ''
end
local searchcount = vim.fn.searchcount { maxcount = 9999 }
return last_search .. '(' .. searchcount.current .. '/' .. searchcount.total .. ')'
end
local function modified()
if vim.bo.modified then
return '+'
elseif vim.bo.modifiable == false or vim.bo.readonly == true then
return '-'
end
return ''
end
require('lualine').setup {
options = {
theme = theme,
component_separators = '',
section_separators = { left = '', right = '' },
},
sections = process_sections {
lualine_a = { 'mode' },
lualine_b = {
'branch',
'diff',
{
'diagnostics',
source = { 'nvim' },
sections = { 'error' },
diagnostics_color = { error = { bg = colors.red, fg = colors.white } },
},
{
'diagnostics',
source = { 'nvim' },
sections = { 'warn' },
diagnostics_color = { warn = { bg = colors.orange, fg = colors.white } },
},
{ 'filename', file_status = false, path = 1 },
{ modified, color = { bg = colors.red } },
{
'%w',
cond = function()
return vim.wo.previewwindow
end,
},
{
'%r',
cond = function()
return vim.bo.readonly
end,
},
{
'%q',
cond = function()
return vim.bo.buftype == 'quickfix'
end,
},
},
lualine_c = {},
lualine_x = {},
lualine_y = { search_result, 'filetype' },
lualine_z = { '%l:%c', '%p%%/%L' },
},
inactive_sections = {
lualine_c = { '%f %y %m' },
lualine_x = {},
},
}

View File

@ -0,0 +1,656 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local M = {}
local lualine_require = require('lualine_require')
local modules = lualine_require.lazy_require {
highlight = 'lualine.highlight',
loader = 'lualine.utils.loader',
utils_section = 'lualine.utils.section',
utils = 'lualine.utils.utils',
utils_notices = 'lualine.utils.notices',
config_module = 'lualine.config',
nvim_opts = 'lualine.utils.nvim_opts',
}
local config -- Stores currently applied config
local timers = {
stl_timer = vim.loop.new_timer(),
tal_timer = vim.loop.new_timer(),
wb_timer = vim.loop.new_timer(),
halt_stl_refresh = false, -- mutex ?
halt_tal_refresh = false,
halt_wb_refresh = false,
}
local last_focus = {}
local refresh_real_curwin
-- The events on which lualine redraws itself
local default_refresh_events =
'WinEnter,BufEnter,BufWritePost,SessionLoadPost,FileChangedShellPost,VimResized,Filetype,CursorMoved,CursorMovedI,ModeChanged'
-- Helper for apply_transitional_separators()
--- finds first applied highlight group after str_checked in status
---@param status string : unprocessed statusline string
---@param str_checked number : position of how far status has been checked
---@return string|nil the hl group name or nil
local function find_next_hl(status, str_checked)
-- Gets the next valid hl group from str_checked
local hl_pos_start, hl_pos_end = status:find('%%#.-#', str_checked)
while true do
if not hl_pos_start then
return nil
end
-- When there are more that one hl group next to one another like
-- %#HL1#%#HL2#%#HL3# we need to return HL3. This makes that happen.
local next_start, next_end = status:find('^%%#.-#', hl_pos_end + 1)
if next_start == nil then
break
end
hl_pos_start, hl_pos_end = next_start, next_end
end
return status:sub(hl_pos_start + 2, hl_pos_end - 1)
end
-- Helper for apply_transitional_separators()
--- applies transitional separator highlight + transitional separator
---@param status string : unprocessed statusline string
---@param str_checked number : position of how far status has been checked
---@param last_hl string : last applied hl group name before str_checked
---@param reverse boolean : reverse the hl group ( true for right separators )
---@return string|nil concatenate separator highlight and transitional separator
local function fill_section_separator(status, is_focused, str_checked, last_hl, sep, reverse)
-- Inserts transitional separator along with transitional highlight
local next_hl = find_next_hl(status, str_checked)
if last_hl == nil then
last_hl = modules.highlight.get_stl_default_hl(is_focused)
end
if next_hl == nil then
next_hl = modules.highlight.get_stl_default_hl(is_focused)
end
if #next_hl == 0 or #last_hl == 0 then
return
end
local transitional_highlight = reverse -- lua ternary assignment x ? y : z
and modules.highlight.get_transitional_highlights(last_hl, next_hl)
or modules.highlight.get_transitional_highlights(next_hl, last_hl)
if transitional_highlight then
return transitional_highlight .. sep
end
end
--- processes statusline string
--- replaces %z/Z{sep} with proper left/right separator highlight + sep
---@param status string : unprocessed statusline string
---@return string : processed statusline string
local function apply_transitional_separators(status, is_focused)
local status_applied = {} -- Collects all the pieces for concatenation
local last_hl -- Stores last highlight group that we found
local last_hl_reseted = false -- Whether last_hl is nil after reset
-- it after %=
local copied_pos = 1 -- Tracks how much we've copied over to status_applied
local str_checked = 1 -- Tracks where the searcher head is at
-- Process entire status replace the %z{sep} & %Z{sep} placeholders
-- with proper transitional separator.
while str_checked ~= nil do
str_checked = status:find('%%', str_checked)
if str_checked == nil then
break
end
table.insert(status_applied, status:sub(copied_pos, str_checked - 1))
-- -1 so we don't copy '%'
copied_pos = str_checked
local next_char = modules.utils.charAt(status, str_checked + 1)
if next_char == '#' then
-- %#hl_name# highlights
last_hl = status:match('^%%#(.-)#', str_checked)
str_checked = str_checked + #last_hl + 3
elseif next_char == 'z' then
-- %z{sep} is marker for left separator and
local sep = status:match('^%%z{(.-)}', str_checked)
str_checked = str_checked + #sep + 4 -- 4 = len(%{})
if not (last_hl == nil and last_hl_reseted) then
local trans_sep = fill_section_separator(status, is_focused, str_checked, last_hl, sep, false)
if trans_sep then
table.insert(status_applied, trans_sep)
end
end
if last_hl_reseted then
last_hl_reseted = false
end
copied_pos = str_checked
elseif next_char == 'Z' then
-- %Z{sep} is marker for right separator and
local sep = status:match('^%%Z{(.-)}', str_checked)
str_checked = str_checked + #sep + 4 -- 4 = len(%{})
if status:find('^%%z', str_checked) or status:find('^%%<%%Z', str_checked) then
-- When transitional right_sep and left_sep are right next to each other
-- and in this exact order skip the left sep as we can't draw both.
str_checked = status:find('}', str_checked) + 1
end
local trans_sep = fill_section_separator(status, is_focused, str_checked, last_hl, sep, true)
if trans_sep then
table.insert(status_applied, trans_sep)
end
copied_pos = str_checked
elseif next_char == '%' then
str_checked = str_checked + 2 -- Skip the following % too
elseif next_char == '=' and last_hl and (last_hl:find('^lualine_a') or last_hl:find('^lualine_b')) then
-- TODO: Fix this properly
-- This check for lualine_a and lualine_b is dumb. It doesn't guarantee
-- c or x section isn't present. Worst case scenario after this patch
-- we have another visual bug that occurs less frequently.
-- Annoying Edge Cases
last_hl = nil
last_hl_reseted = true
str_checked = str_checked + 1 -- Skip the following % too
else
str_checked = str_checked + 1 -- Push it forward to avoid inf loop
end
end
table.insert(status_applied, status:sub(copied_pos)) -- Final chunk
return table.concat(status_applied)
end
--- creates the statusline string
---@param sections table : section config where components are replaced with
--- component objects
---@param is_focused boolean : whether being evaluated for focused window or not
---@return string statusline string
local statusline = modules.utils.retry_call_wrap(function(sections, is_focused, is_winbar)
-- The sequence sections should maintain [SECTION_SEQUENCE]
local section_sequence = { 'a', 'b', 'c', 'x', 'y', 'z' }
local status = {}
local applied_midsection_divider = false
local applied_trunc = false
for _, section_name in ipairs(section_sequence) do
if sections['lualine_' .. section_name] then
-- insert highlight+components of this section to status_builder
local section_data =
modules.utils_section.draw_section(sections['lualine_' .. section_name], section_name, is_focused)
if #section_data > 0 then
if not applied_midsection_divider and section_name > 'c' then
applied_midsection_divider = true
section_data = modules.highlight.format_highlight('c', is_focused) .. '%=' .. section_data
end
if not applied_trunc and section_name > 'b' then
applied_trunc = true
section_data = '%<' .. section_data
end
table.insert(status, section_data)
end
end
end
if applied_midsection_divider == false and config.options.always_divide_middle ~= false and not is_winbar then
-- When non of section x,y,z is present
table.insert(status, modules.highlight.format_highlight('c', is_focused) .. '%=')
end
return apply_transitional_separators(table.concat(status), is_focused)
end)
--- check if any extension matches the filetype and return proper sections
---@param current_ft string : filetype name of current file
---@param is_focused boolean : whether being evaluated for focused window or not
---@return table|nil : (section_table) section config where components are replaced with
--- component objects
-- TODO: change this so it uses a hash table instead of iteration over list
-- to improve redraws. Add buftype / bufname for extensions
-- or some kind of cond ?
local function get_extension_sections(current_ft, is_focused, sec_name)
for _, extension in ipairs(config.extensions) do
if vim.tbl_contains(extension.filetypes, current_ft) then
if is_focused then
return extension[sec_name]
else
return extension['inactive_' .. sec_name] or extension[sec_name]
end
end
end
return nil
end
---@return string statusline string for tabline
local function tabline()
return statusline(config.tabline, 3)
end
local function notify_theme_error(theme_name)
local message_template = theme_name ~= 'auto'
and [[
### options.theme
Theme `%s` not found, falling back to `auto`. Check if spelling is right.
]]
or [[
### options.theme
Theme `%s` failed, falling back to `gruvbox`.
This shouldn't happen.
Please report the issue at https://github.com/nvim-lualine/lualine.nvim/issues .
Also provide what colorscheme you're using.
]]
modules.utils_notices.add_notice(string.format(message_template, theme_name))
end
--- Sets up theme by defining hl groups and setting theme cache in 'highlight.lua'.
--- Uses 'options.theme' variable to apply the theme:
--- - If the value is a string, it'll load a theme of that name.
--- - If it's a table, it's directly used as the theme.
--- If loading the theme fails, this falls back to 'auto' theme.
--- If the 'auto' theme also fails, this falls back to 'gruvbox' theme.
--- Also sets up auto command to reload lualine on ColorScheme or background changes.
local function setup_theme()
local function get_theme_from_config()
local theme_name = config.options.theme
if type(theme_name) == 'string' then
local ok, theme = pcall(modules.loader.load_theme, theme_name)
if ok and theme then
return theme
end
elseif type(theme_name) == 'table' then
-- use the provided theme as-is
return config.options.theme
elseif type(theme_name) == 'function' then
-- call function and use returned (dynamic) theme as-is
return config.options.theme()
end
if theme_name ~= 'auto' then
notify_theme_error(theme_name)
local ok, theme = pcall(modules.loader.load_theme, 'auto')
if ok and theme then
return theme
end
end
notify_theme_error('auto')
return modules.loader.load_theme('gruvbox')
end
local theme = get_theme_from_config()
modules.highlight.create_highlight_groups(theme)
vim.cmd([[autocmd lualine ColorScheme * lua require'lualine'.setup()
autocmd lualine OptionSet background lua require'lualine'.setup()]])
end
---@alias StatusDispatchSecs
---| 'sections'
---| 'winbar'
--- generates lualine.statusline & lualine.winbar function
--- creates a closer that can draw sections of sec_name.
---@param sec_name StatusDispatchSecs
---@return function(focused:bool):string
local function status_dispatch(sec_name)
return function(focused)
local retval
local current_ft = refresh_real_curwin
and vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(refresh_real_curwin), 'filetype')
or vim.bo.filetype
local is_focused = focused ~= nil and focused or modules.utils.is_focused()
if
vim.tbl_contains(
config.options.disabled_filetypes[(sec_name == 'sections' and 'statusline' or sec_name)],
current_ft
)
then
-- disable on specific filetypes
return nil
end
local extension_sections = get_extension_sections(current_ft, is_focused, sec_name)
if extension_sections ~= nil then
retval = statusline(extension_sections, is_focused, sec_name == 'winbar')
else
retval = statusline(config[(is_focused and '' or 'inactive_') .. sec_name], is_focused, sec_name == 'winbar')
end
return retval
end
end
---@alias LualineRefreshOptsKind
---| 'all'
---| 'tabpage'
---| 'window'
---@alias LualineRefreshOptsPlace
---| 'statusline'
---| 'tabline'
---| 'winbar'
---@class LualineRefreshOpts
---@field scope LualineRefreshOptsKind
---@field place LualineRefreshOptsPlace[]
---@field trigger 'autocmd'|'autocmd_redired'|'timer'|'unknown'
--- Refresh contents of lualine
---@param opts LualineRefreshOpts
local function refresh(opts)
if opts == nil then
opts = {}
end
opts = vim.tbl_extend('keep', opts, {
scope = 'tabpage',
place = { 'statusline', 'winbar', 'tabline' },
trigger = 'unknown',
})
-- updating statusline in autocommands context seems to trigger 100 different bugs
-- lets just defer it to a timer context and update there
-- Since updating stl in command mode doesn't take effect
-- refresh ModeChanged command in autocmd context as exception.
-- workaround for
-- https://github.com/neovim/neovim/issues/15300
-- https://github.com/neovim/neovim/issues/19464
-- https://github.com/nvim-lualine/lualine.nvim/issues/753
-- https://github.com/nvim-lualine/lualine.nvim/issues/751
-- https://github.com/nvim-lualine/lualine.nvim/issues/755
-- https://github.com/neovim/neovim/issues/19472
-- https://github.com/nvim-lualine/lualine.nvim/issues/791
if
opts.trigger == 'autocmd'
and vim.v.event.new_mode ~= 'c'
-- scheduling in op-pending mode seems to call the callback forever.
-- so this is restricted in op-pending mode.
-- https://github.com/neovim/neovim/issues/22263
-- https://github.com/nvim-lualine/lualine.nvim/issues/967
-- note this breaks mode component while switching to op-pending mode
and not vim.tbl_contains({ 'no', 'nov', 'noV' }, vim.v.event.new_mode)
and not vim.tbl_contains({ 'no', 'nov', 'noV' }, vim.v.event.old_mode)
then
opts.trigger = 'autocmd_redired'
vim.schedule(function()
M.refresh(opts)
end)
return
end
local wins = {}
local old_actual_curwin = vim.g.actual_curwin
-- ignore focus on filetypes listed in options.ignore_focus
local curwin = vim.api.nvim_get_current_win()
local curtab = vim.api.nvim_get_current_tabpage()
if last_focus[curtab] == nil or not vim.api.nvim_win_is_valid(last_focus[curtab]) then
if
not vim.tbl_contains(
config.options.ignore_focus,
vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(curwin), 'filetype')
)
then
last_focus[curtab] = curwin
else
local tab_wins = vim.api.nvim_tabpage_list_wins(curtab)
if #tab_wins == 1 then
last_focus[curtab] = curwin
else
local focusable_win = curwin
for _, win in ipairs(tab_wins) do
if
not vim.tbl_contains(
config.options.ignore_focus,
vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(win), 'filetype')
)
then
focusable_win = win
break
end
end
last_focus[curtab] = focusable_win
end
end
else
if
not vim.tbl_contains(
config.options.ignore_focus,
vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(curwin), 'filetype')
)
then
last_focus[curtab] = curwin
end
end
vim.g.actual_curwin = last_focus[curtab]
-- gather which windows needs update
if opts.scope == 'all' then
if vim.tbl_contains(opts.place, 'statusline') or vim.tbl_contains(opts.place, 'winbar') then
wins = vim.tbl_filter(function(win)
return vim.fn.win_gettype(win) ~= 'popup'
end, vim.api.nvim_list_wins())
end
elseif opts.scope == 'tabpage' then
if vim.tbl_contains(opts.place, 'statusline') or vim.tbl_contains(opts.place, 'winbar') then
wins = vim.tbl_filter(function(win)
return vim.fn.win_gettype(win) ~= 'popup'
end, vim.api.nvim_tabpage_list_wins(0))
end
elseif opts.scope == 'window' then
wins = { curwin }
end
-- update them
if not timers.halt_stl_refresh and vim.tbl_contains(opts.place, 'statusline') then
for _, win in ipairs(wins) do
refresh_real_curwin = config.options.globalstatus and last_focus[curtab] or win
local set_win = config.options.globalstatus
and vim.fn.win_gettype(refresh_real_curwin) == 'popup'
and refresh_real_curwin
or win
local stl_cur = vim.api.nvim_win_call(refresh_real_curwin, M.statusline)
local stl_last = modules.nvim_opts.get_cache('statusline', { window = set_win })
if stl_cur or stl_last then
modules.nvim_opts.set('statusline', stl_cur, { window = set_win })
end
end
end
if not timers.halt_wb_refresh and vim.tbl_contains(opts.place, 'winbar') then
for _, win in ipairs(wins) do
refresh_real_curwin = win
if vim.api.nvim_win_get_height(win) > 1 then
local wbr_cur = vim.api.nvim_win_call(refresh_real_curwin, M.winbar)
local wbr_last = modules.nvim_opts.get_cache('winbar', { window = win })
if wbr_cur or wbr_last then
modules.nvim_opts.set('winbar', wbr_cur, { window = win })
end
end
end
end
if not timers.halt_tal_refresh and vim.tbl_contains(opts.place, 'tabline') then
refresh_real_curwin = curwin
local tbl_cur = vim.api.nvim_win_call(curwin, tabline)
local tbl_last = modules.nvim_opts.get_cache('tabline', { global = true })
if tbl_cur or tbl_last then
modules.nvim_opts.set('tabline', tbl_cur, { global = true })
end
end
vim.g.actual_curwin = old_actual_curwin
refresh_real_curwin = nil
end
--- Sets &tabline option to lualine
---@param hide boolean|nil if should hide tabline
local function set_tabline(hide)
vim.loop.timer_stop(timers.tal_timer)
timers.halt_tal_refresh = true
vim.cmd([[augroup lualine_tal_refresh | exe "autocmd!" | augroup END]])
if not hide and next(config.tabline) ~= nil then
vim.loop.timer_start(
timers.tal_timer,
0,
config.options.refresh.tabline,
modules.utils.timer_call(timers.tal_timer, 'lualine_tal_refresh', function()
refresh { kind = 'tabpage', place = { 'tabline' }, trigger = 'timer' }
end, 3, 'lualine: Failed to refresh tabline')
)
modules.utils.define_autocmd(
default_refresh_events,
'*',
"call v:lua.require'lualine'.refresh({'kind': 'tabpage', 'place': ['tabline'], 'trigger': 'autocmd'})",
'lualine_tal_refresh'
)
modules.nvim_opts.set('showtabline', 2, { global = true })
timers.halt_tal_refresh = false
else
modules.nvim_opts.restore('tabline', { global = true })
modules.nvim_opts.restore('showtabline', { global = true })
end
end
--- Sets &statusline option to lualine
--- adds auto command to redraw lualine on VimResized event
---@param hide boolean|nil if should hide statusline
local function set_statusline(hide)
vim.loop.timer_stop(timers.stl_timer)
timers.halt_stl_refresh = true
vim.cmd([[augroup lualine_stl_refresh | exe "autocmd!" | augroup END]])
if not hide and (next(config.sections) ~= nil or next(config.inactive_sections) ~= nil) then
if vim.go.statusline == '' then
modules.nvim_opts.set('statusline', '%#Normal#', { global = true })
end
if config.options.globalstatus then
modules.nvim_opts.set('laststatus', 3, { global = true })
vim.loop.timer_start(
timers.stl_timer,
0,
config.options.refresh.statusline,
modules.utils.timer_call(timers.stl_timer, 'lualine_stl_refresh', function()
refresh { kind = 'window', place = { 'statusline' }, trigger = 'timer' }
end, 3, 'lualine: Failed to refresh statusline')
)
modules.utils.define_autocmd(
default_refresh_events,
'*',
"call v:lua.require'lualine'.refresh({'kind': 'window', 'place': ['statusline'], 'trigger': 'autocmd'})",
'lualine_stl_refresh'
)
else
modules.nvim_opts.set('laststatus', 2, { global = true })
vim.loop.timer_start(
timers.stl_timer,
0,
config.options.refresh.statusline,
modules.utils.timer_call(timers.stl_timer, 'lualine_stl_refresh', function()
refresh { kind = 'tabpage', place = { 'statusline' }, trigger = 'timer' }
end, 3, 'lualine: Failed to refresh statusline')
)
modules.utils.define_autocmd(
default_refresh_events,
'*',
"call v:lua.require'lualine'.refresh({'kind': 'tabpage', 'place': ['statusline'], 'trigger': 'autocmd'})",
'lualine_stl_refresh'
)
end
timers.halt_stl_refresh = false
else
modules.nvim_opts.restore('statusline', { global = true })
for _, win in ipairs(vim.api.nvim_list_wins()) do
modules.nvim_opts.restore('statusline', { window = win })
end
modules.nvim_opts.restore('laststatus', { global = true })
end
end
--- Sets &winbar option to lualine
---@param hide boolean|nil if should unset winbar
local function set_winbar(hide)
vim.loop.timer_stop(timers.wb_timer)
timers.halt_wb_refresh = true
vim.cmd([[augroup lualine_wb_refresh | exe "autocmd!" | augroup END]])
if not hide and (next(config.winbar) ~= nil or next(config.inactive_winbar) ~= nil) then
vim.loop.timer_start(
timers.wb_timer,
0,
config.options.refresh.winbar,
modules.utils.timer_call(timers.wb_timer, 'lualine_wb_refresh', function()
refresh { kind = 'tabpage', place = { 'winbar' }, trigger = 'timer' }
end, 3, 'lualine: Failed to refresh winbar')
)
modules.utils.define_autocmd(
default_refresh_events,
'*',
"call v:lua.require'lualine'.refresh({'kind': 'tabpage', 'place': ['winbar'], 'trigger': 'autocmd'})",
'lualine_wb_refresh'
)
timers.halt_wb_refresh = false
elseif vim.fn.has('nvim-0.8') == 1 then
modules.nvim_opts.restore('winbar', { global = true })
for _, win in ipairs(vim.api.nvim_list_wins()) do
modules.nvim_opts.restore('winbar', { window = win })
end
end
end
---@alias LualineHideOptsPlace
---| 'statusline'
---| 'tabline'
---| 'winbar'
---@class LualineHideOpts
---@field place LualineHideOptsPlace[]
---@field unhide boolean
---@param opts LualineHideOpts
local function hide(opts)
if opts == nil then
opts = {}
end
opts = vim.tbl_extend('keep', opts, {
place = { 'statusline', 'tabline', 'winbar' },
unhide = false,
})
local hide_fn = {
statusline = set_statusline,
tabline = set_tabline,
winbar = set_winbar,
}
for _, place in ipairs(opts.place) do
if hide_fn[place] then
hide_fn[place](not opts.unhide)
end
end
end
--- Check neovim compatibilitu
local function verify_nvim_version()
if vim.fn.has('nvim-0.7') == 1 then
return true
end
modules.utils_notices.add_notice([[
### Incompatible Neovim version
Lualine supports neovim 0.7 and up. It seems you're using a older version.
Please update to newer version. Or if you have atleast neovim 0.5 you
can use older compatible versions of lualine using compat tags like
`compat-nvim-0.5`, `compat-nvim-0.6`.
]])
return false
end
-- lualine.setup function
--- sets new user config
--- This function doesn't load components/theme etc... They are done before
--- first statusline redraw and after new config. This is more efficient when
--- lualine config is done in several setup calls as chunks. This way
--- we don't initialize components just to throw them away. Instead they are
--- initialized when we know we will use them.
--- sets &last_status to 2
---@param user_config table table
local function setup(user_config)
if package.loaded['lualine.utils.notices'] then
-- When notices module is not loaded there are no notices to clear.
modules.utils_notices.clear_notices()
end
if verify_nvim_version() then
config = modules.config_module.apply_configuration(user_config)
vim.cmd([[augroup lualine | exe "autocmd!" | augroup END]])
setup_theme()
-- load components & extensions
modules.loader.load_all(config)
set_statusline()
set_tabline()
set_winbar()
end
if package.loaded['lualine.utils.notices'] then
modules.utils_notices.notice_message_startup()
end
end
M = {
setup = setup,
statusline = status_dispatch('sections'),
tabline = tabline,
get_config = modules.config_module.get_config,
refresh = refresh,
winbar = status_dispatch('winbar'),
hide = hide,
}
return M

View File

@ -0,0 +1,291 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local lualine_require = require('lualine_require')
local require = lualine_require.require
local M = require('lualine.utils.class'):extend()
local modules = lualine_require.lazy_require {
highlight = 'lualine.highlight',
utils_notices = 'lualine.utils.notices',
fn_store = 'lualine.utils.fn_store',
}
-- Used to provide a unique id for each component
local component_no = 1
function M._reset_components()
component_no = 1
end
-- variable to store component output for manipulation
M.status = ''
function M:__tostring()
local str = 'Component: ' .. self.options.component_name
if self.debug then
str = str .. '\n---------------------\n' .. vim.inspect(self)
end
return str
end
M.__is_lualine_component = true
---initialize new component
---@param options table options for component
function M:init(options)
self.options = options or {}
component_no = component_no + 1
if not self.options.component_name then
self.options.component_name = tostring(component_no)
end
self.component_no = component_no
self:set_separator()
self:create_option_highlights()
self:set_on_click()
end
---sets the default separator for component based on whether the component
---is in left sections or right sections when separator option is omitted.
function M:set_separator()
if self.options.separator == nil then
if self.options.component_separators then
if self.options.self.section < 'x' then
self.options.separator = self.options.component_separators.left
else
self.options.separator = self.options.component_separators.right
end
end
end
end
---creates hl group from color option
function M:create_option_highlights()
-- set custom highlights
if self.options.color then
self.options.color_highlight = self:create_hl(self.options.color)
end
-- setup icon highlight
if type(self.options.icon) == 'table' and self.options.icon.color then
self.options.icon_color_highlight = self:create_hl(self.options.icon.color)
end
end
---Setup on click function so they can be added during drawing.
function M:set_on_click()
if self.options.on_click ~= nil then
if vim.fn.has('nvim-0.8') == 0 then
modules.utils_notices.add_notice(
'### Options.on_click\nSorry `on_click` can only be used in neovim 0.8 or higher.\n'
)
self.options.on_click = nil
return
end
self.on_click_id = modules.fn_store.register_fn(self.component_no, self.options.on_click)
end
end
---adds spaces to left and right of a component
function M:apply_padding()
local padding = self.options.padding
local l_padding, r_padding
if padding == nil then
padding = 1
end
if type(padding) == 'number' then
l_padding, r_padding = padding, padding
elseif type(padding) == 'table' then
l_padding, r_padding = padding.left, padding.right
end
if l_padding then
if self.status:find('%%#.*#') == 1 then
-- When component has changed the highlight at beginning
-- we will add the padding after the highlight
local pre_highlight = vim.fn.matchlist(self.status, [[\(%#.\{-\}#\)]])[2]
self.status = pre_highlight .. string.rep(' ', l_padding) .. self.status:sub(#pre_highlight + 1, #self.status)
else
self.status = string.rep(' ', l_padding) .. self.status
end
end
if r_padding then
self.status = self.status .. string.rep(' ', r_padding)
end
end
---applies custom highlights for component
function M:apply_highlights(default_highlight)
if self.options.color_highlight then
local hl_fmt
hl_fmt, M.color_fn_cache = self:format_hl(self.options.color_highlight)
self.status = hl_fmt .. self.status
end
if type(self.options.separator) ~= 'table' and self.status:find('%%#') then
-- Apply default highlight only when we aren't applying trans sep and
-- the component has changed it's hl. Since we won't be applying
-- regular sep in those cases so ending with default hl isn't necessary
self.status = self.status .. default_highlight
-- Also put it in applied sep so when sep get striped so does the hl
self.applied_separator = default_highlight
end
-- Prepend default hl when the component doesn't start with hl otherwise
-- color in previous component can cause side effect
if not self.status:find('^%%#') then
self.status = default_highlight .. self.status
end
end
---apply icon to component (appends/prepends component with icon)
function M:apply_icon()
local icon = self.options.icon
if self.options.icons_enabled and icon then
if type(icon) == 'table' then
icon = icon[1]
end
if
self.options.icon_color_highlight
and type(self.options.icon) == 'table'
and self.options.icon.align == 'right'
then
self.status = table.concat {
self.status,
' ',
self:format_hl(self.options.icon_color_highlight),
icon,
self:get_default_hl(),
}
elseif self.options.icon_color_highlight then
self.status = table.concat {
self:format_hl(self.options.icon_color_highlight),
icon,
self:get_default_hl(),
' ',
self.status,
}
elseif type(self.options.icon) == 'table' and self.options.icon.align == 'right' then
self.status = table.concat({ self.status, icon }, ' ')
else
self.status = table.concat({ icon, self.status }, ' ')
end
end
end
---apply separator at end of component only when
---custom highlights haven't affected background
function M:apply_separator()
local separator = self.options.separator
if type(separator) == 'table' then
if self.options.separator[2] == '' then
if self.options.self.section < 'x' then
separator = self.options.component_separators.left
else
separator = self.options.component_separators.right
end
else
return
end
end
if separator and #separator > 0 then
self.status = self.status .. separator
self.applied_separator = self.applied_separator .. separator
end
end
---apply transitional separator for the component
function M:apply_section_separators()
if type(self.options.separator) ~= 'table' then
return
end
if self.options.separator.left ~= nil and self.options.separator.left ~= '' then
self.status = string.format('%%z{%s}%s', self.options.separator.left, self.status)
self.strip_previous_separator = true
end
if self.options.separator.right ~= nil and self.options.separator.right ~= '' then
self.status = string.format('%s%%Z{%s}', self.status, self.options.separator.right)
end
end
---Add on click function description to already drawn item
function M:apply_on_click()
if self.on_click_id then
self.status = self:format_fn(self.on_click_id, self.status)
end
end
---remove separator from tail of this component.
---called by lualine.utils.sections.draw_section to manage unnecessary separators
function M:strip_separator()
if not self.applied_separator then
self.applied_separator = ''
end
self.status = self.status:sub(1, (#self.status - #self.applied_separator))
self.applied_separator = nil
return self.status
end
function M:get_default_hl()
if self.options.color_highlight then
return self:format_hl(self.options.color_highlight)
elseif self.default_hl then
return self.default_hl
else
return modules.highlight.format_highlight(self.options.self.section)
end
end
---create a lualine highlight for color
---@param color table|string|function defined color for hl
---@param hint string|nil hint for hl name
---@return table an identifier to later retrieve the hl for application
function M:create_hl(color, hint)
hint = hint and self.options.component_name .. '_' .. hint or self.options.component_name
return modules.highlight.create_component_highlight_group(color, hint, self.options, false)
end
---Get stl formatted hl group for hl_token
---@param hl_token table identifier received from create_hl or create_component_highlight_group
---@return string stl formatted hl group for hl_token
function M:format_hl(hl_token)
return modules.highlight.component_format_highlight(hl_token)
end
---Wrap str with click format for function of id
---@param id number
---@param str string
---@return string
function M:format_fn(id, str)
return string.format("%%%d@v:lua.require'lualine.utils.fn_store'.call_fn@%s%%T", id, str)
end
-- luacheck: push no unused args
---actual function that updates a component. Must be overwritten with component functionality
function M:update_status(is_focused) end
-- luacheck: pop
---driver code of the class
---@param default_highlight string default hl group of section where component resides
---@param is_focused boolean|number whether drawing for active or inactive statusline.
---@return string stl formatted rendering string for component
function M:draw(default_highlight, is_focused)
self.status = ''
self.applied_separator = ''
if self.options.cond ~= nil and self.options.cond() ~= true then
return self.status
end
self.default_hl = default_highlight
local status = self:update_status(is_focused)
if self.options.fmt then
status = self.options.fmt(status or '', self)
end
if type(status) == 'string' and (#status > 0 or self.options.draw_empty) then
self.status = status
if #status > 0 then
self:apply_icon()
self:apply_padding()
end
self:apply_on_click()
self:apply_highlights(default_highlight)
self:apply_section_separators()
self:apply_separator()
end
return self.status
end
return M

View File

@ -0,0 +1,149 @@
local M = {}
local require = require('lualine_require').require
local utils = require('lualine.utils.utils')
-- vars
local current_git_branch = ''
local current_git_dir = ''
local branch_cache = {} -- stores last known branch for a buffer
local active_bufnr = '0'
-- os specific path separator
local sep = package.config:sub(1, 1)
-- event watcher to watch head file
-- Use file watch for non Windows and poll for Windows.
-- Windows doesn't like file watch for some reason.
local file_changed = sep ~= '\\' and vim.loop.new_fs_event() or vim.loop.new_fs_poll()
local git_dir_cache = {} -- Stores git paths that we already know of
---sets git_branch variable to branch name or commit hash if not on branch
---@param head_file string full path of .git/HEAD file
local function get_git_head(head_file)
local f_head = io.open(head_file)
if f_head then
local HEAD = f_head:read()
f_head:close()
local branch = HEAD:match('ref: refs/heads/(.+)$')
if branch then
current_git_branch = branch
else
current_git_branch = HEAD:sub(1, 6)
end
end
return nil
end
---updates the current value of git_branch and sets up file watch on HEAD file
local function update_branch()
active_bufnr = tostring(vim.api.nvim_get_current_buf())
file_changed:stop()
local git_dir = current_git_dir
if git_dir and #git_dir > 0 then
local head_file = git_dir .. sep .. 'HEAD'
get_git_head(head_file)
file_changed:start(
head_file,
sep ~= '\\' and {} or 1000,
vim.schedule_wrap(function()
-- reset file-watch
update_branch()
end)
)
else
-- set to '' when git dir was not found
current_git_branch = ''
end
branch_cache[vim.api.nvim_get_current_buf()] = current_git_branch
end
---updates the current value of current_git_branch and sets up file watch on HEAD file if value changed
local function update_current_git_dir(git_dir)
if current_git_dir ~= git_dir then
current_git_dir = git_dir
update_branch()
end
end
---returns full path to git directory for dir_path or current directory
---@param dir_path string|nil
---@return string|nil
function M.find_git_dir(dir_path)
local git_dir = vim.env.GIT_DIR
if git_dir then
update_current_git_dir(git_dir)
return git_dir
end
-- get file dir so we can search from that dir
local file_dir = dir_path or vim.fn.expand('%:p:h')
-- extract correct file dir from terminals
if file_dir and file_dir:match('term://.*') then
file_dir = vim.fn.expand(file_dir:gsub('term://(.+)//.+', '%1'))
end
local root_dir = file_dir
-- Search upward for .git file or folder
while root_dir do
if git_dir_cache[root_dir] then
git_dir = git_dir_cache[root_dir]
break
end
local git_path = root_dir .. sep .. '.git'
local git_file_stat = vim.loop.fs_stat(git_path)
if git_file_stat then
if git_file_stat.type == 'directory' then
git_dir = git_path
elseif git_file_stat.type == 'file' then
-- separate git-dir or submodule is used
local file = io.open(git_path)
if file then
git_dir = file:read()
git_dir = git_dir and git_dir:match('gitdir: (.+)$')
file:close()
end
-- submodule / relative file path
if git_dir and git_dir:sub(1, 1) ~= sep and not git_dir:match('^%a:.*$') then
git_dir = git_path:match('(.*).git') .. git_dir
end
end
if git_dir then
local head_file_stat = vim.loop.fs_stat(git_dir .. sep .. 'HEAD')
if head_file_stat and head_file_stat.type == 'file' then
break
else
git_dir = nil
end
end
end
root_dir = root_dir:match('(.*)' .. sep .. '.-')
end
git_dir_cache[file_dir] = git_dir
if dir_path == nil then
update_current_git_dir(git_dir)
end
return git_dir
end
---initializes git_branch module
function M.init()
-- run watch head on load so branch is present when component is loaded
M.find_git_dir()
-- update branch state of BufEnter as different Buffer may be on different repos
utils.define_autocmd('BufEnter', "lua require'lualine.components.branch.git_branch'.find_git_dir()")
end
function M.get_branch(bufnr)
if vim.g.actual_curbuf ~= nil and active_bufnr ~= vim.g.actual_curbuf then
-- Workaround for https://github.com/nvim-lualine/lualine.nvim/issues/286
-- See upstream issue https://github.com/neovim/neovim/issues/15300
-- Diff is out of sync re sync it.
M.find_git_dir()
end
if bufnr then
return branch_cache[bufnr] or ''
end
return current_git_branch
end
return M

View File

@ -0,0 +1,25 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend()
local modules = require('lualine_require').lazy_require {
git_branch = 'lualine.components.branch.git_branch',
highlight = 'lualine.highlight',
utils = 'lualine.utils.utils',
}
-- Initializer
M.init = function(self, options)
M.super.init(self, options)
if not self.options.icon then
self.options.icon = '' -- e0a0
end
modules.git_branch.init()
end
M.update_status = function(_, is_focused)
local buf = (not is_focused and vim.api.nvim_get_current_buf())
local branch = modules.git_branch.get_branch(buf)
return modules.utils.stl_escape(branch)
end
return M

View File

@ -0,0 +1,192 @@
local Buffer = require('lualine.utils.class'):extend()
local modules = require('lualine_require').lazy_require {
highlight = 'lualine.highlight',
utils = 'lualine.utils.utils',
}
---initialize a new buffer from opts
---@param opts table
function Buffer:init(opts)
assert(opts.bufnr, 'Cannot create Buffer without bufnr')
self.bufnr = opts.bufnr
self.buf_index = opts.buf_index
self.options = opts.options
self.highlights = opts.highlights
self:get_props()
end
function Buffer:is_current()
return vim.api.nvim_get_current_buf() == self.bufnr
end
function Buffer:is_alternate()
return vim.fn.bufnr('#') == self.bufnr and not self:is_current()
end
---setup icons, modified status for buffer
function Buffer:get_props()
self.file = modules.utils.stl_escape(vim.api.nvim_buf_get_name(self.bufnr))
self.buftype = vim.api.nvim_buf_get_option(self.bufnr, 'buftype')
self.filetype = vim.api.nvim_buf_get_option(self.bufnr, 'filetype')
local modified = self.options.show_modified_status and vim.api.nvim_buf_get_option(self.bufnr, 'modified')
self.modified_icon = modified and self.options.symbols.modified or ''
self.alternate_file_icon = self:is_alternate() and self.options.symbols.alternate_file or ''
self.icon = ''
if self.options.icons_enabled then
local dev
local status, _ = pcall(require, 'nvim-web-devicons')
if not status then
dev, _ = '', ''
elseif self.filetype == 'TelescopePrompt' then
dev, _ = require('nvim-web-devicons').get_icon('telescope')
elseif self.filetype == 'fugitive' then
dev, _ = require('nvim-web-devicons').get_icon('git')
elseif self.filetype == 'vimwiki' then
dev, _ = require('nvim-web-devicons').get_icon('markdown')
elseif self.buftype == 'terminal' then
dev, _ = require('nvim-web-devicons').get_icon('zsh')
elseif vim.fn.isdirectory(self.file) == 1 then
dev, _ = self.options.symbols.directory, nil
else
dev, _ = require('nvim-web-devicons').get_icon(self.file, vim.fn.expand('#' .. self.bufnr .. ':e'))
end
if dev then
self.icon = dev .. ' '
end
end
end
---returns line configured for handling mouse click
---@param name string
---@return string
function Buffer:configure_mouse_click(name)
return string.format('%%%s@LualineSwitchBuffer@%s%%T', self.bufnr, name)
end
---returns rendered buffer
---@return string
function Buffer:render()
local name = self:name()
if self.options.fmt then
name = self.options.fmt(name or '', self)
end
if self.ellipse then -- show ellipsis
name = '...'
else
name = self:apply_mode(name)
end
name = Buffer.apply_padding(name, self.options.padding)
self.len = vim.fn.strchars(name)
-- setup for mouse clicks
local line = self:configure_mouse_click(name)
-- apply highlight
line = modules.highlight.component_format_highlight(self.highlights[(self.current and 'active' or 'inactive')])
.. line
-- apply separators
if self.options.self.section < 'x' and not self.first then
local sep_before = self:separator_before()
line = sep_before .. line
self.len = self.len + vim.fn.strchars(sep_before)
elseif self.options.self.section >= 'x' and not self.last then
local sep_after = self:separator_after()
line = line .. sep_after
self.len = self.len + vim.fn.strchars(sep_after)
end
return line
end
---apply separator before current buffer
---@return string
function Buffer:separator_before()
if self.current or self.aftercurrent then
return '%Z{' .. self.options.section_separators.left .. '}'
else
return self.options.component_separators.left
end
end
---apply separator after current buffer
---@return string
function Buffer:separator_after()
if self.current or self.beforecurrent then
return '%z{' .. self.options.section_separators.right .. '}'
else
return self.options.component_separators.right
end
end
---returns name of current buffer after filtering special buffers
---@return string
function Buffer:name()
if self.options.filetype_names[self.filetype] then
return self.options.filetype_names[self.filetype]
elseif self.buftype == 'help' then
return 'help:' .. vim.fn.fnamemodify(self.file, ':t:r')
elseif self.buftype == 'terminal' then
local match = string.match(vim.split(self.file, ' ')[1], 'term:.*:(%a+)')
return match ~= nil and match or vim.fn.fnamemodify(vim.env.SHELL, ':t')
elseif self.buftype == 'quickfix' then
local is_loclist = 0 ~= vim.fn.getloclist(0, { filewinid = 1 }).filewinid
return is_loclist and 'Location list' or 'Quickfix List'
elseif vim.fn.isdirectory(self.file) == 1 then
return vim.fn.fnamemodify(self.file, ':p:.')
elseif self.file == '' then
return '[No Name]'
end
local name
if self.options.show_filename_only then
name = vim.fn.fnamemodify(self.file, ':t')
else
name = vim.fn.pathshorten(vim.fn.fnamemodify(self.file, ':p:.'))
end
if self.options.hide_filename_extension then
name = vim.fn.fnamemodify(name, ':r')
end
return name
end
---adds spaces to left and right
function Buffer.apply_padding(str, padding)
local l_padding, r_padding = 1, 1
if type(padding) == 'number' then
l_padding, r_padding = padding, padding
elseif type(padding) == 'table' then
l_padding, r_padding = padding.left or 0, padding.right or 0
end
return string.rep(' ', l_padding) .. str .. string.rep(' ', r_padding)
end
function Buffer:apply_mode(name)
if self.options.mode == 0 then
return string.format('%s%s%s%s', self.alternate_file_icon, self.icon, name, self.modified_icon)
end
if self.options.mode == 1 then
return string.format('%s%s %s%s', self.alternate_file_icon, self.buf_index or '', self.icon, self.modified_icon)
end
if self.options.mode == 2 then
return string.format(
'%s%s %s%s%s',
self.alternate_file_icon,
self.buf_index or '',
self.icon,
name,
self.modified_icon
)
end
if self.options.mode == 3 then
return string.format('%s%s %s%s', self.alternate_file_icon, self.bufnr or '', self.icon, self.modified_icon)
end
-- if self.options.mode == 4 then
return string.format('%s%s %s%s%s', self.alternate_file_icon, self.bufnr or '', self.icon, name, self.modified_icon)
end
return Buffer

View File

@ -0,0 +1,245 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local require = require('lualine_require').require
local Buffer = require('lualine.components.buffers.buffer')
local M = require('lualine.component'):extend()
local highlight = require('lualine.highlight')
local default_options = {
show_filename_only = true,
hide_filename_extension = false,
show_modified_status = true,
mode = 0,
max_length = 0,
filetype_names = {
TelescopePrompt = 'Telescope',
dashboard = 'Dashboard',
packer = 'Packer',
fzf = 'FZF',
alpha = 'Alpha',
},
use_mode_colors = false,
buffers_color = {
active = nil,
inactive = nil,
},
symbols = {
modified = '',
alternate_file = '#',
directory = '',
},
}
-- This function is duplicated in tabs
---returns the proper hl for buffer in section. Used for setting default highlights
---@param section string name of section buffers component is in
---@param is_active boolean
---@return string hl name
local function get_hl(section, is_active)
local suffix = is_active and highlight.get_mode_suffix() or '_inactive'
local section_redirects = {
lualine_x = 'lualine_c',
lualine_y = 'lualine_b',
lualine_z = 'lualine_a',
}
if section_redirects[section] then
section = highlight.highlight_exists(section .. suffix) and section or section_redirects[section]
end
return section .. suffix
end
function M:init(options)
M.super.init(self, options)
-- if use_mode_colors is set, use a function so that the colors update
local default_active = options.use_mode_colors
and function()
return get_hl('lualine_' .. options.self.section, true)
end
or get_hl('lualine_' .. options.self.section, true)
default_options.buffers_color = {
active = default_active,
inactive = get_hl('lualine_' .. options.self.section, false),
}
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
if self.options.component_name == 'buffers' then
self.highlights = {
active = self:create_hl(self.options.buffers_color.active, 'active'),
inactive = self:create_hl(self.options.buffers_color.inactive, 'inactive'),
}
end
end
function M:new_buffer(bufnr, buf_index)
bufnr = bufnr or vim.api.nvim_get_current_buf()
buf_index = buf_index or ''
return Buffer:new {
bufnr = bufnr,
buf_index = buf_index,
options = self.options,
highlights = self.highlights,
}
end
function M:buffers()
local buffers = {}
M.bufpos2nr = {}
for b = 1, vim.fn.bufnr('$') do
if vim.fn.buflisted(b) ~= 0 and vim.api.nvim_buf_get_option(b, 'buftype') ~= 'quickfix' then
buffers[#buffers + 1] = self:new_buffer(b, #buffers + 1)
M.bufpos2nr[#buffers] = b
end
end
return buffers
end
function M:update_status()
local data = {}
local buffers = self:buffers()
local current = -2
-- mark the first, last, current, before current, after current buffers
-- for rendering
if buffers[1] then
buffers[1].first = true
end
if buffers[#buffers] then
buffers[#buffers].last = true
end
for i, buffer in ipairs(buffers) do
if buffer:is_current() then
buffer.current = true
current = i
end
end
if buffers[current - 1] then
buffers[current - 1].beforecurrent = true
end
if buffers[current + 1] then
buffers[current + 1].aftercurrent = true
end
local max_length = self.options.max_length
if type(max_length) == 'function' then
max_length = max_length(self)
end
if max_length == 0 then
max_length = math.floor(2 * vim.o.columns / 3)
end
local total_length
for i, buffer in pairs(buffers) do
if buffer.current then
current = i
end
end
-- start drawing from current buffer and draw left and right of it until
-- all buffers are drawn or max_length has been reached.
if current == -2 then
local b = self:new_buffer()
b.current = true
if self.options.self.section < 'x' then
b.last = true
if #buffers > 0 then
buffers[#buffers].last = nil
end
buffers[#buffers + 1] = b
current = #buffers
else
b.first = true
if #buffers > 0 then
buffers[1].first = nil
end
table.insert(buffers, 1, b)
current = 1
end
end
local current_buffer = buffers[current]
data[#data + 1] = current_buffer:render()
total_length = current_buffer.len
local i = 0
local before, after
while true do
i = i + 1
before = buffers[current - i]
after = buffers[current + i]
local rendered_before, rendered_after
if before == nil and after == nil then
break
end
-- draw left most undrawn buffer if fits in max_length
if before then
rendered_before = before:render()
total_length = total_length + before.len
if total_length > max_length then
break
end
table.insert(data, 1, rendered_before)
end
-- draw right most undrawn buffer if fits in max_length
if after then
rendered_after = after:render()
total_length = total_length + after.len
if total_length > max_length then
break
end
data[#data + 1] = rendered_after
end
end
-- draw ellipsis (...) on relevant sides if all buffers don't fit in max_length
if total_length > max_length then
if before ~= nil then
before.ellipse = true
before.first = true
table.insert(data, 1, before:render())
end
if after ~= nil then
after.ellipse = true
after.last = true
data[#data + 1] = after:render()
end
end
return table.concat(data)
end
function M:draw()
self.status = ''
self.applied_separator = ''
if self.options.cond ~= nil and self.options.cond() ~= true then
return self.status
end
local status = self:update_status()
if type(status) == 'string' and #status > 0 then
self.status = status
self:apply_section_separators()
self:apply_separator()
end
return self.status
end
function M.buffer_jump(buf_pos, bang)
if buf_pos == '$' then
buf_pos = #M.bufpos2nr
else
buf_pos = tonumber(buf_pos)
end
if buf_pos < 1 or buf_pos > #M.bufpos2nr then
if bang ~= '!' then
error('Error: Unable to jump buffer position out of range')
else
return
end
end
vim.api.nvim_set_current_buf(M.bufpos2nr[buf_pos])
end
vim.cmd([[
function! LualineSwitchBuffer(bufnr, mouseclicks, mousebutton, modifiers)
execute ":buffer " . a:bufnr
endfunction
command! -nargs=1 -bang LualineBuffersJump call v:lua.require'lualine.components.buffers'.buffer_jump(<f-args>, "<bang>")
]])
return M

View File

@ -0,0 +1,31 @@
-- Copyright (c) 2023 Willothy
-- MIT license, see LICENSE for more details.
local lualine_require = require('lualine_require')
local M = lualine_require.require('lualine.component'):extend()
local default_options = {
-- default, us, uk, iso, or format (ex. "%d/%m/%Y ...")
style = 'default',
}
function M:init(options)
M.super.init(self, options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
end
function M:update_status()
local fmt = self.options.style
if self.options.style == 'default' then
fmt = '%A, %B %d | %H:%M'
elseif self.options.style == 'us' then
fmt = '%m/%d/%Y'
elseif self.options.style == 'uk' then
fmt = '%d/%m/%Y'
elseif self.options.style == 'iso' then
fmt = '%Y-%m-%d'
end
return os.date(fmt)
end
return M

View File

@ -0,0 +1,59 @@
local require = require('lualine_require').require
local utils = require('lualine.utils.utils')
local M = {}
-- default symbols for diagnostics component
M.symbols = {
icons = {
error = '󰅚 ', -- x000f015a
warn = '󰀪 ', -- x000f002a
info = '󰋽 ', -- x000f02fd
hint = '󰌶 ', -- x000f0336
},
no_icons = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' },
}
-- default options for diagnostics component
M.options = {
colored = true,
update_in_insert = false,
always_visible = false,
sources = { 'nvim_diagnostic', 'coc' },
sections = { 'error', 'warn', 'info', 'hint' },
}
function M.apply_default_colors(opts)
local default_diagnostics_color = {
error = {
fg = utils.extract_color_from_hllist(
{ 'fg', 'sp' },
{ 'DiagnosticError', 'LspDiagnosticsDefaultError', 'DiffDelete' },
'#e32636'
),
},
warn = {
fg = utils.extract_color_from_hllist(
{ 'fg', 'sp' },
{ 'DiagnosticWarn', 'LspDiagnosticsDefaultWarning', 'DiffText' },
'#ffa500'
),
},
info = {
fg = utils.extract_color_from_hllist(
{ 'fg', 'sp' },
{ 'DiagnosticInfo', 'LspDiagnosticsDefaultInformation', 'Normal' },
'#ffffff'
),
},
hint = {
fg = utils.extract_color_from_hllist(
{ 'fg', 'sp' },
{ 'DiagnosticHint', 'LspDiagnosticsDefaultHint', 'DiffChange' },
'#273faf'
),
},
}
opts.diagnostics_color = vim.tbl_deep_extend('keep', opts.diagnostics_color or {}, default_diagnostics_color)
end
return M

View File

@ -0,0 +1,111 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local lualine_require = require('lualine_require')
local modules = lualine_require.lazy_require {
default_config = 'lualine.components.diagnostics.config',
sources = 'lualine.components.diagnostics.sources',
highlight = 'lualine.highlight',
utils = 'lualine.utils.utils',
utils_notices = 'lualine.utils.notices',
}
local M = lualine_require.require('lualine.component'):extend()
M.diagnostics_sources = modules.sources.sources
M.get_diagnostics = modules.sources.get_diagnostics
-- Initializer
function M:init(options)
-- Run super()
M.super.init(self, options)
-- Apply default options
modules.default_config.apply_default_colors(self.options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, modules.default_config.options)
-- Apply default symbols
self.symbols = vim.tbl_extend(
'keep',
self.options.symbols or {},
self.options.icons_enabled ~= false and modules.default_config.symbols.icons
or modules.default_config.symbols.no_icons
)
-- Initialize highlight groups
if self.options.colored then
self.highlight_groups = {
error = self:create_hl(self.options.diagnostics_color.error, 'error'),
warn = self:create_hl(self.options.diagnostics_color.warn, 'warn'),
info = self:create_hl(self.options.diagnostics_color.info, 'info'),
hint = self:create_hl(self.options.diagnostics_color.hint, 'hint'),
}
end
-- Initialize variable to store last update so we can use it in insert
-- mode for no update_in_insert
self.last_diagnostics_count = {}
-- Error out no source
if #self.options.sources < 1 then
modules.utils_notices.add_notice(
'### diagnostics.sources\n\nno sources for diagnostics configured.\nPlease specify which diagnostics source you want lualine to use with `sources` option.\n'
)
end
end
function M:update_status()
local bufnr = vim.api.nvim_get_current_buf()
local diagnostics_count
local result = {}
if self.options.update_in_insert or vim.api.nvim_get_mode().mode:sub(1, 1) ~= 'i' then
local error_count, warning_count, info_count, hint_count = 0, 0, 0, 0
local diagnostic_data = modules.sources.get_diagnostics(self.options.sources)
-- sum all the counts
for _, data in pairs(diagnostic_data) do
error_count = error_count + data.error
warning_count = warning_count + data.warn
info_count = info_count + data.info
hint_count = hint_count + data.hint
end
diagnostics_count = {
error = error_count,
warn = warning_count,
info = info_count,
hint = hint_count,
}
-- Save count for insert mode
self.last_diagnostics_count[bufnr] = diagnostics_count
else -- Use cached count in insert mode with update_in_insert disabled
diagnostics_count = self.last_diagnostics_count[bufnr] or { error = 0, warn = 0, info = 0, hint = 0 }
end
local always_visible = false
if type(self.options.always_visible) == 'boolean' then
always_visible = self.options.always_visible
elseif type(self.options.always_visible) == 'function' then
always_visible = self.options.always_visible()
end
-- format the counts with symbols and highlights
if self.options.colored then
local colors, bgs = {}, {}
for name, hl in pairs(self.highlight_groups) do
colors[name] = self:format_hl(hl)
bgs[name] = modules.utils.extract_highlight_colors(colors[name]:match('%%#(.-)#'), 'bg')
end
local previous_section, padding
for _, section in ipairs(self.options.sections) do
if diagnostics_count[section] ~= nil and (always_visible or diagnostics_count[section] > 0) then
padding = previous_section and (bgs[previous_section] ~= bgs[section]) and ' ' or ''
previous_section = section
table.insert(result, colors[section] .. padding .. self.symbols[section] .. diagnostics_count[section])
end
end
else
for _, section in ipairs(self.options.sections) do
if diagnostics_count[section] ~= nil and (always_visible or diagnostics_count[section] > 0) then
table.insert(result, self.symbols[section] .. diagnostics_count[section])
end
end
end
return table.concat(result, ' ')
end
return M

View File

@ -0,0 +1,100 @@
local M = {}
---functions that how how to retrieve diagnostics from specific source.
---returns error_count:number, warning_count:number,
--- info_count:number, hint_count:number
M.sources = {
nvim_lsp = function()
local error_count, warning_count, info_count, hint_count
local diagnostics = vim.diagnostic.get(0)
local count = { 0, 0, 0, 0 }
for _, diagnostic in ipairs(diagnostics) do
if vim.startswith(vim.diagnostic.get_namespace(diagnostic.namespace).name, 'vim.lsp') then
count[diagnostic.severity] = count[diagnostic.severity] + 1
end
end
error_count = count[vim.diagnostic.severity.ERROR]
warning_count = count[vim.diagnostic.severity.WARN]
info_count = count[vim.diagnostic.severity.INFO]
hint_count = count[vim.diagnostic.severity.HINT]
return error_count, warning_count, info_count, hint_count
end,
nvim_workspace_diagnostic = function()
local diag_severity = vim.diagnostic.severity
local function workspace_diag(severity)
local count = vim.diagnostic.get(nil, { severity = severity })
return vim.tbl_count(count)
end
return workspace_diag(diag_severity.ERROR),
workspace_diag(diag_severity.WARN),
workspace_diag(diag_severity.INFO),
workspace_diag(diag_severity.HINT)
end,
nvim_diagnostic = function()
local diagnostics = vim.diagnostic.get(0)
local count = { 0, 0, 0, 0 }
for _, diagnostic in ipairs(diagnostics) do
count[diagnostic.severity] = count[diagnostic.severity] + 1
end
return count[vim.diagnostic.severity.ERROR],
count[vim.diagnostic.severity.WARN],
count[vim.diagnostic.severity.INFO],
count[vim.diagnostic.severity.HINT]
end,
coc = function()
local data = vim.b.coc_diagnostic_info
if data then
return data.error, data.warning, data.information, data.hint
else
return 0, 0, 0, 0
end
end,
ale = function()
local ok, data = pcall(vim.fn['ale#statusline#Count'], vim.api.nvim_get_current_buf())
if ok then
return data.error + data.style_error, data.warning + data.style_warning, data.info, 0
else
return 0, 0, 0, 0
end
end,
vim_lsp = function()
local ok, data = pcall(vim.fn['lsp#get_buffer_diagnostics_counts'])
if ok then
return data.error, data.warning, data.information, data.hint
else
return 0, 0, 0, 0
end
end,
}
---returns list of diagnostics count from all sources
---@param sources table list of sources
---@return table {{error_count, warning_count, info_count, hint_count}}
M.get_diagnostics = function(sources)
local result = {}
for index, source in ipairs(sources) do
if type(source) == 'string' then
local error_count, warning_count, info_count, hint_count = M.sources[source]()
result[index] = {
error = error_count,
warn = warning_count,
info = info_count,
hint = hint_count,
}
elseif type(source) == 'function' then
local source_result = source()
source_result = type(source_result) == 'table' and source_result or {}
result[index] = {
error = source_result.error or 0,
warn = source_result.warn or 0,
info = source_result.info or 0,
hint = source_result.hint or 0,
}
end
end
return result
end
return M

View File

@ -0,0 +1,138 @@
local lualine_require = require('lualine_require')
local modules = lualine_require.lazy_require {
utils = 'lualine.utils.utils',
Job = 'lualine.utils.job',
}
local M = {}
-- Vars
-- variable to store git diff stats
local git_diff = nil
-- accumulates output from diff process
local diff_output_cache = {}
-- variable to store git_diff job
local diff_job = nil
local active_bufnr = '0'
local diff_cache = {} -- Stores last known value of diff of a buffer
---initialize the module
---param opts table
function M.init(opts)
if type(opts.source) == 'function' then
M.src = opts.source
else
modules.utils.define_autocmd('BufEnter', "lua require'lualine.components.diff.git_diff'.update_diff_args()")
modules.utils.define_autocmd('BufWritePost', "lua require'lualine.components.diff.git_diff'.update_git_diff()")
M.update_diff_args()
end
end
---Api to get git sign count
---scheme :
---{
--- added = added_count,
--- modified = modified_count,
--- removed = removed_count,
---}
---error_code = { added = -1, modified = -1, removed = -1 }
---@param bufnr number|nil
function M.get_sign_count(bufnr)
if bufnr then
return diff_cache[bufnr]
end
if M.src then
git_diff = M.src()
diff_cache[vim.api.nvim_get_current_buf()] = git_diff
elseif vim.g.actual_curbuf ~= nil and active_bufnr ~= vim.g.actual_curbuf then
-- Workaround for https://github.com/nvim-lualine/lualine.nvim/issues/286
-- See upstream issue https://github.com/neovim/neovim/issues/15300
-- Diff is out of sync re sync it.
M.update_diff_args()
end
return git_diff
end
---process diff data and update git_diff{ added, removed, modified }
---@param data string output on stdout od git diff job
local function process_diff(data)
-- Adapted from https://github.com/wbthomason/nvim-vcs.lua
local added, removed, modified = 0, 0, 0
for _, line in ipairs(data) do
if string.find(line, [[^@@ ]]) then
local tokens = vim.fn.matchlist(line, [[^@@ -\v(\d+),?(\d*) \+(\d+),?(\d*)]])
local line_stats = {
mod_count = tokens[3] == nil and 0 or tokens[3] == '' and 1 or tonumber(tokens[3]),
new_count = tokens[5] == nil and 0 or tokens[5] == '' and 1 or tonumber(tokens[5]),
}
if line_stats.mod_count == 0 and line_stats.new_count > 0 then
added = added + line_stats.new_count
elseif line_stats.mod_count > 0 and line_stats.new_count == 0 then
removed = removed + line_stats.mod_count
else
local min = math.min(line_stats.mod_count, line_stats.new_count)
modified = modified + min
added = added + line_stats.new_count - min
removed = removed + line_stats.mod_count - min
end
end
end
git_diff = { added = added, modified = modified, removed = removed }
end
---updates the job args
function M.update_diff_args()
-- Don't show git diff when current buffer doesn't have a filename
active_bufnr = tostring(vim.api.nvim_get_current_buf())
if #vim.fn.expand('%') == 0 then
M.diff_args = nil
git_diff = nil
return
end
M.diff_args = {
cmd = string.format(
[[git -C %s --no-pager diff --no-color --no-ext-diff -U0 -- %s]],
vim.fn.expand('%:h'),
vim.fn.expand('%:t')
),
on_stdout = function(_, data)
if next(data) then
diff_output_cache = vim.list_extend(diff_output_cache, data)
end
end,
on_stderr = function(_, data)
data = table.concat(data, '\n')
if #data > 0 then
git_diff = nil
diff_output_cache = {}
end
end,
on_exit = function()
if #diff_output_cache > 0 then
process_diff(diff_output_cache)
else
git_diff = { added = 0, modified = 0, removed = 0 }
end
diff_cache[vim.api.nvim_get_current_buf()] = git_diff
end,
}
M.update_git_diff()
end
---update git_diff variable
function M.update_git_diff()
if M.diff_args then
diff_output_cache = {}
if diff_job then
diff_job:stop()
end
diff_job = modules.Job(M.diff_args)
if diff_job then
diff_job:start()
end
end
end
return M

View File

@ -0,0 +1,93 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local lualine_require = require('lualine_require')
local modules = lualine_require.lazy_require {
git_diff = 'lualine.components.diff.git_diff',
utils = 'lualine.utils.utils',
utils_notices = 'lualine.utils.notices',
highlight = 'lualine.highlight',
}
local M = lualine_require.require('lualine.component'):extend()
local default_options = {
colored = true,
symbols = { added = '+', modified = '~', removed = '-' },
}
local function apply_default_colors(opts)
local default_diff_color = {
added = {
fg = modules.utils.extract_color_from_hllist(
'fg',
{ 'LuaLineDiffAdd', 'GitSignsAdd', 'GitGutterAdd', 'DiffAdded', 'DiffAdd' },
'#90ee90'
),
},
modified = {
fg = modules.utils.extract_color_from_hllist(
'fg',
{ 'LuaLineDiffChange', 'GitSignsChange', 'GitGutterChange', 'DiffChanged', 'DiffChange' },
'#f0e130'
),
},
removed = {
fg = modules.utils.extract_color_from_hllist(
'fg',
{ 'LuaLineDiffDelete', 'GitSignsDelete', 'GitGutterDelete', 'DiffRemoved', 'DiffDelete' },
'#ff0038'
),
},
}
opts.diff_color = vim.tbl_deep_extend('keep', opts.diff_color or {}, default_diff_color)
end
-- Initializer
function M:init(options)
M.super.init(self, options)
apply_default_colors(self.options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
-- create highlights and save highlight_name in highlights table
if self.options.colored then
self.highlights = {
added = self:create_hl(self.options.diff_color.added, 'added'),
modified = self:create_hl(self.options.diff_color.modified, 'modified'),
removed = self:create_hl(self.options.diff_color.removed, 'removed'),
}
end
modules.git_diff.init(self.options)
end
-- Function that runs every time statusline is updated
function M:update_status(is_focused)
local git_diff = modules.git_diff.get_sign_count((not is_focused and vim.api.nvim_get_current_buf()))
if git_diff == nil then
return ''
end
local colors = {}
if self.options.colored then
-- load the highlights and store them in colors table
for name, highlight_name in pairs(self.highlights) do
colors[name] = self:format_hl(highlight_name)
end
end
local result = {}
-- loop though data and load available sections in result table
for _, name in ipairs { 'added', 'modified', 'removed' } do
if git_diff[name] and git_diff[name] > 0 then
if self.options.colored then
table.insert(result, colors[name] .. self.options.symbols[name] .. git_diff[name])
else
table.insert(result, self.options.symbols[name] .. git_diff[name])
end
end
end
if #result > 0 then
return table.concat(result, ' ')
else
return ''
end
end
return M

View File

@ -0,0 +1,7 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local function encoding()
return vim.opt.fileencoding:get()
end
return encoding

View File

@ -0,0 +1,30 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend()
-- stylua: ignore
local symbols = {
unix = '', -- e712
dos = '', -- e70f
mac = '', -- e711
}
-- Initializer
function M:init(options)
-- Run super()
M.super.init(self, options)
-- Apply default symbols
self.symbols = vim.tbl_extend('keep', self.options.symbols or {}, symbols)
end
-- Function that runs every time statusline is updated
function M:update_status()
local format = vim.bo.fileformat
if self.options.icons_enabled then
return self.symbols[format] or format
else
return format
end
end
return M

View File

@ -0,0 +1,119 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend()
local modules = require('lualine_require').lazy_require {
utils = 'lualine.utils.utils',
}
local default_options = {
symbols = {
modified = '[+]',
readonly = '[-]',
unnamed = '[No Name]',
newfile = '[New]',
},
file_status = true,
newfile_status = false,
path = 0,
shorting_target = 40,
}
local function is_new_file()
local filename = vim.fn.expand('%')
return filename ~= '' and vim.bo.buftype == '' and vim.fn.filereadable(filename) == 0
end
---shortens path by turning apple/orange -> a/orange
---@param path string
---@param sep string path separator
---@param max_len integer maximum length of the full filename string
---@return string
local function shorten_path(path, sep, max_len)
local len = #path
if len <= max_len then
return path
end
local segments = vim.split(path, sep)
for idx = 1, #segments - 1 do
if len <= max_len then
break
end
local segment = segments[idx]
local shortened = segment:sub(1, vim.startswith(segment, '.') and 2 or 1)
segments[idx] = shortened
len = len - (#segment - #shortened)
end
return table.concat(segments, sep)
end
local function filename_and_parent(path, sep)
local segments = vim.split(path, sep)
if #segments == 0 then
return path
elseif #segments == 1 then
return segments[#segments]
else
return table.concat({ segments[#segments - 1], segments[#segments] }, sep)
end
end
M.init = function(self, options)
M.super.init(self, options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
end
M.update_status = function(self)
local path_separator = package.config:sub(1, 1)
local data
if self.options.path == 1 then
-- relative path
data = vim.fn.expand('%:~:.')
elseif self.options.path == 2 then
-- absolute path
data = vim.fn.expand('%:p')
elseif self.options.path == 3 then
-- absolute path, with tilde
data = vim.fn.expand('%:p:~')
elseif self.options.path == 4 then
-- filename and immediate parent
data = filename_and_parent(vim.fn.expand('%:p:~'), path_separator)
else
-- just filename
data = vim.fn.expand('%:t')
end
if data == '' then
data = self.options.symbols.unnamed
end
if self.options.shorting_target ~= 0 then
local windwidth = self.options.globalstatus and vim.go.columns or vim.fn.winwidth(0)
local estimated_space_available = windwidth - self.options.shorting_target
data = shorten_path(data, path_separator, estimated_space_available)
end
data = modules.utils.stl_escape(data)
local symbols = {}
if self.options.file_status then
if vim.bo.modified then
table.insert(symbols, self.options.symbols.modified)
end
if vim.bo.modifiable == false or vim.bo.readonly == true then
table.insert(symbols, self.options.symbols.readonly)
end
end
if self.options.newfile_status and is_new_file() then
table.insert(symbols, self.options.symbols.newfile)
end
return data .. (#symbols > 0 and ' ' .. table.concat(symbols, '') or '')
end
return M

View File

@ -0,0 +1,25 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local function filesize()
local file = vim.fn.expand('%:p')
if file == nil or #file == 0 then
return ''
end
local size = vim.fn.getfsize(file)
if size <= 0 then
return ''
end
local suffixes = { 'b', 'k', 'm', 'g' }
local i = 1
while size > 1024 and i < #suffixes do
size = size / 1024
i = i + 1
end
local format = i == 1 and '%d%s' or '%.1f%s'
return string.format(format, size, suffixes[i])
end
return filesize

View File

@ -0,0 +1,82 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local lualine_require = require('lualine_require')
local modules = lualine_require.lazy_require {
highlight = 'lualine.highlight',
utils = 'lualine.utils.utils',
}
local M = lualine_require.require('lualine.component'):extend()
local default_options = {
colored = true,
icon_only = false,
}
function M:init(options)
M.super.init(self, options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
self.icon_hl_cache = {}
end
function M.update_status()
local ft = vim.bo.filetype or ''
return modules.utils.stl_escape(ft)
end
function M:apply_icon()
if not self.options.icons_enabled then
return
end
local icon, icon_highlight_group
local ok, devicons = pcall(require, 'nvim-web-devicons')
if ok then
icon, icon_highlight_group = devicons.get_icon(vim.fn.expand('%:t'))
if icon == nil then
icon, icon_highlight_group = devicons.get_icon_by_filetype(vim.bo.filetype)
end
if icon == nil and icon_highlight_group == nil then
icon = ''
icon_highlight_group = 'DevIconDefault'
end
if icon then
icon = icon .. ' '
end
if self.options.colored then
local highlight_color = modules.utils.extract_highlight_colors(icon_highlight_group, 'fg')
if highlight_color then
local default_highlight = self:get_default_hl()
local icon_highlight = self.icon_hl_cache[highlight_color]
if not icon_highlight or not modules.highlight.highlight_exists(icon_highlight.name .. '_normal') then
icon_highlight = self:create_hl({ fg = highlight_color }, icon_highlight_group)
self.icon_hl_cache[highlight_color] = icon_highlight
end
icon = self:format_hl(icon_highlight) .. icon .. default_highlight
end
end
else
ok = vim.fn.exists('*WebDevIconsGetFileTypeSymbol')
if ok ~= 0 then
icon = vim.fn.WebDevIconsGetFileTypeSymbol()
if icon then
icon = icon .. ' '
end
end
end
if not icon then
return
end
if self.options.icon_only then
self.status = icon
elseif type(self.options.icon) == 'table' and self.options.icon.align == 'right' then
self.status = self.status .. ' ' .. icon
else
self.status = icon .. self.status
end
end
return M

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local modules = require('lualine_require').lazy_require {
utils = 'lualine.utils.utils',
}
local function hostname()
return modules.utils.stl_escape(vim.loop.os_gethostname())
end
return hostname

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local function location()
local line = vim.fn.line('.')
local col = vim.fn.virtcol('.')
return string.format('%3d:%-2d', line, col)
end
return location

View File

@ -0,0 +1,4 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local get_mode = require('lualine.utils.mode').get_mode
return get_mode

View File

@ -0,0 +1,15 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local function progress()
local cur = vim.fn.line('.')
local total = vim.fn.line('$')
if cur == 1 then
return 'Top'
elseif cur == total then
return 'Bot'
else
return string.format('%2d%%%%', math.floor(cur / total * 100))
end
end
return progress

View File

@ -0,0 +1,31 @@
local M = require('lualine.component'):extend()
local default_options = {
maxcount = 999,
timeout = 500,
}
-- Initializer
function M:init(options)
-- Run super()
M.super.init(self, options)
-- Apply default options
self.options = vim.tbl_extend('keep', self.options or {}, default_options)
end
-- Function that runs every time statusline is updated
function M:update_status()
if vim.v.hlsearch == 0 then
return ''
end
local ok, result = pcall(vim.fn.searchcount, { maxcount = self.options.maxcount, timeout = self.options.timeout })
if not ok or next(result) == nil then
return ''
end
local denominator = math.min(result.total, result.maxcount)
return string.format('[%d/%d]', result.current, denominator)
end
return M

View File

@ -0,0 +1,16 @@
local function selectioncount()
local mode = vim.fn.mode(true)
local line_start, col_start = vim.fn.line('v'), vim.fn.col('v')
local line_end, col_end = vim.fn.line('.'), vim.fn.col('.')
if mode:match('') then
return string.format('%dx%d', math.abs(line_start - line_end) + 1, math.abs(col_start - col_end) + 1)
elseif mode:match('V') or line_start ~= line_end then
return math.abs(line_start - line_end) + 1
elseif mode:match('v') then
return math.abs(col_start - col_end) + 1
else
return ''
end
end
return selectioncount

View File

@ -0,0 +1,48 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend()
function M:update_status()
local component = self.options[1]
local ok, status
if self.options.type == nil then
ok, status = pcall(M.lua_eval, component)
if not ok then
status = M.vim_function(component)
end
else
if self.options.type == 'lua_expr' then
ok, status = pcall(M.lua_eval, component)
if not ok then
status = nil
end
elseif self.options.type == 'vim_fun' then
status = M.vim_function(component)
end
end
return status
end
---evaluate the lua code and return it's result as string
---@param code string
---@return string
function M.lua_eval(code)
local result = loadstring('return ' .. code)()
assert(result, 'String expected got nil')
return tostring(result)
end
---call vim function (name) and return it's result as string
---@param name string
---@return string
function M.vim_function(name)
-- vim function component
local ok, return_val = pcall(vim.api.nvim_call_function, name, {})
if not ok then
return ''
end -- function call failed
ok, return_val = pcall(tostring, return_val)
return ok and return_val or ''
end
return M

View File

@ -0,0 +1,21 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local M = require('lualine.component'):extend()
M.update_status = function(self, is_focused)
-- 1st element in options table is the function provided by config
local ok, retval
ok, retval = pcall(self.options[1], self, is_focused)
if not ok then
return ''
end
if type(retval) ~= 'string' then
ok, retval = pcall(tostring, retval)
if not ok then
return ''
end
end
return retval
end
return M

View File

@ -0,0 +1,37 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local require = require('lualine_require').require
local M = require('lualine.component'):extend()
local utils = require('lualine.utils.utils')
function M:update_status()
local component = self.options[1]
-- vim variable component
-- accepts g:, v:, t:, w:, b:, o, go:, vo:, to:, wo:, bo:
-- filters g portion from g:var
local scope = component:match('[gvtwb]?o?')
-- filters var portion from g:var
local var_name = component:sub(#scope + 2, #component)
-- Displays nothing when variable aren't present
if not (scope and var_name) then
return ''
end
-- Support accessing keys within dictionary
-- https://github.com/nvim-lualine/lualine.nvim/issues/25#issuecomment-907374548
local name_chunks = vim.split(var_name, '%.')
local return_val = vim[scope][name_chunks[1]]
for i = 2, #name_chunks do
if return_val == nil then
break
end
return_val = return_val[name_chunks[i]]
end
if return_val == nil then
return ''
end
local ok
ok, return_val = pcall(tostring, return_val)
return ok and utils.stl_escape(return_val) or ''
end
return M

View File

@ -0,0 +1,193 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local require = require('lualine_require').require
local Tab = require('lualine.components.tabs.tab')
local M = require('lualine.component'):extend()
local highlight = require('lualine.highlight')
local default_options = {
max_length = 0,
tab_max_length = 40,
mode = 0,
use_mode_colors = false,
path = 0,
tabs_color = {
active = nil,
inactive = nil,
},
show_modified_status = true,
symbols = {
modified = '[+]',
},
}
-- This function is duplicated in buffers
---returns the proper hl for tab in section. Used for setting default highlights
---@param section string name of section tabs component is in
---@param is_active boolean
---@return string hl name
local function get_hl(section, is_active)
local suffix = is_active and highlight.get_mode_suffix() or '_inactive'
local section_redirects = {
lualine_x = 'lualine_c',
lualine_y = 'lualine_b',
lualine_z = 'lualine_a',
}
if section_redirects[section] then
section = highlight.highlight_exists(section .. suffix) and section or section_redirects[section]
end
return section .. suffix
end
function M:init(options)
M.super.init(self, options)
-- if use_mode_colors is set, use a function so that the colors update
local default_active = options.use_mode_colors
and function()
return get_hl('lualine_' .. options.self.section, true)
end
or get_hl('lualine_' .. options.self.section, true)
default_options.tabs_color = {
active = default_active,
inactive = get_hl('lualine_' .. options.self.section, false),
}
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
-- stylua: ignore
self.highlights = {
active = self:create_hl(self.options.tabs_color.active, 'active'),
inactive = self:create_hl(self.options.tabs_color.inactive, 'inactive'),
}
end
function M:update_status()
local data = {}
local tabs = {}
for nr, id in ipairs(vim.api.nvim_list_tabpages()) do
tabs[#tabs + 1] = Tab { tabId = id, tabnr = nr, options = self.options, highlights = self.highlights }
end
-- mark the first, last, current, before current, after current tabpages
-- for rendering
local current = vim.fn.tabpagenr()
tabs[1].first = true
tabs[#tabs].last = true
if tabs[current] then
tabs[current].current = true
end
if tabs[current - 1] then
tabs[current - 1].beforecurrent = true
end
if tabs[current + 1] then
tabs[current + 1].aftercurrent = true
end
local max_length = self.options.max_length
if type(max_length) == 'function' then
max_length = max_length(self)
end
if max_length == 0 then
max_length = math.floor(vim.o.columns / 3)
end
local total_length
for i, tab in pairs(tabs) do
if tab.current then
current = i
end
end
local current_tab = tabs[current]
-- start drawing from current tab and draw left and right of it until
-- all tabpages are drawn or max_length has been reached.
if current_tab == nil then -- maybe redundant code
local t = Tab {
tabId = vim.api.nvim_get_current_tabpage(),
tabnr = vim.fn.tabpagenr(),
options = self.options,
highlights = self.highlights,
}
t.current = true
t.last = true
data[#data + 1] = t:render()
else
data[#data + 1] = current_tab:render()
total_length = current_tab.len
local i = 0
local before, after
while true do
i = i + 1
before = tabs[current - i]
after = tabs[current + i]
local rendered_before, rendered_after
if before == nil and after == nil then
break
end
-- draw left most undrawn tab if fits in max_length
if before then
rendered_before = before:render()
total_length = total_length + before.len
if total_length > max_length then
break
end
table.insert(data, 1, rendered_before)
end
-- draw right most undrawn tab if fits in max_length
if after then
rendered_after = after:render()
total_length = total_length + after.len
if total_length > max_length then
break
end
data[#data + 1] = rendered_after
end
end
-- draw ellipsis (...) on relevant sides if all tabs don't fit in max_length
if total_length > max_length then
if before ~= nil then
before.ellipse = true
before.first = true
table.insert(data, 1, before:render())
end
if after ~= nil then
after.ellipse = true
after.last = true
data[#data + 1] = after:render()
end
end
end
return table.concat(data)
end
function M:draw()
self.status = ''
self.applied_separator = ''
if self.options.cond ~= nil and self.options.cond() ~= true then
return self.status
end
local status = self:update_status()
if type(status) == 'string' and #status > 0 then
self.status = status
self:apply_section_separators()
self:apply_separator()
end
return self.status
end
vim.cmd([[
function! LualineSwitchTab(tabnr, mouseclicks, mousebutton, modifiers)
execute a:tabnr . "tabnext"
endfunction
function! LualineRenameTab(...)
if a:0 == 1
let t:tabname = a:1
else
unlet t:tabname
end
redrawtabline
endfunction
command! -nargs=? LualineRenameTab call LualineRenameTab("<args>")
]])
return M

View File

@ -0,0 +1,178 @@
local Tab = require('lualine.utils.class'):extend()
local modules = require('lualine_require').lazy_require {
highlight = 'lualine.highlight',
utils = 'lualine.utils.utils',
}
---initialize a new tab from opts
---@param opts table
function Tab:init(opts)
assert(opts.tabnr, 'Cannot create Tab without tabnr')
self.tabnr = opts.tabnr
self.tabId = opts.tabId
self.options = opts.options
self.highlights = opts.highlights
self.modified_icon = ''
self:get_props()
end
function Tab:get_props()
local buflist = vim.fn.tabpagebuflist(self.tabnr)
local winnr = vim.fn.tabpagewinnr(self.tabnr)
local bufnr = buflist[winnr]
self.file = modules.utils.stl_escape(vim.api.nvim_buf_get_name(bufnr))
self.filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
self.buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype')
if self.options.show_modified_status then
for _, b in ipairs(buflist) do
if vim.api.nvim_buf_get_option(b, 'modified') then
self.modified_icon = self.options.symbols.modified or ''
break
end
end
end
end
---returns name for tab. Tabs name is the name of buffer in last active window
--- of the tab.
---@return string
function Tab:label()
local ok, custom_tabname = pcall(vim.api.nvim_tabpage_get_var, self.tabId, 'tabname')
if not ok then
custom_tabname = nil
end
if custom_tabname and custom_tabname ~= '' then
return modules.utils.stl_escape(custom_tabname)
end
if self.filetype == 'fugitive' then
return 'fugitive: ' .. vim.fn.fnamemodify(self.file, ':h:h:t')
elseif self.buftype == 'help' then
return 'help:' .. vim.fn.fnamemodify(self.file, ':t:r')
elseif self.buftype == 'terminal' then
local match = string.match(vim.split(self.file, ' ')[1], 'term:.*:(%a+)')
return match ~= nil and match or vim.fn.fnamemodify(vim.env.SHELL, ':t')
elseif self.file == '' then
return '[No Name]'
end
if self.options.path == 1 then
return vim.fn.fnamemodify(self.file, ':~:.')
elseif self.options.path == 2 then
return vim.fn.fnamemodify(self.file, ':p')
elseif self.options.path == 3 then
return vim.fn.fnamemodify(self.file, ':p:~')
else
return vim.fn.fnamemodify(self.file, ':t')
end
end
---shortens path by turning apple/orange -> a/orange
---@param path string
---@param sep string path separator
---@param max_len integer maximum length of the full filename string
---@return string
local function shorten_path(path, sep, max_len)
local len = #path
if len <= max_len then
return path
end
local segments = vim.split(path, sep)
for idx = 1, #segments - 1 do
if len <= max_len then
break
end
local segment = segments[idx]
local shortened = segment:sub(1, vim.startswith(segment, '.') and 2 or 1)
segments[idx] = shortened
len = len - (#segment - #shortened)
end
return table.concat(segments, sep)
end
---returns rendered tab
---@return string
function Tab:render()
local name = self:label()
if self.options.tab_max_length ~= 0 then
local path_separator = package.config:sub(1, 1)
name = shorten_path(name, path_separator, self.options.tab_max_length)
end
if self.options.fmt then
name = self.options.fmt(name or '', self)
end
if self.ellipse then -- show ellipsis
name = '...'
else
-- different formats for different modes
if self.options.mode == 0 then
name = tostring(self.tabnr)
if self.modified_icon ~= '' then
name = string.format('%s%s', name, self.modified_icon)
end
elseif self.options.mode == 1 then
if self.modified_icon ~= '' then
name = string.format('%s %s', self.modified_icon, name)
end
else
name = string.format('%s%s %s', tostring(self.tabnr), self.modified_icon, name)
end
end
name = Tab.apply_padding(name, self.options.padding)
self.len = vim.fn.strchars(name)
-- setup for mouse clicks
local line = string.format('%%%s@LualineSwitchTab@%s%%T', self.tabnr, name)
-- apply highlight
line = modules.highlight.component_format_highlight(self.highlights[(self.current and 'active' or 'inactive')])
.. line
-- apply separators
if self.options.self.section < 'x' and not self.first then
local sep_before = self:separator_before()
line = sep_before .. line
self.len = self.len + vim.fn.strchars(sep_before)
elseif self.options.self.section >= 'x' and not self.last then
local sep_after = self:separator_after()
line = line .. sep_after
self.len = self.len + vim.fn.strchars(sep_after)
end
return line
end
---apply separator before current tab
---@return string
function Tab:separator_before()
if self.current or self.aftercurrent then
return '%Z{' .. self.options.section_separators.left .. '}'
else
return self.options.component_separators.left
end
end
---apply separator after current tab
---@return string
function Tab:separator_after()
if self.current or self.beforecurrent then
return '%z{' .. self.options.section_separators.right .. '}'
else
return self.options.component_separators.right
end
end
---adds spaces to left and right
function Tab.apply_padding(str, padding)
local l_padding, r_padding = 1, 1
if type(padding) == 'number' then
l_padding, r_padding = padding, padding
elseif type(padding) == 'table' then
l_padding, r_padding = padding.left or 0, padding.right or 0
end
return string.rep(' ', l_padding) .. str .. string.rep(' ', r_padding)
end
return Tab

View File

@ -0,0 +1,64 @@
local Window = require('lualine.components.windows.window')
local M = require('lualine.components.buffers'):extend()
local default_options = {
disabled_filetypes = {},
disabled_buftypes = { 'quickfix', 'prompt' },
}
function M:init(options)
options.buffers_color = nil -- buffers_color isn't windows option.
M.super.init(self, options)
self.options = vim.tbl_deep_extend('keep', self.options or {}, default_options)
self.options.windows_color = vim.tbl_deep_extend('keep', self.options.windows_color or {}, self.options.buffers_color)
self.options.buffers_color = nil -- this is the default value of colors generated by parent buffers component.
self.highlights = {
active = self:create_hl(self.options.windows_color.active, 'active'),
inactive = self:create_hl(self.options.windows_color.inactive, 'inactive'),
}
end
function M:new_buffer(winnr)
winnr = winnr or vim.api.nvim_get_current_win()
return Window:new {
winnr = winnr,
options = self.options,
highlights = self.highlights,
}
end
--- Override to only return buffers shown in the windows of the current tab
function M:buffers()
local tabnr = vim.api.nvim_get_current_tabpage()
local buffers = {}
for _, winnr in ipairs(vim.api.nvim_tabpage_list_wins(tabnr)) do
if not self:should_hide(winnr) then
buffers[#buffers + 1] = self:new_buffer(winnr)
end
end
return buffers
end
function M:should_hide(winnr)
local bufnr = vim.api.nvim_win_get_buf(winnr)
local filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
local buftype = vim.api.nvim_buf_get_option(bufnr, 'buftype')
local is_filetype_disabled = vim.tbl_contains(self.options.disabled_filetypes, filetype)
local is_buftype_disabled = vim.tbl_contains(self.options.disabled_buftypes, buftype)
local is_floating = '' ~= vim.api.nvim_win_get_config(winnr).relative
return is_floating or is_buftype_disabled or is_filetype_disabled
end
vim.cmd([[
function! LualineSwitchWindow(win_number, mouseclicks, mousebutton, modifiers)
execute a:win_number . 'wincmd w'
endfunction
]])
return M

View File

@ -0,0 +1,35 @@
local Window = require('lualine.components.buffers.buffer'):extend()
---initialize a new buffer from opts
---@param opts table
function Window:init(opts)
assert(opts.winnr, 'Cannot create Window without winnr')
opts.bufnr = vim.api.nvim_win_get_buf(opts.winnr)
Window.super.init(self, opts)
self.winnr = opts.winnr
self.win_number = vim.api.nvim_win_get_number(self.winnr)
end
function Window:is_current()
return vim.api.nvim_get_current_win() == self.winnr
end
function Window:apply_mode(name)
if self.options.mode == 0 then
return string.format('%s%s%s', self.icon, name, self.modified_icon)
end
if self.options.mode == 1 then
return string.format('%s %s%s', self.win_number, self.icon, self.modified_icon)
end
return string.format('%s %s%s%s', self.win_number, self.icon, name, self.modified_icon)
end
function Window:configure_mouse_click(name)
return string.format('%%%s@LualineSwitchWindow@%s%%T', self.win_number, name)
end
return Window

View File

@ -0,0 +1,135 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local require = require('lualine_require').require
local utils = require('lualine.utils.utils')
local modules = require('lualine_require').lazy_require {
utils_notices = 'lualine.utils.notices',
}
local config = {
options = {
icons_enabled = true,
theme = 'auto',
component_separators = { left = '', right = '' },
section_separators = { left = '', right = '' },
disabled_filetypes = {
statusline = {},
winbar = {},
},
ignore_focus = {},
always_divide_middle = true,
globalstatus = vim.go.laststatus == 3,
refresh = {
statusline = 1000,
tabline = 1000,
winbar = 1000,
},
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { 'progress' },
lualine_z = { 'location' },
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = { 'location' },
lualine_y = {},
lualine_z = {},
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
}
--- change separator format 'x' to {left='x', right='x'}
---@param separators string|table
---@return table
local function fix_separators(separators)
if separators ~= nil then
if type(separators) == 'string' then
return { left = separators, right = separators }
end
end
return separators
end
---copy raw disabled_filetypes to inner statusline & winbar tables.
---@param disabled_filetypes table
---@return table
local function fix_disabled_filetypes(disabled_filetypes)
if disabled_filetypes == nil then
return
end
if disabled_filetypes.statusline == nil then
disabled_filetypes.statusline = {}
end
if disabled_filetypes.winbar == nil then
disabled_filetypes.winbar = {}
end
for k, disabled_ft in ipairs(disabled_filetypes) do
table.insert(disabled_filetypes.statusline, disabled_ft)
table.insert(disabled_filetypes.winbar, disabled_ft)
disabled_filetypes[k] = nil
end
return disabled_filetypes
end
---extends config based on config_table
---@param config_table table
---@return table copy of config
local function apply_configuration(config_table)
if not config_table then
return utils.deepcopy(config)
end
local function parse_sections(section_group_name)
if config_table[section_group_name] == nil then
return
end
if not next(config_table[section_group_name]) then
config[section_group_name] = {}
return
end
for section_name, section in pairs(config_table[section_group_name]) do
if section_name == 'refresh' then
config[section_group_name][section_name] =
vim.tbl_deep_extend('force', config[section_group_name][section_name], utils.deepcopy(section))
else
config[section_group_name][section_name] = utils.deepcopy(section)
end
end
end
if vim.fn.has('nvim-0.8') == 0 and (next(config_table.winbar or {}) or next(config_table.inactive_winbar or {})) then
modules.utils_notices.add_notice('### winbar\nSorry `winbar can only be used in neovim 0.8 or higher.\n')
config_table.winbar = {}
config_table.inactive_winbar = {}
end
parse_sections('options')
parse_sections('sections')
parse_sections('inactive_sections')
parse_sections('tabline')
parse_sections('winbar')
parse_sections('inactive_winbar')
if config_table.extensions then
config.extensions = utils.deepcopy(config_table.extensions)
end
config.options.section_separators = fix_separators(config.options.section_separators)
config.options.component_separators = fix_separators(config.options.component_separators)
config.options.disabled_filetypes = fix_disabled_filetypes(config.options.disabled_filetypes)
return utils.deepcopy(config)
end
--- returns current active config
---@return table a copy of config
local function get_current_config()
return utils.deepcopy(config)
end
return {
get_config = get_current_config,
apply_configuration = apply_configuration,
}

View File

@ -0,0 +1,9 @@
-- MIT license, see LICENSE for more details.
-- Extension for aerial.nvim
local M = {}
M.sections = { lualine_a = { 'filetype' } }
M.filetypes = { 'aerial' }
return M

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local nerdtree = require('lualine.extensions.nerdtree')
local M = {}
M.sections = vim.deepcopy(nerdtree.sections)
M.filetypes = { 'CHADTree' }
return M

View File

@ -0,0 +1,20 @@
local M = {}
M.sections = {
lualine_a = {
function()
return vim.fn['ctrlspace#context#Configuration']().Symbols.CS
end,
},
lualine_b = { 'ctrlspace#api#StatuslineModeSegment' },
lualine_y = { 'ctrlspace#api#StatuslineTabSegment' },
lualine_z = {
function()
return 'CtrlSpace'
end,
},
}
M.filetypes = { 'ctrlspace' }
return M

View File

@ -0,0 +1,11 @@
-- MIT license, see LICENSE for more details.
-- Extension for fern file explorer.
local nerdtree = require('lualine.extensions.nerdtree')
local M = {}
M.sections = vim.deepcopy(nerdtree.sections)
M.filetypes = { 'fern' }
return M

View File

@ -0,0 +1,17 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local M = {}
local function fugitive_branch()
local icon = '' -- e0a0
return icon .. ' ' .. vim.fn.FugitiveHead()
end
M.sections = {
lualine_a = { fugitive_branch },
lualine_z = { 'location' },
}
M.filetypes = { 'fugitive' }
return M

View File

@ -0,0 +1,45 @@
--[[
lualine extension for fzf filetypes:
works with both https://github.com/junegunn/fzf.vim and https://github.com/ibhagwan/fzf-lua
-- fzf-lua must be set-up in split mode
]]
local function has_fzf()
return pcall(require, 'fzf-lua')
end
local function fzf_picker()
if not has_fzf() then
return ''
end
local info_string = vim.inspect(require('fzf-lua').get_info()['fnc'])
return info_string:gsub('"', '')
end
local function fzf_element()
if not has_fzf() then
return ''
end
local fzf = require('fzf-lua')
local selected = fzf.get_info().selected
return fzf.path.entry_to_file(selected).path
end
local function fzf_statusline()
return 'FZF'
end
local M = {}
M.sections = {
lualine_a = { fzf_statusline },
lualine_y = { fzf_element },
lualine_z = { fzf_picker },
}
M.filetypes = { 'fzf' }
return M

View File

@ -0,0 +1,31 @@
-- lualine extension for lazy.nvim
local ok, lazy = pcall(require, 'lazy')
if not ok then
return ''
end
local M = {}
M.sections = {
lualine_a = {
function()
return 'lazy 💤'
end,
},
lualine_b = {
function()
return 'loaded: ' .. lazy.stats().loaded .. '/' .. lazy.stats().count
end,
},
lualine_c = {
{
require('lazy.status').updates,
cond = require('lazy.status').has_updates,
},
},
}
M.filetypes = { 'lazy' }
return M

View File

@ -0,0 +1,16 @@
local M = {}
M.sections = {
lualine_a = {
function()
return 'MAN'
end,
},
lualine_b = { { 'filename', file_status = false } },
lualine_y = { 'progress' },
lualine_z = { 'location' },
}
M.filetypes = { 'man' }
return M

View File

@ -0,0 +1,29 @@
-- lualine extension for mason.nvim
local mason_registry
local function maybe_set_registry()
local ok, registry = pcall(require, 'mason-registry')
if ok then
mason_registry = registry
end
end
local M = {}
M.sections = {
lualine_a = {
function()
return 'Mason'
end,
},
lualine_b = {
function()
maybe_set_registry()
return 'Installed: ' .. #mason_registry.get_installed_packages() .. '/' .. #mason_registry.get_all_package_specs()
end,
},
}
M.filetypes = { 'mason' }
return M

View File

@ -0,0 +1,19 @@
local M = {}
M.sections = {
lualine_a = {
function()
local ft = vim.opt_local.filetype:get()
return (ft == 'Mundo') and 'Change tree' or (ft == 'MundoDiff') and 'Change diff'
end,
},
lualine_y = { 'progress' },
lualine_z = { 'location' },
}
M.filetypes = {
'Mundo',
'MundoDiff',
}
return M

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local nerdtree = require('lualine.extensions.nerdtree')
local M = {}
M.sections = vim.deepcopy(nerdtree.sections)
M.filetypes = { 'neo-tree' }
return M

View File

@ -0,0 +1,15 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local function get_short_cwd()
return vim.fn.fnamemodify(vim.fn.getcwd(), ':~')
end
local M = {}
M.sections = {
lualine_a = { get_short_cwd },
}
M.filetypes = { 'nerdtree' }
return M

View File

@ -0,0 +1,18 @@
-- MIT license, see LICENSE for more details.
-- Extension for nvim-dap-ui
local M = {}
M.sections = {
lualine_a = { { 'filename', file_status = false } },
}
M.filetypes = {
'dap-repl',
'dapui_console',
'dapui_watches',
'dapui_stacks',
'dapui_breakpoints',
'dapui_scopes',
}
return M

View File

@ -0,0 +1,11 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local nerdtree = require('lualine.extensions.nerdtree')
local M = {}
M.sections = vim.deepcopy(nerdtree.sections)
M.filetypes = { 'NvimTree' }
return M

View File

@ -0,0 +1,20 @@
-- Extension for oil.nvim
local M = {}
M.sections = {
lualine_a = {
function()
local ok, oil = pcall(require, 'oil')
if ok then
return vim.fn.fnamemodify(oil.get_current_dir(), ':~')
else
return ''
end
end,
},
}
M.filetypes = { 'oil' }
return M

View File

@ -0,0 +1,16 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local M = {}
M.sections = {
lualine_a = {
function()
return 'OverseerList'
end,
},
}
M.filetypes = { 'OverseerList' }
return M

View File

@ -0,0 +1,34 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
--
local function is_loclist()
return vim.fn.getloclist(0, { filewinid = 1 }).filewinid ~= 0
end
local function label()
return is_loclist() and 'Location List' or 'Quickfix List'
end
local function title()
if is_loclist() then
return vim.fn.getloclist(0, { title = 0 }).title
end
return vim.fn.getqflist({ title = 0 }).title
end
local M = {}
function M.init()
-- Make sure ft wf doesn't create a custom statusline
vim.g.qf_disable_statusline = true
end
M.sections = {
lualine_a = { label },
lualine_b = { title },
lualine_z = { 'location' },
}
M.filetypes = { 'qf' }
return M

View File

@ -0,0 +1,9 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local M = {}
M.sections = { lualine_a = { 'filetype' } }
M.filetypes = { 'Outline' }
return M

View File

@ -0,0 +1,16 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local function toggleterm_statusline()
return 'ToggleTerm #' .. vim.b.toggle_number
end
local M = {}
M.sections = {
lualine_a = { toggleterm_statusline },
}
M.filetypes = { 'toggleterm' }
return M

View File

@ -0,0 +1,22 @@
local M = {}
local function get_trouble_mode()
local opts = require('trouble.config').options
local words = vim.split(opts.mode, '[%W]')
for i, word in ipairs(words) do
words[i] = word:sub(1, 1):upper() .. word:sub(2)
end
return table.concat(words, ' ')
end
M.sections = {
lualine_a = {
get_trouble_mode,
},
}
M.filetypes = { 'Trouble' }
return M

View File

@ -0,0 +1,494 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
local M = {}
local lualine_require = require('lualine_require')
local require = lualine_require.require
local modules = lualine_require.lazy_require {
utils = 'lualine.utils.utils',
color_utils = 'lualine.utils.color_utils',
}
local section_highlight_map = { x = 'c', y = 'b', z = 'a' }
local active_theme = nil
local theme_hls = {}
local create_cterm_colors = false
-- table to store the highlight names created by lualine
local loaded_highlights = {}
-- table to map mode to highlight suffixes
local mode_to_highlight = {
['VISUAL'] = '_visual',
['V-BLOCK'] = '_visual',
['V-LINE'] = '_visual',
['SELECT'] = '_visual',
['S-LINE'] = '_visual',
['S-BLOCK'] = '_visual',
['REPLACE'] = '_replace',
['V-REPLACE'] = '_replace',
['INSERT'] = '_insert',
['COMMAND'] = '_command',
['EX'] = '_command',
['MORE'] = '_command',
['CONFIRM'] = '_command',
['TERMINAL'] = '_terminal',
}
--- Get highlight suffix for current mode, or inactive if not focused
---@return string mode_suffix
function M.get_mode_suffix()
local mode = require('lualine.utils.mode').get_mode()
return mode_to_highlight[mode] or '_normal'
end
--- determine if an highlight exist and isn't cleared
---@param highlight_name string
---@return boolean whether hl_group was defined with highlight_name
function M.highlight_exists(highlight_name)
return loaded_highlights[highlight_name] or false
end
--- clears loaded_highlights table and highlights
local function clear_highlights()
for highlight_name, _ in pairs(loaded_highlights) do
vim.cmd('highlight clear ' .. highlight_name)
end
loaded_highlights = {}
end
---converts cterm, color_name type colors to #rrggbb format
---@param color string|number
---@return string
local function sanitize_color(color)
if color == nil or color == '' or (type(color) == 'string' and color:lower() == 'none') then
return 'None'
end
if type(color) == 'string' then
if color:sub(1, 1) == '#' then
return color
end -- RGB value
return modules.color_utils.color_name2rgb(color)
elseif type(color) == 'number' then
if color > 255 then
error("What's this it can't be higher then 255 and you've given " .. color)
end
return modules.color_utils.cterm2rgb(color)
end
end
---converts color_name type colors to cterm format and let cterm color pass through
---@param color string|number
---@return string
local function sanitize_color_for_cterm(color)
if type(color) == 'number' then
if color > 255 then
error("What's this it can't be higher then 255 and you've given " .. color)
end
return color
end
return modules.color_utils.rgb2cterm(sanitize_color(color))
end
function M.get_lualine_hl(name)
local hl = loaded_highlights[name]
if hl and not hl.empty then
if hl.link then
return modules.utils.extract_highlight_colors(hl.link)
end
local hl_def = {
fg = hl.fg ~= 'None' and vim.deepcopy(hl.fg) or nil,
bg = hl.bg ~= 'None' and vim.deepcopy(hl.bg) or nil,
sp = hl.sp ~= 'None' and vim.deepcopy(hl.sp) or nil,
}
if hl.gui then
for _, flag in ipairs(vim.split(hl.gui, ',')) do
if flag ~= 'None' then
hl_def[flag] = true
end
end
end
return hl_def
end
end
--- Define a hl_group
---@param name string
---@param foreground string|number: color
---@param background string|number: color
---@param gui table cterm/gui options like bold/italic etc.
---@param link string hl_group name to link new hl to
function M.highlight(name, foreground, background, gui, link)
local command = { 'highlight!' }
if link and #link > 0 then
if loaded_highlights[name] and loaded_highlights[name].link == link then
return
end
vim.list_extend(command, { 'link', name, link })
else
local foreground_rgb = sanitize_color(foreground)
local background_rgb = sanitize_color(background)
gui = (gui ~= nil and gui ~= '') and gui or 'None'
if
loaded_highlights[name]
and loaded_highlights[name].fg == foreground_rgb
and loaded_highlights[name].bg == background_rgb
and loaded_highlights[name].gui == gui
then
return -- color is already defined why are we doing this anyway ?
end
table.insert(command, name)
table.insert(command, 'guifg=' .. foreground_rgb)
table.insert(command, 'guibg=' .. background_rgb)
table.insert(command, 'gui=' .. gui)
if create_cterm_colors then
-- Not setting color from xxxground_rgb to let possible user 256 number through
table.insert(command, 'ctermfg=' .. sanitize_color_for_cterm(foreground))
table.insert(command, 'ctermbg=' .. sanitize_color_for_cterm(background))
table.insert(command, 'cterm=' .. gui)
end
end
vim.cmd(table.concat(command, ' '))
-- update attached hl groups
local old_hl_def = loaded_highlights[name]
if old_hl_def and next(old_hl_def.attached) then
-- Update attached hl groups as they announced to depend on hl_group 'name'
-- 'hl' being in 'name's attached table means 'hl'
-- depends of 'name'.
-- 'hl' key in attached table will contain a table that
-- defines the relation between 'hl' & 'name'.
-- name.attached.hl = { bg = 'fg' } means
-- hl's fg is same as 'names' bg . So 'hl's fg should
-- be updated when ever 'name' changes it's 'bg'
local bg_changed = old_hl_def.bg ~= background
local fg_changed = old_hl_def.bg ~= foreground
local gui_changed = old_hl_def.gui ~= gui
for attach_name, attach_desc in pairs(old_hl_def.attached) do
if bg_changed and attach_desc.bg and loaded_highlights[attach_name] then
M.highlight(
attach_name,
attach_desc.bg == 'fg' and background or loaded_highlights[attach_name].fg,
attach_desc.bg == 'bg' and background or loaded_highlights[attach_name].bg,
loaded_highlights[attach_name].gui,
loaded_highlights[attach_name].link
)
end
if fg_changed and attach_desc.fg and loaded_highlights[attach_name] then
M.highlight(
attach_name,
attach_desc.fg == 'fg' and foreground or loaded_highlights[attach_name].fg,
attach_desc.fg == 'bg' and foreground or loaded_highlights[attach_name].bg,
loaded_highlights[attach_name].gui,
loaded_highlights[attach_name].link
)
end
if gui_changed and attach_desc.gui and loaded_highlights[attach_name] then
M.highlight(
attach_name,
loaded_highlights[attach_name].fg,
loaded_highlights[attach_name].bg,
gui,
loaded_highlights[attach_name].link
)
end
end
end
-- store current hl state
loaded_highlights[name] = {
fg = foreground,
bg = background,
gui = gui,
link = link,
attached = old_hl_def and old_hl_def.attached or {},
}
end
---Attach a hl to another, so the attached auto updates on change to hl that it's attached too.
---@param provider string the hl receiver is getting attached to
---@param receiver string the hl that will be auto updated upon change to provider
---@param provider_el_type string (fg/bg) what element receiver relates to of provider
---@param receiver_el_type string (fg/bg) what element provider relates to of receiver
local function attach_hl(provider, receiver, provider_el_type, receiver_el_type)
if loaded_highlights[provider] == nil then
loaded_highlights[provider] = { empty = true, attached = {} }
end
loaded_highlights[provider].attached[receiver] = { [provider_el_type] = receiver_el_type }
end
---define hl_groups for a theme
---@param theme table
function M.create_highlight_groups(theme)
clear_highlights()
active_theme = theme
theme_hls = {}
local psudo_options = { self = { section = 'a' } }
create_cterm_colors = not vim.go.termguicolors
for mode, sections in pairs(theme) do
theme_hls[mode] = {}
for section, color in pairs(sections) do
local hl_tag = mode
psudo_options.self.section = section
theme_hls[mode][section] = M.create_component_highlight_group(color, hl_tag, psudo_options, true)
end
end
end
---@description: adds '_mode' at end of highlight_group
---@param highlight_group string name of highlight group
---@return string highlight group name with mode
local function append_mode(highlight_group, is_focused)
if is_focused == nil then
is_focused = modules.utils.is_focused()
end
if is_focused == false then
return highlight_group .. '_inactive'
end
return highlight_group .. M.get_mode_suffix()
end
-- Helper function for create component highlight
---Handles fall back of colors when creating highlight group
---@param hl_name string name of highlight that we are setting default values for
---@param mode string mode which default component color should be given.
---@param section string the lualine section component is in.
---@param color table color passed for creating component highlight
---@param options table Options table of component this is first fall back
local function get_default_component_color(hl_name, mode, section, color, options)
local default_theme_color
if active_theme[mode] and active_theme[mode][section] then
default_theme_color = active_theme[mode][section]
elseif section >= 'c' and active_theme[mode] and active_theme[mode][section_highlight_map[section]] then
default_theme_color = active_theme[mode][section_highlight_map[section]]
elseif section >= 'c' and active_theme.normal[section_highlight_map[section]] then
default_theme_color = active_theme.normal[section_highlight_map[section]]
else
default_theme_color = active_theme.normal[section]
end
local ret = { fg = color.fg, bg = color.bg, gui = color.gui }
if ret.fg and ret.bg then
return ret
end
local function apply_default(def_color, def_name)
if type(def_color) == 'function' and loaded_highlights[def_name] and not loaded_highlights[def_name].empty then
if loaded_highlights[def_name].link then
def_color = loaded_highlights[def_name].link
else
def_color = loaded_highlights[def_name]
end
end
if type(def_color) == 'function' then
def_color = def_color { section = section }
end
if type(def_color) == 'string' then
def_color = modules.utils.extract_highlight_colors(def_color)
end
if type(def_color) == 'table' then
if not ret.fg then
ret.fg = def_color.fg
attach_hl(def_name, hl_name, 'fg', 'fg')
end
if not ret.bg then
ret.bg = def_color.bg
attach_hl(def_name, hl_name, 'bg', 'bg')
end
end
end
if
options.color
and options.color_highlight
and options.color_highlight.name
and options.color_highlight.name .. '_' .. mode ~= hl_name
then
apply_default(options.color, options.color_highlight.name .. '_' .. mode)
end
if not ret.fg or not ret.bg then
apply_default(default_theme_color, string.format('lualine_%s_%s', section, mode))
end
ret.fg = sanitize_color(ret.fg)
ret.bg = sanitize_color(ret.bg)
return ret
end
---Create highlight group with fg bg and gui from theme
---@param color table has to be { fg = "#rrggbb", bg="#rrggbb" gui = "effect" }
--- all the color elements are optional if fg or bg is not given options
--- must be provided So fg and bg can default the themes colors
---@param highlight_tag string is unique tag for highlight group
---returns the name of highlight group
---@param options table is parameter of component.init() function
---@return table that can be used by component_format_highlight
--- to retrieve highlight group
function M.create_component_highlight_group(color, highlight_tag, options, apply_no_default)
local section = options.self.section
local tag_id = 0
while
M.highlight_exists(table.concat({ 'lualine', section, highlight_tag }, '_'))
or (section and M.highlight_exists(table.concat({ 'lualine', section, highlight_tag, 'normal' }, '_')))
do
highlight_tag = highlight_tag .. '_' .. tostring(tag_id)
tag_id = tag_id + 1
end
if type(color) == 'string' then
local highlight_group_name = table.concat({ 'lualine', section, highlight_tag }, '_')
M.highlight(highlight_group_name, nil, nil, nil, color) -- l8nk to group
return {
name = highlight_group_name,
fn = nil,
no_mode = true,
link = true,
section = section,
options = options,
no_default = apply_no_default,
}
end
if type(color) ~= 'function' and (apply_no_default or (color.bg and color.fg)) then
-- When bg and fg are both present we don't need to set highlights for
-- each mode as they will surely look the same. So we can work without options
local highlight_group_name = table.concat({ 'lualine', section, highlight_tag }, '_')
M.highlight(highlight_group_name, color.fg, color.bg, color.gui, nil)
return {
name = highlight_group_name,
fn = nil,
no_mode = true,
section = section,
options = options,
no_default = apply_no_default,
}
end
local modes = {
'normal',
'insert',
'visual',
'replace',
'command',
'terminal',
'inactive',
}
for _, mode in ipairs(modes) do
local hl_name = table.concat({ 'lualine', section, highlight_tag, mode }, '_')
local cl = color
if type(color) == 'function' then
cl = color { section = section } or {}
end
if type(cl) == 'string' then
cl = { link = cl }
else
cl = get_default_component_color(hl_name, mode, section, cl, options)
end
M.highlight(hl_name, cl.fg, cl.bg, cl.gui, cl.link)
end
return {
name = table.concat({ 'lualine', section, highlight_tag }, '_'),
fn = type(color) == 'function' and color,
no_mode = false,
link = false,
section = section,
options = options,
no_default = apply_no_default,
}
end
---@description: retrieve highlight_groups for components
---@param highlight table return value of create_component_highlight_group
--- return value of create_component_highlight_group is to be passed in
--- this parameter to receive highlight that was created
---@return string formatted highlight group name
function M.component_format_highlight(highlight, is_focused)
if not highlight.fn then
local highlight_group = highlight.name
if highlight.no_mode then
return '%#' .. highlight_group .. '#'
end
highlight_group = append_mode(highlight_group, is_focused)
return '%#' .. highlight_group .. '#'
else
local color = highlight.fn { section = highlight.section } or {}
local hl_name = highlight.name
if type(color) == 'string' then
M.highlight(hl_name .. M.get_mode_suffix(), nil, nil, nil, color)
return '%#' .. hl_name .. M.get_mode_suffix() .. '#'
elseif type(color) == 'table' then
if not highlight.no_default and not (color.fg and color.bg) then
hl_name = append_mode(highlight.name, is_focused)
color =
get_default_component_color(hl_name, M.get_mode_suffix():sub(2), highlight.section, color, highlight.options)
end
M.highlight(hl_name, color.fg, color.bg, color.gui, color.link)
return '%#' .. hl_name .. '#', color
end
end
end
---@description: retrieve highlight_groups for section
---@param section string highlight group name without mode
--- return value of create_component_highlight_group is to be passed in
--- this parameter to receive highlight that was created
---@param is_focused boolean
---@return string formatted highlight group name
function M.format_highlight(section, is_focused)
local mode = append_mode('', is_focused):sub(2)
local ret = ''
if theme_hls[mode] and theme_hls[mode][section] then
ret = M.component_format_highlight(theme_hls[mode][section], is_focused)
elseif theme_hls[mode] and section > 'c' and theme_hls[mode][section_highlight_map[section]] then
ret = M.component_format_highlight(theme_hls[mode][section_highlight_map[section]], is_focused)
elseif theme_hls['normal'] and theme_hls['normal'][section] then
ret = M.component_format_highlight(theme_hls['normal'][section], is_focused)
elseif theme_hls['normal'] and section > 'c' and theme_hls['normal'][section_highlight_map[section]] then
ret = M.component_format_highlight(theme_hls['normal'][section_highlight_map[section]], is_focused)
end
return ret
end
---@description : Provides transitional highlights for section separators.
---@param left_hl string this highlights bg is used for fg of transitional hl
---@param right_hl string this highlights bg is used for bg of transitional hl
--- '▶️' and '◀️' ' needs reverse colors so the caller should swap left and right
---@return string formatted highlight group name
function M.get_transitional_highlights(left_hl, right_hl)
-- When both left and right highlights are same or one is absent
-- nothing to transition to.
if left_hl == nil or right_hl == nil or left_hl == right_hl then
return nil
end
-- construct the name of highlight group
local highlight_name = table.concat({ 'lualine_transitional', left_hl, 'to', right_hl }, '_')
if not M.highlight_exists(highlight_name) then
-- Create the highlight_group if needed
-- Get colors from highlights
local fg = modules.utils.extract_highlight_colors(left_hl, 'bg')
local bg = modules.utils.extract_highlight_colors(right_hl, 'bg')
if not fg and not bg then
return nil -- Color retrieval failed
end
if bg == fg then
return nil -- Separator won't be visible anyway
end
M.highlight(highlight_name, fg, bg, nil, nil)
attach_hl(left_hl, highlight_name, 'bg', 'fg')
attach_hl(right_hl, highlight_name, 'bg', 'bg')
end
return '%#' .. highlight_name .. '#'
end
function M.get_stl_default_hl(focused)
if focused == 3 then
return 'TabLineFill'
elseif not focused then
return 'StatusLineNC'
else
return 'StatusLine'
end
end
return M

View File

@ -0,0 +1,38 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit itchyny, jackno (lightline)
-- stylua: ignore
local colors = {
black = '#000000',
maroon = '#800000',
green = '#008000',
olive = '#808000',
navy = '#000080',
purple = '#800080',
teal = '#008080',
silver = '#c0c0c0',
gray = '#808080',
red = '#ff0000',
lime = '#00ff00',
yellow = '#ffff00',
blue = '#0000ff',
fuchsia = '#ff00ff',
aqua = '#00ffff',
white = '#ffffff',
}
return {
normal = {
a = { fg = colors.white, bg = colors.blue, gui = 'bold' },
b = { fg = colors.white, bg = colors.gray },
c = { fg = colors.silver, bg = colors.black },
},
insert = { a = { fg = colors.white, bg = colors.green, gui = 'bold' } },
visual = { a = { fg = colors.white, bg = colors.purple, gui = 'bold' } },
replace = { a = { fg = colors.white, bg = colors.red, gui = 'bold' } },
inactive = {
a = { fg = colors.silver, bg = colors.gray, gui = 'bold' },
b = { fg = colors.gray, bg = colors.black },
c = { fg = colors.silver, bg = colors.black },
},
}

View File

@ -0,0 +1,43 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color0 = '#ffffff',
color1 = '#99c794',
color2 = '#65737e',
color3 = '#343d46',
color4 = '#6699cc',
color5 = '#d8dee9',
color6 = '#f99157',
color7 = '#ec5f67',
}
return {
insert = {
a = { fg = colors.color0, bg = colors.color1, gui = 'bold' },
b = { fg = colors.color0, bg = colors.color2 },
c = { fg = colors.color0, bg = colors.color3 },
},
normal = {
a = { fg = colors.color0, bg = colors.color4, gui = 'bold' },
b = { fg = colors.color0, bg = colors.color2 },
c = { fg = colors.color0, bg = colors.color3 },
},
inactive = {
a = { fg = colors.color5, bg = colors.color2, gui = 'bold' },
b = { fg = colors.color5, bg = colors.color3 },
c = { fg = colors.color2, bg = colors.color3 },
},
visual = {
a = { fg = colors.color0, bg = colors.color6, gui = 'bold' },
b = { fg = colors.color0, bg = colors.color2 },
c = { fg = colors.color0, bg = colors.color3 },
},
replace = {
a = { fg = colors.color0, bg = colors.color7, gui = 'bold' },
b = { fg = colors.color0, bg = colors.color2 },
c = { fg = colors.color0, bg = colors.color3 },
},
}

View File

@ -0,0 +1,6 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
local background = vim.opt.background:get()
return require('lualine.themes.papercolor_' .. background)

View File

@ -0,0 +1,43 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color14 = '#718c00',
color0 = '#666666',
color1 = '#c8c8c8',
color2 = '#808080',
color3 = '#fafafa',
color4 = '#4271ae',
color5 = '#4d4d4c',
color6 = '#b4b4b4',
color7 = '#555555',
color8 = '#8959a8',
color11 = '#f5871f',
}
return {
inactive = {
a = { fg = colors.color0, bg = colors.color1, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
c = { fg = colors.color0, bg = colors.color1 },
},
normal = {
a = { fg = colors.color1, bg = colors.color4, gui = 'bold' },
b = { fg = colors.color5, bg = colors.color6 },
c = { fg = colors.color7, bg = colors.color1 },
},
visual = {
a = { fg = colors.color1, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color5, bg = colors.color6 },
},
replace = {
a = { fg = colors.color1, bg = colors.color11, gui = 'bold' },
b = { fg = colors.color5, bg = colors.color6 },
},
insert = {
a = { fg = colors.color1, bg = colors.color14, gui = 'bold' },
b = { fg = colors.color5, bg = colors.color6 },
},
}

View File

@ -0,0 +1,172 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
local utils = require('lualine.utils.utils')
local loader = require('lualine.utils.loader')
local color_name = vim.g.colors_name
if color_name then
-- All base16 colorschemes share the same theme
if 'base16' == color_name:sub(1, 6) then
color_name = 'base16'
end
-- Check if there's a theme for current colorscheme
-- If there is load that instead of generating a new one
local ok, theme = pcall(loader.load_theme, color_name)
if ok and theme then
return theme
end
end
---------------
-- Constants --
---------------
-- fg and bg must have this much contrast range 0 < contrast_threshold < 0.5
local contrast_threshold = 0.3
-- how much brightness is changed in percentage for light and dark themes
local brightness_modifier_parameter = 10
-- Turns #rrggbb -> { red, green, blue }
local function rgb_str2num(rgb_color_str)
if rgb_color_str:find('#') == 1 then
rgb_color_str = rgb_color_str:sub(2, #rgb_color_str)
end
local red = tonumber(rgb_color_str:sub(1, 2), 16)
local green = tonumber(rgb_color_str:sub(3, 4), 16)
local blue = tonumber(rgb_color_str:sub(5, 6), 16)
return { red = red, green = green, blue = blue }
end
-- Turns { red, green, blue } -> #rrggbb
local function rgb_num2str(rgb_color_num)
local rgb_color_str = string.format('#%02x%02x%02x', rgb_color_num.red, rgb_color_num.green, rgb_color_num.blue)
return rgb_color_str
end
-- Returns brightness level of color in range 0 to 1
-- arbitrary value it's basically an weighted average
local function get_color_brightness(rgb_color)
local color = rgb_str2num(rgb_color)
local brightness = (color.red * 2 + color.green * 3 + color.blue) / 6
return brightness / 256
end
-- returns average of colors in range 0 to 1
-- used to determine contrast level
local function get_color_avg(rgb_color)
local color = rgb_str2num(rgb_color)
return (color.red + color.green + color.blue) / 3 / 256
end
-- Clamps the val between left and right
local function clamp(val, left, right)
if val > right then
return right
end
if val < left then
return left
end
return val
end
-- Changes brightness of rgb_color by percentage
local function brightness_modifier(rgb_color, percentage)
local color = rgb_str2num(rgb_color)
color.red = clamp(color.red + (color.red * percentage / 100), 0, 255)
color.green = clamp(color.green + (color.green * percentage / 100), 0, 255)
color.blue = clamp(color.blue + (color.blue * percentage / 100), 0, 255)
return rgb_num2str(color)
end
-- Changes contrast of rgb_color by amount
local function contrast_modifier(rgb_color, amount)
local color = rgb_str2num(rgb_color)
color.red = clamp(color.red + amount, 0, 255)
color.green = clamp(color.green + amount, 0, 255)
color.blue = clamp(color.blue + amount, 0, 255)
return rgb_num2str(color)
end
-- Changes brightness of foreground color to achieve contrast
-- without changing the color
local function apply_contrast(highlight)
local highlight_bg_avg = get_color_avg(highlight.bg)
local contrast_threshold_config = clamp(contrast_threshold, 0, 0.5)
local contrast_change_step = 5
if highlight_bg_avg > 0.5 then
contrast_change_step = -contrast_change_step
end
-- Don't waste too much time here max 25 iteration should be more than enough
local iteration_count = 1
while math.abs(get_color_avg(highlight.fg) - highlight_bg_avg) < contrast_threshold_config and iteration_count < 25 do
highlight.fg = contrast_modifier(highlight.fg, contrast_change_step)
iteration_count = iteration_count + 1
end
end
-- Get the colors to create theme
-- stylua: ignore
local colors = {
normal = utils.extract_color_from_hllist('bg', { 'PmenuSel', 'PmenuThumb', 'TabLineSel' }, '#000000'),
insert = utils.extract_color_from_hllist('fg', { 'String', 'MoreMsg' }, '#000000'),
replace = utils.extract_color_from_hllist('fg', { 'Number', 'Type' }, '#000000'),
visual = utils.extract_color_from_hllist('fg', { 'Special', 'Boolean', 'Constant' }, '#000000'),
command = utils.extract_color_from_hllist('fg', { 'Identifier' }, '#000000'),
back1 = utils.extract_color_from_hllist('bg', { 'Normal', 'StatusLineNC' }, '#000000'),
fore = utils.extract_color_from_hllist('fg', { 'Normal', 'StatusLine' }, '#000000'),
back2 = utils.extract_color_from_hllist('bg', { 'StatusLine' }, '#000000'),
}
-- Change brightness of colors
-- Darken if light theme (or) Lighten if dark theme
local normal_color = utils.extract_highlight_colors('Normal', 'bg')
if normal_color ~= nil then
if get_color_brightness(normal_color) > 0.5 then
brightness_modifier_parameter = -brightness_modifier_parameter
end
for name, color in pairs(colors) do
colors[name] = brightness_modifier(color, brightness_modifier_parameter)
end
end
-- Basic theme definition
local M = {
normal = {
a = { bg = colors.normal, fg = colors.back1, gui = 'bold' },
b = { bg = colors.back1, fg = colors.normal },
c = { bg = colors.back2, fg = colors.fore },
},
insert = {
a = { bg = colors.insert, fg = colors.back1, gui = 'bold' },
b = { bg = colors.back1, fg = colors.insert },
c = { bg = colors.back2, fg = colors.fore },
},
replace = {
a = { bg = colors.replace, fg = colors.back1, gui = 'bold' },
b = { bg = colors.back1, fg = colors.replace },
c = { bg = colors.back2, fg = colors.fore },
},
visual = {
a = { bg = colors.visual, fg = colors.back1, gui = 'bold' },
b = { bg = colors.back1, fg = colors.visual },
c = { bg = colors.back2, fg = colors.fore },
},
command = {
a = { bg = colors.command, fg = colors.back1, gui = 'bold' },
b = { bg = colors.back1, fg = colors.command },
c = { bg = colors.back2, fg = colors.fore },
},
}
M.terminal = M.command
M.inactive = M.normal
-- Apply proper contrast so text is readable
for _, section in pairs(M) do
for _, highlight in pairs(section) do
apply_contrast(highlight)
end
end
return M

View File

@ -0,0 +1,8 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- License: MIT License
local background = vim.opt.background:get()
local style = vim.g.ayucolor or ((background == 'dark') and vim.g.ayuprefermirage and 'mirage' or background)
return require('lualine.themes.ayu_' .. style)

View File

@ -0,0 +1,40 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color2 = '#0f1419',
color3 = '#ffee99',
color4 = '#e6e1cf',
color5 = '#14191f',
color13 = '#b8cc52',
color10 = '#36a3d9',
color8 = '#f07178',
color9 = '#3e4b59',
}
return {
visual = {
a = { fg = colors.color2, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
replace = {
a = { fg = colors.color2, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
inactive = {
c = { fg = colors.color4, bg = colors.color2 },
a = { fg = colors.color4, bg = colors.color5, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
normal = {
c = { fg = colors.color9, bg = colors.color2 },
a = { fg = colors.color2, bg = colors.color10, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
insert = {
a = { fg = colors.color2, bg = colors.color13, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
}

View File

@ -0,0 +1,40 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color2 = '#f3f3f3',
color3 = '#A37ACC',
color4 = '#5C6773',
color5 = '#d3d3d3',
color13 = '#86B300',
color10 = '#59c2ff',
color8 = '#f07178',
color9 = '#828C99',
}
return {
visual = {
a = { fg = colors.color2, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
replace = {
a = { fg = colors.color2, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
inactive = {
c = { fg = colors.color4, bg = colors.color2 },
a = { fg = colors.color4, bg = colors.color5, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
normal = {
c = { fg = colors.color9, bg = colors.color2 },
a = { fg = colors.color2, bg = colors.color10, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
insert = {
a = { fg = colors.color2, bg = colors.color13, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
}

View File

@ -0,0 +1,40 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color2 = '#242b38',
color3 = '#d4bfff',
color4 = '#d9d7ce',
color5 = '#272d38',
color13 = '#bbe67e',
color10 = '#59c2ff',
color8 = '#f07178',
color9 = '#607080',
}
return {
visual = {
a = { fg = colors.color2, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
replace = {
a = { fg = colors.color2, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
inactive = {
c = { fg = colors.color4, bg = colors.color2 },
a = { fg = colors.color4, bg = colors.color5, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
normal = {
c = { fg = colors.color9, bg = colors.color2 },
a = { fg = colors.color2, bg = colors.color10, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
insert = {
a = { fg = colors.color2, bg = colors.color13, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
}

View File

@ -0,0 +1,112 @@
local modules = require('lualine_require').lazy_require { notices = 'lualine.utils.notices' }
local function add_notice(notice)
modules.notices.add_notice('theme(base16): ' .. notice)
end
local function setup(colors)
local theme = {
normal = {
a = { fg = colors.bg, bg = colors.normal },
b = { fg = colors.light_fg, bg = colors.alt_bg },
c = { fg = colors.fg, bg = colors.bg },
},
replace = {
a = { fg = colors.bg, bg = colors.replace },
b = { fg = colors.light_fg, bg = colors.alt_bg },
},
insert = {
a = { fg = colors.bg, bg = colors.insert },
b = { fg = colors.light_fg, bg = colors.alt_bg },
},
visual = {
a = { fg = colors.bg, bg = colors.visual },
b = { fg = colors.light_fg, bg = colors.alt_bg },
},
inactive = {
a = { fg = colors.dark_fg, bg = colors.bg },
b = { fg = colors.dark_fg, bg = colors.bg },
c = { fg = colors.dark_fg, bg = colors.bg },
},
}
theme.command = theme.normal
theme.terminal = theme.insert
return theme
end
local function setup_default()
return setup {
bg = '#282a2e',
alt_bg = '#373b41',
dark_fg = '#969896',
fg = '#b4b7b4',
light_fg = '#c5c8c6',
normal = '#81a2be',
insert = '#b5bd68',
visual = '#b294bb',
replace = '#de935f',
}
end
local function setup_base16_nvim()
-- Continue to load nvim-base16
local loaded, base16 = pcall(require, 'base16-colorscheme')
if not loaded then
add_notice(
'nvim-base16 is not currently present in your runtimepath, make sure it is properly installed,'
.. ' fallback to default colors.'
)
return nil
end
if not base16.colors and not vim.env.BASE16_THEME then
add_notice(
'nvim-base16 is not loaded yet, you should update your configuration to load it before lualine'
.. ' so that the colors from your colorscheme can be used, fallback to "tomorrow-night" theme.'
)
elseif not base16.colors and not base16.colorschemes[vim.env.BASE16_THEME] then
add_notice(
'The colorscheme "%s" defined by the environment variable "BASE16_THEME" is not handled by'
.. ' nvim-base16, fallback to "tomorrow-night" theme.'
)
end
local colors = base16.colors or base16.colorschemes[vim.env.BASE16_THEME or 'tomorrow-night']
return setup {
bg = colors.base01,
alt_bg = colors.base02,
dark_fg = colors.base03,
fg = colors.base04,
light_fg = colors.base05,
normal = colors.base0D,
insert = colors.base0B,
visual = colors.base0E,
replace = colors.base09,
}
end
local function setup_base16_vim()
-- Check if tinted-theming/base16-vim is already loaded
if vim.g.base16_gui00 and vim.g.base16_gui0F then
return setup {
bg = vim.g.base16_gui01,
alt_bg = vim.g.base16_gui02,
dark_fg = vim.g.base16_gui03,
fg = vim.g.base16_gui04,
light_fg = vim.g.base16_gui05,
normal = vim.g.base16_gui0D,
insert = vim.g.base16_gui0B,
visual = vim.g.base16_gui0E,
replace = vim.g.base16_gui09,
}
end
return nil
end
return setup_base16_vim() or setup_base16_nvim() or setup_default()

View File

@ -0,0 +1,38 @@
-- Copyright (c) 2020-2021 Shatur95
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
gray = '#3C3C3C',
lightred = '#D16969',
blue = '#569CD6',
pink = '#C586C0',
black = '#262626',
white = '#D4D4D4',
green = '#608B4E',
}
return {
normal = {
b = { fg = colors.green, bg = colors.black },
a = { fg = colors.black, bg = colors.green, gui = 'bold' },
c = { fg = colors.white, bg = colors.black },
},
visual = {
b = { fg = colors.pink, bg = colors.black },
a = { fg = colors.black, bg = colors.pink, gui = 'bold' },
},
inactive = {
b = { fg = colors.black, bg = colors.blue },
a = { fg = colors.white, bg = colors.gray, gui = 'bold' },
},
replace = {
b = { fg = colors.lightred, bg = colors.black },
a = { fg = colors.black, bg = colors.lightred, gui = 'bold' },
c = { fg = colors.white, bg = colors.black },
},
insert = {
b = { fg = colors.blue, bg = colors.black },
a = { fg = colors.black, bg = colors.blue, gui = 'bold' },
c = { fg = colors.white, bg = colors.black },
},
}

View File

@ -0,0 +1,48 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit itchyny, jackno (lightline)
-- stylua: ignore
local colors = {
gray = '#44475a',
lightgray = '#5f6a8e',
orange = '#ffb86c',
purple = '#bd93f9',
red = '#ff5555',
yellow = '#f1fa8c',
green = '#50fa7b',
white = '#f8f8f2',
black = '#282a36',
}
return {
normal = {
a = { bg = colors.purple, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
insert = {
a = { bg = colors.green, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
visual = {
a = { bg = colors.yellow, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
replace = {
a = { bg = colors.red, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
command = {
a = { bg = colors.orange, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
inactive = {
a = { bg = colors.gray, fg = colors.white, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.gray, fg = colors.white },
},
}

View File

@ -0,0 +1,53 @@
-- Copyright (c) 2020-2021 gnuyent
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
bg0 = '#323d43',
bg1 = '#3c474d',
bg3 = '#505a60',
fg = '#d8caac',
aqua = '#87c095',
green = '#a7c080',
orange = '#e39b7b',
purple = '#d39bb6',
red = '#e68183',
grey1 = '#868d80',
}
return {
normal = {
a = { bg = colors.green, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
insert = {
a = { bg = colors.fg, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
visual = {
a = { bg = colors.red, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
replace = {
a = { bg = colors.orange, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
command = {
a = { bg = colors.aqua, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
terminal = {
a = { bg = colors.purple, fg = colors.bg0, gui = 'bold' },
b = { bg = colors.bg3, fg = colors.fg },
c = { bg = colors.bg1, fg = colors.fg },
},
inactive = {
a = { bg = colors.bg1, fg = colors.grey1, gui = 'bold' },
b = { bg = colors.bg1, fg = colors.grey1 },
c = { bg = colors.bg1, fg = colors.grey1 },
},
}

View File

@ -0,0 +1,29 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
fg1 = '#282828',
color2 = '#504945',
fg2 = '#ddc7a1',
color3 = '#32302f',
color4 = '#a89984',
color5 = '#7daea3',
color6 = '#a9b665',
color7 = '#d8a657',
color8 = '#d3869b',
color9 = '#ea6962',
}
return {
normal = {
a = { fg = colors.fg1, bg = colors.color4, gui = 'bold' },
b = { fg = colors.fg2, bg = colors.color2 },
c = { fg = colors.fg2, bg = colors.color3 },
},
command = { a = { fg = colors.fg1, bg = colors.color5, gui = 'bold' } },
inactive = { a = { fg = colors.fg2, bg = colors.color2 } },
insert = { a = { fg = colors.fg1, bg = colors.color6, gui = 'bold' } },
replace = { a = { fg = colors.fg1, bg = colors.color7, gui = 'bold' } },
terminal = { a = { fg = colors.fg1, bg = colors.color8, gui = 'bold' } },
visual = { a = { fg = colors.fg1, bg = colors.color9, gui = 'bold' } },
}

View File

@ -0,0 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- License: MIT License
local background = vim.opt.background:get()
return require('lualine.themes.gruvbox_' .. background)

View File

@ -0,0 +1,48 @@
-- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
black = '#282828',
white = '#ebdbb2',
red = '#fb4934',
green = '#b8bb26',
blue = '#83a598',
yellow = '#fe8019',
gray = '#a89984',
darkgray = '#3c3836',
lightgray = '#504945',
inactivegray = '#7c6f64',
}
return {
normal = {
a = { bg = colors.gray, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.gray },
},
insert = {
a = { bg = colors.blue, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.lightgray, fg = colors.white },
},
visual = {
a = { bg = colors.yellow, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.inactivegray, fg = colors.black },
},
replace = {
a = { bg = colors.red, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.black, fg = colors.white },
},
command = {
a = { bg = colors.green, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.inactivegray, fg = colors.black },
},
inactive = {
a = { bg = colors.darkgray, fg = colors.gray, gui = 'bold' },
b = { bg = colors.darkgray, fg = colors.gray },
c = { bg = colors.darkgray, fg = colors.gray },
},
}

View File

@ -0,0 +1,47 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
black = '#3c3836',
white = '#f9f5d7',
orange = '#af3a03',
green = '#427b58',
blue = '#076678',
gray = '#d5c4a1',
darkgray = '#7c6f64',
lightgray = '#ebdbb2',
inactivegray = '#a89984'
}
return {
normal = {
a = { bg = colors.darkgray, fg = colors.white, gui = 'bold' },
b = { bg = colors.gray, fg = colors.darkgray },
c = { bg = colors.lightgray, fg = colors.darkgray },
},
insert = {
a = { bg = colors.blue, fg = colors.white, gui = 'bold' },
b = { bg = colors.gray, fg = colors.darkgray },
c = { bg = colors.gray, fg = colors.black },
},
visual = {
a = { bg = colors.orange, fg = colors.white, gui = 'bold' },
b = { bg = colors.gray, fg = colors.darkgray },
c = { bg = colors.darkgray, fg = colors.white },
},
replace = {
a = { bg = colors.green, fg = colors.white, gui = 'bold' },
b = { bg = colors.gray, fg = colors.darkgray },
c = { bg = colors.gray, fg = colors.black },
},
command = {
a = { bg = colors.darkgray, fg = colors.white, gui = 'bold' },
b = { bg = colors.gray, fg = colors.darkgray },
c = { bg = colors.lightgray, fg = colors.darkgray },
},
inactive = {
a = { bg = colors.lightgray, fg = colors.inactivegray },
b = { bg = colors.lightgray, fg = colors.inactivegray },
c = { bg = colors.lightgray, fg = colors.inactivegray },
},
}

View File

@ -0,0 +1,48 @@
-- Copyright (c) 2021 Jnhtr
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
black = '#1c1e26',
white = '#6C6F93',
red = '#F43E5C',
green = '#09F7A0',
blue = '#25B2BC',
yellow = '#F09383',
gray = '#E95678',
darkgray = '#1A1C23',
lightgray = '#2E303E',
inactivegray = '#1C1E26',
}
return {
normal = {
a = { bg = colors.gray, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.white },
},
insert = {
a = { bg = colors.blue, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.white },
},
visual = {
a = { bg = colors.yellow, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.white },
},
replace = {
a = { bg = colors.red, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.white },
},
command = {
a = { bg = colors.green, fg = colors.black, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.white },
c = { bg = colors.darkgray, fg = colors.white },
},
inactive = {
a = { bg = colors.inactivegray, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.inactivegray, fg = colors.lightgray },
c = { bg = colors.inactivegray, fg = colors.lightgray },
},
}

View File

@ -0,0 +1,7 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: itchyny(lightline)
-- License: MIT License
local background = vim.opt.background:get()
return require('lualine.themes.iceberg_' .. background)

View File

@ -0,0 +1,42 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color2 = '#161821',
color3 = '#b4be82',
color4 = '#c6c8d1',
color5 = '#2e313f',
color8 = '#e2a478',
color9 = '#3e445e',
color10 = '#0f1117',
color11 = '#17171b',
color12 = '#818596',
color15 = '#84a0c6',
}
return {
visual = {
a = { fg = colors.color2, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
replace = {
a = { fg = colors.color2, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
inactive = {
a = { fg = colors.color9, bg = colors.color10, gui = 'bold' },
b = { fg = colors.color9, bg = colors.color10 },
c = { fg = colors.color9, bg = colors.color10 },
},
normal = {
a = { fg = colors.color11, bg = colors.color12, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
c = { fg = colors.color4, bg = colors.color10 },
},
insert = {
a = { fg = colors.color2, bg = colors.color15, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
}

View File

@ -0,0 +1,40 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color5 = '#668e3d',
color8 = '#757ca3',
color9 = '#8b98b6',
color10 = '#cad0de',
color11 = '#2d539e',
color0 = '#e8e9ec',
color1 = '#9fa6c0',
color2 = '#c57339',
}
return {
replace = {
b = { fg = colors.color0, bg = colors.color1 },
a = { fg = colors.color0, bg = colors.color2, gui = 'bold' },
},
visual = {
b = { fg = colors.color0, bg = colors.color1 },
a = { fg = colors.color0, bg = colors.color5, gui = 'bold' },
},
normal = {
b = { fg = colors.color0, bg = colors.color1 },
a = { fg = colors.color0, bg = colors.color8, gui = 'bold' },
c = { fg = colors.color9, bg = colors.color10 },
},
inactive = {
b = { fg = colors.color9, bg = colors.color10 },
a = { fg = colors.color9, bg = colors.color10, gui = 'bold' },
c = { fg = colors.color9, bg = colors.color10 },
},
insert = {
b = { fg = colors.color0, bg = colors.color1 },
a = { fg = colors.color0, bg = colors.color11, gui = 'bold' },
},
}

View File

@ -0,0 +1,41 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Generated by lightline to lualine theme converter
-- https://gist.github.com/shadmansaleh/000871c9a608a012721c6acc6d7a19b9
-- stylua: ignore
local colors = {
color2 = '#30302c',
color3 = '#f0a0c0',
color4 = '#e8e8d3',
color5 = '#4e4e43',
color8 = '#cf6a4c',
color9 = '#666656',
color10 = '#808070',
color11 = '#8197bf',
color14 = '#99ad6a',
}
return {
visual = {
a = { fg = colors.color2, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
replace = {
a = { fg = colors.color2, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
inactive = {
c = { fg = colors.color9, bg = colors.color2 },
a = { fg = colors.color10, bg = colors.color2, gui = 'bold' },
b = { fg = colors.color9, bg = colors.color2 },
},
normal = {
c = { fg = colors.color10, bg = colors.color2 },
a = { fg = colors.color2, bg = colors.color11, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
insert = {
a = { fg = colors.color2, bg = colors.color14, gui = 'bold' },
b = { fg = colors.color4, bg = colors.color5 },
},
}

View File

@ -0,0 +1,42 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: Lokesh Krishna(lightline)
-- stylua: ignore
local colors = {
fg = '#eeffff',
bg = '#263238',
blue = '#82aaff',
green = '#c3e88d',
purple = '#c792ea',
red1 = '#f07178',
red2 = '#ff5370',
yellow = '#ffcb6b',
gray1 = '#314549',
gray2 = '#2E3C43',
gray3 = '#515559',
}
return {
normal = {
a = { fg = colors.bg, bg = colors.blue, gui = 'bold' },
b = { fg = colors.fg, bg = colors.gray3 },
c = { fg = colors.fg, bg = colors.gray2 },
},
insert = {
a = { fg = colors.bg, bg = colors.green, gui = 'bold' },
b = { fg = colors.fg, bg = colors.gray3 },
},
visual = {
a = { fg = colors.bg, bg = colors.purple, gui = 'bold' },
b = { fg = colors.fg, bg = colors.gray3 },
},
replace = {
a = { fg = colors.bg, bg = colors.red1, gui = 'bold' },
b = { fg = colors.fg, bg = colors.gray3 },
},
inactive = {
a = { fg = colors.fg, bg = colors.bg, gui = 'bold' },
b = { fg = colors.fg, bg = colors.bg },
c = { fg = colors.fg, bg = colors.gray2 },
},
}

View File

@ -0,0 +1,48 @@
-- Copyright (c) 2020-2021 ronniedroid
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
black = '#000000',
white = '#eeeeee',
red = '#ffa0a0',
green = '#88cf88',
blue = '#92baff',
magenta = '#feacd0',
cyan = '#a0bfdf',
gray = '#2f2f2f',
darkgray = '#202020',
lightgray = '#434343'
}
return {
normal = {
a = { bg = colors.blue, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.blue },
c = { bg = colors.gray, fg = colors.white },
},
insert = {
a = { bg = colors.cyan, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.cyan },
c = { bg = colors.gray, fg = colors.white },
},
visual = {
a = { bg = colors.magenta, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.magenta },
c = { bg = colors.gray, fg = colors.white },
},
replace = {
a = { bg = colors.red, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.red },
c = { bg = colors.gray, fg = colors.white },
},
command = {
a = { bg = colors.green, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.lightgray, fg = colors.green },
c = { bg = colors.gray, fg = colors.white },
},
inactive = {
a = { bg = colors.darkgray, fg = colors.lightgray, gui = 'bold' },
b = { bg = colors.darkgray, fg = colors.lightgray },
c = { bg = colors.darkgray, fg = colors.lightgray },
},
}

View File

@ -0,0 +1,31 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: challsted(lightline)
-- stylua: ignore
local colors = {
black = '#232526',
gray = '#808080',
white = '#f8f8f2',
cyan = '#66d9ef',
green = '#a6e22e',
orange = '#ef5939',
pink = '#f92672',
red = '#ff0000',
yellow = '#e6db74',
}
return {
normal = {
a = { fg = colors.black, bg = colors.cyan, gui = 'bold' },
b = { fg = colors.black, bg = colors.pink },
c = { fg = colors.orange, bg = colors.black },
},
insert = { a = { fg = colors.black, bg = colors.green, gui = 'bold' } },
visual = { a = { fg = colors.black, bg = colors.yellow, gui = 'bold' } },
replace = { a = { fg = colors.black, bg = colors.red, gui = 'bold' } },
inactive = {
a = { fg = colors.pink, bg = colors.black, gui = 'bold' },
b = { fg = colors.white, bg = colors.pink },
c = { fg = colors.gray, bg = colors.black },
},
}

View File

@ -0,0 +1,40 @@
-- moonfly color scheme for lualine
--
-- URL: github.com/bluz71/vim-moonfly-colors
-- License: MIT (https://opensource.org/licenses/MIT)
-- stylua: ignore
local colors = {
color3 = '#303030',
color6 = '#9e9e9e',
color7 = '#80a0ff',
color8 = '#ae81ff',
color0 = '#1c1c1c',
color1 = '#ff5189',
color2 = '#c6c6c6',
}
return {
replace = {
a = { fg = colors.color0, bg = colors.color1, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
inactive = {
a = { fg = colors.color6, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color6, bg = colors.color3 },
c = { fg = colors.color6, bg = colors.color3 },
},
normal = {
a = { fg = colors.color0, bg = colors.color7, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
c = { fg = colors.color2, bg = colors.color3 },
},
visual = {
a = { fg = colors.color0, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
insert = {
a = { fg = colors.color0, bg = colors.color2, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
}

View File

@ -0,0 +1,37 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
color3 = '#2c3043',
color6 = '#a1aab8',
color7 = '#82aaff',
color8 = '#ae81ff',
color0 = '#092236',
color1 = '#ff5874',
color2 = '#c3ccdc',
}
return {
replace = {
a = { fg = colors.color0, bg = colors.color1, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
inactive = {
a = { fg = colors.color6, bg = colors.color3, gui = 'bold' },
b = { fg = colors.color6, bg = colors.color3 },
c = { fg = colors.color6, bg = colors.color3 },
},
normal = {
a = { fg = colors.color0, bg = colors.color7, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
c = { fg = colors.color2, bg = colors.color3 },
},
visual = {
a = { fg = colors.color0, bg = colors.color8, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
insert = {
a = { fg = colors.color0, bg = colors.color2, gui = 'bold' },
b = { fg = colors.color2, bg = colors.color3 },
},
}

View File

@ -0,0 +1,28 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- stylua: ignore
local colors = {
nord1 = '#3B4252',
nord3 = '#4C566A',
nord5 = '#E5E9F0',
nord6 = '#ECEFF4',
nord7 = '#8FBCBB',
nord8 = '#88C0D0',
nord13 = '#EBCB8B',
}
return {
normal = {
a = { fg = colors.nord1, bg = colors.nord8, gui = 'bold' },
b = { fg = colors.nord5, bg = colors.nord1 },
c = { fg = colors.nord5, bg = colors.nord3 },
},
insert = { a = { fg = colors.nord1, bg = colors.nord6, gui = 'bold' } },
visual = { a = { fg = colors.nord1, bg = colors.nord7, gui = 'bold' } },
replace = { a = { fg = colors.nord1, bg = colors.nord13, gui = 'bold' } },
inactive = {
a = { fg = colors.nord1, bg = colors.nord8, gui = 'bold' },
b = { fg = colors.nord5, bg = colors.nord1 },
c = { fg = colors.nord5, bg = colors.nord1 },
},
}

View File

@ -0,0 +1,36 @@
-- Copyright (c) 2020-2021 shadmansaleh
-- MIT license, see LICENSE for more details.
-- Credit: Zoltan Dalmadi(lightline)
-- stylua: ignore
local colors = {
blue = '#61afef',
green = '#98c379',
purple = '#c678dd',
cyan = '#56b6c2',
red1 = '#e06c75',
red2 = '#be5046',
yellow = '#e5c07b',
fg = '#abb2bf',
bg = '#282c34',
gray1 = '#828997',
gray2 = '#2c323c',
gray3 = '#3e4452',
}
return {
normal = {
a = { fg = colors.bg, bg = colors.green, gui = 'bold' },
b = { fg = colors.fg, bg = colors.gray3 },
c = { fg = colors.fg, bg = colors.gray2 },
},
command = { a = { fg = colors.bg, bg = colors.yellow, gui = 'bold' } },
insert = { a = { fg = colors.bg, bg = colors.blue, gui = 'bold' } },
visual = { a = { fg = colors.bg, bg = colors.purple, gui = 'bold' } },
terminal = { a = { fg = colors.bg, bg = colors.cyan, gui = 'bold' } },
replace = { a = { fg = colors.bg, bg = colors.red1, gui = 'bold' } },
inactive = {
a = { fg = colors.gray1, bg = colors.bg, gui = 'bold' },
b = { fg = colors.gray1, bg = colors.bg },
c = { fg = colors.gray1, bg = colors.gray2 },
},
}

Some files were not shown because too many files have changed in this diff Show More