Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Electron (!) via Tauri #336

Draft
wants to merge 69 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
51496bf
start of port to tauri
smolck Jul 27, 2021
8d463a2
main thing is we now use webgl1 instead of 2 'cuz reasons
smolck Jul 27, 2021
023a17b
More stuff, don't worry about it, kind of a mess rn
smolck Jul 30, 2021
b3a3773
fix the build
smolck Jul 30, 2021
44166ef
formatting is nice
smolck Jul 30, 2021
092cf93
lots of stuff but hey text renders
smolck Aug 1, 2021
7121b90
option_set handling and I just realized fonts w/webview may be a bit …
smolck Aug 1, 2021
64128e8
well this is kinda verbose
smolck Aug 1, 2021
9fa634c
less repetition, although kinda hacky . . . but it does work
smolck Aug 1, 2021
8f5b5a0
We have input! and dead keys are broken I think . . .
smolck Aug 1, 2021
8523d6a
and now the cursor shows up too
smolck Aug 1, 2021
c231679
Fix grid_scroll handler parsing
smolck Aug 1, 2021
abbbeea
cmdline works now . . . or at least sort of
smolck Aug 2, 2021
3080a44
proper url for roboto-mono.ttf asset
smolck Aug 2, 2021
55691d1
Add font-related command, usefulness/use TBD
smolck Aug 2, 2021
45cd7a1
colors!
smolck Aug 2, 2021
5618676
now we have modes too
smolck Aug 2, 2021
28d1891
Don't need this log
smolck Aug 2, 2021
6d461e7
or this one
smolck Aug 2, 2021
9651356
win_viewport and flush
smolck Aug 2, 2021
e3269f5
popupmenu redraw events
smolck Aug 2, 2021
71cebec
cmdline_pos handling
smolck Aug 2, 2021
25c6a02
set_title
smolck Aug 2, 2021
75b0db0
make the search feature thing work . . . sorta
smolck Aug 2, 2021
3e5120b
fix bug causing the statusline to not appear
smolck Aug 2, 2021
f9998f2
fix cursor.ts error and remove log
smolck Aug 2, 2021
03a8b91
fix initial ui size being wrong/too large/etc.
smolck Aug 2, 2021
759f344
no. just. no.
smolck Aug 2, 2021
463b1cb
let's not document.body.appendChild the font atlas
smolck Aug 3, 2021
cdb108a
quick little cleanup
smolck Aug 3, 2021
1deb506
win_close & grid_destroy
smolck Aug 4, 2021
6e06297
use master nvim-rs, ext message preparation, close stuff, maybe other…
smolck Aug 5, 2021
4f2cd06
Format this file
smolck Aug 7, 2021
18b1087
refactor rust redraw event handling, ext messages
smolck Aug 9, 2021
86bcd26
One time use shortcuts, and groundwork for global shortcuts
smolck Aug 9, 2021
bad1642
format helpers
smolck Aug 9, 2021
7842f6a
cargo fmt
smolck Aug 9, 2021
f606daf
Wildmenu
smolck Aug 10, 2021
bdaf028
formatting
smolck Aug 10, 2021
234de84
Ugly code, but hey now we have nyancat and state and buffers and stuff
smolck Aug 10, 2021
f15ce5d
pick-color and messages stuff and stealInput stuff and stuff
smolck Aug 11, 2021
1820c09
explorer component is now a thing that works . . . sort of, kinda broken
smolck Aug 11, 2021
6a47ebd
code actions work again . . . I think
smolck Aug 13, 2021
27e3a13
stylua and prettier
smolck Aug 13, 2021
d5df063
lsp diagnostics (in statusline) working again . . . I think
smolck Aug 13, 2021
4314864
win_float_pos . . . and man are floats broken
smolck Aug 13, 2021
3094e86
formatting
smolck Aug 13, 2021
7fdeb20
signature help
smolck Aug 13, 2021
52f60d9
lsp hover and don't send method in notify for hover & signature-help
smolck Aug 13, 2021
5884a01
lsp references UI now works
smolck Aug 13, 2021
f8731dc
git stuff in statusline
smolck Aug 13, 2021
475e75b
Fix (?) background being grey/off
smolck Aug 13, 2021
8b51938
ext_tabline and win_hide (which apparently is necessary for ext_tabline)
smolck Aug 13, 2021
685e048
window nameplates and stuff
smolck Aug 14, 2021
8c8cb93
refactor and break things to fix later/soon
smolck Aug 31, 2021
681af89
Restructure things since src/main and src/common are no longer necess…
smolck Aug 31, 2021
ead9b8a
Make components work and stuff
smolck Aug 31, 2021
3228db2
more components and stuff
smolck Sep 4, 2021
bfb4dd4
Remove and maybe add stuff and loadingSize stuff which is ugly
smolck Sep 4, 2021
b79b966
Let's not talk about how long this took me
smolck Sep 4, 2021
4f4fba4
code actions! and it might be kinda finicky
smolck Sep 4, 2021
3dc3882
Just gonna ignore these for now I think, this stuff needs work anyways
smolck Sep 5, 2021
e526e06
Add color picker and . . . it doesn't work, so that's a thing
smolck Sep 6, 2021
1c105c0
Remove stuff we don't need anymore
smolck Sep 6, 2021
b8d9972
Fallback to roboto mono like is supposed to happen
smolck Sep 6, 2021
ef7f4ac
fix package things
smolck Sep 7, 2021
529c4dd
remove tauri conf icon stuff
smolck Sep 7, 2021
c1f1435
use non-gpu-backed canvaskit for testing and stuff
smolck Sep 8, 2021
0577d46
this makes text look . . . good? finally??
smolck Sep 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,027 changes: 8,041 additions & 986 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"description": "Extensible Neovim GUI forked from Veonim",
"main": "build/main/main.js",
"scripts": {
"dev": "npm run build && electron build/main/main.js",
"tauri": "tauri",
"dev": "npm run build && tauri dev",
"prod": "npm run build:prod && NODE_ENV=production electron build/main/main.js",
"prod:start": "NODE_ENV=production electron build/main/main.js",
"build": "node tools/build.js",
Expand All @@ -31,6 +32,8 @@
},
"homepage": "https://github.com/smolck/uivonim",
"dependencies": {
"@tauri-apps/api": "^1.0.0-beta.5",
"canvaskit-wasm": "^0.29.0",
"feather-icons": "^4.28.0",
"fuzzaldrin-plus": "^0.6.0",
"highlight.js": "^10.7.2",
Expand All @@ -48,13 +51,15 @@
"@babel/plugin-transform-modules-commonjs": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"@medv/finder": "^2.0.0",
"@tauri-apps/cli": "^1.0.0-beta.6",
"@types/fuzzaldrin-plus": "^0.6.2",
"@types/marked": "^2.0.4",
"@types/node": "^16.4.7",
"@types/webgl2": "0.0.6",
"babel-loader": "^8.2.2",
"babel-plugin-inferno": "^6.3.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"copy-webpack-plugin": "^9.0.1",
"electron": "^13.1.7",
"electron-builder": "^22.11.7",
"electron-devtools-installer": "^3.2.0",
Expand Down
2 changes: 1 addition & 1 deletion runtime/lua/uivonim.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local M = {}

function M.notify_uivonim(message, ...)
vim.rpcnotify(0, 'uivonim', message, {...})
vim.rpcnotify(0, 'uivonim', message, { ... })
end

function M.disable_default_shortcuts()
Expand Down
91 changes: 91 additions & 0 deletions runtime/lua/uivonim/git.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
local M = {}
local Job = require('plenary.job')
local notify_uivonim = require('uivonim').notify_uivonim

local function shell(cwd, cb, ...)
local args = { ... }
local command = args[1]
table.remove(args, 1)

local stuff = {}
local j = Job:new({
command = command,
args = args,
cwd = cwd,
enable_recording = true,
on_stdout = function(_, data)
table.insert(stuff, data)
end,
on_exit = vim.schedule_wrap(function()
cb(stuff)
end),
})

local ok = pcall(function()
j:start()
end)

if not ok then
cb()
end

-- TODO(smolck): args here should be . . . ?
-- def at https://github.com/nvim-lua/plenary.nvim/blob/6a51028a103518826423b0c408077ea7e258f1ee/lua/plenary/job.lua#L445
-- local _, res = pcall(function()
-- return j:sync(2000, 5)
-- end)
-- return res
end

local function get_git_status(cwd, cb)
shell(cwd, function(res)
if not res then
cb()
else
local sum = { additions = 0, deletions = 0 }
local mapped = vim.tbl_map(function(s)
-- TODO(smolck): Does this work on all OSes & circumstances etc.?
local stuff = vim.fn.split(s, '\t')

return {
additions = tonumber(stuff[1]),
deletions = tonumber(stuff[2]),
}
end, res)

for _, tbl in ipairs(mapped) do
sum.additions = sum.additions + tbl.additions
sum.deletions = sum.deletions + tbl.deletions
end

cb(sum)
end
end, 'git', 'diff', '--numstat')
end

local function get_branch(cwd, cb)
shell(cwd, cb, 'git', 'rev-parse', '--abbrev-ref', 'HEAD')
end

-- TODO(smolck): Make this smarter? i.e. only `notify_uivonim` if the
-- branch/status is different from last time.

-- TODO(smolck): Does this need to be async with getting the branch
-- and status? Don't want to slow things down . . .
function M.notify_branch()
local cwd = vim.fn.getcwd()
get_branch(cwd, function(maybe_branch)
local branch = maybe_branch and maybe_branch[1] or ''
notify_uivonim('git_branch', branch)
end)
end

function M.notify_status()
local cwd = vim.fn.getcwd()
get_git_status(cwd, function(maybe_status)
local status = maybe_status or { additions = 0, deletions = 0 }
notify_uivonim('git_status', status)
end)
end

return M
68 changes: 45 additions & 23 deletions runtime/lua/uivonim/lsp.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local M = {}
local util = vim.lsp.util
local notify_uivonim = require'uivonim'.notify_uivonim
local notify_uivonim = require('uivonim').notify_uivonim

local function get_cursor_pos()
local pos = vim.api.nvim_win_get_cursor(0)
Expand Down Expand Up @@ -37,7 +37,9 @@ local function signature_help_to_show_params(signature_help)
show_params.totalSignatures = #signature_help.signatures
show_params.selectedSignature = active_signature
show_params.label = signature.label
show_params.documentation = (signature.documentation and signature.documentation.value) or signature.documentation or ''
show_params.documentation = (signature.documentation and signature.documentation.value)
or signature.documentation
or ''

if signature.parameters and #signature.parameters > 0 then
local active_parameter = signature_help.activeParameter or 0
Expand Down Expand Up @@ -83,7 +85,11 @@ function M.signature_help_close()
notify_uivonim('signature-help-close')
end

function M.signature_help(_, method, result)
function M.signature_help(
_,
_ --[[method]],
result
)
if not (result and result.signatures and result.signatures[1]) then
print('No signature help available')
return
Expand All @@ -95,7 +101,7 @@ function M.signature_help(_, method, result)
return
end

notify_uivonim('signature-help', method, show_params)
notify_uivonim('signature-help', show_params)

-- Close autocmd
vim.api.nvim_command("autocmd CursorMoved <buffer> ++once lua pcall(require'uivonim/lsp'.signature_help_close, true)")
Expand All @@ -105,7 +111,11 @@ function M.hover_close()
notify_uivonim('hover-close')
end

function M.hover(_, method, result)
function M.hover(
_,
_ --[[method]],
result
)
if not (result and result.contents) then
-- TODO(smolck): Maybe let the user know somehow by telling Uivonim about it?
return
Expand All @@ -118,45 +128,57 @@ function M.hover(_, method, result)
return
end

notify_uivonim('hover', method, markdown_lines)
notify_uivonim('hover', markdown_lines)

-- Close autocmd
vim.api.nvim_command(
"autocmd CursorMoved,BufHidden,InsertCharPre <buffer> ++once lua pcall(require'uivonim/lsp'.hover_close, true)"
)
end

function M.references(_, method, result)
if not result then return end
function M.references(
_,
_ --[[method]],
result
)
if not result then
return
end

local list = util.locations_to_items(result)
notify_uivonim('references', method, list)
notify_uivonim('references', list)
end

function M.symbols(_, method, result)
if not result then return end
function M.symbols(
_,
_ --[[method]],
result
)
if not result then
return
end

-- TODO: use non-hierarchical UI element (i.e., strip filename) for documentSymbol
notify_uivonim('references', method, util.symbols_to_items(result))
notify_uivonim('references', util.symbols_to_items(result))
end

function M.code_action(_, _, actions)
if actions == nil or vim.tbl_isempty(actions) then
print("No code actions available")
print('No code actions available')
return
end

notify_uivonim('code-action', actions)
end

function M.handle_chosen_code_action(action_chosen)
local buf = require'vim.lsp.buf'
local buf = require('vim.lsp.buf')

if action_chosen.edit or type(action_chosen.command) == "table" then
if action_chosen.edit or type(action_chosen.command) == 'table' then
if action_chosen.edit then
util.apply_workspace_edit(action_chosen.edit)
end
if type(action_chosen.command) == "table" then
if type(action_chosen.command) == 'table' then
buf.execute_command(action_chosen.command)
end
else
Expand Down Expand Up @@ -190,13 +212,13 @@ function M.on_publish_diagnostics(thing1, thing2, params, client_id, thing5, con
end

M.callbacks = {
['textDocument/signatureHelp'] = M.signature_help;
['textDocument/hover'] = M.hover;
['textDocument/references'] = M.references;
['textDocument/codeAction'] = M.code_action;
['textDocument/documentSymbol'] = M.symbols;
['textDocument/publishDiagnostics'] = M.on_publish_diagnostics;
['workspace/symbol'] = M.symbols;
['textDocument/signatureHelp'] = M.signature_help,
['textDocument/hover'] = M.hover,
['textDocument/references'] = M.references,
['textDocument/codeAction'] = M.code_action,
['textDocument/documentSymbol'] = M.symbols,
['textDocument/publishDiagnostics'] = M.on_publish_diagnostics,
['workspace/symbol'] = M.symbols,
}

return M
18 changes: 12 additions & 6 deletions runtime/uivonim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ hi! link uvnCursor Cursor
" Create autocmds
aug UivonimAU
au BufAdd,BufEnter,BufDelete,BufUnload,BufWipeout,FileType,ColorScheme,DirChanged * call rpcnotify(0, 'uivonim-state', UivonimState())
au BufEnter * call rpcnotify(0, 'uivonim-autocmd', 'BufEnter', expand('<abuf>'), rpcnotify(0, 'uivonim', 'update-nameplates'))
au BufWipeout * call rpcnotify(0, 'uivonim-autocmd', 'BufWipeout', expand('<abuf>'))
au BufWritePost * call rpcnotify(0, 'uivonim-autocmd', 'BufWritePost', expand('<abuf>'))
au OptionSet * if (&ro != 1) | call rpcnotify(0, 'uivonim-autocmd', 'OptionSet', expand('<amatch>'), v:option_new, v:option_old) | endif
au FileType * call rpcnotify(0, 'uivonim-autocmd', 'FileType', bufnr(expand('<afile>')), expand('<amatch>'))
au WinEnter * call rpcnotify(0, 'uivonim-autocmd', 'WinEnter', win_getid())

au DirChanged * lua (function() local git = require'uivonim/git'; git.notify_branch(); git.notify_status() end)()
" TODO(smolck): Good autocmd for updating this? Or is there a better one? Or
" . . .
au BufWrite * lua require'uivonim/git'.notify_status()

au BufEnter,VimEnter,WinNew,WinEnter * call rpcnotify(0, 'uivonim', 'update-window-nameplates')
" au BufWipeout * call rpcnotify(0, 'uivonim-autocmd', 'BufWipeout', expand('<abuf>'))
" au BufWritePost * call rpcnotify(0, 'uivonim-autocmd', 'BufWritePost', expand('<abuf>'))
" au OptionSet * if (&ro != 1) | call rpcnotify(0, 'uivonim-autocmd', 'OptionSet', expand('<amatch>'), v:option_new, v:option_old) | endif
" au FileType * call rpcnotify(0, 'uivonim-autocmd', 'FileType', bufnr(expand('<afile>')), expand('<amatch>'))
" au WinEnter * call rpcnotify(0, 'uivonim-autocmd', 'WinEnter', win_getid())
aug END
4 changes: 4 additions & 0 deletions src-tauri/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by Cargo
# will have compiled files and executables
/target/
WixTools
Loading