Hello,
For Neovim, I have successfully integrated LanguageServer.jl through lspconfig as instructed here. Auto-completion and hover documentation worked.
I want to integrate JuliaFormatter.jl and StaticLint.jl which are installed in the project located in ~/.julia/environment/nvim-lspconfig
but I can’t figure how to do it.
nvim-lspconfig.lua
-- (1) install lsp, formatter, and linter with Mason
-- --
-- import lsp keymaps
local on_attach = require("config.keymaps_lspsaga").on_attach
-- import local UTF-8 icons
local diagnostic_signs = require("util.icons").diagnostic_signs
local config = function()
require("neoconf").setup({})
-- nvim-cmp package
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- lspconfig package
local lspconfig = require("lspconfig")
-- set diagnostic icons
for type, icon in pairs(diagnostic_signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
-- (2) LSP Setup
-- -- --
-- lua
lspconfig.lua_ls.setup({
-- attach nvim-cmp
capabilities = capabilities,
-- set lsp keymaps
on_attach = on_attach,
settings = {
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { "nvim" }, -- was vim
},
workspace = {
-- make language server aware of runtime files
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
-- python
lspconfig.pyright.setup({
-- attach nvim-cmp
capabilities = capabilities,
-- set lsp keymaps
on_attach = on_attach,
-- features
settings = {
pyright = {
disableOrganizeImports = false,
analysis = {
useLibraryCodeForTypes = true,
autoSearchPaths = true,
diagnosticMode = "workspace",
autoImportCompletions = true,
},
},
},
})
-- haskell
lspconfig.hls.setup({
-- attach nvim-cmp
capabilities = capabilities,
-- set lsp keymaps
on_attach = on_attach,
-- settings for haskell
settings = {
haskell = {
formattingProvider = "fourmolu", -- using fourmolu
},
},
})
-- julia
-- uses project ~/.julia/environments/nvim-lspconfig
-- requires only: Pkg add LanguageServer
-- doc: https://github.com/neovim/nvim-lspconfig/blob/b972e7154bc94ab4ecdbb38c8edbccac36f83996/doc/server_configurations.md#julials
-- auto-completion worked
lspconfig.julials.setup({})
-- (3) linter and formatter objects
-- -- --
-- lua
local luacheck = require("efmls-configs.linters.luacheck") -- linter
local stylua = require("efmls-configs.formatters.stylua") -- formatter
-- python
local flake8 = require("efmls-configs.linters.flake8") -- linter
local black = require("efmls-configs.formatters.black") -- formatter
-- haskell
local hlint = { -- linter
lintCommand = "hlint --stdin",
lintStdin = true,
lintFormats = {"%f:%l:%c: %m"},
}
local fourmolu = { -- formatter
formatCommand = "fourmolu --stdin-input-file ${INPUT}",
formatStdin = true,
}
-- (4) efm server
-- -- --
lspconfig.efm.setup({
filetypes = {
-- lua
"lua",
-- python
"python",
-- haskell
"haskell",
},
init_options = {
documentFormatting = true,
documentRangeFormatting = true,
hover = true,
documentSymbol = true,
codeAction = true,
completion = true,
},
settings = {
languages = {
-- lua
lua = { luacheck, stylua },
-- python
python = { flake8, black },
-- haskell
haskell = { hlint, fourmolu },
},
},
})
end
return {
"neovim/nvim-lspconfig",
config = config,
lazy = false,
dependencies = {
"windwp/nvim-autopairs",
"williamboman/mason.nvim",
"creativenull/efmls-configs-nvim",
},
}