Skip to content

Instantly share code, notes, and snippets.

@CFiggers
Last active January 27, 2024 15:58
Show Gist options
  • Save CFiggers/54a769db23f2a58f45e673e6b6373fe0 to your computer and use it in GitHub Desktop.
Save CFiggers/54a769db23f2a58f45e673e6b6373fe0 to your computer and use it in GitHub Desktop.
Minimal Config for Janet LSP in Neovim (using Lazy.nvim + nvim-lspconfig)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
-- Lazy.nvim setup
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
"janet-lang/janet.vim",
{
"neovim/nvim-lspconfig",
lazy = false,
config = function()
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")
if not configs.janet then
configs.janet = {
default_config = {
cmd = { "janet-lsp" },
filetypes = { "janet", "jdn" },
root_dir = lspconfig.util.root_pattern("project.janet"),
single_file_support = true,
settings = {},
},
}
end
lspconfig.janet.setup({
capabilities = vim.lsp.protocol.make_client_capabilities(),
on_attach = function()
-- Remove this 👇 if you don't want to be notified
print("starting janet-lsp")
-- Optional keymaps here 👇
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = 0 })
vim.keymap.set("n", "<leader>k", vim.lsp.buf.hover, { buffer = 0 })
vim.keymap.set("n", "<leader>gf", vim.lsp.buf.format, {})
end,
})
end,
},
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment