Skip to content

Commit

Permalink
Merge pull request #1527 from rsteube/add-rust-analyzer
Browse files Browse the repository at this point in the history
added rust-analyzer
  • Loading branch information
rsteube authored Feb 27, 2023
2 parents a41b9ba + 8a1f6a2 commit 436c49a
Show file tree
Hide file tree
Showing 11 changed files with 230 additions and 0 deletions.
33 changes: 33 additions & 0 deletions completers/rust-analyzer_completer/cmd/analysisStats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var analysisStatsCmd = &cobra.Command{
Use: "analysis-stats",
Short: "Batch typecheck project and print summary statistics",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(analysisStatsCmd).Standalone()

analysisStatsCmd.Flags().Bool("disable-build-scripts", false, "Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis")
analysisStatsCmd.Flags().Bool("disable-proc-macros", false, "Don't use expand proc macros")
analysisStatsCmd.Flags().Bool("memory-usage", false, "Collect memory usage statistics")
analysisStatsCmd.Flags().Bool("no-sysroot", false, "Don't load sysroot crates (`std`, `core` & friends)")
analysisStatsCmd.Flags().StringP("only", "o", "", "Only analyze items matching this path")
analysisStatsCmd.Flags().String("output", "", "")
analysisStatsCmd.Flags().Bool("parallel", false, "Run type inference in parallel")
analysisStatsCmd.Flags().Bool("randomize", false, "Randomize order in which crates, modules, and items are processed")
analysisStatsCmd.Flags().Bool("skip-inference", false, "Only resolve names, don't run type inference")
analysisStatsCmd.Flags().Bool("source-stats", false, "Print the total length of all source and macro files (whitespace is not counted)")
analysisStatsCmd.Flags().Bool("with-deps", false, "Also analyze all dependencies")
rootCmd.AddCommand(analysisStatsCmd)

carapace.Gen(analysisStatsCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
24 changes: 24 additions & 0 deletions completers/rust-analyzer_completer/cmd/diagnostics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var diagnosticsCmd = &cobra.Command{
Use: "diagnostics",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(diagnosticsCmd).Standalone()

diagnosticsCmd.Flags().Bool("disable-build-scripts", false, "Don't run build scripts or load `OUT_DIR` values by running `cargo check` before analysis.")
diagnosticsCmd.Flags().Bool("disable-proc-macros", false, "Don't use expand proc macros.")
rootCmd.AddCommand(diagnosticsCmd)

carapace.Gen(diagnosticsCmd).PositionalCompletion(
carapace.ActionDirectories(),
)
}
19 changes: 19 additions & 0 deletions completers/rust-analyzer_completer/cmd/highlight.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var highlightCmd = &cobra.Command{
Use: "highlight",
Short: "Highlight stdin as html",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(highlightCmd).Standalone()

highlightCmd.Flags().Bool("rainbow", false, "Enable rainbow highlighting of identifiers")
rootCmd.AddCommand(highlightCmd)
}
22 changes: 22 additions & 0 deletions completers/rust-analyzer_completer/cmd/lsif.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var lsifCmd = &cobra.Command{
Use: "lsif",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(lsifCmd).Standalone()

rootCmd.AddCommand(lsifCmd)

carapace.Gen(lsifCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}
19 changes: 19 additions & 0 deletions completers/rust-analyzer_completer/cmd/parse.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var parseCmd = &cobra.Command{
Use: "parse",
Short: "Parse stdin",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(parseCmd).Standalone()

parseCmd.Flags().Bool("no-dump", false, "Suppress printing")
rootCmd.AddCommand(parseCmd)
}
18 changes: 18 additions & 0 deletions completers/rust-analyzer_completer/cmd/procMacro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var procMacroCmd = &cobra.Command{
Use: "proc-macro",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(procMacroCmd).Standalone()

rootCmd.AddCommand(procMacroCmd)
}
33 changes: 33 additions & 0 deletions completers/rust-analyzer_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "rust-analyzer",
Short: "LSP server for the Rust programming language",
Long: "https://github.com/rust-lang/rust-analyzer",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().BoolP("help", "h", false, "Print help")
rootCmd.Flags().String("log-file", "", "Log to the specified file instead of stderr")
rootCmd.Flags().Bool("no-log-buffering", false, "Flush log records to the file immediately")
rootCmd.Flags().Bool("print-config-schema", false, "Dump a LSP config JSON schema")
rootCmd.Flags().BoolP("quiet", "q", false, "Verbosity level")
rootCmd.Flags().CountP("verbose", "v", "Verbosity level, can be repeated multiple times")
rootCmd.Flags().Bool("version", false, "Print version")
rootCmd.Flags().Bool("wait-dbg", false, "Wait until a debugger is attached to (requires debug build)")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"log-file": carapace.ActionFiles(),
})
}
19 changes: 19 additions & 0 deletions completers/rust-analyzer_completer/cmd/search.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var searchCmd = &cobra.Command{
Use: "search",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(searchCmd).Standalone()

searchCmd.Flags().String("debug", "", "Prints debug information for any nodes with source exactly equal to snippet.")
rootCmd.AddCommand(searchCmd)
}
18 changes: 18 additions & 0 deletions completers/rust-analyzer_completer/cmd/ssr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var ssrCmd = &cobra.Command{
Use: "ssr",
Short: "",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(ssrCmd).Standalone()

rootCmd.AddCommand(ssrCmd)
}
18 changes: 18 additions & 0 deletions completers/rust-analyzer_completer/cmd/symbols.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var symbolsCmd = &cobra.Command{
Use: "symbols",
Short: "Parse stdin and print the list of symbols",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(symbolsCmd).Standalone()

rootCmd.AddCommand(symbolsCmd)
}
7 changes: 7 additions & 0 deletions completers/rust-analyzer_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/rust-analyzer_completer/cmd"

func main() {
cmd.Execute()
}

0 comments on commit 436c49a

Please sign in to comment.