zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
25.25k stars 1.18k forks source link

aspell, used to work but not now? #3546

Closed JackDinn closed 1 hour ago

JackDinn commented 2 days ago

❱micro --version Version: 2.0.15-dev Commit hash: 04c57704 Compiled on August 28, 2024 ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ ❱micro -plugin list The following plugins are currently installed: initlua (0.0.0-unknown) aspell (1.3.0) autoclose (1.0.0) comment (1.0.0) diff (1.0.0) ftoptions (1.0.0) linter (1.0.0) literate (1.0.0) status (1.0.0) ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ ❱uname -r 6.10.13-3-MANJARO

I used to use spellchecking with micro, i keep a quick note as i always forget how to set it up. This was my note.

##############  MY ADDED SHORCUTS  #######################

.config/micro/bindings.json
{
    "Alt-/": "lua:comment.comment",
    "CtrlUnderscore": "lua:comment.comment",
    "Alt-l": "lua:initlua.toggleAspell",
    "Tab": "Autocomplete|lua:aspell.acceptsug|IndentSelection|InsertTab"
    "AltA": "lua:aspell.addpersonal"
}

##############  ASpell  #######################

you'll have to use a lua script to achieve this. In ~/.config/micro/init.lua, you can make a function:

function toggleAspell(bp)
    bp.Buf:SetOptionNative("aspell.check", not bp.Buf.Settings["aspell.check"])
end

and then in ~/.config/micro/bindings.json, (if it not already) you can bind the function above:

{
    "Alt-l": "lua:initlua.toggleAspell"
}

Personal Dictionary list ~/.aspell.en.pws

Alt+Shift+A = Add word to personal dictionary.

However, although this used to work, pressing Alt-l does not do anything now?

JoeKar commented 1 day ago

I currently wonder why you need a extra lua script, since you could use lua:aspell.togglecheck directly or can't you?

JackDinn commented 1 day ago

I cant, it shows an error micro -debug

use Ctrl+e to try: lua:aspell.togglecheck

Unknown command lua:aspell.togglecheck

❱cat log.txt 2024/11/23 17:27:22 Micro started

EDIT: I don't know, I definitely have Lua installed. I have removed and reinstalled micro but it just wont do anything with lua

lua:print("Hello, World!")

outputs Unknown command lua:print("Hello, World!")

❱yay -Qi lua
Name            : lua
Version         : 5.4.7-1
Description     : Powerful lightweight programming language designed for extending applications
Architecture    : x86_64
URL             : https://www.lua.org/
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : readline
Optional Deps   : None
Required By     : gpick  nmap  vlc  wireplumber
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 1517.38 KiB
Packager        : Anatol Pomozov <anatolik@archlinux.org>
Build Date      : Tue 25 Jun 2024 18:41:52 BST
Install Date    : Tue 16 Jul 2024 08:59:27 BST
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

❱yay -Qi micro
Name            : micro
Version         : 2.0.14-1
Description     : Modern and intuitive terminal-based text editor
Architecture    : x86_64
URL             : https://micro-editor.github.io/
Licenses        : MIT
Groups          : None
Provides        : None
Depends On      : None
Optional Deps   : wl-clipboard: for copying/pasting text using Wayland
                  xclip: for copying/pasting text using X [installed]
Required By     : micro-manjaro
Optional For    : None
Conflicts With  : None
Replaces        : None
Installed Size  : 12.19 MiB
Packager        : Alexander F. Rødseth <xyproto@archlinux.org>
Build Date      : Wed 28 Aug 2024 12:23:13 BST
Install Date    : Sat 23 Nov 2024 17:55:39 GMT
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature

EDIT:

lua is fine.

❱lua -v
Lua 5.4.7  Copyright (C) 1994-2024 Lua.org, PUC-Rio

⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼ /home/greg ⎼⎼⎼⎼⎼⎼⎼⎼⎼⎼
❱lua
Lua 5.4.7  Copyright (C) 1994-2024 Lua.org, PUC-Rio
> print("hh")
hh
> os.exit()

So i dont know what else to check.

JoeKar commented 7 hours ago

@Andriamanitra: Any ideas? For me it is working, so I assume there is something special with its setup.

JackDinn commented 5 hours ago

The only thing is this plugin that i showed above that says

initlua (0.0.0-unknown)

maybe its a hint what the problem is but i get this.

❱micro -plugin install initlua
Unknown plugin "initlua"
Andriamanitra commented 2 hours ago

use Ctrl+e to try: lua:aspell.togglecheck

Unknown command lua:aspell.togglecheck

You can't use the "lua:foo.bar" syntax in the command prompt. This syntax is only for keybindings. You can use set aspell.check on and set aspell.check off in the command prompt to change the configuration value (there's also a plugin called toggler that adds a command to toggle any boolean setting). If you want to have a command to toggle the value you can add something like this in your init.lua:

local config = import("micro/config")

function toggleAspell(bp)
    bp.Buf:SetOptionNative("aspell.check", not bp.Buf.Settings["aspell.check"])
end

function init()
    config.MakeCommand("toggle-aspell", toggleAspell, config.NoComplete)
end

I don't know, I definitely have Lua installed. I have removed and reinstalled micro but it just wont do anything with lua

You don't need to have Lua installed as the interpreter is embedded into micro.

The only thing is this plugin that i showed above that says

initlua (0.0.0-unknown)

maybe its a hint what the problem is but i get this.

❱micro -plugin install initlua
Unknown plugin "initlua"

The "initlua" is not a real plugin, it refers to your init script in ~/.config/micro/init.lua.


What do you get if you run show aspell and show aspell.check in micro's command prompt? Does the value for show aspell.check change if you change the value through the keybinding you have configured? What about if you change it with set aspell.check on?

JackDinn commented 1 hour ago

show aspell true

show aspell.check true

ahh, set aspell.check on works

hmm, so show aspell.check was set to true but that was not working but after i used set aspell.check on it sets show aspell.check to on and set aspell.check off sets it to off. Neither set it to true or false which was what mine was set to (true in this case).

So how do i setup a keybinding to toggle set aspell.check on/off since my old note/script does not work ?

JoeKar commented 1 hour ago

So how do i setup a keybinding to toggle set aspell.check on/off since my old note/script does not work ?

This is, what...

I currently wonder why you need a extra lua script, since you could use lua:aspell.togglecheck directly or can't you?

...is used for: bind Alt-l "lua:aspell.togglecheck" So the root cause most probably was, that aspell.check was set to a boolean value, while it uses on|off|auto.

JackDinn commented 1 hour ago

i tried the code i used to use again but it just toggles it back and forth between true/false , but it needs to be on/off.

Something has changed as this used to work.

Anyhow, i have added toggler, but still dont know exactly how to use it to toggle aspell.check on/off.

JackDinn commented 1 hour ago

ok i adjusted my original script,

im still not sure how to use toggler, but never mind.

This work, thank god. I wonder why a toggle-able boolean setting does no longer except true/false but meh.

Cheers @Andriamanitra & @JoeKar

local config = import("micro/config")

function toggleAspell(bp)
    if bp.Buf.Settings["aspell.check"] == "on" then
        bp.Buf:SetOptionNative("aspell.check", "off")
    else
        bp.Buf:SetOptionNative("aspell.check", "on")
    end
end

function init()
    config.MakeCommand("toggleAspell", toggleAspell, config.NoComplete)
end