diff --git a/.github/workflows/pr-tests.yaml b/.github/workflows/pr-tests.yaml index fa90407..29fa2f7 100644 --- a/.github/workflows/pr-tests.yaml +++ b/.github/workflows/pr-tests.yaml @@ -22,3 +22,12 @@ jobs: - name: Build app run: nix develop --command bash -c "cd server && go build" + - name: Build VS Code extension + run: nix build .#vs-code-extension + + - name: Upload VS Code extension + uses: actions/upload-artifact@v4 + with: + name: vs-code-extension + path: result/config-lsp-*.vsix + diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4e7fece..7c1e02b 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,7 +19,7 @@ builds: dir: ./server archives: - - format: tar.gz + - formats: [ 'tar.gz' ] # this name template makes the OS and Arch compatible with the results of `uname`. name_template: >- {{ .ProjectName }}_ @@ -31,7 +31,7 @@ archives: # use zip for windows archives format_overrides: - goos: windows - format: zip + formats: [ 'zip' ] changelog: sort: asc diff --git a/flake.lock b/flake.lock index 35080e0..f1d265f 100644 --- a/flake.lock +++ b/flake.lock @@ -26,11 +26,11 @@ ] }, "locked": { - "lastModified": 1733668782, - "narHash": "sha256-tPsqU00FhgdFr0JiQUiBMgPVbl1jbPCY5gbFiJycL3I=", + "lastModified": 1741396135, + "narHash": "sha256-wqmdLr7h4Bk8gyKutgaApJKOM8JVvywI5P48NuqJ9Jg=", "owner": "tweag", "repo": "gomod2nix", - "rev": "514283ec89c39ad0079ff2f3b1437404e4cba608", + "rev": "0983848bf2a7ccbfe24d874065adb8fd0f23729b", "type": "github" }, "original": { @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1739214665, - "narHash": "sha256-26L8VAu3/1YRxS8MHgBOyOM8xALdo6N0I04PgorE7UM=", + "lastModified": 1741513245, + "narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "64e75cd44acf21c7933d61d7721e812eac1b5a0a", + "rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 3e85932..d90fac6 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ "aarch64-windows" ] (system: let - version = "0.1.4"; # CI:CD-VERSION + version = "0.2.0"; # CI:CD-VERSION pkgs = import nixpkgs { inherit system; overlays = [ @@ -42,7 +42,7 @@ pname = "github.com/Myzel394/config-lsp"; version = version; src = ./server; - vendorHash = "sha256-eO1eY+2XuOCd/dKwgFtu05+bnn/Cv8ZbUIwRjCwJF+U="; + vendorHash = "sha256-ttr45N8i86mSJX9Scy/Cf+YlxU5wAKMVb0YhKg28JKM="; ldflags = [ "-s" "-w" ]; checkPhase = '' go test -v $(pwd)/... @@ -136,6 +136,7 @@ mailutils wireguard-tools antlr + just ]) ++ (if pkgs.stdenv.isLinux then with pkgs; [ postfix ] else []); diff --git a/justfile b/justfile new file mode 100644 index 0000000..292f2d5 --- /dev/null +++ b/justfile @@ -0,0 +1,30 @@ +#!/usr/bin/env just --justfile + +set dotenv-load := true + +default: + @just --list + +# Lint whole project +lint: + cd server && gofmt -s -w . + # cd vs-code-extension && yarn run lint + +# Build config-lsp and test it in nvim (config-lsp will be loaded automatically) +[working-directory: "./server"] +test-nvim file: + go build -o ./result/bin/config-lsp && rm -rf ~/.local/state/nvim/lsp.log && DOTFILES_IGNORE_CONFIG_LSP=1 nvim {{file}} -c ':source nvim-lsp-debug.lua' + +# Show Mason Logs +show-nvim-logs: + bat ~/.local/state/nvim/lsp.log + +[working-directory: "./server"] +test: + nix develop --command bash -c 'go test ./... -count=1' + +# Ready for a PR? Run this recipe before opening the PR! +ready: + just lint + just test + diff --git a/server/common/diagnostics.go b/server/common/diagnostics.go index fbd5fdb..5ebd92d 100644 --- a/server/common/diagnostics.go +++ b/server/common/diagnostics.go @@ -6,7 +6,10 @@ import ( ) func ClearDiagnostics(context *glsp.Context, uri protocol.DocumentUri) { - go context.Notify( + // Diagnostics are sent synchronously, as sending them async + // could result in a race condition when we send diagnostics + // to the client. + context.Notify( protocol.ServerTextDocumentPublishDiagnostics, protocol.PublishDiagnosticsParams{ URI: uri, diff --git a/server/common/options.go b/server/common/options.go index 35773e0..3ac4edb 100644 --- a/server/common/options.go +++ b/server/common/options.go @@ -13,13 +13,30 @@ type ServerOptionsType struct { // we show a native warning. The error message boxes just clutter // the interface. NoUndetectableErrors bool + + // If true, the server will not detect typos and suggest + // the correct keywords. + // Since the server finds typos using the Damerau-Levenshtein distance, + // and this is done each time code actions are requested + // (which happens quite often), these suggestions can eat a lot of resources. + // You may want to enable this option if you are dealing with little + // resources or if you're low on battery. + NoTypoSuggestions bool } var ServerOptions = new(ServerOptionsType) func InitServerOptions() { + ServerOptions.NoUndetectableErrors = false + ServerOptions.NoTypoSuggestions = false + if slices.Contains(os.Args, "--no-undetectable-errors") { Log.Info("config-lsp will not return errors for undetectable files") ServerOptions.NoUndetectableErrors = true } + + if slices.Contains(os.Args, "--no-typo-suggestions") { + Log.Info("config-lsp will not detect typos for keywords") + ServerOptions.NoTypoSuggestions = true + } } diff --git a/server/doc-values/value-path.go b/server/doc-values/value-path.go index 1aced7c..2ca9a8c 100644 --- a/server/doc-values/value-path.go +++ b/server/doc-values/value-path.go @@ -48,11 +48,15 @@ func (v PathValue) GetTypeDescription() []string { func (v PathValue) DeprecatedCheckIsValid(value string) []*InvalidValue { if !utils.DoesPathExist(value) { - return []*InvalidValue{{ - Err: PathDoesNotExistError{}, - Start: 0, - End: uint32(len(value)), - }} + if v.RequiredType == PathTypeExistenceOptional { + return nil + } else { + return []*InvalidValue{{ + Err: PathDoesNotExistError{}, + Start: 0, + End: uint32(len(value)), + }} + } } isValid := false diff --git a/server/fetch_tags.js b/server/fetch_tags.js new file mode 100644 index 0000000..fa11764 --- /dev/null +++ b/server/fetch_tags.js @@ -0,0 +1,27 @@ +// Creates a JSON object in the form of: +// { +// [