Skip to content

Commit 64708f4

Browse files
committed
feat: test ci
1 parent 3f8a5d3 commit 64708f4

File tree

11 files changed

+188
-43
lines changed

11 files changed

+188
-43
lines changed

.github/workflows/ci.yml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
tests:
9+
strategy:
10+
matrix:
11+
os: [ubuntu-latest]
12+
runs-on: ${{ matrix.os }}
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Install Neovim
16+
shell: bash
17+
run: |
18+
mkdir -p /tmp/nvim
19+
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
20+
cd /tmp/nvim
21+
chmod a+x ./nvim.appimage
22+
./nvim.appimage --appimage-extract
23+
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
24+
- name: Run Tests
25+
run: |
26+
nvim --version
27+
[ ! -d tests ] && exit 0
28+
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
29+
docs:
30+
runs-on: ubuntu-latest
31+
needs: tests
32+
if: ${{ github.ref == 'refs/heads/master' }}
33+
steps:
34+
- uses: actions/checkout@v3
35+
- name: panvimdoc
36+
uses: kdheepak/panvimdoc@main
37+
with:
38+
vimdoc: BeastVim
39+
version: "Neovim >= 0.8.0"
40+
demojify: true
41+
treesitter: true
42+
- name: Push changes
43+
uses: stefanzweifel/git-auto-commit-action@v4
44+
with:
45+
commit_message: "chore(build): auto-generate vimdoc"
46+
commit_user_name: "github-actions[bot]"
47+
commit_user_email: "github-actions[bot]@users.noreply.github.com"
48+
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
49+
release:
50+
name: release
51+
if: ${{ github.ref == 'refs/heads/master' }}
52+
needs:
53+
- docs
54+
- tests
55+
runs-on: ubuntu-latest
56+
steps:
57+
- uses: google-github-actions/release-please-action@v3
58+
id: release
59+
with:
60+
release-type: simple
61+
package-name: BeastVim
62+
- uses: actions/checkout@v3
63+
- name: tag stable versions
64+
if: ${{ steps.release.outputs.release_created }}
65+
run: |
66+
git config user.name github-actions[bot]
67+
git config user.email github-actions[bot]@users.noreply.github.com
68+
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
69+
git tag -d stable || true
70+
git push origin :stable || true
71+
git tag -a stable -m "Last Stable Release"
72+
git push origin stable

lua/tvl/config/lsp/keymaps.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function M.get()
3333
}
3434
end
3535

36-
function M.resolve(buffer)
36+
function M.resolve(bufnr)
3737
local Keys = require("lazy.core.handler.keys")
3838
local keymaps = {}
3939

@@ -50,7 +50,7 @@ function M.resolve(buffer)
5050
end
5151

5252
local opts = require("tvl.util").opts("nvim-lspconfig")
53-
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
53+
local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
5454
for _, client in ipairs(clients) do
5555
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
5656
for _, keymap in ipairs(maps) do
@@ -60,14 +60,14 @@ function M.resolve(buffer)
6060
return keymaps
6161
end
6262

63-
M.attach = function(_, buffer)
63+
M.attach = function(_, bufnr)
6464
local Keys = require("lazy.core.handler.keys")
65-
local keymaps = M.resolve(buffer)
65+
local keymaps = M.resolve(bufnr)
6666

6767
for _, keys in pairs(keymaps) do
6868
local opts = Keys.opts(keys)
6969
opts.silent = opts.silent ~= false
70-
opts.buffer = buffer
70+
opts.buffer = bufnr
7171
vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts)
7272
end
7373
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# How to Create a Component
2+
3+
A lualine component is a function that return a string.
4+
5+
To create a new component, follow these steps:
6+
1. Open the `components.lua` file.
7+
2. Add the following code snippet to the file:
8+
```lua
9+
M.<your_component_name> = function()
10+
return <content>
11+
end
12+
```
13+
Replace `<your_component_name>` with the desired name for your component.
14+
Replace `<content>` with the code or functionality you want your component to have.

lua/tvl/config/lualine/components.lua

+67-26
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
local config = require("tvl.config.lualine.config").options
2-
local icons = require("tvl.core.icons")
1+
local Config = require("tvl.config.lualine.config").options
2+
local Icons = require("tvl.core.icons")
3+
local Util = require("tvl.util")
34

45
local M = {}
56

6-
local hl_str = function(str, hl_cur, hl_after)
7+
---@param text string text to be highlighted
8+
---@param hl_cur string highlight group for current text
9+
---@param hl_after? string highlight group for text after current text
10+
local hl_str = function(text, hl_cur, hl_after)
711
if hl_after == nil then
8-
return "%#" .. hl_cur .. "#" .. str .. "%*"
12+
return "%#" .. hl_cur .. "#" .. text .. "%*"
913
end
10-
return "%#" .. hl_cur .. "#" .. str .. "%*" .. "%#" .. hl_after .. "#"
14+
return "%#" .. hl_cur .. "#" .. text .. "%*" .. "%#" .. hl_after .. "#"
1115
end
1216

