Skip to content
CoreLanguagePublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

CoreLSP — using the Core language server

This repo is docs only. The server itself (core-lsp) is hosted on the Core VPS; here is how to install and use it with your editor.

The server speaks LSP over stdio and gives you, for .cr files:

  • diagnostics from core check on every edit
  • hover for keywords, primitive types, say / alloc / free / assert
  • completion for keywords, types, stdlib modules, local func names
  • document symbols (func / struct / class / enum / interface / trait)

Requirements

  • Python 3 (3.8+; the server is stdlib-only, no pip packages)
  • the core compiler on your PATH (for diagnostics) — install it

Install the server

mkdir -p ~/.local/bin
curl -fsSL http://94.24.39.227/dl/core-lsp.py -o ~/.local/bin/core-lsp
chmod +x ~/.local/bin/core-lsp

Check it starts:

~/.local/bin/core-lsp --help 2>/dev/null || echo "core-lsp installed"

To use a different compiler binary: export CORE_BIN=/path/to/core.

VS Code

Install the core-lang extension (syntax + client; source in the main repo under editors/vscode), then set:

{
  "core-lang.serverPath": "/home/YOU/.local/bin/core-lsp",
  "core-lang.coreBin": "core"
}

Neovim (built-in LSP, 0.8+)

Note: .cr is also Crystal's extension. The snippet below only attaches inside Core projects (a core.toml found upward), so the two never clash.

-- ~/.config/nvim/lua/core-lsp.lua (require it from your init.lua)
vim.filetype.add({ extension = { cr = 'core' } })

vim.api.nvim_create_autocmd('FileType', {
  pattern = 'core',
  callback = function(args)
    local root = vim.fs.dirname(vim.fs.find({ 'core.toml' },
      { upward = true, path = args.file })[1] or args.file)
    vim.lsp.start({
      name = 'core-lsp',
      cmd = { 'python3', vim.fn.expand('~/.local/bin/core-lsp') },
      root_dir = root,
    })
  end,
})

Helix

~/.config/helix/languages.toml (use an absolute path — Helix does not expand ~):

[[language]]
name = "core"
scope = "source.core"
file-types = ["cr"]
comment-token = "//"
language-servers = ["core-lsp"]

[language-server.core-lsp]
command = "python3"
args = ["/home/YOU/.local/bin/core-lsp"]

Troubleshooting

Symptom Fix
no diagnostics core not on PATH, or set CORE_BIN to it; run core check file.cr by hand to see the error
server won't start python3 --version (need 3.8+); re-download — the file must be exactly core-lsp.py, 7723 bytes
wrong language attaches to .cr scope the filetype to Core projects (see Neovim note above)

Updating

Re-run the install curl line — the VPS always serves the latest server. The full server source and protocol details live in the main repo at tools/lsp/core_lsp.py.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors