Home

Awesome

LSP Plugin for Lite XL editor

Plugin that provides intellisense for Lite XL by leveraging the LSP protocol While still a work in progress it already implements all the most important features to make your life easier while coding with Lite XL. Using it requires Lite XL v2.1+ (for Lite XL v2.0.1 to Lite XL v2.0.5 check out the 0.1 branch). lint+ is optionally used to render diagnostic messages while you type so make sure to get it. Also, the snippets plugin is used to properly process the received autocompletions in the form of snippets, so grab that too.

To use, clone this project into the lsp directory in your plugins folder. Finally you will need the Widgets lib so make sure to also drop it into your lite-xl configs directory. For example:

cd ~/.config/lite-xl/
git clone https://github.com/lite-xl/lite-xl-lsp plugins/lsp
git clone https://github.com/lite-xl/lite-xl-widgets libraries/widget
git clone https://github.com/liquidev/lintplus plugins/lintplus
wget https://raw.githubusercontent.com/vqns/lite-xl-snippets/main/snippets.lua \
  -O plugins/snippets.lua
wget https://raw.githubusercontent.com/vqns/lite-xl-snippets/main/lsp_snippets.lua \
  -O plugins/lsp_snippets.lua

The lite-xl configs directory should have:

Features

Stuff that is currently implemented:

Setting a LSP Server

The easiest method of setting up a lsp server is by using the config.lua file shipped with the lsp plugin which already contains a list of predefined servers (notice: not all of them have been tested to work). Require this file on your users init.lua, call setup() on the desired lsp servers or overwrite the configuration options of the defined lsp servers if needed as shown below:

Examples:

local lspconfig = require "plugins.lsp.config"

-- Activate clangd without overwriting any settings for c/c++
-- autocompletion (requires a compile_commands.json file on
-- your project directory usually generated by build tools
-- like cmake or meson)
-- See: https://clangd.llvm.org/installation.html#project-setup
lspconfig.clangd.setup()

-- Activate gopls
lspconfig.gopls.setup()

-- Activate the lua-language-server, set the server command and
-- modify the default settings in order to disable diagnostics.
lspconfig.sumneko_lua.setup {
  command = {
    "/path/to/lua-language-server/bin/Linux/lua-language-server",
    "-E",
    "/path/to/lua-language-server/main.lua"
  },
  settings = {
    Lua = {
      diagnostics = {
        enable = false
      }
    }
  }
}

-- Activate intelephense and pass additional initializationOptions
-- like the license key and storage path.
lspconfig.intelephense.setup {
  init_options = {
    licenceKey = "MYLICENSEKEY",
    storagePath = "/home/myuser/.cache/intelephense"
  }
}

If your preferred LSP server is not listed on the config.lua file feel free to submit a pull request with the addition!

Manually Configuring a LSP Server

Besides the config.lua method, you can fully define an lsp server in your user init.lua file. You would need to require the lsp plugin and use the add_server function as shown on the following example:

local lsp = require "plugins.lsp"

lsp.add_server {
  -- Name of server
  name = "intelephense",
  -- Main language
  language = "PHP",
  -- If the server supports multiple languages:
  -- language = {
  --   { id = "javascript", pattern = "%.js$" },
  --   { id = "typescript", pattern = "%.ts$" },
  -- }
  -- If no pattern matches, the file extension is used instead.
  -- File types that are supported by this server
  file_patterns = { "%.php$" },
  -- LSP command and optional arguments
  command = { "intelephense", "--stdio" },
  -- Optional table of settings to pass into the lsp
  -- Note that also having a settings.json or settings.lua in
  -- your workspace directory with a table of settings is supported.
  settings = {
    intelephense = {
      files = {
        exclude = {
          "**/.git/**"
        }
      }
    }
  },
  -- Optional table of initializationOptions for the LSP
  init_options = {
    storagePath = "/home/myuser/.cache/intelephense"
  },
  -- Set by default to 16 should only be modified if having issues with a server
  requests_per_second = 16,
  -- Some servers like bash language server support incremental changes
  -- which are more performant but don't advertise it, set to true to force
  -- incremental changes even if server doesn't advertise them.
  incremental_changes = false,
  -- True to debug the lsp client when developing it
  verbose = false
}

LSP Plugin Settings

Configuration options that can be used to control the plugin behaviour:

---Show a symbol hover information when mouse cursor is on top.
---@type boolean
config.plugins.lsp.mouse_hover = true

---The amount of time in milliseconds before showing the tooltip.
---@type integer
config.plugins.lsp.mouse_hover_delay = 300

---Show diagnostic messages
---@type boolean
config.plugins.lsp.show_diagnostics = true

---Stop servers that aren't needed by any of the open files
---@type boolean
config.plugins.lsp.stop_unneeded_servers = true

---Set to a file path to log all json
---@type string
config.plugins.lsp.log_file = ""

---Setting to true prettyfies json for more readability on the log
---but this setting will impact performance so only enable it when
---in need of easy to read json output when developing the plugin.
---@type boolean
config.plugins.lsp.prettify_json = false

---Send a server stderr output to lite log
---@type boolean
config.plugins.lsp.log_server_stderr = false

---Force verbosity off even if a server is configured with verbosity on
---@type boolean
config.plugins.lsp.force_verbosity_off = false

---Yield when reading from LSP which may give you better UI responsiveness
---when receiving large responses, but will affect LSP performance.
---@type boolean
config.plugins.lsp.more_yielding = false

TODO

Screenshots

Some images to easily visualize the progress :)

Completion

Completion

Completion

Completion

Completion

Symbol hover

Hover

Hover

Function signatures

Signature

Document symbols

Doc Symbols Doc Symbols

Goto definition

Goto Definition

Diagnostics rendering using Lint+

Diagnostics