-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add command to switch language #12
Comments
I will probably do a PR, but I am not sure how to implement this properly. I think we should do as rust-tools do: call the local ltex_languages = {
"auto",
"ar",
"ast-ES",
"be-BY",
"br-FR",
"ca-ES",
"ca-ES-valencia",
"da-DK",
"de",
"de-AT",
"de-CH",
"de-DE",
"de-DE-x-simple-language",
"el-GR",
"en",
"en-AU",
"en-CA",
"en-GB",
"en-NZ",
"en-US",
"en-ZA",
"eo",
"es",
"es-AR",
"fa",
"fr",
"ga-IE",
"gl-ES",
"it",
"ja-JP",
"km-KH",
"nl",
"nl-BE",
"pl-PL",
"pt",
"pt-AO",
"pt-BR",
"pt-MZ",
"pt-PT",
"ro-RO",
"ru-RU",
"sk-SK",
"sl-SI",
"sv",
"ta-IN",
"tl-PH",
"uk-UA",
"zh-CN",
}
vim.api.nvim_create_user_command("LtexSwitchLang", function(args)
local splited_args = vim.split(args.args, " ", {trimemtpy=true})
local ltex_clients = vim.lsp.get_active_clients({bufnr=0, name="ltex"})
for _, ltex_client in ipairs(ltex_clients) do
vim.lsp.stop_client(ltex_client.id, false)
end
setup_ltex(splited_args[1])
end, {
nargs = 1,
complete = function (ArgLead, _, _)
return vim.tbl_filter(function(el) return el:find(ArgLead, 1, true) end, ltex_languages)
end
})
end, |
Hi @Fymyte, how are you? I think that it will be useful for previewing and temporary things, I would like to extend this feat (or fork in similar) to offer "magic comments" depending on the type of file. Thank you very much. |
my idea is to use some echo export PROJECT_LANG=fr > .envrc in local lang = os.getenv 'PROJECT_LANG' or 'en'
require('lspconfig').ltex.setup {
settings = {
ltex = {
language = lang,
}
}
} |
Hi everyone, I just encountered this wonder plugin from ltex issue board, and I am very happy using it so far! I also love this idea, but after a glimpse at the repo, I think maybe it comes with an (optional but elegant to have) cost of refactoring the current code. I noticed that many other lsp extension plugins inverses the control and do something like -- from https://github.com/jose-elias-alvarez/typescript.nvim
require("typescript").setup({
-- additional behaviors here
disable_commands = false, -- prevent the plugin from creating Vim commands
debug = false, -- enable debug logging for commands
go_to_source_definition = {
fallback = true, -- fall back to standard LSP definition on failure
},
-- lspconfig arguments here, passed to internal calls of lspconfig setup()
server = { -- pass options to lspconfig's setup method
on_attach = ..., -- This on_attach function is often some one-size-fit-all stuff provided by user or neovim distros. We can extend on_attach in the implementation of `require("ltexextra").setup` function.
},
}) The same pattern is used in deno, clangd, dart, rust plugins
I think this is less necessary. Magic comments or modlines should apply to specific files instead of a filetype, right? ltex already offers per-file config via magic comments, markdown front matters, and latex babel calls. For per-filetype configs, maybe vim autocmd is sufficient? Or adding another config field in ltex_extra will work, which does not require peeking into the file content. |
Yeah, it's part of the things I want to do with architecture. Especially for giving better compatibility with the flow of 'ftplugin' or 'Lazy.nvim'. It's not soo complex, someday I will get the time. The "magic comments" it's not my happiest idea, but I had some trouble exchanging commands through Ltex server. I don't know what expect in the future. |
First off: thanks so much for #the plugin @barreiroleo , it's cleared a lot of headaches for me and I'm using it daily :) I was wondering what the current plans are for implementing this feature? I saw the branch Now, I don't have much experience with lua, nvim plugins, and/or development in general (I'm an academic researcher) but I'd be interested in contributing if that's wanted. I'm currently daily-driving a simple (hopefully unproblematic) implementation of the feature (ad2aa19 and 30f808b): a simple If you're interested in this, I'd definitely be happy to work on a PR. No worries, if not, of course. In that case just: thanks again :) |
Hi @jkorb, it's nice to hear that. I've frozen the implementation of that because I don't use this very much and I'm not sure about the more comfortable flow. As always, the PRs are very welcome. Particularly for me, I don't care if is a full implementation or very clean code. Something to start is nice to have. Sorry for the delay, I missed the notification. |
At setup, add a command to change the cheched language
Provide a command like
LTextSwitchLang <lang>
with lang autocompletion
I have this in my config
It is not perfect but a good starting point as it provides the the Command only when ltex is setup
It does not remove it once ltex dies though,and produce a warning saying that the previous instance of ltex died
Available languages from ltex: https://valentjn.github.io/ltex/settings.html#ltexlanguage
The text was updated successfully, but these errors were encountered: