From 19c99b95c12d8197cf08b491f50f1a03d11b593f Mon Sep 17 00:00:00 2001 From: karitham Date: Sat, 8 Aug 2026 01:02:57 +0200 Subject: [PATCH] treewide: rename binary output name --- README.md | 64 +++++++++++++++--------------- flake.nix | 7 +--- log/log.go | 4 +- lsp/consts.go | 2 +- lsp/initialize.go | 8 ++-- main.go | 14 +++---- options/options.go | 12 +++--- options/options_test.go | 8 ++-- resolver/resolver_test.go | 4 +- tests/e2e/enums/test.sh | 2 +- tests/e2e/field_line_comma/test.sh | 2 +- tests/e2e/fields/test.sh | 2 +- tests/e2e/run-e2e.sh | 4 +- 13 files changed, 65 insertions(+), 68 deletions(-) diff --git a/README.md b/README.md index 8480daf..659b495 100644 --- a/README.md +++ b/README.md @@ -19,33 +19,33 @@ Fork of https://github.com/joyme123/thrift-ls, parser + lexer + formatter rewrit go install github.com/karitham/thrift-ls@latest ``` -This installs the `thriftls` binary. It speaks LSP over stdio and doubles as +This installs the `thrift-ls` binary. It speaks LSP over stdio and doubles as a CLI formatter. ## Usage ``` -thriftls [flags] run the language server (default) -thriftls lsp [flags] run the language server -thriftls format [flags] format a thrift file -thriftls dump [--ir] dump the parse tree and formatter IR +thrift-ls [flags] run the language server (default) +thrift-ls lsp [flags] run the language server +thrift-ls format [flags] format a thrift file +thrift-ls dump [--ir] dump the parse tree and formatter IR ``` -Run `thriftls --help` or `thriftls format --help` for the full flag list. +Run `thrift-ls --help` or `thrift-ls format --help` for the full flag list. ### As a language server -`thriftls` is a plain LSP server speaking JSON-RPC over stdio. No editor +`thrift-ls` is a plain LSP server speaking JSON-RPC over stdio. No editor extension is required: any LSP client can attach to the binary directly. ```bash -thriftls +thrift-ls ``` or, explicitly: ```bash -thriftls lsp +thrift-ls lsp ``` #### helix @@ -54,36 +54,36 @@ Helix ships a thrift language definition, so only the server and the attachment are needed in `~/.config/helix/languages.toml`: ```toml -[language-server.thriftls] -command = "thriftls" +[language-server.thrift-ls] +command = "thrift-ls" [[language]] name = "thrift" -language-servers = ["thriftls"] +language-servers = ["thrift-ls"] # optional: format on save via the LSP auto-format = true ``` -`thriftls` must be on `PATH`, or use an absolute path as `command`. The -server logs to `$TMPDIR/thriftls.log`; raise verbosity with `-logLevel`. +`thrift-ls` must be on `PATH`, or use an absolute path as `command`. The +server logs to `$TMPDIR/thrift-ls.log`; raise verbosity with `-logLevel`. #### neovim -Install `thriftls` with [mason](https://github.com/williamboman/mason.nvim) -(`MasonInstall thriftls`), then enable it via +Install `thrift-ls` with [mason](https://github.com/williamboman/mason.nvim) +(`MasonInstall thrift-ls`), then enable it via [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig), which ships a -`thriftls` config: +`thrift-ls` config: ```lua -vim.lsp.enable("thriftls") +vim.lsp.enable("thrift-ls") ``` #### vim -Use `thriftls` as the LSP provider for thrift files: +Use `thrift-ls` as the LSP provider for thrift files: ```vim -let g:lsp_settings = { 'thrift': { 'cmd': ['thriftls'] } } +let g:lsp_settings = { 'thrift': { 'cmd': ['thrift-ls'] } } ``` #### vscode @@ -96,16 +96,16 @@ at your own binary. ```bash # print the formatted file to stdout -thriftls format path/to/file.thrift +thrift-ls format path/to/file.thrift # overwrite the file in place -thriftls format -w path/to/file.thrift +thrift-ls format -w path/to/file.thrift # print a diff instead -thriftls format -d path/to/file.thrift +thrift-ls format -d path/to/file.thrift # batch-format a tree -find . -name "*.thrift" | xargs -n 1 thriftls format -w +find . -name "*.thrift" | xargs -n 1 thrift-ls format -w ``` Formatting flags: @@ -119,20 +119,20 @@ Formatting flags: | `--align` | `field`, `assign`, or `disable` | | `---separator` | Separators per construct (`struct`, `union`, `exception`, `enum`, `argument`, `throws`, `list`, `map`): `comma`, `semicolon`, `none`, or `preserve` (keep as written) | | `--break-` | Always break the construct's bodies onto multiple lines (same constructs) | -| `--config` | Path to a `thriftls.json` config file | +| `--config` | Path to a `thrift-ls.json` config file | | `-I` | Additional include path, like the thrift compiler's `-I` (repeatable) | Flags override the config file. ### Debugging: `dump` -`thriftls dump` prints the parse tree — every token with its position, +`thrift-ls dump` prints the parse tree — every token with its position, blank-line count, and attached comment trivia, plus the node spans — which is useful to understand how the lexer attached a comment or why the formatter moved something: ```bash -thriftls dump path/to/file.thrift +thrift-ls dump path/to/file.thrift ``` With `--ir`, it also builds the formatter's document IR, prints it (which @@ -140,7 +140,7 @@ records the layout decisions on the groups), and dumps the IR tree showing which groups broke and which stayed flat: ```bash -thriftls dump --ir --printWidth 100 path/to/file.thrift +thrift-ls dump --ir --printWidth 100 path/to/file.thrift ``` ## Formatter behavior @@ -214,9 +214,9 @@ Trailing comments may overflow their line without affecting alignment. ## Configuration -Configuration lives in a `thriftls.json` file, discovered by walking up from +Configuration lives in a `thrift-ls.json` file, discovered by walking up from the file being formatted or the workspace root (like Biome). Set the -`THRIFTLS_CONFIG` env var to point at an explicit config file. +`THRIFT_LS_CONFIG` env var to point at an explicit config file. ```json { @@ -331,7 +331,7 @@ to the current file's directory. If not found, it searches each path in ### logLevel -Controls logging verbosity (the server logs to `$TMPDIR/thriftls.log`): +Controls logging verbosity (the server logs to `$TMPDIR/thrift-ls.log`): - 1: fatal - 2: error @@ -354,7 +354,7 @@ printer, LSP offset mapper, and range formatting each have their own fuzz targets; the corpus entries under `testdata/fuzz` are permanent regression tests. -`thriftls dump` (see above) is the debugging companion: it shows the parse +`thrift-ls dump` (see above) is the debugging companion: it shows the parse tree and the formatter's document IR with the layout decisions, so a formatting issue can be pinned to the parser, the IR construction, or the printer. diff --git a/flake.nix b/flake.nix index c92ffb8..8bcb7dc 100644 --- a/flake.nix +++ b/flake.nix @@ -14,18 +14,15 @@ # The language server / formatter binary for this module. thriftls = pkgs: - pkgs.buildGoModule.override { go = pkgs.go_1_26; } { + pkgs.buildGoModule { pname = "thriftls"; - version = "0.1"; + version = "0.1.0"; src = nixpkgs.lib.cleanSource ./.; vendorHash = "sha256-zWy0x3yktLA8dtcbwzue3aB7a+SlqwWO86G3ZP8DgOQ="; ldflags = [ "-s" "-w" ]; - postInstall = '' - mv "$out/bin/thrift-ls" "$out/bin/thriftls" - ''; meta = { description = "A Thrift language server and formatter"; homepage = "https://github.com/karitham/thrift-ls"; diff --git a/log/log.go b/log/log.go index c3652f0..a5085a5 100644 --- a/log/log.go +++ b/log/log.go @@ -1,6 +1,6 @@ // Package log configures the process-wide slog logger for thrift-ls. // -// thrift-ls logs to a file in the temp directory (thriftls.log) so that LSP +// thrift-ls logs to a file in the temp directory (thrift-ls.log) so that LSP // traffic on stdio is never polluted with log output. package log @@ -15,7 +15,7 @@ import ( // level uses the historical thrift-ls scale (1 fatal .. 6 trace), matching // the old logrus levels so CLI flags keep their meaning. func Init(level int) { - file := os.TempDir() + "/thriftls.log" + file := os.TempDir() + "/thrift-ls.log" logFile, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o766) if err != nil { diff --git a/lsp/consts.go b/lsp/consts.go index 38deade..635836a 100644 --- a/lsp/consts.go +++ b/lsp/consts.go @@ -1,7 +1,7 @@ package lsp const ( - ServerName = "thriftls" + ServerName = "thrift-ls" ServerVersion = "0.1" LanguageIDThrift = "thrift" diff --git a/lsp/initialize.go b/lsp/initialize.go index 19b2732..0110bcf 100644 --- a/lsp/initialize.go +++ b/lsp/initialize.go @@ -154,7 +154,7 @@ func initializeResult() *protocol.InitializeResult { DocumentSelector: thriftSelector, }, StaticRegistrationOptions: protocol.StaticRegistrationOptions{ - ID: new("thriftls"), + ID: new("thrift-ls"), }, }, DefinitionProvider: &protocol.DefinitionOptions{ @@ -172,7 +172,7 @@ func initializeResult() *protocol.InitializeResult { }, }, StaticRegistrationOptions: protocol.StaticRegistrationOptions{ - ID: new("thriftls"), + ID: new("thrift-ls"), }, }, ReferencesProvider: &protocol.ReferenceOptions{ @@ -185,7 +185,7 @@ func initializeResult() *protocol.InitializeResult { WorkDoneProgressOptions: protocol.WorkDoneProgressOptions{ WorkDoneProgress: new(true), }, - Label: new("thriftls"), + Label: new("thrift-ls"), }, CodeActionProvider: &protocol.CodeActionOptions{ CodeActionKinds: []protocol.CodeActionKind{protocol.CodeActionKindSourceFixAll}, @@ -243,7 +243,7 @@ func initializeResult() *protocol.InitializeResult { Range: protocol.Boolean(false), }, StaticRegistrationOptions: protocol.StaticRegistrationOptions{ - ID: new("thriftls"), + ID: new("thrift-ls"), }, }, Workspace: &protocol.WorkspaceOptions{ diff --git a/main.go b/main.go index b748bb5..78458ec 100644 --- a/main.go +++ b/main.go @@ -24,7 +24,7 @@ import ( func main() { cmd := &cli.Command{ - Name: "thriftls", + Name: "thrift-ls", Usage: "Thrift language server and formatter", Version: lsp.ServerVersion, Flags: lspFlags(), @@ -69,7 +69,7 @@ func main() { } if err := cmd.Run(context.Background(), os.Args); err != nil { - fmt.Fprintln(os.Stderr, "thriftls:", err) + fmt.Fprintln(os.Stderr, "thrift-ls:", err) os.Exit(1) } } @@ -83,7 +83,7 @@ func lspFlags() []cli.Flag { }, &cli.StringFlag{ Name: "config", - Usage: "path to a thriftls.json config file", + Usage: "path to a thrift-ls.json config file", }, &cli.StringSliceFlag{ Name: "I", @@ -132,7 +132,7 @@ func formatFlags() []cli.Flag { }, &cli.StringFlag{ Name: "config", - Usage: "path to a thriftls.json config file", + Usage: "path to a thrift-ls.json config file", }, &cli.StringSliceFlag{ Name: "I", @@ -213,7 +213,7 @@ func formatAction(ctx context.Context, cmd *cli.Command) error { func dumpAction(ctx context.Context, cmd *cli.Command) error { file := cmd.Args().First() if file == "" { - return errors.New("must specify a thrift file to dump, e.g. thriftls dump file.thrift") + return errors.New("must specify a thrift file to dump, e.g. thrift-ls dump file.thrift") } src, err := os.ReadFile(file) @@ -353,7 +353,7 @@ func loadConfig(path, dir string) *options.Patch { } func fatal(err error) { - fmt.Fprintln(os.Stderr, "thriftls:", err) + fmt.Fprintln(os.Stderr, "thrift-ls:", err) os.Exit(1) } @@ -361,7 +361,7 @@ func fatal(err error) { // self-validate, and write, diff, or print. func formatFile(file string, write, diffOut bool, configPath string, cli options.Patch) error { if file == "" { - return errors.New("must specify a thrift file to format, e.g. thriftls format file.thrift") + return errors.New("must specify a thrift file to format, e.g. thrift-ls format file.thrift") } src, err := os.ReadFile(file) diff --git a/options/options.go b/options/options.go index 759819a..3900089 100644 --- a/options/options.go +++ b/options/options.go @@ -3,8 +3,8 @@ // sources can be layered — defaults, a JSON config file, CLI flags, and LSP // workspace settings — each overriding the previous. // -// The config file is thriftls.json, discovered by walking up from the file -// being formatted, like Biome's config discovery. THRIFTLS_CONFIG overrides +// The config file is thrift-ls.json, discovered by walking up from the file +// being formatted, like Biome's config discovery. THRIFT_LS_CONFIG overrides // the search with an explicit path. package options @@ -22,7 +22,7 @@ import ( ) // ConfigFileName is the JSON config file name. -const ConfigFileName = "thriftls.json" +const ConfigFileName = "thrift-ls.json" // Separators configures trailing separators per construct. A nil value is // unset. It is an alias of the formatter's per-construct container, so @@ -326,11 +326,11 @@ func Load(path string) (*Patch, error) { return &p, nil } -// FindConfig returns the config file path for dir: THRIFTLS_CONFIG when set, -// otherwise the nearest thriftls.json walking up from dir. It returns an +// FindConfig returns the config file path for dir: THRIFT_LS_CONFIG when set, +// otherwise the nearest thrift-ls.json walking up from dir. It returns an // empty path when no config exists. func FindConfig(dir string) (string, error) { - if path := os.Getenv("THRIFTLS_CONFIG"); path != "" { + if path := os.Getenv("THRIFT_LS_CONFIG"); path != "" { return path, nil } diff --git a/options/options_test.go b/options/options_test.go index 69fcd83..5a1a81a 100644 --- a/options/options_test.go +++ b/options/options_test.go @@ -163,7 +163,7 @@ func TestFindConfig(t *testing.T) { } // Config in an ancestor directory is found walking up. - cfgPath := filepath.Join(dir, "thriftls.json") + cfgPath := filepath.Join(dir, "thrift-ls.json") if err := os.WriteFile(cfgPath, []byte("{}"), 0o644); err != nil { t.Fatal(err) } @@ -174,7 +174,7 @@ func TestFindConfig(t *testing.T) { } // A nearer config wins. - near := filepath.Join(dir, "a", "thriftls.json") + near := filepath.Join(dir, "a", "thrift-ls.json") if err := os.WriteFile(near, []byte("{}"), 0o644); err != nil { t.Fatal(err) } @@ -187,7 +187,7 @@ func TestFindConfig(t *testing.T) { func TestLoadAndEffective(t *testing.T) { dir := t.TempDir() - cfgPath := filepath.Join(dir, "thriftls.json") + cfgPath := filepath.Join(dir, "thrift-ls.json") content := `{ "printWidth": 100, @@ -239,7 +239,7 @@ func TestLoadRejectsUnknownOverrideKeys(t *testing.T) { // Config files written for the old overrides feature should fail loudly // rather than silently ignoring per-file settings. dir := t.TempDir() - cfgPath := filepath.Join(dir, "thriftls.json") + cfgPath := filepath.Join(dir, "thrift-ls.json") content := `{ "printWidth": 100, diff --git a/resolver/resolver_test.go b/resolver/resolver_test.go index 26de238..f901569 100644 --- a/resolver/resolver_test.go +++ b/resolver/resolver_test.go @@ -18,7 +18,7 @@ import ( func TestConfigRelativeIncludePaths(t *testing.T) { dir := t.TempDir() - cfgPath := filepath.Join(dir, "thriftls.json") + cfgPath := filepath.Join(dir, "thrift-ls.json") if err := os.WriteFile(cfgPath, []byte(`{"includePaths": ["project/base"]}`), 0o644); err != nil { t.Fatal(err) } @@ -91,7 +91,7 @@ func (f *absMapFile) Close() error { return nil } // TestConfigAbsoluteIncludePaths keeps absolute paths as-is. func TestConfigAbsoluteIncludePaths(t *testing.T) { dir := t.TempDir() - cfgPath := filepath.Join(dir, "thriftls.json") + cfgPath := filepath.Join(dir, "thrift-ls.json") abs := filepath.Join(dir, "elsewhere") if err := os.WriteFile(cfgPath, []byte(`{"includePaths": ["`+abs+`"]}`), 0o644); err != nil { diff --git a/tests/e2e/enums/test.sh b/tests/e2e/enums/test.sh index c20880d..f652be8 100755 --- a/tests/e2e/enums/test.sh +++ b/tests/e2e/enums/test.sh @@ -13,7 +13,7 @@ do align=${options[1]} field_line_comma=${options[2]} echo "indent: ${indent}, align: ${align}, field_line_comma: ${field_line_comma}" - got=$("$THRIFTLS_BIN" format -indent "${indent}" -align "${align}" -field-separator "${field_line_comma}" tests/e2e/enums/enums.thrift) + got=$("$THRIFT_LS_BIN" format -indent "${indent}" -align "${align}" -field-separator "${field_line_comma}" tests/e2e/enums/enums.thrift) expected=$(cat "$f") if [ "$got" == "$expected" ];then echo "pass" diff --git a/tests/e2e/field_line_comma/test.sh b/tests/e2e/field_line_comma/test.sh index 0db03ea..0bfcf4a 100755 --- a/tests/e2e/field_line_comma/test.sh +++ b/tests/e2e/field_line_comma/test.sh @@ -11,7 +11,7 @@ do read -ra options <<<"$substr" field_line_comma=${options[0]} echo "fieldLineComma: ${field_line_comma}" - got=$("$THRIFTLS_BIN" format -field-separator "${field_line_comma}" tests/e2e/field_line_comma/fields.thrift) + got=$("$THRIFT_LS_BIN" format -field-separator "${field_line_comma}" tests/e2e/field_line_comma/fields.thrift) expected=$(cat "$f") if [ "$got" == "$expected" ];then echo "pass" diff --git a/tests/e2e/fields/test.sh b/tests/e2e/fields/test.sh index c07b2fd..8a101b9 100644 --- a/tests/e2e/fields/test.sh +++ b/tests/e2e/fields/test.sh @@ -12,7 +12,7 @@ do indent=${options[0]} align=${options[1]} echo "indent: ${indent}, align: ${align}" - got=$("$THRIFTLS_BIN" format -indent "${indent}" -align "${align}" tests/e2e/fields/fields.thrift) + got=$("$THRIFT_LS_BIN" format -indent "${indent}" -align "${align}" tests/e2e/fields/fields.thrift) expected=$(cat "$f") if [ "$got" == "$expected" ];then echo "pass" diff --git a/tests/e2e/run-e2e.sh b/tests/e2e/run-e2e.sh index f24a114..ad9f1a0 100755 --- a/tests/e2e/run-e2e.sh +++ b/tests/e2e/run-e2e.sh @@ -3,8 +3,8 @@ set -euo pipefail BIN_DIR=$(mktemp -d) trap 'rm -rf "$BIN_DIR"' EXIT -go build -o "$BIN_DIR/thriftls" . -export THRIFTLS_BIN="$BIN_DIR/thriftls" +go build -o "$BIN_DIR/thrift-ls" . +export THRIFT_LS_BIN="$BIN_DIR/thrift-ls" for f in ./tests/e2e/* do -- 2.51.2