kickstart.nvim
kickstart.nvim copied to clipboard
LSP for html config
Hello. I love Kickstart and am really trying to figure out most of this stuff through research and documentation, but I am stuck on this issue I have formatting html.
I used :Mason to install the html-lsp (turns out to be vscode-html-language-server), and when it formats my files it's using 8-space-width tabs for everything, which is highly annoying.
Where would I find the documentation to configure this? I assume it's a config in the language server itself but there is no docs I can find explaining it, and further, I'd like to configure it right there in init.lua rather than in a separate file, if possible.
How do I figure this out?
What's worked for me is adding in a .editorconfig file. Generally that helps with most of the formatting issues that aren't being applied in real-time with an LSP from Mason.
https://editorconfig.org/
Hopefully that helps!
You know, I have never heard of this, but I'm already in love with it. Though I'd still like to know if it's possible to do it in lua.
Neovim wise, you typically will just do the vim settings within your init.lua
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
Link here: https://neovim.io/doc/user/options.html#'shiftwidth'
Oh, and this should affect the formatting of the html-lsp? I must be doing it wrong then. Mine is unaffected by those.
I suspect you have a problem with the vim-sleuth
plugin:
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
I frequently find that it does not guess the right parameters so in my config I disable this and set them manually. Try this:
diff --git a/init.lua b/init.lua
index 88658ef..17efddb 100644
--- a/init.lua
+++ b/init.lua
@@ -154,6 +154,10 @@ vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
+vim.opt.expandtab = true
+vim.opt.shiftwidth = 4
+vim.opt.tabstop = 4
+
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
@@ -226,7 +230,7 @@ vim.opt.rtp:prepend(lazypath)
-- NOTE: Here is where you install your plugins.
require('lazy').setup({
-- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link).
- 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
+ -- 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
-- NOTE: Plugins can also be added by using a table,
-- with the first argument being the link and the following
@damccull Did @dam9000's suggested work around work for you?
Yes. A combination of the two makes my life easier. I relieved sleuth and that's what solved it. Then I added an editor config for great success.
Super glad to hear! Closing this for now. Thanks!