nvim-config/fnl/lazy-setup.fnl
2023-07-27 21:07:29 -06:00

97 lines
3.5 KiB
Fennel

(let [lazypath (.. (vim.fn.stdpath "data") "/lazy/lazy.nvim")]
(if (not (vim.loop.fs_stat lazypath))
(vim.fn.system
["git"
"clone"
"--filter=blob:none"
"https://github.com/folke/lazy.nvim.git"
"--branch=stable"
lazypath]))
(vim.opt.rtp:prepend lazypath))
(let [lazy (require :lazy)]
(lazy.setup
["https://github.com/rktjmp/hotpot.nvim"
{:url "https://github.com/nvim-telescope/telescope.nvim"
:tag "0.1.2"
:dependencies ["nvim-lua/plenary.nvim"]}
{:url "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
:build (.. "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release"
" && cmake --build build --config Release"
" && cmake --install build --prefix build" )}
{:url "https://github.com/nvim-treesitter/nvim-treesitter"
:build ":TSUpdate"}
{:url "https://github.com/neovim/nvim-lspconfig"
:dependencies
["https://github.com/williamboman/mason.nvim"
"williamboman/mason-lspconfig.nvim"
{:url "https://github.com/j-hui/fidget.nvim"
:tag "legacy"
:opts {}}
"folke/neodev.nvim"]}
]))
(let [telescope (require :telescope)]
(pcall (telescope.load_extension :fzf)))
;; Syntax Highlighting via Treesitter
;; NOTE: if you add a language to treesitter for syntax highlighting or otherwise
;; consider also adding the LSP via Mason below...
(let
[treesitter (require :nvim-treesitter.configs)]
(treesitter.setup
{:ensure_installed [:c :lua :vim :vimdoc :query ; required
:fennel] ; add new languages here
:sync_install false
:auto_install false
:ignore_install [] ; could :ensure_installed :all, then ignore unwanted.
:highlight {:enable true}
:indent {:enable true}}))
;; Language Server Protocols via Mason
(let
[neodev (require :neodev)
mason (require :mason)
mason-lspconfig (require :mason-lspconfig)
servers
{:lua_ls
{:filetypes [:lua]
:Lua
{:workspace {:checkThirdParty false} }
:telemetry {:enable false}
:diagnostics {:globals
[:vim
]}}
:fennel_language_server
{:filetypes [:fennel]
:fennel
{:workspace {:library (vim.api.nvim_list_runtime_paths)}
:diagnostics {:globals
[:vim
]}}}
:bashls {:filetypes [:bash]}
}
on_attach (fn [_ bufnr]
(let
[nmap #(vim.keymap.set :n $1 $2 {:buffer bufnr :desc (.. "LSP: " $3)})
telescope (require :telescope.builtin)
]
(nmap :gd vim.lsp.buf.definition "[G]o to [D]efiniton")
(nmap :gr telescope.lsp_references "[G]o to [R]eferences")
(nmap :gI vim.lsp.buf.implementation "[G]o to [I]mplementation")
(vim.api.nvim_buf_create_user_command bufnr "Format"
#(vim.lsp.buf.format)
"Format current buffer with LSP")))
]
(neodev.setup)
(mason.setup)
(mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers)})
(mason-lspconfig.setup_handlers
[(fn [server_name] (let [server (. (require :lspconfig) server_name)]
(server.setup
{:capabilities (vim.lsp.protocol.make_client_capabilities)
:on_attach on_attach
:settings (. servers server_name)
:filetypes (or (. servers server_name :filetypes) []) })))
]))