1317
local function hide_in_width()
@@ -35,26 +39,26 @@ M.branch = {
3539
end
3640
prev_branch = str
3741
local icon = hl_str("", "SLGitIcon", "SLBranchName")
38-
return hl_str(config.separator_icon.left, "SLSeparator")
42+
return hl_str(Config.separator_icon.left, "SLSeparator")
3943
.. hl_str(icon, "SLGitIcon")
4044
.. hl_str(truncate(str, 10), "SLBranchName")
41-
.. hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
45+
.. hl_str(Config.separator_icon.right, "SLSeparator", "SLSeparator")
4246
end,
4347
}
4448

4549
M.position = function()
4650
-- print(vim.inspect(config.separator_icon))
4751
local current_line = vim.fn.line(".")
4852
local current_column = vim.fn.col(".")
49-
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
50-
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
53+
local left_sep = hl_str(Config.separator_icon.left, "SLSeparator")
54+
local right_sep = hl_str(Config.separator_icon.right, "SLSeparator", "SLSeparator")
5155
local str = "Ln " .. current_line .. ", Col " .. current_column
5256
return left_sep .. hl_str(str, "SLPosition", "SLPosition") .. right_sep
5357
end
5458

5559
M.spaces = function()
56-
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
57-
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
60+
local left_sep = hl_str(Config.separator_icon.left, "SLSeparator")
61+
local right_sep = hl_str(Config.separator_icon.right, "SLSeparator", "SLSeparator")
5862
local str = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
5963
return left_sep .. hl_str(str, "SLShiftWidth", "SLShiftWidth") .. right_sep
6064
end
@@ -73,15 +77,32 @@ M.diagnostics = function()
7377
end
7478

