Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure Neovim to use asy -lsp? #372

Open
kiryph opened this issue Apr 17, 2023 · 3 comments
Open

How to configure Neovim to use asy -lsp? #372

kiryph opened this issue Apr 17, 2023 · 3 comments

Comments

@kiryph
Copy link

kiryph commented Apr 17, 2023

I have followed :h lspconfig-new of https://github.com/neovim/nvim-lspconfig for Neovim.

https://github.com/neovim/nvim-lspconfig/blob/8cbfc30c4b238cc2465ff256803f7747376f046a/doc/lspconfig.txt#L324-L350

ADDING NEW SERVERS                                    *lspconfig-new*

The steps for adding and enabling a new server configuration are:

1. load the `lspconfig` module (note that this is a stylistic choice)  
   local lspconfig = require 'lspconfig'
 
2. define the configuration  
   local configs = require 'lspconfig.configs'

   -- Check if the config is already defined (useful when reloading this file)
   if not configs.foo_lsp then
     configs.foo_lsp = {
       default_config = {
         cmd = {'/home/neovim/lua-language-server/run.sh'},
         filetypes = {'lua'},
         root_dir = function(fname)
           return lspconfig.util.find_git_ancestor(fname)
         end,
         settings = {},
       },
     }
   end

3. call `setup()` to enable the FileType autocmd  
   lspconfig.foo_lsp.setup{}

to have in my init.lua using Neovim 0.9:

-- Asymptote LSP
local lspconfig = require 'lspconfig'
local configs = require 'lspconfig.configs'
local util = require 'lspconfig.util'

if not configs.asy_ls then
   configs.asy_ls = {
    default_config = {
      cmd = {'asy', '-lsp'},
      filetypes = {'asy'},
      root_dir = function(fname)
        return util.find_git_ancestor(fname)
      end,
      single_file_support = true,
      settings = {},
    },
  }
end
lspconfig.asy_ls.setup{}

But when I open an asy file, no LSP client gets attached to the buffer

 Press q or <Esc> to close this window. Press <Tab> to view server doc.
 
 Language client log: /Users/kiryph/.local/state/nvim/lsp.log
 Detected filetype:   asy
 
 0 client(s) attached to this buffer: 
 
 Other clients that match the filetype: asy
 
 Config: asy_ls
 	filetypes:         asy
 	root directory:    /Users/kiryph/lsp-asy
 	cmd:               asy -lsp
 	cmd is executable: true
 	autostart:         true
 	custom handlers:   

and I see following errors in the :LspLog

[START][2023-04-17 10:38:31] LSP logging initiated
[ERROR][2023-04-17 10:38:31] .../vim/lsp/rpc.lua:734	"rpc"	"asy"	"stderr"	"-: 1.15: syntax error"
[ERROR][2023-04-17 10:38:31] .../vim/lsp/rpc.lua:734	"rpc"	"asy"	"stderr"	"\n"

I am not sure who to ask.

My Environment

Asymptote version 2.85
NVIM: v0.9.0
macOS: 12.6.3
CPU: Intel
@kiryph
Copy link
Author

kiryph commented Apr 17, 2023

Apparently, you have to compile asymptote yourself. The full version info of asymptote gives me for asy from MacTex 2023 and Homebrew:

❯ which -a asy
/usr/local/bin/asy
/Library/TeX/texbin/asy

❯ asy --version
Asymptote version 2.85 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]

ENABLED OPTIONS:
V3D      3D vector graphics output
WebGL    3D HTML rendering
OpenGL   3D OpenGL rendering
GSL      GNU Scientific Library (special functions)
FFTW3    Fast Fourier transforms
XDR      External Data Representation (portable binary file format for V3D)
CURL     URL support
Readline Interactive history and editing
GC       Boehm garbage collector
threads  Render OpenGL in separate thread

DISABLED OPTIONS:
SSBO     GLSL shader storage buffer objects
Eigen    Eigenvalue library
LSP      Language Server Protocol
Sigsegv  Distinguish stack overflows from segmentation faults

See LSP entry under DISABLED OPTIONS.

I am surprised that I can invoke asy -lsp without an error which clearly says that LSP is not enabled.

Unfortunately, there are no easy to follow compilation instructions for asymptote on macOS with LSP enabled, e.g.

#304

https://formulae.brew.sh/formula/asymptote

MacPorts also do not offer a variant with LSP enabled: https://ports.macports.org/port/asymptote/

@johncbowman
Copy link
Member

In commit 456ae99, I have now removed the lsp option when LSP support is disabled, so that --lsp returns an error (and -lsp is then parsed as -l -s -p when LSP support is disabled).

I don't think anyone has got LSP working yet under MacOS.

@johncbowman
Copy link
Member

As a first step, to compile with --lsp under MacOS, you first need to fix the names of these boost libraries:

ln -s /opt/local/lib/libboost_thread-mt.dylib /opt/local/lib/libboost_thread.dylib
ln -s /opt/local/lib/libboost_filesystem-mt.dylib /opt/local/lib/libboost_filesystem.dylib

and then run configure and make again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants