~wahn/lsp-testing

Some simple code to test the Language Server Protocol

3043ce8 Compile time vs. runtime integer overflow.

~wahn pushed to ~wahn/lsp-testing git

8 months ago

16d205d Simple square calculation program.

~wahn pushed to ~wahn/lsp-testing git

1 year, 3 months ago

#Some simple code to test the Language Server Protocol

See https://www.janwalter.org/jekyll/lsp/2022/10/01/language-servers.html for now.

#Makefile

% make
% make clean

#Hello World

For each language there should be at least one Hello World program. See:

https://en.wikipedia.org/wiki/%22Hello,_World!%22_program

#C

#include <stdio.h>
#include <stdlib.h>

int main() {
  printf("Hello, World!\n");
  return EXIT_SUCCESS;
}

Other examples:

  1. libc-version.c: Prints the version of libc.so (does not work on Mac OSX)
  2. copy.c: Simple version of the cp(1) command.
  3. seek_io.c: Demonstrate the use of lseek() and file I/O system calls.

#C++

#include <iostream>

int main() {
  std::cout << "Hello, World!\n";
  return EXIT_SUCCESS;
}

#Clojure

https://clojure.org/

(println "Hello, World!")

#Erlang

https://www.erlang.org/

-module(hello).
-export([hello_world/0]).

hello_world() -> io:fwrite("Hello, World!\n").

#Haskell

https://www.haskell.org/

main :: IO ()
main = putStrLn "Hello, World!"

#Python

https://www.python.org/

print("Hello, World!")

#Rust

https://www.rust-lang.org/

fn main() {
    println!("Hello, World!");
}

#Scala

https://www.scala-lang.org/

The Hello World program on Wikipedia is here:

https://en.wikipedia.org/wiki/Scala_(programming_language)#%22Hello_World%22_example

@main def main() = {
  println("Hello, World!")
}

#Zig

No Hello World program on Wikipedia (yet):

https://ziglang.org/documentation/master/

const std = @import("std");

pub fn main() !void {
    const stdout = std.io.getStdOut().writer();
    try stdout.print("Hello, {s}!", .{"World"});
}

#Language Servers

#C and C++

% hx --health c
Configured language server: clangd
Binary for language server: /usr/local/Cellar/llvm/15.0.1/bin/clangd
Configured debug adapter: lldb-vscode
Binary for debug adapter: /usr/local/Cellar/llvm/15.0.1/bin/lldb-vscode
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓
% hx --health cpp
Configured language server: clangd
Binary for language server: /usr/local/Cellar/llvm/15.0.1/bin/clangd
Configured debug adapter: lldb-vscode
Binary for debug adapter: /usr/local/Cellar/llvm/15.0.1/bin/lldb-vscode
Highlight queries: ✓
Textobject queries: ✓
Indent queries: 

#Clojure

% hx --health clojure
Configured language server: clojure-lsp
Binary for language server: /usr/local/bin/clojure-lsp
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: 

#Erlang

https://github.com/erlang-ls/erlang_ls

% hx --health erlang
Configured language server: erlang_ls
Binary for language server: /Users/jan/git/github/erlang_ls/_build/default/bin/erlang_ls
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✓
Indent queries: 

#Haskell

Install ghc and cabal-install:

% brew install ghc cabal-install

Download the language server haskell-language-server from:

https://downloads.haskell.org/~hls/haskell-language-server-1.8.0.0/

After that we should be fine:

% hx --health haskell
Configured language server: haskell-language-server-wrapper
Binary for language server: /usr/local/haskell-language-server-1.8.0.0/bin/haskell-language-server-wrapper
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: 

#Python

% hx --health python
Configured language server: pylsp
Binary for language server: /Users/jan/.local/bin/pylsp
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✓
Indent queries: 

#Rust

% hx --health rust
Configured language server: rust-analyzer
Binary for language server: /usr/local/bin/rust-analyzer
Configured debug adapter: lldb-vscode
Binary for debug adapter: /usr/local/Cellar/llvm/15.0.1/bin/lldb-vscode
Highlight queries: ✓
Textobject queries: ✓
Indent queries: 

#Scala

Install coursier and metals (via coursier):

% brew install coursier/formulas/coursier
% cs setup
% coursier install metals

After that we should be fine:

% hx --health scala
Configured language server: metals
Binary for language server: /Users/jan/Library/Application Support/Coursier/bin/metals
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: 

#Zig

% hx --health zig
Configured language server: zls
Binary for language server: /Users/jan/zls/zls
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: