tekumara / typos-lsp

Source code spell checker for Visual Studio Code, Neovim and other LSP clients
https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode
MIT License
168 stars 4 forks source link

Report spelling errors as info rather than warnings #17

Closed AspieSoft closed 9 months ago

AspieSoft commented 9 months ago

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

tekumara commented 9 months ago

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

AspieSoft commented 9 months ago

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 commented 9 months ago

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.

AspieSoft commented 9 months ago

Ok, that makes sense. Thank you.

tekumara commented 9 months ago

@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 commented 8 months ago

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 commented 8 months ago

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 commented 8 months ago

@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 commented 8 months ago

@fusillicode: Putting it in init_options works for me:

typos_lsp = {
  init_options = {
    diagnosticSeverity = 'Warning',
  },
},
fusillicode commented 8 months ago

@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 commented 8 months ago

@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 commented 8 months ago

@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 commented 8 months ago

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 πŸ™ πŸ™‡β€β™‚οΈ