nix-conf/home-manager/nvim/extraconfig.fnl

96 lines
2.9 KiB
Fennel

(do
(local cmp (require :cmp))
(local avante (require :avante))
(local cmp-nvim-lsp (require :cmp_nvim_lsp))
(local treesitter (require :nvim-treesitter.configs))
;; Configure fennel-ls LSP server using new vim.lsp API
;; Note: vim-fennel-syntax plugin handles filetype detection automatically
(local base-capabilities (vim.lsp.protocol.make_client_capabilities))
(local capabilities (cmp-nvim-lsp.default_capabilities base-capabilities))
;; Find fennel-ls in PATH
(local fennel-ls-path (vim.fn.exepath "fennel-ls"))
(local fennel-ls-cmd (if (= fennel-ls-path "") ["fennel-ls"] [fennel-ls-path]))
;; Setup fennel-ls using autocmd to start on Fennel files
(vim.api.nvim_create_autocmd "FileType" {
:pattern [:fennel]
:callback (fn []
(local root (vim.fs.find [".nfnl.fnl" ".git" "fnl"] {:upward true}))
(local root-dir (if root (vim.fs.dirname (. root 1)) (vim.fn.getcwd)))
(vim.lsp.start {
:name :fennel_ls
:cmd fennel-ls-cmd
:root_dir root-dir
:settings {
:fennel {
:extra-globals "vim"
}
}
:capabilities capabilities
}))
})
;; Enable inlay hints for better documentation
(vim.lsp.inlay_hint.enable true {:buftype [""]})
;; Configure Treesitter to ensure Fennel grammar is installed
;; Use writable directory for parsers (not the read-only nix store)
(local parser_install_dir (.. (vim.fn.stdpath :data) "/treesitter"))
(vim.opt.runtimepath:prepend parser_install_dir)
(treesitter.setup {
:ensure_installed [:fennel :lua]
:highlight {:enable true}
:indent {:enable true}
:parser_install_dir parser_install_dir
})
(cmp.setup {
:mapping {
:<C-Space> (cmp.mapping.complete)
:<CR> (cmp.mapping.confirm {:select true})
:<Tab> (cmp.mapping.select_next_item)
:<S-Tab> (cmp.mapping.select_prev_item)
}
:sources [
{:name :nvim_lsp}
{:name :buffer}
{:name :path}
]
})
(vim.api.nvim_create_autocmd "LspAttach" {
:callback (fn [args]
(local buf args.buf)
(local opts {:buffer buf})
(vim.keymap.set "n" "gd" vim.lsp.buf.definition opts)
(vim.keymap.set "n" "gr" vim.lsp.buf.references opts)
(vim.keymap.set "n" "K" vim.lsp.buf.hover opts)
(vim.keymap.set "n" "<leader>rn" vim.lsp.buf.rename opts)
(vim.keymap.set "n" "<leader>ca" vim.lsp.buf.code_action opts)
(vim.keymap.set "n" "<leader>f" (fn []
(vim.lsp.buf.format {:async true}))
opts)
(vim.keymap.set "n" "<A-j>" ":m .+1<CR>==")
(vim.keymap.set "n" "<A-k>" ":m .-2<CR>=="))
})
(avante.setup {
:provider "ollama"
:providers {
:ollama {
:endpoint "http://127.0.0.1:11434"
:model "gpt-oss:20b"
:extra_request_body {
:temperature 0
:num_ctx 8192
}
}
}
})
)