GithubHelp home page GithubHelp logo

quantonganh / snippets-ls Goto Github PK

View Code? Open in Web Editor NEW
47.0 5.0 7.0 42 KB

A simple language server to just insert snippets into Helix (and other text editor, IDE)

License: MIT License

Go 51.41% Nix 48.59%

snippets-ls's Introduction

snippets-ls

A simple language server to just insert snippets into Helix (and other text editor, IDE)

https://quantonganh.com/2023/07/31/create-snippets-in-helix

Installation

You can download the latest binary from the release page.

Install via homebrew

brew install quantonganh/tap/snippets-ls

Install via go

$ go install github.com/quantonganh/snippets-ls@latest

Don't forget to append ~/go/bin to your $PATH.

Install via nix flake with home-manager

Include the following in the inputs of flake.nix for home-manager:

inputs = {
  # load compatible nixpkgs and home-mananger repos; they need not be 23.05
  nixpkgs = { url = "github:nixos/nixpkgs/nixos-23.05"; };
  home-manager = {
    url = "github:nix-community/home-manager/release-23.05";
    inputs.nixpkgs.follows = "nixpkgs";
  };
  # ...
  snippets-ls = {
    url = "github:quantonganh/snippets-ls";
    inputs.nixpkgs.follows = "nixpkgs";
  };
};

There are in turn many suitable ways to configure the outputs of flake.nix. One option is to use an overlay with something like

outputs = inputs:
  with inputs;
  let
    system = "x86_64-linux"; # or other system as applicable (such as "x86_64-darwin")
    pkgs = import nixpkgs {
      inherit system;
      overlays = [ pkgs_overlay ];
    };
    # ...
    pkgs_overlay = final: prev: {
      # ...
      external.snippets-ls = snippets-ls.packages.${prev.system}.snippets-ls;
    };
  in {
    homeConfigurations.YOUR-USER-NAME-HERE = home-manager.lib.homeManagerConfiguration {
      inherit pkgs;
      modules = [ ./home.nix ];
    };
  };
};

The use of this overlay allows you to call this packages with pkgs.external.snippets-ls, such the list of packages in home.nix can look something like

home.packages = with pkgs; [
  # ...
  external.snippets-ls
];

Usage

Create your own snippets follow VSCode syntax. Alternatively, you can make use of pre-existing sample for various programming languages.

Update your configuration file located at ~/.config/helix/languages.toml:

[[language]]
name = "go"
formatter = { command = "goimports"}
language-servers = ["gopls", "snippets-ls"]

[language-server.snippets-ls]
command = "snippets-ls"
args = ["-config", "/Users/quantong/.config/helix/go-snippets.json"]

Subsequently, as you start working on your file, input a snippet prefix to observe the suggestion. If it does not work, take a look at ~/.cache/helix/helix.log for additional insights.

snippets-ls's People

Contributors

quantonganh avatar perlinm avatar samhh avatar imadnyc avatar bddvlpr avatar

Stargazers

Jose Storopoli avatar Peter Abbasi avatar  avatar Emilio Junior Francischetti avatar Silas Enrique avatar Alex Caza avatar Rubem Pacelli avatar ztsv avatar Mark Bundschuh avatar  avatar noor aldeen avatar Michael B. avatar Jorge Gomez avatar Le Dang Nhat Tien avatar  avatar l1nu5r avatar Global Young avatar  avatar Robert Wahler avatar Jeffrey Fetzer avatar Shawn Pande avatar Nathaniel Brough avatar Zeger Van de Vannet avatar Ben Cooper avatar John D. Mitchell avatar Andrea Titolo avatar Joel Quiles avatar Caesar Wang avatar Stepan Zhukovsky avatar Perma avatar nshern avatar Sujay avatar Antonius Naumann avatar  avatar  avatar Nikolay Kolev avatar Kyle L. Davis avatar alaska avatar Bruno Rocha avatar Ilja Rotar avatar David Thiel avatar Ken Micklas avatar H4ckint0sh avatar  avatar Eder Sosa avatar Ben Hansen avatar

Watchers

Evgeniy Tatarkin avatar Ken Micklas avatar  avatar Suraj avatar  avatar

snippets-ls's Issues

Having trouble setting up

I'm having trouble trying to set this up, I have this in the logs:
2023-12-02T23:15:33.194 helix_lsp::transport [ERROR] snippets-ls <- MethodNotFound: MethodNotFound 2023-12-02T23:15:33.194 helix_lsp::transport [ERROR] Discarding Language Server response without a request (id=Null) Err(Rpc(Error { code: MethodNotFound, message: "MethodNotFound", data: None }))

Tab to next position

Thanks for your time end effort. Any chance of getting tabbing in to next/previous position?

Install doesn't work due to declared path

Installing the LS using go install fails:

> go install github.com/quantonganh/snippets-ls@latest
go: downloading github.com/quantonganh/snippets-ls v0.0.3
go: github.com/quantonganh/snippets-ls@latest: version constraints conflict:
        github.com/quantonganh/[email protected]: parsing go.mod:
        module declares its path as: github.com/quantonganh/go-lsp
                but was required as: github.com/quantonganh/snippets-ls

Which could be solved by updating the declared path in go.mod.

(Thanks for the project btw!)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.