Skip to content

Andriamanitra/mlsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

µlsp

LSP client for micro-editor. Note that this is a work in progress and has not yet been tested extensively – expect there to be some bugs. Please open an issue if you run into any!

Demo

https://asciinema.org/a/610761

Installation

Simply clone the repository to your micro plugins directory:

git clone https://github.com/Andriamanitra/mlsp ~/.config/micro/plug/mlsp

You will also need to install language servers for the programming languages you want to use.

The plugin currently provides following commands:

  • lsp deno lsp starts a language server by executing command deno lsp. Without arguments the lsp command will try to guess the right server by looking at the currently open filetype.
  • lsp-stop deno stops the language server with name deno. Without arguments the lsp-stop command will stop all currently running language servers.
  • hover shows hover information for the code under cursor.
  • format formats the buffer that is currently open.
  • autocomplete for code completion suggestions. PROTIP: If you wish to use the same key as micro's autocompletion (tab by default), enable tabAutocomplete in config.lua instead of binding command:autocomplete to a key!
  • goto-definition – open the definition for the symbol under cursor
  • goto-declaration – open the declaration for the symbol under cursor
  • goto-typedefinition – open the type definition for the symbol under cursor
  • goto-implementation – open the implementation for the symbol under cursor
  • find-references - find all references to the symbol under cursor (shows the results in a new pane)
  • document-symbols - list all symbols in the current document
  • diagnostic-info - show more information about a diagnostic on the current line (useful for multiline diagnostic messages)

You can type the commands on micro command prompt or bind them to keys by adding something like this to your bindings.json:

{
  "F7": "command:lsp",
  "F8": "command:format",
  "Alt-h": "command:hover",
  "Alt-d": "command:goto-definition",
  "Alt-r": "command:find-references"
}

Supported features

  • get hover information
  • show diagnostics (disabled by default, edit config.lua to enable)
  • autocomplete using tab (disabled by default, edit config.lua to enable)
  • format document
  • format selection
  • go to definition
  • go to declaration
  • go to implementation
  • go to type definition
  • find references
  • list document symbols
  • rename symbol
  • code actions
  • incremental document synchronization (better performance when editing large files)
  • suggest a feature

Showing LSP information on statusline

The plugin provides a function mlsp.status that can be used in the status line format. Here is an example configuration (~/.config/micro/settings.json) that uses it:

{
    "statusformatl": "$(filename) $(modified)($(line),$(col)) | ft:$(opt:filetype) | µlsp:$(mlsp.status)"
}

See micro documentation and the built-in status plugin for more information on customizing the statusline.

Known issues

  • The very first autocompletion with rust-analyzer after initialization is very slow (it can take multiple seconds).

Other similar projects

About

Language Server Protocol plugin for micro-editor

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages