-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db0a947
Showing
11 changed files
with
280 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: CI | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
matrix: | ||
# os: [ubuntu-latest, windows-latest] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Install Neovim | ||
shell: bash | ||
run: | | ||
mkdir -p /tmp/nvim | ||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage | ||
cd /tmp/nvim | ||
chmod a+x ./nvim.appimage | ||
./nvim.appimage --appimage-extract | ||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH | ||
- name: Run Tests | ||
run: | | ||
nvim --version | ||
[ ! -d tests ] && exit 0 | ||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}" | ||
docs: | ||
runs-on: ubuntu-latest | ||
needs: tests | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: panvimdoc | ||
uses: kdheepak/panvimdoc@main | ||
with: | ||
vimdoc: word.nvim | ||
version: "Neovim >= 0.8.0" | ||
demojify: true | ||
treesitter: true | ||
- name: Push changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: "chore(build): auto-generate vimdoc" | ||
commit_user_name: "github-actions[bot]" | ||
commit_user_email: "github-actions[bot]@users.noreply.github.com" | ||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>" | ||
release: | ||
name: release | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
needs: | ||
- docs | ||
- tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: google-github-actions/release-please-action@v3 | ||
id: release | ||
with: | ||
release-type: simple | ||
package-name: word.nvim | ||
extra-files: | | ||
lua/lazy/core/config.lua | ||
- uses: actions/checkout@v3 | ||
- name: tag stable versions | ||
if: ${{ steps.release.outputs.release_created }} | ||
run: | | ||
git config user.name github-actions[bot] | ||
git config user.email github-actions[bot]@users.noreply.github.com | ||
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git" | ||
git tag -d stable || true | ||
git push origin :stable || true | ||
git tag -a stable -m "Last Stable Release" | ||
git push origin stable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json", | ||
"runtime": { | ||
"version": "LuaJIT" | ||
}, | ||
"workspace": { | ||
"library": [ | ||
"runtime/lua", | ||
"${3rd}/luv/library" | ||
], | ||
"ignoreDir": [ | ||
"test" | ||
], | ||
"checkThirdParty": "Disable" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
column_width = 100 | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 2 | ||
quote_style = "AutoPreferSingle" | ||
call_parentheses = "Input" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
## WIP |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
return { | ||
ui_launch = function() require('word.ui').launch() end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
local default_opts = {} | ||
|
||
return { | ||
setup = function(opts) end, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
local M = {} | ||
|
||
M.setup = function(opts) | ||
require('word.config').setup(opts) | ||
end | ||
|
||
return setmetatable(M, { | ||
__index = function(_, k) | ||
return require('word.commands')[k] | ||
end, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
local Menu = require('nui.menu') | ||
local event = require('nui.utils.autocmd').event | ||
local Layout = require('nui.layout') | ||
|
||
local menu = Menu({ | ||
position = '50%', | ||
size = { width = '50%', height = '60%' }, | ||
border = { | ||
style = 'single', | ||
text = { top = '[Choose-an-Element]', top_align = 'center' }, | ||
}, | ||
win_options = { | ||
winhighlight = 'Normal:Normal,FloatBorder:Normal', | ||
}, | ||
}, { | ||
lines = { | ||
Menu.item('Hydrogen (H)'), | ||
Menu.item('Carbon (C)'), | ||
Menu.item('Nitrogen (N)'), | ||
Menu.separator('Noble-Gases', { char = '-', text_align = 'right' }), | ||
Menu.item('Helium (He)'), | ||
Menu.item('Neon (Ne)'), | ||
Menu.item('Argon (Ar)'), | ||
}, | ||
max_width = 20, | ||
keymap = { | ||
focus_next = { 'j', '<Down>', '<Tab>' }, | ||
focus_prev = { 'k', '<Up>', '<S-Tab>' }, | ||
close = { '<Esc>', '<C-c>' }, | ||
submit = { '<CR>', '<Space>' }, | ||
}, | ||
on_close = function() | ||
print('Menu Closed!') | ||
end, | ||
on_submit = function(item) | ||
print('Menu Submitted: ', item.text) | ||
end, | ||
}) | ||
|
||
local layout = Layout( | ||
{ position = '50%', size = { width = 80, height = '60%' } }, | ||
Layout.Box({ | ||
Layout.Box(menu, { size = '60%' }), | ||
}, { dir = 'col' }) | ||
) | ||
|
||
layout:mount() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
local Popup = require('nui.popup') | ||
local event = require('nui.utils.autocmd').event | ||
local Layout = require('nui.layout') | ||
local NuiLine = require('nui.line') | ||
|
||
local Util = require('word.util') | ||
|
||
local cet6_json_path = '~/cet.json' | ||
local bookmark_json_path = '~/cet-bookmark.json' | ||
|
||
local dict = vim.json.decode(Util.read_file(cet6_json_path)) | ||
local words = vim.tbl_keys(dict) | ||
table.sort(words, function(a, b) | ||
return a:lower() < b:lower() | ||
end) | ||
|
||
local popup = Popup({ | ||
enter = true, | ||
focusable = true, | ||
border = { style = 'rounded' }, | ||
position = '50%', | ||
size = { width = '50%', height = '60%' }, | ||
}) | ||
|
||
local layout = Layout( | ||
{ | ||
position = '50%', | ||
size = { width = '50%', height = '60%' }, | ||
}, | ||
Layout.Box({ | ||
Layout.Box(popup, { size = '100%' }), | ||
}, { dir = 'row' }) | ||
) | ||
|
||
local toggle_ed = {} | ||
|
||
local buf_update = function(bufnr, line_nr) | ||
for i = 1, #words do | ||
local word = words[i] | ||
local line = NuiLine() | ||
|
||
local sig = toggle_ed[i] and 'x' or ' ' | ||
if line_nr == i then | ||
line:append(('[%s]\t'):format(sig), 'Error') | ||
else | ||
line:append(('[%s]\t'):format(sig), 'Error') | ||
end | ||
line:append(('%-16s'):format(word), 'Function') | ||
line:append('\t') | ||
line:append(('%s'):format(dict[word]), 'String') | ||
line:render(bufnr, -1, i) | ||
end | ||
end | ||
|
||
local keymap_setup = function() | ||
popup:map('n', 'm', function() | ||
local line_nr = vim.fn.line '.' | ||
if toggle_ed[line_nr] then | ||
toggle_ed[line_nr] = nil | ||
else | ||
toggle_ed[line_nr] = true | ||
end | ||
buf_update(popup.bufnr, line_nr) | ||
end) | ||
-- update bookmark | ||
popup:map('n', 'w', function() | ||
local save = {} | ||
for i in pairs(toggle_ed) do | ||
table.insert(save, words[i]) | ||
end | ||
local data = vim.json.encode(save) | ||
Util.write_file(bookmark_json_path, data) | ||
end) | ||
-- show words' detail | ||
-- popup:map('n', 'o', show_detail()) | ||
end | ||
|
||
local launch = function() | ||
layout:mount() | ||
popup:on(event.BufLeave, function() | ||
popup:unmount() | ||
end) | ||
keymap_setup() | ||
buf_update(popup.bufnr) | ||
end | ||
|
||
launch() | ||
|
||
return { | ||
launch = launch, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
local M = {} | ||
|
||
M.read_file = function(path) | ||
path = vim.fs.normalize(path) | ||
local fd = assert(io.open(path, 'r')) | ||
if fd == nil then | ||
vim.notify('fail to open file', vim.log.levels.ERROR, { title = 'word.nvim' }) | ||
return | ||
end | ||
---@type string | ||
local data = fd:read('*a') | ||
fd:close() | ||
return data | ||
end | ||
|
||
M.write_file = function(path, data) | ||
path = vim.fs.normalize(path) | ||
local fd = assert(io.open(path, 'w')) | ||
if fd == nil then | ||
vim.notify('fail to open file', vim.log.levels.ERROR, { title = 'word.nvim' }) | ||
return | ||
end | ||
fd:write(data) | ||
fd:close() | ||
end | ||
return M |