From 26d3a71bc0cacc5530a86a510db94c34946a1346 Mon Sep 17 00:00:00 2001 From: Tray Dennis Date: Mon, 16 Sep 2024 04:36:43 -0400 Subject: [PATCH] doc: Add configuration for Neovims Built-In lsp interface --- README.md | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 66b791f..af5e331 100644 --- a/README.md +++ b/README.md @@ -125,22 +125,38 @@ Install the [Super HTML VSCode extension](https://marketplace.visualstudio.com/i 1. Download a prebuilt version of `superhtml` from the Releases section (or build it yourself). 2. Put `superhtml` in your `PATH`. 3. Configure `superhtml` for your chosen lsp - - ##### [LspZero](https://github.com/VonHeikemen/lsp-zero.nvim) - - ```lua - local lsp = require("lsp-zero") - - require('lspconfig.configs').superhtml = { - default_config = { - name = 'superhtml', - cmd = {'superhtml', 'lsp'}, - filetypes = {'html', 'shtml', 'htm'}, - root_dir = require('lspconfig.util').root_pattern('.git') - } - } - - lsp.configure('superhtml', {force_setup = true}) - ``` + + - ##### [Neovim Built-In](https://neovim.io/doc/user/lsp.html#vim.lsp.start()) + + ```lua + vim.api.nvim_create_autocmd("Filetype", { + pattern = { "html", "shtml", "htm" }, + callback = function() + vim.lsp.start({ + name = "superhtml", + cmd = { "superhtml", "lsp" }, + root_dir = vim.fs.dirname(vim.fs.find({".git"}, { upward = true })[1]) + }) + end + }) + ``` + + - ##### [LspZero](https://github.com/VonHeikemen/lsp-zero.nvim) + + ```lua + local lsp = require("lsp-zero") + + require('lspconfig.configs').superhtml = { + default_config = { + name = 'superhtml', + cmd = {'superhtml', 'lsp'}, + filetypes = {'html', 'shtml', 'htm'}, + root_dir = require('lspconfig.util').root_pattern('.git') + } + } + + lsp.configure('superhtml', {force_setup = true}) + ``` #### Helix Add to your `.config/helix/languages.toml`: