Editor Integration¶
Any editor supporting the Language Server Protocol can connect to the Sharpy language server. The server communicates over stdio using JSON-RPC.
See lsp-server.md for the full list of supported LSP features.
Neovim¶
Using nvim-lspconfig¶
Add a custom server configuration:
local lspconfig = require('lspconfig')
local configs = require('lspconfig.configs')
-- Register the Sharpy language server
if not configs.sharpy then
configs.sharpy = {
default_config = {
cmd = { 'sharpyc', 'lsp' },
filetypes = { 'sharpy' },
root_dir = function(fname)
return lspconfig.util.find_git_ancestor(fname)
or lspconfig.util.root_pattern('*.spyproj')(fname)
end,
settings = {},
},
}
end
lspconfig.sharpy.setup({})
Filetype Detection¶
Add .spy filetype detection in ~/.config/nvim/filetype.lua:
Optional: Tree-sitter Highlighting¶
If no tree-sitter grammar is available for Sharpy, Python highlighting is a reasonable fallback:
Emacs¶
Using eglot (built-in, Emacs 29+)¶
;; Define a major mode for .spy files
(define-derived-mode sharpy-mode python-mode "Sharpy"
"Major mode for Sharpy (.spy) files.")
(add-to-list 'auto-mode-alist '("\\.spy\\'" . sharpy-mode))
;; Register the LSP server with eglot
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(sharpy-mode "sharpyc" "lsp")))
Using lsp-mode¶
(require 'lsp-mode)
(define-derived-mode sharpy-mode python-mode "Sharpy"
"Major mode for Sharpy (.spy) files.")
(add-to-list 'auto-mode-alist '("\\.spy\\'" . sharpy-mode))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("sharpyc" "lsp"))
:major-modes '(sharpy-mode)
:server-id 'sharpy-lsp))
(add-hook 'sharpy-mode-hook #'lsp)
Sublime Text¶
Using the LSP Package¶
- Install the LSP package via Package Control
- Open Preferences > Package Settings > LSP > Settings and add:
{
"clients": {
"sharpy": {
"enabled": true,
"command": ["sharpyc", "lsp"],
"selector": "source.sharpy",
"schemes": ["file"]
}
}
}
- Create a
.sublime-syntaxfile or use Python syntax as a fallback for.spyfiles.
Helix¶
Add to ~/.config/helix/languages.toml:
[[language]]
name = "sharpy"
scope = "source.sharpy"
injection-regex = "sharpy"
file-types = ["spy"]
roots = ["*.spyproj"]
comment-token = "#"
indent = { tab-width = 4, unit = " " }
[language-server.sharpy]
command = "sharpyc"
args = ["lsp"]
[[language]]
name = "sharpy"
language-servers = ["sharpy"]
Zed¶
Add to your Zed settings (~/.config/zed/settings.json):
{
"lsp": {
"sharpy": {
"binary": {
"path": "sharpyc",
"arguments": ["lsp"]
}
}
},
"languages": {
"Sharpy": {
"language_servers": ["sharpy"]
}
}
}
General¶
For any LSP-capable editor not listed above, configure:
- Command:
sharpyc lsp - Transport: stdio (stdin/stdout)
- File types:
.spy - Language ID:
sharpy