@fresh-editor/fresh-editor 0.2.17 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/package.json +1 -1
  3. package/plugins/astro-lsp.ts +118 -0
  4. package/plugins/bash-lsp.ts +161 -0
  5. package/plugins/clojure-lsp.ts +125 -0
  6. package/plugins/cmake-lsp.ts +138 -0
  7. package/plugins/config-schema.json +275 -29
  8. package/plugins/dart-lsp.ts +144 -0
  9. package/plugins/diagnostics_panel.ts +4 -12
  10. package/plugins/diff_nav.i18n.json +128 -0
  11. package/plugins/diff_nav.ts +196 -0
  12. package/plugins/elixir-lsp.ts +120 -0
  13. package/plugins/erlang-lsp.ts +121 -0
  14. package/plugins/fsharp-lsp.ts +125 -0
  15. package/plugins/git_gutter.ts +5 -0
  16. package/plugins/gleam-lsp.ts +124 -0
  17. package/plugins/graphql-lsp.ts +139 -0
  18. package/plugins/haskell-lsp.ts +125 -0
  19. package/plugins/julia-lsp.ts +111 -0
  20. package/plugins/kotlin-lsp.ts +162 -0
  21. package/plugins/lib/finder.ts +19 -12
  22. package/plugins/lib/fresh.d.ts +30 -1
  23. package/plugins/lua-lsp.ts +161 -0
  24. package/plugins/nim-lsp.ts +118 -0
  25. package/plugins/nix-lsp.ts +125 -0
  26. package/plugins/nushell-lsp.ts +144 -0
  27. package/plugins/ocaml-lsp.ts +119 -0
  28. package/plugins/perl-lsp.ts +118 -0
  29. package/plugins/php-lsp.ts +165 -0
  30. package/plugins/pkg.ts +37 -76
  31. package/plugins/protobuf-lsp.ts +144 -0
  32. package/plugins/r-lsp.ts +118 -0
  33. package/plugins/ruby-lsp.ts +165 -0
  34. package/plugins/scala-lsp.ts +119 -0
  35. package/plugins/schemas/package.schema.json +437 -272
  36. package/plugins/schemas/theme.schema.json +18 -0
  37. package/plugins/solidity-lsp.ts +130 -0
  38. package/plugins/sql-lsp.ts +129 -0
  39. package/plugins/svelte-lsp.ts +119 -0
  40. package/plugins/swift-lsp.ts +120 -0
  41. package/plugins/tailwindcss-lsp.ts +119 -0
  42. package/plugins/terraform-lsp.ts +144 -0
  43. package/plugins/theme_editor.i18n.json +70 -14
  44. package/plugins/theme_editor.ts +71 -39
  45. package/plugins/toml-lsp.ts +162 -0
  46. package/plugins/typst-lsp.ts +165 -0
  47. package/plugins/vue-lsp.ts +118 -0
  48. package/plugins/yaml-lsp.ts +163 -0
@@ -826,6 +826,24 @@
826
826
  212,
827
827
  212
828
828
  ]
829
+ },
830
+ "punctuation_bracket": {
831
+ "description": "Punctuation brackets ({, }, (, ), [, ])",
832
+ "$ref": "#/$defs/ColorDef",
833
+ "default": [
834
+ 212,
835
+ 212,
836
+ 212
837
+ ]
838
+ },
839
+ "punctuation_delimiter": {
840
+ "description": "Punctuation delimiters (;, ,, .)",
841
+ "$ref": "#/$defs/ColorDef",
842
+ "default": [
843
+ 212,
844
+ 212,
845
+ 212
846
+ ]
829
847
  }
830
848
  }
831
849
  }
