Skip to content

yaegassy/coc-ast-grep

Repository files navigation

[WIP] coc-ast-grep

fork from a ast-grep-vscode

coc.nvim extension for ast-grep language server

coc-ast-grep-screenshot

Install

You need to have coc.nvim installed for this extension to work.

e.g. vim-plug:

Plug 'yaegassy/coc-ast-grep', {'do': 'yarn install --frozen-lockfile'}

Usage

The ast-grep language server requires sgconfig.yml in the project root to work properly.

!!Known Issues!!

The language client will crash if sgconfig.yml is not in the project root or if the rules are not properly configured.

I think it needs to be adjusted either on the ast-grep language server (sg lsp) side or on the coc.nvim side.

!!Note!!

Currently the extension is only enabled in typescript files.

{
  // ...snip
  "activationEvents": [
    "onLanguage:typescript"
  ],
  // ...snip
}

Configuration options

  • astGrep.enable: Enable coc-ast-grep extension, default: true
  • astGrep.serverPath: Specify the language server binary path. If the binary is not found, use the binary included in the extension, default: sg
  • astGrep.configPath: Customize ast-grep config file path relative.

To register a ast-grep language server without coc-extension

Add the following settings to coc-settings.json.

{
  "languageserver": {
    "ast-grep": {
      "command": "sg",
      "args": ["lsp"],
      "filetypes": ["typescript"],
      "rootPatterns": [
        "sgconfig.yml"
      ]
    }
  }
}

Thanks

License

MIT


This extension is built with create-coc-extension

About

coc.nvim extension for ast-grep language server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published