feat: nvim: add Fennel config support via nfnl, treesitter, plugins
This commit is contained in:
parent
2e6aa91f36
commit
9d852d120e
2 changed files with 143 additions and 1 deletions
96
home-manager/nvim/extraconfig.fnl
Normal file
96
home-manager/nvim/extraconfig.fnl
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
(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
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue