Deprecated: Function get_magic_quotes_gpc() is deprecated in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 99

Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 619

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1169

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176

Warning: Cannot modify header information - headers already sent by (output started at /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php:99) in /hermes/walnacweb04/walnacweb04ab/b2791/pow.jasaeld/htdocs/De1337/nothing/index.php on line 1176
8000 GitHub - erasin/hx-lsp: lsp for helix , support snippets, actions
Nothing Special   »   [go: up one dir, main page]

Skip to content

erasin/hx-lsp

Repository files navigation

hx-lsp

中文文档 中文文档

An LSP tool that provides custom code snippets and Code Actions for Helix Editor.

Features

  • LSP Command
    • reload snippets
    • reload actions
  • Completion: snippets (helix#9801)
  • CodeAction: actions
  • Document Color (helix#12308)
  • Word Convert case (action)
    • case_snake
      • CasePascal
      • caseCamel
  • Markdown Only
    • Table Formater (action) The line of the selected area consists of '|: -'.
    • Order,Unorder,Task List (action)
    • Bold/Italic/Strikethrough (action)

Install

From crate

cargo install --force hx-lsp

From source

git clone https://github.com/erasin/hx-lsp.git
cd hx-lsp
cargo install --path .

Use

Modify the language configuration file languages.toml for Helix Editor.

  • $XDG_CONFIG_HOME/helix/languages.toml: Helix Configuration file.
  • WORKSPACE_ROOT/.helix/languages.toml : Configuration file under project workspace root.

About 'WORKSPACE_ROOT', It is read the 'rootPath' from the 'initialize' provided by Helix, when there are multiple levels of rootPath(language.roots of languages.toml), It will read the closest of root '.helix'.

Example, Add support for markdown.

[language-server.hx-lsp]
command = "hx-lsp"

[[language]]
name = "markdown"
language-servers = [ "marksman", "markdown-oxide", "hx-lsp" ]

# or only use choose features
language-servers = [ "marksman", "markdown-oxide", { name = "hx-lsp", only-features = [ "document-colors" ] } ]

About language id, Read helix/languages.toml and helix wiki language server configurations

helix lsp support options only-features and except-features filter server features。 hx-lsp 支持

  • completion
  • code-action
  • document-colors

Configuration

The Configuration file supports the jsonc format.

Comment style: // ..., /* ... */, # ...

Snippets file loading path:

  • $XDG_CONFIG_HOME/helix/snippets/
  • WORKSPACE_ROOT/.helix/snippets/

Actions file loading path:

  • $XDG_CONFIG_HOME/helix/actions/
  • WORKSPACE_ROOT/.helix/actions/

In LSP textDocument/didOpen request, The Configuration file with name that is language_id.json will be loading.

Use :lsp-workspace-command open picker, and reload snippets or actions script.

Completion: snippets

Code Snippets support vscode snippets format. The same file suffix supports global suffixes such as. code-snippets and language pack suffixes such as. json.

~~For better use snippet completion, Use helix master and merge helix#9081 Add a snippet system to support smart-tab。 ~~

.
└── snippets
    ├── global.code-snippets
    ├── html.json
    └── markdown.json

Snippet Format:

  • name: String, index
  • prefix: String Or Vec<String>, editor completion item
  • body: String Or Vec<String>, snippet connent
  • description: Option<String | Vec<String>> Tip content
{
  "mdbookNote": {
    "prefix": "mdbookNote",
    "body": [
      "```admonish note ${1:title=\"$2\"}",
      "${3:content}",
      "```"
    ],
    "description": "mdbook admonish note"
  },

  "mdbookBob": {
    "prefix": "mdbookBob",
    "body": "```svgbob \n$1\n```",
    "description": "mdbook svgbob "
  },
  "dir": {
    "prefix": "dir",
    "body": [
      "TM_FILENAME: $TM_FILENAME",
      "TM_FILENAME_BASE: $TM_FILENAME_BASE",
      "TM_DIRECTORY: $TM_DIRECTORY",
      "TM_FILEPATH: ${TM_FILEPATH}",
      "RELATIVE_FILEPATH: $RELATIVE_FILEPATH",
      "WORKSPACE_NAME: $WORKSPACE_NAME ",
      "WORKSPACE_FOLDER: $WORKSPACE_FOLDER "
    ],
    "description": "path of current"
  }
}

CodeAction: actions

.
└── actions
    ├── html.json
    └── markdown.json

Snippet Formatter:

  • title: String helix editor show Code Action Item
  • flter: String Or Vec<String> Shell script: return true,1 or empty ,
  • shell: String Or Vec<String> Shell script: take shell script
  • description: Option<String | Vec<String>> Tip content
/* actions/markdown.json */
{
	"bold": {
		"title": "bold",
		"filter": "",
		"shell": ["echo -n **${TM_SELECTED_TEXT}**"],
		"description": "bold"
	},
	"italic": {
		"title": "italic",
		"filter": "",
		"shell": ["echo -n _${TM_SELECTED_TEXT}_"],
		"description": "italic"
	}
}
/* actions/go.json */
{
	"run main": {
		"title": "run main",
		"filter": "[[ \"$TM_CURRENT_LINE\" == *main* ]] && echo true || echo false",
		"shell": [
			"alacritty --hold --working-directory ${TM_DIRECTORY} -e go run ${TM_FILENAME};"
			"notify-send \"Golang\" \"RUN: ${TM_FILENAME}\""
		],
		"description": "go run main"
	},
	"run main in tmux": {
		"title": "tmux: go run main",
		"filter": "[[ \"$(cat)\" == *main* ]] && echo true || echo false",
		"shell": [
			"tmux split-window -h -c ${WORKSPACE_FOLDER}; tmux send 'go run ${TM_FILENAME}' Enter"
		],
		"description": "go run main"
	}
}

Variables

Support variable for snippet body and action shell.

Read vscode Variables

Support like $UUID${UUID}

path

  • TM_SELECTED_TEXT
  • TM_CURRENT_LINE
  • TM_CURRENT_WORD
  • TM_LINE_INDEX
  • TM_LINE_NUMBER
  • TM_FILENAME
  • TM_FILENAME_BASE
  • TM_DIRECTORY
  • TM_FILEPATH
  • RELATIVE_FILEPATH
  • CLIPBOARD
  • WORKSPACE_NAME
  • WORKSPACE_FOLDER

time

  • CURRENT_YEAR
  • CURRENT_YEAR_SHORT
  • CURRENT_MONTH
  • CURRENT_MONTH_NAME
  • CURRENT_MONTH_NAME_SHORT
  • CURRENT_DATE
  • CURRENT_DAY_NAME
  • CURRENT_DAY_NAME_SHORT
  • CURRENT_HOUR
  • CURRENT_MINUTE
  • CURRENT_SECOND
  • CURRENT_SECONDS_UNIX
  • CURRENT_TIMEZONE_OFFSET

other

  • RANDOM
  • RANDOM_HEX
  • UUID

DocumentColor

  • hex
    • #ffffff; support hex color
  • rgb
    • rgb(255, 255, 255) supports integers
    • rgb(2.0, 255.0, 255.0) supports floating-point values
    • rgb(100%, 0%, 50%) supports percentages
      • rgba(1.0, 0.0, 0.0, 0.5)
  • hsl
    • hsl(240, 50%, 50%) hue 0-360 degrees, saturation and lightness in percentages.
    • hsl(180, 0.5, 0.5) floating-point values
      • hsla(300, 100%, 100%, 0.5)
  • hsv
    • hsv(300, 100%, 100%) hue 0-360 degrees, saturation and value in percentages.
    • hsv(180, 0.5, 0.5) floating-point values
      • hsva(180, 0.5, 0.5, 0.5)

bevy color

  • srgb(1.0,0.0,0.0)
  • srgba(1.0, 0.0, 0.0, 0.8)

About

lsp for helix , support snippets, actions

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0