@@ -0,0 +1,130 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Solidity LSP Helper Plugin
6
+ *
7
+ * Provides user-friendly error handling for Solidity LSP server issues.
8
+ * When nomicfoundation-solidity-language-server fails to start, this plugin
9
+ * shows an actionable popup with installation instructions.
10
+ *
11
+ * Features:
12
+ * - Detects Solidity LSP server errors
13
+ * - Shows popup with install commands (npm)
14
+ * - Provides option to disable Solidity LSP
15
+ *
16
+ * VS Code: "Solidity" by Nomic Foundation (Hardhat), "Solidity" by Juan Blanco
17
+ * Neovim: nvim-lspconfig solidity
18
+ * Alternative: solc (Solidity compiler with diagnostics)
19
+ */
20
+
21
+ interface LspServerErrorData {
22
+ language: string;
23
+ server_command: string;
24
+ error_type: string;
25
+ message: string;
26
+ }
27
+
28
+ interface LspStatusClickedData {
29
+ language: string;
30
+ has_error: boolean;
31
+ }
32
+
33
+ interface ActionPopupResultData {
34
+ popup_id: string;
35
+ action_id: string;
36
+ }
37
+
38
+ // Install commands for Solidity LSP server
39
+ // See: https://github.com/NomicFoundation/hardhat-vscode/tree/main/server
40
+ const INSTALL_COMMANDS = {
41
+ npm: "npm i -g @nomicfoundation/solidity-language-server",
42
+ };
43
+
44
+ // Track error state for Solidity LSP
45
+ let solidityLspError: { serverCommand: string; message: string } | null = null;
46
+
47
+ /**
48
+ * Handle LSP server errors for Solidity
49
+ */
50
+ function on_solidity_lsp_server_error(data: LspServerErrorData): void {
51
+ if (data.language !== "solidity") {
52
+ return;
53
+ }
54
+
55
+ editor.debug(`solidity-lsp: Server error - ${data.error_type}: ${data.message}`);
56
+
57
+ solidityLspError = {
58
+ serverCommand: data.server_command,
59
+ message: data.message,
60
+ };
61
+
62
+ if (data.error_type === "not_found") {
63
+ editor.setStatus(
64
+ `Solidity LSP server '${data.server_command}' not found. Click status bar for help.`
65
+ );
66
+ } else {
67
+ editor.setStatus(`Solidity LSP error: ${data.message}`);
68
+ }
69
+ }
70
+ registerHandler("on_solidity_lsp_server_error", on_solidity_lsp_server_error);
71
+ editor.on("lsp_server_error", "on_solidity_lsp_server_error");
72
+
73
+ /**
74
+ * Handle status bar click when there's a Solidity LSP error
75
+ */
76
+ function on_solidity_lsp_status_clicked(data: LspStatusClickedData): void {
77
+ if (data.language !== "solidity" || !solidityLspError) {
78
+ return;
79
+ }
80
+
81
+ editor.debug("solidity-lsp: Status clicked, showing help popup");
82
+
83
+ editor.showActionPopup({
84
+ id: "solidity-lsp-help",
85
+ title: "Solidity Language Server Not Found",
86
+ message: `"${solidityLspError.serverCommand}" (by Nomic Foundation) provides code completion, diagnostics, and navigation for Solidity smart contracts. Requires Node.js. Copy the command below to install it, or visit https://github.com/NomicFoundation/hardhat-vscode for details.`,
87
+ actions: [
88
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
89
+ { id: "disable", label: "Disable Solidity LSP" },
90
+ { id: "dismiss", label: "Dismiss (ESC)" },
91
+ ],
92
+ });
93
+ }
94
+ registerHandler("on_solidity_lsp_status_clicked", on_solidity_lsp_status_clicked);
95
+ editor.on("lsp_status_clicked", "on_solidity_lsp_status_clicked");
96
+
97
+ /**
98
+ * Handle action popup results for Solidity LSP help
99
+ */
100
+ function on_solidity_lsp_action_result(data: ActionPopupResultData): void {
101
+ if (data.popup_id !== "solidity-lsp-help") {
102
+ return;
103
+ }
104
+
105
+ editor.debug(`solidity-lsp: Action selected - ${data.action_id}`);
106
+
107
+ switch (data.action_id) {
108
+ case "copy_npm":
109
+ editor.setClipboard(INSTALL_COMMANDS.npm);
110
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
111
+ break;
112
+
113
+ case "disable":
114
+ editor.disableLspForLanguage("solidity");
115
+ editor.setStatus("Solidity LSP disabled");
116
+ solidityLspError = null;
117
+ break;
118
+
119
+ case "dismiss":
120
+ case "dismissed":
121
+ break;
122
+
123
+ default:
124
+ editor.debug(`solidity-lsp: Unknown action: ${data.action_id}`);
125
+ }
126
+ }
127
+ registerHandler("on_solidity_lsp_action_result", on_solidity_lsp_action_result);
128
+ editor.on("action_popup_result", "on_solidity_lsp_action_result");
129
+
130
+ editor.debug("solidity-lsp: Plugin loaded");
@@ -0,0 +1,129 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * SQL LSP Helper Plugin
6
+ *
7
+ * Provides user-friendly error handling for SQL LSP server issues.
8
+ * When sqls fails to start, this plugin shows an actionable
9
+ * popup with installation instructions.
10
+ *
11
+ * Server: sqls (github.com/sqls-server/sqls)
12
+ * VS Code: SQLTools extension, Database Client JDBC
13
+ * Neovim: nvim-lspconfig sqls
14
+ * Note: sqls needs a config.yml for database connections
15
+ * Alternative: sql-language-server (npm)
16
+ */
17
+
18
+ interface LspServerErrorData {
19
+ language: string;
20
+ server_command: string;
21
+ error_type: string;
22
+ message: string;
23
+ }
24
+
25
+ interface LspStatusClickedData {
26
+ language: string;
27
+ has_error: boolean;
28
+ }
29
+
30
+ interface ActionPopupResultData {
31
+ popup_id: string;
32
+ action_id: string;
33
+ }
34
+
35
+ const INSTALL_COMMANDS = {
36
+ go: "go install github.com/sqls-server/sqls@latest",
37
+ brew: "brew install sqls",
38
+ npm_alt: "npm install -g sql-language-server",
39
+ };
40
+
41
+ let sqlLspError: { serverCommand: string; message: string } | null = null;
42
+
43
+ function on_sql_lsp_server_error(data: LspServerErrorData): void {
44
+ if (data.language !== "sql") {
45
+ return;
46
+ }
47
+
48
+ editor.debug(`sql-lsp: Server error - ${data.error_type}: ${data.message}`);
49
+
50
+ sqlLspError = {
51
+ serverCommand: data.server_command,
52
+ message: data.message,
53
+ };
54
+
55
+ if (data.error_type === "not_found") {
56
+ editor.setStatus(
57
+ `SQL LSP server '${data.server_command}' not found. Click status bar for help.`
58
+ );
59
+ } else {
60
+ editor.setStatus(`SQL LSP error: ${data.message}`);
61
+ }
62
+ }
63
+ registerHandler("on_sql_lsp_server_error", on_sql_lsp_server_error);
64
+ editor.on("lsp_server_error", "on_sql_lsp_server_error");
65
+
66
+ function on_sql_lsp_status_clicked(data: LspStatusClickedData): void {
67
+ if (data.language !== "sql" || !sqlLspError) {
68
+ return;
69
+ }
70
+
71
+ editor.debug("sql-lsp: Status clicked, showing help popup");
72
+
73
+ editor.showActionPopup({
74
+ id: "sql-lsp-help",
75
+ title: "SQL Language Server Not Found",
76
+ message: `"${sqlLspError.serverCommand}" provides completion, hover, and diagnostics for SQL files. It requires a config.yml to connect to your database. See: https://github.com/sqls-server/sqls\n\nAlternative: sql-language-server (npm) supports MySQL, PostgreSQL, SQLite.\nVS Code users: Try the SQLTools extension.`,
77
+ actions: [
78
+ { id: "copy_go", label: `Copy: ${INSTALL_COMMANDS.go}` },
79
+ { id: "copy_brew", label: `Copy: ${INSTALL_COMMANDS.brew}` },
80
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm_alt}` },
81
+ { id: "disable", label: "Disable SQL LSP" },
82
+ { id: "dismiss", label: "Dismiss (ESC)" },
83
+ ],
84
+ });
85
+ }
86
+ registerHandler("on_sql_lsp_status_clicked", on_sql_lsp_status_clicked);
87
+ editor.on("lsp_status_clicked", "on_sql_lsp_status_clicked");
88
+
89
+ function on_sql_lsp_action_result(data: ActionPopupResultData): void {
90
+ if (data.popup_id !== "sql-lsp-help") {
91
+ return;
92
+ }
93
+
94
+ editor.debug(`sql-lsp: Action selected - ${data.action_id}`);
95
+
96
+ switch (data.action_id) {
97
+ case "copy_go":
98
+ editor.setClipboard(INSTALL_COMMANDS.go);
99
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.go);
100
+ break;
101
+
102
+ case "copy_brew":
103
+ editor.setClipboard(INSTALL_COMMANDS.brew);
104
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.brew);
105
+ break;
106
+
107
+ case "copy_npm":
108
+ editor.setClipboard(INSTALL_COMMANDS.npm_alt);
109
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm_alt);
110
+ break;
111
+
112
+ case "disable":
113
+ editor.disableLspForLanguage("sql");
114
+ editor.setStatus("SQL LSP disabled");
115
+ sqlLspError = null;
116
+ break;
117
+
118
+ case "dismiss":
119
+ case "dismissed":
120
+ break;
121
+
122
+ default:
123
+ editor.debug(`sql-lsp: Unknown action: ${data.action_id}`);
124
+ }
125
+ }
126
+ registerHandler("on_sql_lsp_action_result", on_sql_lsp_action_result);
127
+ editor.on("action_popup_result", "on_sql_lsp_action_result");
128
+
129
+ editor.debug("sql-lsp: Plugin loaded");
@@ -0,0 +1,119 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Svelte LSP Helper Plugin
6
+ *
7
+ * Server: svelte-language-server (binary: svelteserver)
8
+ * VS Code: "Svelte for VS Code" extension
9
+ * Neovim: nvim-lspconfig svelte
10
+ * Note: Also install typescript-svelte-plugin for TS integration
11
+ * CLI tool: svelte-check for CI diagnostics
12
+ */
13
+
14
+ interface LspServerErrorData {
15
+ language: string;
16
+ server_command: string;
17
+ error_type: string;
18
+ message: string;
19
+ }
20
+
21
+ interface LspStatusClickedData {
22
+ language: string;
23
+ has_error: boolean;
24
+ }
25
+
26
+ interface ActionPopupResultData {
27
+ popup_id: string;
28
+ action_id: string;
29
+ }
30
+
31
+ const INSTALL_COMMANDS = {
32
+ npm: "npm install -g svelte-language-server",
33
+ yarn: "yarn global add svelte-language-server",
34
+ pnpm: "pnpm add -g svelte-language-server",
35
+ };
36
+
37
+ let svelteLspError: { serverCommand: string; message: string } | null = null;
38
+
39
+ function on_svelte_lsp_server_error(data: LspServerErrorData): void {
40
+ if (data.language !== "svelte") {
41
+ return;
42
+ }
43
+
44
+ editor.debug(`svelte-lsp: Server error - ${data.error_type}: ${data.message}`);
45
+
46
+ svelteLspError = {
47
+ serverCommand: data.server_command,
48
+ message: data.message,
49
+ };
50
+
51
+ if (data.error_type === "not_found") {
52
+ editor.setStatus(
53
+ `Svelte LSP server '${data.server_command}' not found. Click status bar for help.`
54
+ );
55
+ } else {
56
+ editor.setStatus(`Svelte LSP error: ${data.message}`);
57
+ }
58
+ }
59
+ registerHandler("on_svelte_lsp_server_error", on_svelte_lsp_server_error);
60
+ editor.on("lsp_server_error", "on_svelte_lsp_server_error");
61
+
62
+ function on_svelte_lsp_status_clicked(data: LspStatusClickedData): void {
63
+ if (data.language !== "svelte" || !svelteLspError) {
64
+ return;
65
+ }
66
+
67
+ editor.debug("svelte-lsp: Status clicked, showing help popup");
68
+
69
+ editor.showActionPopup({
70
+ id: "svelte-lsp-help",
71
+ title: "Svelte Language Server Not Found",
72
+ message: `"${svelteLspError.serverCommand}" provides completion, diagnostics, and formatting for Svelte components.\n\nFor TypeScript integration, also install typescript-svelte-plugin in your project.\nUse svelte-check for CI diagnostics.\nVS Code users: Install the "Svelte for VS Code" extension.\nSee: https://github.com/sveltejs/language-tools`,
73
+ actions: [
74
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
75
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
76
+ { id: "disable", label: "Disable Svelte LSP" },
77
+ { id: "dismiss", label: "Dismiss (ESC)" },
78
+ ],
79
+ });
80
+ }
81
+ registerHandler("on_svelte_lsp_status_clicked", on_svelte_lsp_status_clicked);
82
+ editor.on("lsp_status_clicked", "on_svelte_lsp_status_clicked");
83
+
84
+ function on_svelte_lsp_action_result(data: ActionPopupResultData): void {
85
+ if (data.popup_id !== "svelte-lsp-help") {
86
+ return;
87
+ }
88
+
89
+ editor.debug(`svelte-lsp: Action selected - ${data.action_id}`);
90
+
91
+ switch (data.action_id) {
92
+ case "copy_npm":
93
+ editor.setClipboard(INSTALL_COMMANDS.npm);
94
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
95
+ break;
96
+
97
+ case "copy_pnpm":
98
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
99
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
100
+ break;
101
+
102
+ case "disable":
103
+ editor.disableLspForLanguage("svelte");
104
+ editor.setStatus("Svelte LSP disabled");
105
+ svelteLspError = null;
106
+ break;
107
+
108
+ case "dismiss":
109
+ case "dismissed":
110
+ break;
111
+
112
+ default:
113
+ editor.debug(`svelte-lsp: Unknown action: ${data.action_id}`);
114
+ }
115
+ }
116
+ registerHandler("on_svelte_lsp_action_result", on_svelte_lsp_action_result);
117
+ editor.on("action_popup_result", "on_svelte_lsp_action_result");
118
+
119
+ editor.debug("svelte-lsp: Plugin loaded");
@@ -0,0 +1,120 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Swift LSP Helper Plugin
6
+ *
7
+ * Server: sourcekit-lsp (bundled with Xcode/Swift toolchain)
8
+ * VS Code: "Swift" extension by Swift Server Work Group
9
+ * Neovim: nvim-lspconfig sourcekit
10
+ * macOS: Included with Xcode (xcrun sourcekit-lsp)
11
+ * Linux: Install Swift toolchain from swift.org
12
+ * Note: For Xcode projects, also install xcode-build-server
13
+ */
14
+
15
+ interface LspServerErrorData {
16
+ language: string;
17
+ server_command: string;
18
+ error_type: string;
19
+ message: string;
20
+ }
21
+
22
+ interface LspStatusClickedData {
23
+ language: string;
24
+ has_error: boolean;
25
+ }
26
+
27
+ interface ActionPopupResultData {
28
+ popup_id: string;
29
+ action_id: string;
30
+ }
31
+
32
+ const INSTALL_COMMANDS = {
33
+ macos: "xcode-select --install",
34
+ linux: "# Download Swift from https://swift.org/download/",
35
+ xcode_build_server: "brew install xcode-build-server",
36
+ };
37
+
38
+ let swiftLspError: { serverCommand: string; message: string } | null = null;
39
+
40
+ function on_swift_lsp_server_error(data: LspServerErrorData): void {
41
+ if (data.language !== "swift") {
42
+ return;
43
+ }
44
+
45
+ editor.debug(`swift-lsp: Server error - ${data.error_type}: ${data.message}`);
46
+
47
+ swiftLspError = {
48
+ serverCommand: data.server_command,
49
+ message: data.message,
50
+ };
51
+
52
+ if (data.error_type === "not_found") {
53
+ editor.setStatus(
54
+ `Swift LSP server '${data.server_command}' not found. Click status bar for help.`
55
+ );
56
+ } else {
57
+ editor.setStatus(`Swift LSP error: ${data.message}`);
58
+ }
59
+ }
60
+ registerHandler("on_swift_lsp_server_error", on_swift_lsp_server_error);
61
+ editor.on("lsp_server_error", "on_swift_lsp_server_error");
62
+
63
+ function on_swift_lsp_status_clicked(data: LspStatusClickedData): void {
64
+ if (data.language !== "swift" || !swiftLspError) {
65
+ return;
66
+ }
67
+
68
+ editor.debug("swift-lsp: Status clicked, showing help popup");
69
+
70
+ editor.showActionPopup({
71
+ id: "swift-lsp-help",
72
+ title: "Swift Language Server Not Found",
73
+ message: `"${swiftLspError.serverCommand}" provides completion, diagnostics, and navigation for Swift files. It is bundled with the Swift toolchain.\n\nmacOS: Install Xcode Command Line Tools. Use 'xcrun sourcekit-lsp' if not in PATH.\nLinux: Download the Swift toolchain from swift.org.\nFor Xcode projects: Install xcode-build-server for build system integration.\nVS Code users: Install the "Swift" extension.\nSee: https://github.com/swiftlang/sourcekit-lsp`,
74
+ actions: [
75
+ { id: "copy_macos", label: `Copy: ${INSTALL_COMMANDS.macos}` },
76
+ { id: "copy_xbs", label: `Copy: ${INSTALL_COMMANDS.xcode_build_server}` },
77
+ { id: "disable", label: "Disable Swift LSP" },
78
+ { id: "dismiss", label: "Dismiss (ESC)" },
79
+ ],
80
+ });
81
+ }
82
+ registerHandler("on_swift_lsp_status_clicked", on_swift_lsp_status_clicked);
83
+ editor.on("lsp_status_clicked", "on_swift_lsp_status_clicked");
84
+
85
+ function on_swift_lsp_action_result(data: ActionPopupResultData): void {
86
+ if (data.popup_id !== "swift-lsp-help") {
87
+ return;
88
+ }
89
+
90
+ editor.debug(`swift-lsp: Action selected - ${data.action_id}`);
91
+
92
+ switch (data.action_id) {
93
+ case "copy_macos":
94
+ editor.setClipboard(INSTALL_COMMANDS.macos);
95
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.macos);
96
+ break;
97
+
98
+ case "copy_xbs":
99
+ editor.setClipboard(INSTALL_COMMANDS.xcode_build_server);
100
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.xcode_build_server);
101
+ break;
102
+
103
+ case "disable":
104
+ editor.disableLspForLanguage("swift");
105
+ editor.setStatus("Swift LSP disabled");
106
+ swiftLspError = null;
107
+ break;
108
+
109
+ case "dismiss":
110
+ case "dismissed":
111
+ break;
112
+
113
+ default:
114
+ editor.debug(`swift-lsp: Unknown action: ${data.action_id}`);
115
+ }
116
+ }
117
+ registerHandler("on_swift_lsp_action_result", on_swift_lsp_action_result);
118
+ editor.on("action_popup_result", "on_swift_lsp_action_result");
119
+
120
+ editor.debug("swift-lsp: Plugin loaded");
@@ -0,0 +1,119 @@
1
+ /// <reference path="./lib/fresh.d.ts" />
2
+ const editor = getEditor();
3
+
4
+ /**
5
+ * Tailwind CSS LSP Helper Plugin
6
+ *
7
+ * Server: @tailwindcss/language-server (binary: tailwindcss-language-server)
8
+ * VS Code: "Tailwind CSS IntelliSense" official extension
9
+ * Neovim: nvim-lspconfig tailwindcss
10
+ * Note: Needs Tailwind CSS in your project (tailwind.config.js or CSS @import)
11
+ * Features: class completion, color preview, hover info, linting
12
+ */
13
+
14
+ interface LspServerErrorData {
15
+ language: string;
16
+ server_command: string;
17
+ error_type: string;
18
+ message: string;
19
+ }
20
+
21
+ interface LspStatusClickedData {
22
+ language: string;
23
+ has_error: boolean;
24
+ }
25
+
26
+ interface ActionPopupResultData {
27
+ popup_id: string;
28
+ action_id: string;
29
+ }
30
+
31
+ const INSTALL_COMMANDS = {
32
+ npm: "npm install -g @tailwindcss/language-server",
33
+ yarn: "yarn global add @tailwindcss/language-server",
34
+ pnpm: "pnpm add -g @tailwindcss/language-server",
35
+ };
36
+
37
+ let tailwindLspError: { serverCommand: string; message: string } | null = null;
38
+
39
+ function on_tailwindcss_lsp_server_error(data: LspServerErrorData): void {
40
+ if (data.language !== "tailwindcss") {
41
+ return;
42
+ }
43
+
44
+ editor.debug(`tailwindcss-lsp: Server error - ${data.error_type}: ${data.message}`);
45
+
46
+ tailwindLspError = {
47
+ serverCommand: data.server_command,
48
+ message: data.message,
49
+ };
50
+
51
+ if (data.error_type === "not_found") {
52
+ editor.setStatus(
53
+ `Tailwind CSS LSP server '${data.server_command}' not found. Click status bar for help.`
54
+ );
55
+ } else {
56
+ editor.setStatus(`Tailwind CSS LSP error: ${data.message}`);
57
+ }
58
+ }
59
+ registerHandler("on_tailwindcss_lsp_server_error", on_tailwindcss_lsp_server_error);
60
+ editor.on("lsp_server_error", "on_tailwindcss_lsp_server_error");
61
+
62
+ function on_tailwindcss_lsp_status_clicked(data: LspStatusClickedData): void {
63
+ if (data.language !== "tailwindcss" || !tailwindLspError) {
64
+ return;
65
+ }
66
+
67
+ editor.debug("tailwindcss-lsp: Status clicked, showing help popup");
68
+
69
+ editor.showActionPopup({
70
+ id: "tailwindcss-lsp-help",
71
+ title: "Tailwind CSS Language Server Not Found",
72
+ message: `"${tailwindLspError.serverCommand}" provides class name completion, color previews, hover info, and linting for Tailwind CSS.\n\nRequires Tailwind CSS configured in your project (tailwind.config.js or v4 CSS @import).\nVS Code users: Install "Tailwind CSS IntelliSense" extension.\nSee: https://github.com/tailwindlabs/tailwindcss-intellisense`,
73
+ actions: [
74
+ { id: "copy_npm", label: `Copy: ${INSTALL_COMMANDS.npm}` },
75
+ { id: "copy_pnpm", label: `Copy: ${INSTALL_COMMANDS.pnpm}` },
76
+ { id: "disable", label: "Disable Tailwind CSS LSP" },
77
+ { id: "dismiss", label: "Dismiss (ESC)" },
78
+ ],
79
+ });
80
+ }
81
+ registerHandler("on_tailwindcss_lsp_status_clicked", on_tailwindcss_lsp_status_clicked);
82
+ editor.on("lsp_status_clicked", "on_tailwindcss_lsp_status_clicked");
83
+
84
+ function on_tailwindcss_lsp_action_result(data: ActionPopupResultData): void {
85
+ if (data.popup_id !== "tailwindcss-lsp-help") {
86
+ return;
87
+ }
88
+
89
+ editor.debug(`tailwindcss-lsp: Action selected - ${data.action_id}`);
90
+
91
+ switch (data.action_id) {
92
+ case "copy_npm":
93
+ editor.setClipboard(INSTALL_COMMANDS.npm);
94
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.npm);
95
+ break;
96
+
97
+ case "copy_pnpm":
98
+ editor.setClipboard(INSTALL_COMMANDS.pnpm);
99
+ editor.setStatus("Copied: " + INSTALL_COMMANDS.pnpm);
100
+ break;
101
+
102
+ case "disable":
103
+ editor.disableLspForLanguage("tailwindcss");
104
+ editor.setStatus("Tailwind CSS LSP disabled");
105
+ tailwindLspError = null;
106
+ break;
107
+
108
+ case "dismiss":
109
+ case "dismissed":
110
+ break;
111
+
112
+ default:
113
+ editor.debug(`tailwindcss-lsp: Unknown action: ${data.action_id}`);
114
+ }
115
+ }
116
+ registerHandler("on_tailwindcss_lsp_action_result", on_tailwindcss_lsp_action_result);
117
+ editor.on("action_popup_result", "on_tailwindcss_lsp_action_result");
118
+
119
+ editor.debug("tailwindcss-lsp: Plugin loaded");