npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

miniscript-languageserver

v1.5.7

Published

Language server for MiniScript

Downloads

1,229

Readme

miniscript-languageserver

miniscript-languageserver

miniscript-languageserver is a Language Server for MiniScript that offers a variety of features, including:

  • Auto-completion
  • Hover tooltips
  • Syntax highlighting and more

This language server is compatible with any client that follows the LSP standards.

For an example of how it integrates with a popular editor, take a look at the examples.

Supported Providers

miniscript-languageserver supports the following language server protocol (LSP) features:

  • Completion: Auto-completion suggestions for code.
  • Hover: Displays information about a symbol when you hover over it.
  • Color: Color information for syntax highlighting and theming.
  • Definition: Navigate to the definition of a symbol.
  • Formatter: Automatically format the code according to set rules.
  • Signature Help: Shows function or method signatures while typing.
  • Document Symbol: Lists all symbols in a document (e.g., functions, classes).
  • Workspace Symbol: Search for symbols across the workspace.
  • Diagnostic: Provides error, warning, and information diagnostics.
  • Semantic Tokens: Enhanced token classification for syntax highlighting and analysis.

Install

npm install -g miniscript-languageserver

Usage

miniscript-languageserver

Example Implementations

This section provides a collection of IDEs that implement the miniscript-languageserver.

  • VSCode: Visual Studio Code setup for miniscript-languageserver.
  • Sublime Text: Instructions for integrating with Sublime Text.
  • IntelliJ: Guide for using miniscript-languageserver with IntelliJ.
  • Neovim (nvim): Configuration for Neovim users.

Any other IDEs that follow the LSP standards should also work with miniscript-languageserver.

VSCode

  1. Create language client file.
import * as path from 'path';
import {
  LanguageClient,
  LanguageClientOptions,
  ServerOptions,
  TransportKind
} from 'vscode-languageclient/node';

const serverModule = context.asAbsolutePath(
  path.join('node_modules', 'miniscript-languageserver', 'index.js')
);

const serverOptions: ServerOptions = {
  run: { module: serverModule, transport: TransportKind.ipc }
};

const clientOptions: LanguageClientOptions = {
  documentSelector: [{ scheme: 'file', language: 'miniscript' }],
  synchronize: {
    fileEvents: workspace.createFileSystemWatcher('**/*')
  },
  diagnosticCollectionName: 'miniscript'
};

const client = new LanguageClient(
  'languageServerExample',
  'Language Server Example',
  serverOptions,
  clientOptions
);

client.registerProposedFeatures();
client.start();

Sublime

  1. Install the LSP Package from the Sublime Text Package Control.
  2. Create the following LSP client configuration in your Sublime settings:
{
  "show_diagnostics_panel_on_save": 0,
  "clients": {
    "miniscript": {
      "enabled": true,
      "command": ["miniscript-languageserver", "--stdio"],
      "selector": "source.miniscript"
    }
  },
  "semantic_highlighting": true
}
  1. Create a Sublime syntax file for miniscript. The highlighting will be provided via the semantic provider, so there's no need to add additional patterns here. Use the following configuration:
%YAML 1.2
---
name: miniscript
file_extensions:
  - src
scope: source.miniscript

contexts:
  main:
    - match: '.+'
      scope: text.miniscript

IntelliJ

To set up miniscript-languageserver in IntelliJ, follow these steps:

  1. Install miniscript-languageserver.
  2. Install the LSP4IJ plugin from the JetBrains Plugin Marketplace.
  3. Go to Languages & Frameworks > Language Servers.
  4. Click the "+" icon to add a new language server configuration.
  5. In the Name field, enter miniscript.
  6. In the Command field, enter miniscript-languageserver --stdio.
  7. In the Filename Patterns section:
    • Set File Name Pattern to *.src.
    • Set Language Id to miniscript.
  8. Restart IntelliJ.

You should now have miniscript-languageserver set up and ready to use with IntelliJ.

nvim

  1. Add the following configuration to your init.vim:
" Install vim-plug if it's not already installed
call plug#begin('~/.vim/plugged')

" Install LSP config plugin
Plug 'neovim/nvim-lspconfig'

call plug#end()

" LSP configuration for miniscript-languageserver
lua <<EOF
  local configs = require'lspconfig.configs'
  local lspconfig = require'lspconfig'

  -- Enable debug-level logging
  vim.lsp.set_log_level("debug")

  if not configs.miniscript then
    configs.miniscript = {
      default_config = {
        cmd = { "miniscript-languageserver", "--stdio" },
        filetypes = { "src" },
        root_dir = lspconfig.util.root_pattern(".git", vim.fn.getcwd()),
        settings = {},
        on_attach = function(client, bufnr)           -- Optional on_attach function
          -- Set up hover keybinding here
          vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', { noremap = true, silent = true })
        end,
      },
    }
  end

  -- Register and start the miniscript LSP
  lspconfig.miniscript.setup{}
EOF

autocmd BufRead,BufNewFile *.src set filetype=src
  1. Don't forget to run :PlugInstall to install the necessary plugins.

This configuration ensures that miniscript-languageserver will be properly integrated into Neovim, and that .src files will be recognized with the correct syntax highlighting and LSP features.

How to Add Tooltips

Tooltips in miniscript-languageserver can help provide additional context, such as method descriptions, to users. You can contribute your own tooltips by following this workflow:

  1. Fork and create a pull request (PR) with your changes to the miniscript-meta repository, where the meta descriptions are stored.
  2. Once your changes are merged, create a separate PR in this repository to update the version of miniscript-languageserver to include the new meta descriptions.

Additionally, you can define method-specific tooltips directly in the code using comments. This allows for quick, tooltips for individual methods.

// @type Bar
// @property {string} virtualMoo
Bar = {}
Bar.moo = ""

// Hello world
// I am **bold**
// @description Alternative description
// @example test("title", 123)
// @param {string} title - The title of the book.
// @param {string|number} author - The author of the book.
// @return {Bar} - Some info about return
Bar.test = function(test, abc)
  print "test"
  return self
end function

// @type Foo
Foo = new Bar
// @return {Foo}
Foo.New = function(message)
  result = new Foo
  return result
end function

myVar = Foo.New

myVar.test // shows defined signature of Bar.test on hover
myVar.virtualMoo // shows virtual property of type string on hover