feat: fennelize init
This commit is contained in:
parent
781a29c66f
commit
77ae83dc19
5 changed files with 104 additions and 88 deletions
|
@ -24,10 +24,7 @@
|
|||
;; autocmd, so it'll only apply to buffers you're interested in.
|
||||
;; Will use backslashes on Windows.
|
||||
;; Defaults to compiling all .fnl files, you may want to limit it to your fnl/ directory.
|
||||
:source-file-patterns [:./fnl/.*.fnl
|
||||
:./fnl/*.fnl
|
||||
:./fnl/**/*.fnl
|
||||
:./new-init.fnl]
|
||||
:source-file-patterns [:./fnl/.*.fnl :./fnl/*.fnl :./fnl/**/*.fnl :./init.fnl]
|
||||
;; A function that is given the absolute path of a Fennel file and should return
|
||||
;; the equivalent Lua path, by default this will translate `fnl/foo/bar.fnl` to `lua/foo/bar.lua`.
|
||||
;; See the "Writing Lua elsewhere" tip below for an example function that writes to a sub directory.
|
||||
|
|
74
init.fnl
Normal file
74
init.fnl
Normal file
|
@ -0,0 +1,74 @@
|
|||
(when (= (os.getenv :TERM) :xterm-kitty)
|
||||
((. (require :scripts.chameleon) :setup))
|
||||
((. (require :scripts.kitty-padding) :setup)))
|
||||
|
||||
(require :keymaps)
|
||||
(require :plugins)
|
||||
(require :scripts.obsidian-sync)
|
||||
((. (require :scripts.autoroot) :setup))
|
||||
(set vim.opt.relativenumber true)
|
||||
(set vim.opt.number true)
|
||||
(set vim.opt.laststatus 3)
|
||||
(set vim.opt.undofile true)
|
||||
(set vim.opt.tabstop 4)
|
||||
(set vim.opt.shiftwidth 2)
|
||||
(set vim.treesitter.indent true)
|
||||
(set vim.opt.foldexpr "nvim_treesitter#foldexpr()")
|
||||
(set vim.opt.foldmethod :expr)
|
||||
(set vim.opt.foldenable false)
|
||||
(set vim.opt.signcolumn :yes)
|
||||
(set vim.opt.updatetime 250)
|
||||
(set vim.opt.list true)
|
||||
(set vim.opt.listchars {:nbsp "␣" :tab "» " :trail "·"})
|
||||
(set vim.opt.scrolloff 10)
|
||||
(vim.cmd.colorscheme :oxocarbon)
|
||||
(set vim.g.node_host_prog (nixCats :bin.neovim-node-host))
|
||||
(set vim.g.loaded_node_provider nil)
|
||||
((. (require :nvim-treesitter.configs) :setup) {:additional_vim_regex_highlighting false
|
||||
:auto_install false
|
||||
:disable (fn [_ buf]
|
||||
(local max-filesize
|
||||
(* 100 1024))
|
||||
(local (ok stats)
|
||||
(pcall vim.loop.fs_stat
|
||||
(vim.api.nvim_buf_get_name buf)))
|
||||
(when (and (and ok
|
||||
stats)
|
||||
(> stats.size
|
||||
max-filesize))
|
||||
true))
|
||||
:ensure_installed {}
|
||||
:highlight {:enable true}
|
||||
:ignore_install {}
|
||||
:incremental_selection {:enable true
|
||||
:keymaps {:init_selection :<CR>
|
||||
:node_decremental :<C-j>
|
||||
:node_incremental :<C-k>
|
||||
:scope_incremental :<BS>}}
|
||||
:modules [:highlight
|
||||
:incremental_selection
|
||||
:indent]
|
||||
:sync_install false})
|
||||
|
||||
(vim.api.nvim_create_autocmd [:TermOpen]
|
||||
{:callback (fn []
|
||||
(vim.cmd "setlocal nonumber norelativenumber"))
|
||||
:group (vim.api.nvim_create_augroup :terminal {})})
|
||||
|
||||
(vim.api.nvim_create_autocmd :TextYankPost
|
||||
{:callback (fn []
|
||||
(vim.highlight.on_yank {:higroup :Visual
|
||||
:timeout 300}))})
|
||||
|
||||
(set vim.lsp.handlers.textDocument/hover
|
||||
(vim.lsp.with vim.lsp.handlers.hover {:silent true}))
|
||||
|
||||
(vim.api.nvim_create_autocmd [:VimResized]
|
||||
{:callback (fn []
|
||||
(local current-tab
|
||||
(vim.api.nvim_get_current_tabpage))
|
||||
(vim.cmd "tabdo wincmd =")
|
||||
(vim.api.nvim_set_current_tabpage current-tab))
|
||||
:desc "Resize splits with terminal window"
|
||||
:group (vim.api.nvim_create_augroup :EqualizeSplits
|
||||
{})})
|
103
init.lua
103
init.lua
|
@ -1,98 +1,53 @@
|
|||
if os.getenv("TERM") == "xterm-kitty" then
|
||||
-- [nfnl] Compiled from ./init.fnl by https://github.com/Olical/nfnl, do not edit.
|
||||
if (os.getenv("TERM") == "xterm-kitty") then
|
||||
require("scripts.chameleon").setup()
|
||||
require("scripts.kitty-padding").setup()
|
||||
else
|
||||
end
|
||||
|
||||
require("keymaps")
|
||||
require("plugins")
|
||||
require("scripts.obsidian-sync")
|
||||
|
||||
require("scripts.autoroot").setup()
|
||||
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.number = true
|
||||
|
||||
-- Global statusline
|
||||
vim.opt.laststatus = 3
|
||||
-- Persistent undos across session
|
||||
vim.opt.undofile = true
|
||||
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 2
|
||||
|
||||
vim.treesitter.indent = true
|
||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||
vim.opt.foldmethod = "expr"
|
||||
vim.opt.foldenable = false
|
||||
|
||||
vim.opt.signcolumn = "yes"
|
||||
vim.opt.updatetime = 250
|
||||
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = { tab = "» ", trail = "·", nbsp = "␣" }
|
||||
|
||||
vim.opt.listchars = {nbsp = "\226\144\163", tab = "\194\187 ", trail = "\194\183"}
|
||||
vim.opt.scrolloff = 10
|
||||
|
||||
vim.cmd.colorscheme("oxocarbon")
|
||||
|
||||
vim.g.node_host_prog = nixCats("bin.neovim-node-host")
|
||||
vim.g.loaded_node_provider = nil
|
||||
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {},
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
modules = { "highlight", "incremental_selection", "indent" },
|
||||
ignore_install = {},
|
||||
highlight = { enable = true },
|
||||
disable = function(_, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
additional_vim_regex_highlighting = false,
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = "<CR>",
|
||||
node_incremental = "<C-k>",
|
||||
scope_incremental = "<BS>",
|
||||
node_decremental = "<C-j>",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- no line numbers for terminals
|
||||
vim.api.nvim_create_autocmd({
|
||||
"TermOpen",
|
||||
}, {
|
||||
group = vim.api.nvim_create_augroup("terminal", {}),
|
||||
callback = function()
|
||||
vim.cmd("setlocal nonumber norelativenumber")
|
||||
end,
|
||||
})
|
||||
|
||||
-- flash yanked test
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "Visual", timeout = 300 })
|
||||
end,
|
||||
})
|
||||
|
||||
-- silence the hover 'no information available' notification
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
silent = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ "VimResized" }, {
|
||||
group = vim.api.nvim_create_augroup("EqualizeSplits", {}),
|
||||
callback = function()
|
||||
local current_tab = vim.api.nvim_get_current_tabpage()
|
||||
vim.cmd("tabdo wincmd =")
|
||||
vim.api.nvim_set_current_tabpage(current_tab)
|
||||
end,
|
||||
desc = "Resize splits with terminal window",
|
||||
})
|
||||
local function _2_(_, buf)
|
||||
local max_filesize = (100 * 1024)
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ((ok and stats) and (stats.size > max_filesize)) then
|
||||
return true
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
require("nvim-treesitter.configs").setup({disable = _2_, ensure_installed = {}, highlight = {enable = true}, ignore_install = {}, incremental_selection = {enable = true, keymaps = {init_selection = "<CR>", node_decremental = "<C-j>", node_incremental = "<C-k>", scope_incremental = "<BS>"}}, modules = {"highlight", "incremental_selection", "indent"}, additional_vim_regex_highlighting = false, auto_install = false, sync_install = false})
|
||||
local function _4_()
|
||||
return vim.cmd("setlocal nonumber norelativenumber")
|
||||
end
|
||||
vim.api.nvim_create_autocmd({"TermOpen"}, {callback = _4_, group = vim.api.nvim_create_augroup("terminal", {})})
|
||||
local function _5_()
|
||||
return vim.highlight.on_yank({higroup = "Visual", timeout = 300})
|
||||
end
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {callback = _5_})
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {silent = true})
|
||||
local function _6_()
|
||||
local current_tab = vim.api.nvim_get_current_tabpage()
|
||||
vim.cmd("tabdo wincmd =")
|
||||
return vim.api.nvim_set_current_tabpage(current_tab)
|
||||
end
|
||||
return vim.api.nvim_create_autocmd({"VimResized"}, {callback = _6_, desc = "Resize splits with terminal window", group = vim.api.nvim_create_augroup("EqualizeSplits", {})})
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
(if (os.getenv :TERM)
|
||||
((. (require :scripts.chameleon) :setup) (. (require :scripts.kitty-padding)
|
||||
:setup))
|
||||
{})
|
|
@ -1,6 +0,0 @@
|
|||
-- [nfnl] Compiled from ./new-init.fnl by https://github.com/Olical/nfnl, do not edit.
|
||||
if os.getenv("TERM") then
|
||||
return require("scripts.chameleon").setup(require("scripts.kitty-padding").setup)
|
||||
else
|
||||
return {}
|
||||
end
|
Loading…
Reference in a new issue