Giter VIP home page Giter VIP logo

scheme-langserver's Introduction

Scheme-langserver

Implementing support like autocomplete, goto definition, or documentation on hover is a significant effort for programming. However, comparing to other language like java, python, javascript and c, language server protocol implementation for lisp language are just made in a vacuum. Geiser, racket langserver and swish-lint etc., their works are all based on repl(Read-Eval-Print Loop) or keyword tokenizer instead of programming. For example, if a programmer was coding on an unaccomplished project, in which the codes are not fully runnable, Geiser or any others would only complete top-level binding identifiers listed by environment-symbols procedure (for Chez). Which means for local bindings and unaccomplished codes, though making effort for programming is supposed of the importance mostly, Geiser and its counterparts help nothing. Familiar cases occur with goto definition and many other functionalities.

A primary cause is, for scheme and other lisp dialects, their abundant data sets and flexible control structures raise program analysis a big challenge. In fact, scheme even don't have commonly acknowledged project management frameworks and corresponding extension system. As for extensions SS, and SCM, most programmers suppose their codes are writing for a running environment and don't provide any library information. Although with Akku and Snow, SLS and SLD files can base a project on a stable library framework, involve, load and many other procedures which maintain dynamic library linkages make static code analysis telling less.

This package is a language server protocol implementation helping scheme programming. It provides completion, definition and will provide many other functionalities. These functionalities are established on static code analysis with r6rs standard and some obvious rules for unaccomplished codes. This package itself and related libraries are published or going to be published with Akku, which is a package manager for Scheme.

This package also has been tested with Chez Scheme versions 9.4 and 9.5.

Your donation will make this world better. Also, you can issue your advice and I might implement if it was available. paypal

Setup

Building

Pre-require

  1. Chez Scheme;

NOTE If you wanted to enable scheme-langserver's muti-thread feature, it would require Chez Scheme to have been compiled with the --threads option. This uses chez scheme's FFI to call up the pipe() and poll() system calls, and therefore requires a UNIX-like operating system to function correctly. It has been tested with linux and should work on the BSDs and on Mac OS X. If using OS X, the glibtool package will be required.

  1. Akku
  2. chez-exe

NOTE chez-exe requires boot files and kernel files of Chez Scheme. So, the compile command maybe like follows:scheme --script gen-config.ss --bootpath /path-to-ChezScheme/{machine-type}/boot/{machine-type}

For Linux

git clone https://github.com/ufo5260987423/scheme-langserver
cd scheme-langserver
akku install
bash .akku/env
compile-chez-program run.ss
./run path-to-logfile

TODO: for Windows

Installation for LunarVim

In the near future, I will pull request to mason.nvim and mason-lspconfig.nvim. In that case, you will be able to get this implementation automatically with LunarVim.

But now, for installed plugin nvim-lspconfig, we have to manually do some installation: after manually building from above step Building, an executable file run would be available at {path-to-run}. Then, create file ~/.local/share/lunarvim/site/pack/packer/start/nvim-lspconfig/lua/lspconfig/server_configurations/scheme_langserver.lua as follows:

local util = require 'lspconfig.util'
local bin_name = '{path-to-run}'
local cmd = { bin_name }

return {
  default_config = {
    cmd = cmd,
    filetypes = { 'scheme' },
    root_dir = util.find_git_ancestor,
    single_file_support = true,
  },
  docs = {
    description = [[
https://github.com/ufo5260987423/scheme-langserver
`scheme-langserver`, a language server protocol implementation for scheme
]]   ,
  },
}

Then configure your ~/.config/lvim/init.lua and add following codes like:

require 'lspconfig'.scheme_langserver.setup {}

NOTE For LunarVim, default scheme file extension doesn't include ".SLS". A patch to .local/share/lunarvim/lvim/ftdetec/ is to add sls.lua file as following:

vim.cmd [[ au BufRead,BufNewFile *.sls set filetype=scheme ]]

TODO: Installation for VScode

Status

This project is still in early development, so you may run into rough edges with any of the features. The following list shows the status of various features.

Features

NOTE I made some configuration with .config/lvim/config.lua like following

vim.keymap.set('n', 'gr', builtin.lsp_references, {})
vim.keymap.set('n', 'gd', builtin.lsp_definitions, {})
  1. Top-level and local identifiers binding completion. Top-level and local identifiers binding
  2. Goto definition. Goto definition with telescope.nvim
  3. Compatible with package manager: Akku.
  4. File changes synchronizing and corresponding index changing.
  5. Hover.
  6. References. Find references with telescope.nvim
  7. Document symbol. Find document symbols with telescope.nvim

TODOs

  1. Renaming.
  2. *-syntax(define-syntax, let-syntax, etc.) based local identifier binding.
  3. Fully compatible with r6rs standard.
  4. Cross-platform Parallel indexing.
  5. Macro expanding.
  6. Code eval.
  7. Code diagnostic.
  8. Add cross-language semantic supporting.
  9. Self-made annotator.
  10. Type inference.

TODO:Contributing

Debug

Output Log

Following tips from Building, Installation for Lunar Vim and Installation for VScode, if anyone wants to do some developing and log something, it will be convenient to add path-to-log-file and re-write file ~/.local/share/lunarvim/site/pack/packer/start/nvim-lspconfig/lua/lspconfig/server_configurations/scheme_langserver.lua as follows:

local util = require 'lspconfig.util'
local bin_name = '{path-to-run}'
local cmd = { bin_name ,"path-to-log-file"}

return {
  default_config = {
    cmd = cmd,
    filetypes = { 'scheme' },
    root_dir = util.find_git_ancestor,
    single_file_support = true,
  },
  docs = {
    description = [[
https://github.com/ufo5260987423/scheme-langserver
`scheme-langserver`, a language server protocol implementation for scheme
]]   ,
  },
}

Recurring with Log

With above output log, you may use tests/log-debug.sps recurring bugs:

  1. Rename {path-to-log}(usually ~/scheme-langserver.log) as ~/ready-for-analyse.log;
  2. run scheme --script tests/log-debug.sps

Test

Almost all key procedures and APIs are tested. You can find out what I've done in tests directory or just run following command in {scheme-langserver-root-directory}

bash test.sh

scheme-langserver's People

Contributors

ufo5260987423 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.