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

NVIM config in Readme #29

Closed vanguard-bit closed 6 months ago

vanguard-bit commented 6 months ago

typos-vscode is the only listed netrw lsp for nvim in Mason ....so the configuration for don't really know lua in readme is gonna be useful Thanks!

tekumara commented 6 months ago

Hiya I'm not too familar with nvim, does the config mentioned here not work for you?

YDX-2147483647 commented 6 months ago

I refer to https://github.com/neovim/nvim-lspconfig/blob/f5dab1398b12f1c96c5b185f802e3065f355b4a8/doc/server_configurations.md#typos_lsp and add the following to my init.lua. It works.

local lspconfig = require('lspconfig')
lspconfig.typos_lsp.setup{}

To debug, you can open a file and run :LspInfo.

By the way, the workspace should has typos.toml, _typos.toml, or .typos.toml. Otherwise, root_dir can't be determined, therefore typos is not enabled. If you want to always enable, the following might work. Single file mode is supported.

lspconfig.typos_lsp.setup{
  root_dir = function(fname)
    return require('lspconfig.util').root_pattern('typos.toml', '_typos.toml', '.typos.toml')(fname)
      or vim.fn.getcwd()
  end,
}
vanguard-bit commented 6 months ago

I actually used the setup from nvim lsp-config....but it didn't get attached to buffer....i should try what you suggested....and i always have problem setting up root directory for all the lsps

tekumara commented 6 months ago

Thanks @YDX-2147483647 ! Did that work for you @vanguard-bit ?

vanguard-bit commented 6 months ago

yep it works now Thanks @tekumara and @YDX-2147483647

dmtrKovalenko commented 2 weeks ago

Somehow setting up the root_dir made my config to fail on every save, for some reason specifically in lua files. Sending it here maybe someone is also looking for the root of the problem

Error  18:27:27 msg_show.lua_error Error detected while processing BufWritePost Autocommands for "<buffer=3>":
18:27:27 msg_show Error executing lua callback: ....10.0/share/nvim/runtime/lua/vim/lsp/_changetracking.lua:175: attempt to index local 'buf_state' (a nil value)
stack traceback:
    ....10.0/share/nvim/runtime/lua/vim/lsp/_changetracking.lua:175: in function '_get_and_set_name'
    .../Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/lsp.lua:465: in function 'text_document_did_save_handler'
    .../Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/lsp.lua:543: in function <.../Cellar/neovim/0.10.0/share/nvim/runtime/lua/vim/lsp.lua:542>
)