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.
|
;; autocmd, so it'll only apply to buffers you're interested in.
|
||||||
;; Will use backslashes on Windows.
|
;; Will use backslashes on Windows.
|
||||||
;; Defaults to compiling all .fnl files, you may want to limit it to your fnl/ directory.
|
;; Defaults to compiling all .fnl files, you may want to limit it to your fnl/ directory.
|
||||||
:source-file-patterns [:./fnl/.*.fnl
|
:source-file-patterns [:./fnl/.*.fnl :./fnl/*.fnl :./fnl/**/*.fnl :./init.fnl]
|
||||||
:./fnl/*.fnl
|
|
||||||
:./fnl/**/*.fnl
|
|
||||||
:./new-init.fnl]
|
|
||||||
;; A function that is given the absolute path of a Fennel file and should return
|
;; 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`.
|
;; 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.
|
;; 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.chameleon").setup()
|
||||||
require("scripts.kitty-padding").setup()
|
require("scripts.kitty-padding").setup()
|
||||||
|
else
|
||||||
end
|
end
|
||||||
|
|
||||||
require("keymaps")
|
require("keymaps")
|
||||||
require("plugins")
|
require("plugins")
|
||||||
require("scripts.obsidian-sync")
|
require("scripts.obsidian-sync")
|
||||||
|
|
||||||
require("scripts.autoroot").setup()
|
require("scripts.autoroot").setup()
|
||||||
|
|
||||||
vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
|
|
||||||
-- Global statusline
|
|
||||||
vim.opt.laststatus = 3
|
vim.opt.laststatus = 3
|
||||||
-- Persistent undos across session
|
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
|
|
||||||
vim.opt.tabstop = 4
|
vim.opt.tabstop = 4
|
||||||
vim.opt.shiftwidth = 2
|
vim.opt.shiftwidth = 2
|
||||||
|
|
||||||
vim.treesitter.indent = true
|
vim.treesitter.indent = true
|
||||||
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
||||||
vim.opt.foldmethod = "expr"
|
vim.opt.foldmethod = "expr"
|
||||||
vim.opt.foldenable = false
|
vim.opt.foldenable = false
|
||||||
|
|
||||||
vim.opt.signcolumn = "yes"
|
vim.opt.signcolumn = "yes"
|
||||||
vim.opt.updatetime = 250
|
vim.opt.updatetime = 250
|
||||||
|
|
||||||
vim.opt.list = true
|
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.opt.scrolloff = 10
|
||||||
|
|
||||||
vim.cmd.colorscheme("oxocarbon")
|
vim.cmd.colorscheme("oxocarbon")
|
||||||
|
|
||||||
vim.g.node_host_prog = nixCats("bin.neovim-node-host")
|
vim.g.node_host_prog = nixCats("bin.neovim-node-host")
|
||||||
vim.g.loaded_node_provider = nil
|
vim.g.loaded_node_provider = nil
|
||||||
|
local function _2_(_, buf)
|
||||||
require("nvim-treesitter.configs").setup({
|
local max_filesize = (100 * 1024)
|
||||||
ensure_installed = {},
|
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||||
sync_install = false,
|
if ((ok and stats) and (stats.size > max_filesize)) then
|
||||||
auto_install = false,
|
return true
|
||||||
modules = { "highlight", "incremental_selection", "indent" },
|
else
|
||||||
ignore_install = {},
|
return nil
|
||||||
highlight = { enable = true },
|
end
|
||||||
disable = function(_, buf)
|
end
|
||||||
local max_filesize = 100 * 1024 -- 100 KB
|
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})
|
||||||
---@diagnostic disable-next-line: undefined-field
|
local function _4_()
|
||||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
return vim.cmd("setlocal nonumber norelativenumber")
|
||||||
if ok and stats and stats.size > max_filesize then
|
end
|
||||||
return true
|
vim.api.nvim_create_autocmd({"TermOpen"}, {callback = _4_, group = vim.api.nvim_create_augroup("terminal", {})})
|
||||||
end
|
local function _5_()
|
||||||
end,
|
return vim.highlight.on_yank({higroup = "Visual", timeout = 300})
|
||||||
additional_vim_regex_highlighting = false,
|
end
|
||||||
incremental_selection = {
|
vim.api.nvim_create_autocmd("TextYankPost", {callback = _5_})
|
||||||
enable = true,
|
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {silent = true})
|
||||||
keymaps = {
|
local function _6_()
|
||||||
init_selection = "<CR>",
|
local current_tab = vim.api.nvim_get_current_tabpage()
|
||||||
node_incremental = "<C-k>",
|
vim.cmd("tabdo wincmd =")
|
||||||
scope_incremental = "<BS>",
|
return vim.api.nvim_set_current_tabpage(current_tab)
|
||||||
node_decremental = "<C-j>",
|
end
|
||||||
},
|
return vim.api.nvim_create_autocmd({"VimResized"}, {callback = _6_, desc = "Resize splits with terminal window", group = vim.api.nvim_create_augroup("EqualizeSplits", {})})
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
-- 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",
|
|
||||||
})
|
|
||||||
|
|
|
@ -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