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

Report spelling errors as info rather than warnings #17

Closed
AspieSoft opened this issue Oct 22, 2023 · 13 comments · Fixed by #18
Closed

Report spelling errors as info rather than warnings #17

AspieSoft opened this issue Oct 22, 2023 · 13 comments · Fixed by #18

Comments

@AspieSoft
Copy link

In the vscode extension settings, if I set the log level to "info", it continues to report spelling errors as warnings.

@tekumara
Copy link
Owner

Interesting, could you share a screenshot? I'm not sure how to replicate this behaviour.

@AspieSoft
Copy link
Author

AspieSoft commented Oct 22, 2023

In this extension, The setting is set to "info", but still returns a "warning" (yellow).

vscode-typos-spell-checker

In the code spell checker extension, I get the report as "info" (blue)

vscode-code-spell-checker

I was originally using the code spell checker extension, but went looking for something with less false positives, and your extension seems to do great at that.

Having spelling errors marked as "info" instead of as a "warning", would make it easier to separate programing warnings from spelling mistakes.

This issue is also consistent under the "problems" tab of vscode.

@tekumara
Copy link
Owner

Ah gotcha. So Typos: Log Level refers to the logging that appears in the Output -> Typos pane.

It sounds like you'd like to configure the diagnostic severity which isn't currently supported but is something that I'd be happy to add.

@tekumara tekumara changed the title Changing "Log Level" to info does nothing. Report spelling errors as info rather than warnings Oct 22, 2023
@AspieSoft
Copy link
Author

Ok, that makes sense. Thank you.

tekumara added a commit that referenced this issue Oct 22, 2023
tekumara added a commit that referenced this issue Oct 22, 2023
tekumara added a commit that referenced this issue Oct 22, 2023
tekumara pushed a commit that referenced this issue Oct 22, 2023
🤖 I have created a release *beep* *boop*
---


##
[0.1.7](v0.1.6...v0.1.7)
(2023-10-22)


### Features

* configurable diagnostic severity
([7e7e743](7e7e743)),
closes [#17](#17)
* typos 1.16.20
([fb013ea](fb013ea))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: potatobot-prime[bot] <132267321+potatobot-prime[bot]@users.noreply.github.com>
@tekumara
Copy link
Owner

@AspieSoft I've released v0.1.7 which has the new setting typos.diagnosticSeverity. You can use this to configure diagnostics to display as Information instead of Warning.

@fusillicode
Copy link

I'm really sorry for bothering you all on this closed issue but I didn't find a better place where to ask 😞

Question: the diagnostics levels cannot be customized on NeoVim via nvim-lspconfig, only on VSCode, right?
Asking because I kind of tried everything but didn't managed to make the diagnostics being reported as anything different from errors.

Sorry for the dumb question and once again for the bother.

P.S: thank you really a lot for all you amazing work! 🙇‍♂️

@tekumara
Copy link
Owner

Hey @fusillicode it should be possible on any editor than can provide initialisation options to the lsp server. I'm sorry I don't know how to do that with neovim but if you find a way let us know 😊

@fusillicode
Copy link

@tekumara thanks really a lot for the quick feedback! 🙇‍♂️

If I make it to work with Neovim I'll come back with the solution and maybe open a PR to document the thing! 👍

Thanks again for everything! ♾️ 🙇‍♂️

@nghialm269
Copy link

@fusillicode: Putting it in init_options works for me:

typos_lsp = {
  init_options = {
    diagnosticSeverity = 'Warning',
  },
},

@fusillicode
Copy link

fusillicode commented Nov 29, 2023

@nghialm269 thanks for the feedback but unfortunately it's not working on my side https://github.com/fusillicode/dotfiles/blob/39fa7e51d89924091703c9ebc68897e8cec5a468/nvim/lua/mason-tools.lua#L49-L53 🥲

Where did you put that config in your Neovim config if I can ask?

@nghialm269
Copy link

@fusillicode: here is the mini config file from nvim-lspconfig:

local on_windows = vim.loop.os_uname().version:match("Windows")

local function join_paths(...)
	local path_sep = on_windows and "\\" or "/"
	local result = table.concat({ ... }, path_sep)
	return result
end

vim.cmd([[set runtimepath=$VIMRUNTIME]])

local temp_dir = vim.loop.os_getenv("TEMP") or "/tmp"

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack")
local lspconfig_path = join_paths(package_root, "test", "start", "nvim-lspconfig")

if vim.fn.isdirectory(lspconfig_path) ~= 1 then
	vim.fn.system({ "git", "clone", "https://github.com/neovim/nvim-lspconfig", lspconfig_path })
end

vim.lsp.set_log_level("trace")
require("vim.lsp.log").set_format_func(vim.inspect)
local nvim_lsp = require("lspconfig")
local on_attach = function(_, bufnr)
	local function buf_set_option(...)
		vim.api.nvim_buf_set_option(bufnr, ...)
	end

	buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")

	-- Mappings.
	local opts = { buffer = bufnr, noremap = true, silent = true }
	vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
	vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
	vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
	vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
	vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
	vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
	vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
	vim.keymap.set("n", "<space>wl", function()
		print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
	end, opts)
	vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, opts)
	vim.keymap.set("n", "<space>rn", vim.lsp.buf.rename, opts)
	vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
	vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
	vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
	vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
	vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
end

-- Add the server that troubles you here
local name = "typos_lsp"
local cmd = { '/home/nghialm/.local/share/nvim/mason/bin/typos-lsp' } -- needed for elixirls, lua_ls, omnisharp
if not name then
	print("You have not defined a server name, please edit minimal_init.lua")
end
if not nvim_lsp[name].document_config.default_config.cmd and not cmd then
	print([[You have not defined a server default cmd for a server
    that requires it please edit minimal_init.lua]])
end

nvim_lsp[name].setup({
	cmd = cmd,
	on_attach = on_attach,
	init_options = {
		diagnosticSeverity = 'Warning',
	},
})

-- test typo symbo

save to mini.lua, change the path to typos-lsp and run neovim with: nvim --clean -u mini.lua mini.lua

you should see the warning typo in the last line (symbo)

@fusillicode
Copy link

@nghialm269 thanks so much for coming back so quickly and with that extensive example! ♾️ 🙇‍♂️
I think now I understand the issue 🙏
It's just a matter of fixing my setup 🥲
Thanks again!

@fusillicode
Copy link

fusillicode commented Nov 29, 2023

To anyone who will bump into this, my issue was fixed thanks to this.

More specifically the diagnosticSeverity must be passed to the LSP (typos) as part of init_options, not settings (https://github.com/neovim/nvim-lspconfig/blob/39546f730bdff8eccf7cec344cfce694f19ac908/CONTRIBUTING.md?plain=1#L39).

I managed to do this ☝️ in my (at the time of writing) config in this way.

♾️ thanks once again to @nghialm269 🙏 🙇‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants