AutoYADM commit: 2025-06-14 04:33:37
This commit is contained in:
parent
3cb87ea64d
commit
b75efd6035
2 changed files with 36 additions and 7 deletions
|
@ -1,16 +1,44 @@
|
||||||
|
# Author: Daniel Fichtinger
|
||||||
|
# License: ISC
|
||||||
|
|
||||||
|
# How it works:
|
||||||
|
# the only way to specify a dictionary for ltex-ls is through
|
||||||
|
# the LSP configuration. in kak-lsp, this is in toml format and
|
||||||
|
# always set as an option from Kakoune.
|
||||||
|
#
|
||||||
|
# Live-reloading is supported, meaning that if we update the configuration
|
||||||
|
# mid-session, ltex-ls will load the new dictionary. However, we have to set
|
||||||
|
# the _full_ config each time
|
||||||
|
#
|
||||||
|
# So we define a command that reads a line-delimited list of words from our dictionary file
|
||||||
|
# It uses kak -f to format them into a toml array format s.t.
|
||||||
|
# foo\nbar\n becomes
|
||||||
|
# ["foo", "bar"]
|
||||||
|
#
|
||||||
|
# Then we filter the current lsp_servers option, and replace the \[.*\] occurrences
|
||||||
|
# _only_ on the dictionary line, to update the dict array to our new list.
|
||||||
|
#
|
||||||
|
# If we run this command hooked to ltex-ls startup, then our custom dictionary
|
||||||
|
# will be loaded. Now we can easily define a command to add a word to the dictionary -- all it has to do is append the word to the end of the dict file, the call ltex-dict-set
|
||||||
provide-module ltex-dict %~
|
provide-module ltex-dict %~
|
||||||
|
|
||||||
declare-option str ltex_dict_path %exp{%val{config}/ltex-dict.txt}
|
declare-option -docstring %{
|
||||||
define-command ltex-dict-set %{
|
Path to the custom dictionary. Must be a textfile with newline delimited words.
|
||||||
|
|
||||||
|
Default: %exp{%val{config}/ltex-dict.txt}
|
||||||
|
} str ltex_dict_path %exp{%val{config}/ltex-dict.txt}
|
||||||
|
define-command -hidden ltex-dict-set %{
|
||||||
set-option buffer lsp_servers %sh{
|
set-option buffer lsp_servers %sh{
|
||||||
echo >/tmp/test.txt
|
|
||||||
list="$(cat "$kak_opt_ltex_dict_path" | kak -f '<a-o>%<a-J>Zbi\"<esc>a\"<esc>z<a-,>r,x_i[<esc>a]<esc>')"
|
list="$(cat "$kak_opt_ltex_dict_path" | kak -f '<a-o>%<a-J>Zbi\"<esc>a\"<esc>z<a-,>r,x_i[<esc>a]<esc>')"
|
||||||
notify-send "$list"
|
echo "$kak_opt_lsp_servers" | sed "/^\s*dictionary =/ s/\[.*\]/$list/g"
|
||||||
echo "$kak_opt_lsp_servers" | sed "/^\s*dictionary =/ s/\[\]/$list/g"
|
|
||||||
echo "$kak_opt_lsp_servers" | sed "/^\s*dictionary =/ s/\[\]/REPLACED/g" >/tmp/test.txt
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
define-command ltex-add %{
|
define-command -docstring %{
|
||||||
|
Adds the current word word to the dictionary.
|
||||||
|
|
||||||
|
If the selection size is 1, then the word the cursor is on is added.
|
||||||
|
If the selection is larger, its contents are added verbatim.
|
||||||
|
} ltex-add %{
|
||||||
execute-keys -draft %sh{
|
execute-keys -draft %sh{
|
||||||
if [ "$kak_selection_length" = 1 ]; then
|
if [ "$kak_selection_length" = 1 ]; then
|
||||||
printf 'bw_<a-|>{ cat; echo; } | tee -a %s<ret>\n' "$kak_opt_ltex_dict_path"
|
printf 'bw_<a-|>{ cat; echo; } | tee -a %s<ret>\n' "$kak_opt_ltex_dict_path"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
foobartest
|
foobartest
|
||||||
apple
|
apple
|
||||||
SonarAuth
|
SonarAuth
|
||||||
|
Fichtinger
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue