### Neovim LSP Setup for LanguageServer.jl Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Command to set up a dedicated Julia environment for Neovim's LSP and install the required packages. This environment is automatically used by the default nvim-lspconfig setup. ```bash julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer"); Pkg.add("SymbolServer"); Pkg.add("StaticLint")' ``` -------------------------------- ### Instantiate and Run Language Server Source: https://github.com/julia-vscode/languageserver.jl/blob/main/docs/src/index.md Create an instance of the LanguageServerInstance with specified input/output streams and environment path, then start the server by calling run. ```julia using LanguageServer server = LanguageServerInstance(stdin, stdout, "/path/to/environment") run(server) ``` -------------------------------- ### Install LanguageServer.jl Source: https://github.com/julia-vscode/languageserver.jl/blob/main/docs/src/index.md Use the Julia package manager to add the LanguageServer package to your environment. ```julia using Pkg Pkg.add("LanguageServer") ``` -------------------------------- ### Install Julia Language Server Packages Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Command to install necessary Julia packages for the LanguageServer. Ensure Julia is in your PATH or specify the full path to the julia binary. ```julia using Pkg Pkg.add("LanguageServer") Pkg.add("SymbolServer") Pkg.add("StaticLint") ``` -------------------------------- ### Vim/Neovim Plugin Configuration with vim-plug Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Minimal vimrc/init.vim configuration for installing and setting up LanguageClient-neovim and julia-vim using vim-plug. Ensure LanguageServer, SymbolServer, and StaticLint packages are installed in Julia. ```viml call g:plug#begin() Plug 'JuliaEditorSupport/julia-vim' Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'} Plug 'roxma/nvim-completion-manager' " optional call g:plug#end() " julia let g:default_julia_version = '1.0' " language server let g:LanguageClient_autoStart = 1 let g:LanguageClient_serverCommands = { \ 'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', \ 'using LanguageServer; \ using Pkg; \ import StaticLint; \ import SymbolServer; \ env_path = dirname(Pkg.Types.Context().env.project_file); \ \ server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, ""); \ server.runlinter = true; \ run(server); \ '] \ } noremap K :call LanguageClient_textDocument_hover() noremap gd :call LanguageClient_textDocument_definition() noremap :call LanguageClient_textDocument_rename() ``` -------------------------------- ### Install completion-nvim plugin Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Vimscript snippet for installing the completion-nvim plugin using vim-plug. This plugin provides better Neovim built-in LSP completion. ```vim Plug 'nvim-lua/completion-nvim' | " better neovim built in lsp completion ``` -------------------------------- ### Alternative Julia Binary Path Configuration Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Example of how to specify a custom path to the Julia binary in the LanguageClient_serverCommands configuration if Julia is not in the system's PATH. ```viml let g:LanguageClient_serverCommands = { \ 'julia': ['/Applications/Julia-0.6.app/Contents/Resources/julia/bin/julia', ... } ``` -------------------------------- ### Configure Julia Language Server in kak-lsp.toml Source: https://github.com/julia-vscode/languageserver.jl/wiki/Kakoune Specify the command and arguments to launch the Julia Language Server. Ensure LanguageServer.jl, StaticLint.jl, and SymbolServer.jl are installed in your Julia environment. ```toml [language.julia] filetypes = ["julia"] roots = [".git"] command = "julia" args = [ "--startup-file=no", "--history-file=no", "-e", """ using LanguageServer; using Pkg; import StaticLint; import SymbolServer; env_path = dirname(Pkg.Types.Context().env.project_file); server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path, ""); server.runlinter = true; run(server); """, ] ``` -------------------------------- ### Configure nvim-cmp for Julia LSP Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Sets up nvim-cmp for autocompletion with the Julia LSP. Ensure you have cmp-nvim-lsp installed. This configuration defines key mappings for navigation and completion. ```lua use({ "hrsh7th/nvim-cmp", requires = { { "hrsh7th/cmp-nvim-lsp" } }, config = function() cmp.setup({ completion = { completeopt = "menu,menuone,noselect", }, -- You must set mapping. mapping = { [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.close(), }, -- You should specify your *installed* sources. sources = { { name = "nvim_lsp" }, }, }) end, }) ``` -------------------------------- ### Compile Julia Language Server Sysimage Source: https://github.com/julia-vscode/languageserver.jl/wiki/Helix This shell command compiles a sysimage for the Julia Language Server, which can significantly speed up startup times. Ensure you have `PackageCompiler` installed. Adjust the output path if necessary. ```sh julia --startup-file=no --project=@helix-lsp -e 'import Pkg; Pkg.add(["LanguageServer", "PackageCompiler"]); Pkg.update();using PackageCompiler; create_sysimage(:LanguageServer, sysimage_path=dirname(Pkg.Types.Context().env.project_file) * "/languageserver.so")' ``` -------------------------------- ### Basic Julia Language Configuration for Helix Source: https://github.com/julia-vscode/languageserver.jl/wiki/Helix This TOML configuration defines the basic settings for the Julia language in Helix, including file types, root markers, and the language server command. Use this as a starting point for your `languages.toml`. ```toml [[language]] name = "julia" scope = "source.julia" injection-regex = "julia" file-types = ["jl"] roots = ["Project.toml", "Manifest.toml", "JuliaProject.toml"] comment-token = "#" language-servers = ["julia"] indent = { tab-width = 4, unit = " " } [language-server.julia] command = "julia" timeout = 60 args = ["-e", "using LanguageServer; runserver();"] ``` -------------------------------- ### Enable Built-in LSP in Neovim Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Lua code to enable the Julia Language Server using Neovim's built-in LSP functionality. This assumes the nvim-lspconfig plugin is installed and configured. ```lua vim.lsp.enable('julials') ``` -------------------------------- ### Initialize completion-nvim and julials LSP Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Lua code to initialize the completion-nvim plugin and the julials LSP. It sets up the diagnostic handler and attaches it to the buffer. ```lua autocmd BufEnter * lua require'completion'.on_attach() lua << EOF local nvim_lsp = require'nvim_lsp' local on_attach_vim = function() require'diagnostic'.on_attach() end nvim_lsp.julials.setup({on_attach=on_attach_vim}) EOF ``` -------------------------------- ### Configure nvim-lspconfig for Julia LSP Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Sets up the Julia Language Server using nvim-lspconfig. This includes defining LSP capabilities, customizing diagnostic handlers, and attaching the LSP to the buffer. It disables virtual text for diagnostics, which is recommended for Julia. ```lua use({ "neovim/nvim-lspconfig", config = function() local function create_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.preselectSupport = true capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } } capabilities.textDocument.completion.completionItem.deprecatedSupport = true capabilities.textDocument.completion.completionItem.insertReplaceSupport = true capabilities.textDocument.completion.completionItem.labelDetailsSupport = true capabilities.textDocument.completion.completionItem.commitCharactersSupport = true capabilities.textDocument.completion.completionItem.resolveSupport = { properties = { "documentation", "detail", "additionalTextEdits" }, } capabilities.textDocument.completion.completionItem.documentationFormat = { "markdown" } capabilities.textDocument.codeAction = { dynamicRegistration = true, codeActionLiteralSupport = { codeActionKind = { valueSet = (function() local res = vim.tbl_values(vim.lsp.protocol.CodeActionKind) table.sort(res) return res end)(), }, }, } return capabilities end -- disable virtual text (recommended for julia) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { virtual_text = false, underline = false, signs = true, update_in_insert = false, }) local on_attach = function(client, bufnr) vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") end local lspconfig = require("lspconfig") local function lsp_setup(name, config) lspconfig[name].setup(config) end lsp_setup("julials", { on_attach = on_attach, capabilities = create_capabilities(), }) end, }) ``` -------------------------------- ### Run LanguageServer.jl Instance Source: https://github.com/julia-vscode/languageserver.jl/blob/main/README.md Execute this command to run an instance of LanguageServer.jl. Specify the project environment path. If no path is given, it defaults to the parent project or the default Julia environment. ```sh julia --project=/path/to/LanguageServer.jl/environment \ -e "using LanguageServer; runserver()" \ ``` -------------------------------- ### Standalone Julia Language Server Script for Helix Source: https://github.com/julia-vscode/languageserver.jl/wiki/Helix This Julia script can be used as an alternative to direct configuration in `languages.toml`. It sets up the environment and runs the language server. Make the script executable and add it to your PATH. ```julia #!julia --project=@helix-lsp --startup-file=no --history-file=no --quiet import Pkg project_path = let dirname(something( Base.load_path_expand(( p = get(ENV, "JULIA_PROJECT", nothing); isnothing(p) ? nothing : isempty(p) ? nothing : p )), Base.current_project(pwd()), Pkg.Types.Context().env.project_file, Base.active_project(), )) end ls_install_path = joinpath(get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")), "environments", "helix-lsp"); pushfirst!(LOAD_PATH, ls_install_path); using LanguageServer; popfirst!(LOAD_PATH); depot_path = get(ENV, "JULIA_DEPOT_PATH", "") symbol_server_path = joinpath(homedir(), ".cache", "helix", "julia_lsp_symbol_server") mkpath(symbol_server_path) server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path, nothing, symbol_server_path, true) server.runlinter = true run(server) ``` -------------------------------- ### Kakoune Configuration for kak-lsp Source: https://github.com/julia-vscode/languageserver.jl/wiki/Kakoune Append this configuration to your kakrc file to enable LSP features for Julia and other supported filetypes. Includes settings for diagnostics, hover information, and auto-enabling LSP on window focus. ```kakscript plug "kak-lsp/kak-lsp" do %{ cargo build --release --locked cargo install --force --path . } config %{ # uncomment to enable debugging # eval %sh{echo ${kak_opt_lsp_cmd} >> /tmp/kak-lsp.log} # set global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log" # this is not necessary; the `lsp-enable-window` will take care of it # eval %sh{${kak_opt_lsp_cmd} --kakoune -s $kak_session} set global lsp_diagnostic_line_error_sign '║' set global lsp_diagnostic_line_warning_sign '┊' set global lsp_hover_max_lines 40 define-command ne -docstring 'go to next error/warning from lsp' %{ lsp-find-error --include-warnings } define-command pe -docstring 'go to previous error/warning from lsp' %{ lsp-find-error --previous --include-warnings } define-command ee -docstring 'go to current error/warning from lsp' %{ lsp-find-error --include-warnings; lsp-find-error --previous --include-warnings } define-command lsp-restart -docstring 'restart lsp server' %{ lsp-stop; lsp-start } hook global WinSetOption filetype=(c|cpp|cc|rust|javascript|typescript|julia) %{ set-option window lsp_hover_anchor false lsp-auto-hover-enable echo -debug "Enabling LSP for filtetype %opt{filetype}" lsp-enable-window } hook global KakEnd .* lsp-exit } ``` -------------------------------- ### Configure Julia LSP in Kate Source: https://github.com/julia-vscode/languageserver.jl/wiki/Kate This JSON configuration is used in Kate's LSP client settings to enable support for the Julia Language Server. It specifies the command to run the server, the root directory, and the path to the Julia executable. ```json { "servers": { "julia": { "command": ["julia", "-e", "using LanguageServer; runserver();"], "root": ".", "path": ["%{ENV:HOME}/.juliaup/bin"], "url": "https://github.com/julia-vscode/LanguageServer.jl", "highlightingModeRegex": "^Julia$" } } } ``` -------------------------------- ### Helix Configuration with Compiled Julia Sysimage Source: https://github.com/julia-vscode/languageserver.jl/wiki/Helix This TOML configuration specifies how Helix should use a pre-compiled Julia Language Server sysimage. It includes paths to the sysimage and detailed arguments for running the server. Remember to replace `` with your actual username. ```toml [language-server.julia-lsp] command = "julia" timeout = 60 args = [ "--project=@helix-lsp", "--startup-file=no", "--history-file=no", "--quiet", "-J/home//.julia/environments/helix-lsp/languageserver.so", "--sysimage-native-code=yes", "-e", "\"import Pkg\nproject_path = let\n dirname(something(\n Base.load_path_expand((\n p = get(ENV, \"JULIA_PROJECT\", nothing);\n isnothing(p) ? nothing : isempty(p) ? nothing : p\n )),\n Base.current_project(pwd()),\n Pkg.Types.Context().env.project_file,\n Base.active_project(),\n ))\n end\nlS_install_path = joinpath(get(DEPOT_PATH, 1, joinpath(homedir(), \".julia\")), \"environments\", \"helix-lsp\");\npushfirst!(LOAD_PATH, ls_install_path);\nusing LanguageServer;\npopfirst!(LOAD_PATH);\ndepot_path = get(ENV, \"JULIA_DEPOT_PATH\", \"\")\nsymbol_server_path = joinpath(homedir(), \".cache\", \"helix\", \"julia_lsp_symbol_server\")\nmkpath(symbol_server_path)\nserver = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path, nothing, symbol_server_path, true)\nserver.runlinter = true\nrun(server)\n\"" ] ``` -------------------------------- ### Set Busy/Ready Status Source: https://github.com/julia-vscode/languageserver.jl/wiki/Specification The server sends `window/setStatusBusy` before handling a request and `window/setStatusReady` when finished to allow the client to display a 'busy' indicator. ```json { "method": "window/setStatusBusy", "jsonrpc": "2.0" } ``` ```json { "method": "window/setStatusReady", "jsonrpc": "2.0" } ``` -------------------------------- ### Helix Configuration for Script-Based Julia LSP Source: https://github.com/julia-vscode/languageserver.jl/wiki/Helix This TOML configuration tells Helix to use a custom script (e.g., `julia-lsp-helix`) as the Julia language server command. Ensure the script is executable and in your system's PATH. ```toml [language-server.julia] command = "julia-lsp-helix" timeout = 60 ``` -------------------------------- ### Apply Workspace Edits Source: https://github.com/julia-vscode/languageserver.jl/wiki/Specification The code action provider expects a client-side registered function `language-julia.applytextedit` that can apply a vector of `WorkspaceEdit`s to client-side documents. ```json { "jsonrpc": "2.0", "id": 24, "method": "julia/reload-modules", "params": null } ``` ```json { "jsonrpc": "2.0", "id": 30, "method": "julia/lint-package", "params": null } ``` -------------------------------- ### Configure diagnostic-nvim settings Source: https://github.com/julia-vscode/languageserver.jl/wiki/Vim-and-Neovim Vimscript variables to configure the diagnostic-nvim plugin. These settings disable virtual text, underline, and enable auto-popup while jumping. ```vim let g:diagnostic_auto_popup_while_jump = 0 let g:diagnostic_enable_virtual_text = 0 let g:diagnostic_enable_underline = 0 let g:completion_timer_cycle = 200 "default value is 80 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.