lsp_defaults_test.go 935 B

1234567891011121314151617181920212223242526272829303132333435
  1. package config
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. )
  6. func TestApplyLSPDefaults(t *testing.T) {
  7. t.Parallel()
  8. // Create a config with an LSP that should get defaults
  9. config := &Config{
  10. LSP: map[string]LSPConfig{
  11. "gopls": {
  12. Command: "gopls", // This should get defaults from powernap
  13. },
  14. "custom": {
  15. Command: "custom-lsp",
  16. RootMarkers: []string{"custom.toml"}, // This should keep its explicit config
  17. },
  18. },
  19. }
  20. // Apply defaults
  21. config.applyLSPDefaults()
  22. // Check that gopls got defaults (it should have some root markers now)
  23. goplsConfig := config.LSP["gopls"]
  24. require.NotEmpty(t, goplsConfig.RootMarkers, "gopls should have received default root markers")
  25. // Check that custom LSP kept its explicit config
  26. customConfig := config.LSP["custom"]
  27. require.Equal(t, []string{"custom.toml"}, customConfig.RootMarkers, "custom LSP should keep its explicit root markers")
  28. }