7579
local error_count, warn_count, info_count, hint_count = nvim_diagnostic()
76-
local error_hl = hl_str(icons.diagnostics.error .. " " .. error_count, "SLError", "SLError")
77-
local warn_hl = hl_str(icons.diagnostics.warn .. " " .. warn_count, "SLWarning", "SLWarning")
78-
local info_hl = hl_str(icons.diagnostics.info .. " " .. info_count, "SLInfo", "SLInfo")
79-
local hint_hl = hl_str(icons.diagnostics.hint .. " " .. hint_count, "SLInfo", "SLInfo")
80-
local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator")
81-
local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
80+
local error_hl = hl_str(Icons.diagnostics.error .. " " .. error_count, "SLError", "SLError")
81+
local warn_hl = hl_str(Icons.diagnostics.warn .. " " .. warn_count, "SLWarning", "SLWarning")
82+
---@diagnostic disable-next-line: unused-local
83+
local info_hl = hl_str(Icons.diagnostics.info .. " " .. info_count, "SLInfo", "SLInfo")
84+
local hint_hl = hl_str(Icons.diagnostics.hint .. " " .. hint_count, "SLInfo", "SLInfo")
85+
local left_sep = hl_str(Config.thin_separator_icon.left, "SLSeparator")
86+
local right_sep = hl_str(Config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
8287
return left_sep .. error_hl .. " " .. warn_hl .. " " .. hint_hl .. right_sep
8388
end
8489

90+
---@param content string
91+
---@param type? "fill"|"empty"
92+
local build_module = function(content, type)
93+
local left_sep = ""
94+
local right_sep = ""
95+
if type == "fill" then
96+
left_sep = hl_str(Config.separator_icon.left, "SLSeparator")
97+
right_sep = hl_str(Config.separator_icon.right, "SLSeparator", "SLSeparator")
98+
end
99+
if type == "empty" then
100+
left_sep = hl_str(Config.thin_separator_icon.left, "SLSeparator")
101+
right_sep = hl_str(Config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
102+
end
103+
return left_sep .. content .. right_sep
104+
end
105+
85106
M.diff = {
86107
"diff",
87108
colored = true,
@@ -91,16 +112,16 @@ M.diff = {
91112
removed = "SLDiffDelete",
92113
},
93114
symbols = {
94-
added = icons.git.added .. " ",
95-
modified = icons.git.modified .. " ",
96-
removed = icons.git.removed .. " ",
115+
added = Icons.git.added .. " ",
116+
modified = Icons.git.modified .. " ",
117+
removed = Icons.git.removed .. " ",
97118
}, -- changes diff symbols
98119
fmt = function(str)
99120
if str == "" then
100121
return ""
101122
end
102-
local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator")
103-
local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
123+
local left_sep = hl_str(Config.thin_separator_icon.left, "SLSeparator")
124+
local right_sep = hl_str(Config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
104125
return left_sep .. str .. right_sep
105126
end,
106127
cond = hide_in_width,
@@ -109,12 +130,32 @@ M.diff = {
109130
M.mode = {
110131
"mode",
111132
fmt = function(str)
112-
local left_sep = hl_str(config.separator_icon.left, "SLSeparator", "SLPadding")
113-
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLPadding")
133+
local left_sep = hl_str(Config.separator_icon.left, "SLSeparator", "SLPadding")
134+
local right_sep = hl_str(Config.separator_icon.right, "SLSeparator", "SLPadding")
114135
return left_sep .. hl_str(str, "SLMode") .. right_sep
115136
end,
116137
}
117138

139+
M.cmp_source = function(name)
140+
local ok, _ = pcall(require, "cmp")
141+
if not ok then
142+
return ""
143+
end
144+
for _, s in ipairs(require("cmp").core.sources) do
145+
if s.name == name then
146+
-- Warning if not icons.misc doesn't have name
147+
if not Icons.misc[name] then
148+
Util.notify("No icon for " .. name, "warn")
149+
end
150+
print("hello")
151+
end
152+
end
153+
return function()
154+
local text = Icons.misc[name]
155+
return build_module(hl_str(text, "CmpItemKindVariable"), "fill")
156+
end
157+
end
158+
118159
local prev_filetype = ""
119160
M.filetype = {
120161
"filetype",
@@ -155,8 +196,8 @@ M.filetype = {
155196
prev_filetype = str
156197
filetype_str = str
157198
end
158-
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
159-
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
199+
local left_sep = hl_str(Config.separator_icon.left, "SLSeparator")
200+
local right_sep = hl_str(Config.separator_icon.right, "SLSeparator", "SLSeparator")
160201
-- Upper case first character
161202
filetype_str = filetype_str:gsub("%a", string.upper, 1)
162203
local filetype_hl = hl_str(filetype_str, "SLFiletype", "SLFiletype")

lua/tvl/config/lualine/config.lua

-5
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ local default = {
1212
-- thin_separator_icon = { left = " ", right = " " },
1313
}
1414

15-
---@type LualineConfig
16-
M.options = {}
17-
1815
---@param type "bubble" | "triangle"
1916
local function make_separator(type)
2017
if type == "bubble" then
@@ -35,6 +32,4 @@ M.setup = function(opts)
3532
end
3633
end
3734

38-
M.setup()
39-
4035
return M

lua/tvl/config/lualine/init.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ local config = require("tvl.config.lualine.config")
22

33
local M = {}
44

5-
local function setup()
5+
local function setup_lualine()
66
local cpn = require("tvl.config.lualine.components")
77
local theme = require("tvl.config.lualine.highlights").custom(config.options)
88

@@ -27,7 +27,7 @@ local function setup()
2727
sections = {
2828
lualine_a = { cpn.branch },
2929
lualine_b = { cpn.diagnostics },
30-
lualine_c = {},
30+
lualine_c = { cpn.cmp_source("codeium") },
3131
lualine_x = { cpn.diff },
3232
lualine_y = { cpn.position, cpn.filetype },
3333
lualine_z = { cpn.spaces, cpn.mode },
@@ -45,13 +45,13 @@ local function setup()
4545
})
4646
end
4747

48-
M.setup = config.setup
48+
M.setup_config = config.setup
4949

5050
M.load = function()
51-
setup()
51+
setup_lualine()
5252
vim.api.nvim_create_autocmd("ColorScheme", {
5353
callback = function()
54-
setup()
54+
setup_lualine()
5555
end,
5656
})
5757
end

lua/tvl/core/keymaps.lua

+2
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ map("n", "<leader>/", ":split<CR>", opts)
6565
-------------------- Switch two windows ------------------------
6666
map("n", "<A-o>", "<C-w>r", opts)
6767

68+
-- TODO: move this to compile.nvim
6869
-------------------- Compile --------------------------------
6970
map("n", "<c-m-n>", "<cmd>only | Compile<CR>", opts)
7071

72+
-- TODO: move this to treesitter
7173
-------------------- Inspect --------------------------------
7274
map("n", "<F2>", "<cmd>Inspect<CR>", opts)
7375

lua/tvl/core/resources/coding.lua

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ return {
1414
},
1515
},
1616

17+
-- TODO: move to `lsp - typescript`
1718
{
1819
"mattn/emmet-vim",
1920
event = { "BufRead", "BufNewFile" },

lua/tvl/core/resources/editor.lua

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ return {
2828
},
2929
},
3030
opts = require("tvl.config.neo-tree"),
31+
deactivate = function()
32+
vim.cmd([[Neotree close]])
33+
end,
3134
init = function()
3235
vim.g.neo_tree_remove_legacy_commands = 1
3336
if vim.fn.argc() == 1 then

lua/tvl/core/resources/ui.lua

+7-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ return {
113113
end,
114114
config = function(_, opts)
115115
local lualine_config = require("tvl.config.lualine")
116-
lualine_config.setup(opts)
116+
lualine_config.setup_config(opts)
117117
lualine_config.load()
118118
end,
119119
},
@@ -346,7 +346,12 @@ return {
346346
},
347347
},
348348
lsp = {
349-
progress = { enabled = true },
349+
progress = {
350+
enabled = true,
351+
format = "lsp_progress",
352+
format_done = "lsp_progress_done",
353+
view = "mini",
354+
},
350355
hover = { enabled = false },
351356
signature = { enabled = false },
352357
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**

0 commit comments

Comments
 (0)