orgmode fixed, added comment plugin, added formatter

This commit is contained in:
foxora 2026-02-24 19:54:52 +00:00
parent 44adc7ddd4
commit eea145e01b
9 changed files with 329 additions and 209 deletions

View file

@ -1,97 +1,95 @@
local servers = {} local servers = {}
servers.lua_ls = { servers.lua_ls = {
settings = { settings = {
Lua = { Lua = {
formatters = { formatters = {
ignoreComments = false, ignoreComments = false,
}, },
signatureHelp = { enable = true }, signatureHelp = { enable = true },
diagnostics = { diagnostics = {
globals = { 'nixCats', 'vim' }, globals = { "nixCats", "vim" },
-- disable = { 'missing-fields' }, -- disable = { 'missing-fields' },
}, },
workspace = { workspace = {
-- make the server aware of the neovim runtime files -- make the server aware of the neovim runtime files
library = vim.api.nvim_get_runtime_file("", true), library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false, checkThirdParty = false,
}, },
}, },
telemetry = { enabled = false }, telemetry = { enabled = false },
}, },
} }
servers.nil_ls = { servers.nil_ls = {
settings = {}, settings = {},
} }
local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD") local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD")
servers.rust_analyzer = { servers.rust_analyzer = {
cmd = { rust_analyzer_cmd }, cmd = { rust_analyzer_cmd },
settings = { settings = {
server = { server = {
-- For debugging rust-analyzer, to see log location do :LspInfo in neovim -- For debugging rust-analyzer, to see log location do :LspInfo in neovim
-- extraEnv = { {["RA_LOG"]="project_model=debug"} }, -- extraEnv = { {["RA_LOG"]="project_model=debug"} },
}, },
cargo = { cargo = {
allFeatures = false, allFeatures = false,
allTargets = false, allTargets = false,
buildScripts = { enable = true }, buildScripts = { enable = true },
target = "x86_64-unknown-linux-gnu", target = "x86_64-unknown-linux-gnu",
}, },
diagnostics = { diagnostics = {
enable = true, enable = true,
}, },
}, },
} }
servers.hls = { servers.hls = {
settings = {}, settings = {},
} }
-- Taken from nixCats example: -- Taken from nixCats example:
-- If you were to comment out this autocommand -- If you were to comment out this autocommand
-- and instead pass the on attach function directly to -- and instead pass the on attach function directly to
-- nvim-lspconfig, it would do the same thing. -- nvim-lspconfig, it would do the same thing.
-- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach? -- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach?
-- but you would still end up triggering on a FileType event anyway, so, it makes little difference. -- but you would still end up triggering on a FileType event anyway, so, it makes little difference.
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup('nixCats-lsp-attach', { clear = true }), group = vim.api.nvim_create_augroup("nixCats-lsp-attach", { clear = true }),
callback = function(event) callback = function(event)
require('lsp.capabilities').on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf) require("lsp.capabilities").on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf)
end end,
}) })
require("lze").load { require("lze").load({
{ {
"nvim-lspconfig", "nvim-lspconfig",
event = "FileType", event = "FileType",
after = function(plugin) after = function(plugin)
-- Just register configs, don't enable yet -- Just register configs, don't enable yet
for server_name, cfg in pairs(servers) do for server_name, cfg in pairs(servers) do
vim.lsp.config(server_name, { vim.lsp.config(server_name, {
capabilities = require('lsp.capabilities').get(server_name), capabilities = require("lsp.capabilities").get(server_name),
settings = (cfg or {}).settings, settings = (cfg or {}).settings,
filetypes = (cfg or {}).filetypes, filetypes = (cfg or {}).filetypes,
cmd = (cfg or {}).cmd, cmd = (cfg or {}).cmd,
root_pattern = (cfg or {}).root_pattern, root_pattern = (cfg or {}).root_pattern,
}) })
end end
-- Enable on-demand per filetype
for server_name, cfg in pairs(servers) do
local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes
if filetypes then
vim.api.nvim_create_autocmd('FileType', {
pattern = filetypes,
callback = function()
vim.lsp.enable(server_name)
end,
})
end
end
end,
},
}
-- Enable on-demand per filetype
for server_name, cfg in pairs(servers) do
local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes
if filetypes then
vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function()
vim.lsp.enable(server_name)
end,
})
end
end
end,
},
})

View file

@ -0,0 +1,23 @@
return {
{
"comment.nvim",
event = { "BufReadPost", "BufNewFile" },
after = function(plugin)
require("Comment").setup({
toggler = {
line = "<leader>cc",
block = "<leader>bc",
},
opleader = {
line = "<leader>c",
block = "<leader>b",
},
extra = {
above = "<leader>c<S-o>",
below = "<leader>co",
eol = "<leader>cA",
},
})
end,
},
}

View file

@ -0,0 +1,33 @@
-- docs -> https://github.com/stevearc/conform.nvim
return {
{
"conform.nvim",
enabled = nixCats("format") or false,
keys = {
{ "<leader>p", desc = "Format File (pretty :3)" },
},
after = function(plugin)
local conform = require("conform")
conform.setup({
formatters_by_ft = {
lua = nixCats("lang.lua") and { "stylua" } or nil,
nix = nixCats("lang.nix") and { "nixfmt" } or nil,
rust = nixCats("lang.rust") and { "rustfmt", lsp_format = "fallback" } or nil,
haskell = nixCats("lang.haskell") and { "ormolu" } or nil,
},
format_on_save = {
timeout_ms = 500,
},
})
vim.keymap.set({ "n", "v" }, "<leader>p", function()
conform.format({
lsp_fallback = false,
async = false,
timeout_ms = 1000,
})
end, { desc = "Format File (pretty :3)" })
end,
},
}

View file

@ -1,8 +1,10 @@
require("lze").load { require("lze").load({
{ import = "plugins.dressing", }, { import = "plugins.dressing" },
{ import = "plugins.telescope", }, { import = "plugins.telescope" },
{ import = "plugins.treesitter", }, { import = "plugins.treesitter" },
{ import = "plugins.fyler", }, { import = "plugins.fyler" },
{ import = "plugins.mini-hipatterns", }, { import = "plugins.mini-hipatterns" },
--{ import = "plugins.neocord", }, { import = "plugins.orgmode" },
} { import = "plugins.format" },
{ import = "plugins.comment" },
})

View file

@ -1,5 +0,0 @@
return {
{
"neocord",
},
}

View file

@ -0,0 +1,16 @@
# options: https://github.com/nvim-orgmode/orgmode/blob/master/docs/installation.org
return {
{
"nvim-orgmode/orgmode",
event = { "FileType" },
ft = { "org" },
after = function(plugin)
require("orgmode").setup({
org_agenda_files = "~/.orgmode/**/*",
org_default_notes_file = "~/.orgmode/refile.org",
})
vim.lsp.enable("org")
end,
},
}

View file

@ -1,36 +1,78 @@
return { return {
{ {
"telescope.nvim", "telescope.nvim",
cmd = { "Telescope" }, cmd = { "Telescope" },
keys = { keys = {
{ "<leader>f", function() return require('telescope.builtin').find_files() end, mode = {"n"}, desc = 'Telescope search [F]iles' }, {
{ "<leader>tr", function() return require('telescope.builtin').oldfiles() end, mode = {"n"}, desc = '[T]elescope search [R]ecent files' }, "<leader>f",
{ "<leader>ts", function() return require('telescope.builtin').live_grep() end, mode = {"n"}, desc = '[T]elescope [S]earch cwd with grep' }, function()
{ "<leader>tw", function() return require('telescope.builtin').grep_string() end, mode = {"n"}, desc = '[T]elescope search current [W]ord' }, return require("telescope.builtin").find_files()
{ "<leader>tk", function() return require('telescope.builtin').keymaps() end, mode = {"n"}, desc = '[T]elescope search [K]eymaps' }, end,
{ "<leader>tb", function() return require('telescope.builtin').buffers() end, mode = {"n"}, desc = '[T]elescope search [B]uffers' }, mode = { "n" },
}, desc = "Telescope search [F]iles",
load = function (name) },
vim.cmd.packadd(name) {
vim.cmd.packadd("telescope-fzf-native.nvim") "<leader>tr",
end, function()
after = function(plugin) return require("telescope.builtin").oldfiles()
local telescope = require("telescope") end,
local actions = require("telescope.actions") mode = { "n" },
desc = "[T]elescope search [R]ecent files",
},
{
"<leader>ts",
function()
return require("telescope.builtin").live_grep()
end,
mode = { "n" },
desc = "[T]elescope [S]earch cwd with grep",
},
{
"<leader>tw",
function()
return require("telescope.builtin").grep_string()
end,
mode = { "n" },
desc = "[T]elescope search current [W]ord",
},
{
"<leader>tk",
function()
return require("telescope.builtin").keymaps()
end,
mode = { "n" },
desc = "[T]elescope search [K]eymaps",
},
{
"<leader>tb",
function()
return require("telescope.builtin").buffers()
end,
mode = { "n" },
desc = "[T]elescope search [B]uffers",
},
},
load = function(name)
vim.cmd.packadd(name)
vim.cmd.packadd("telescope-fzf-native.nvim")
end,
after = function(plugin)
local telescope = require("telescope")
local actions = require("telescope.actions")
telescope.setup { telescope.setup({
defaults = { defaults = {
mappings = { mappings = {
i = { i = {
["<C-k>"] = actions.move_selection_previous, -- move to prev result ["<C-k>"] = actions.move_selection_previous, -- move to prev result
["<C-j>"] = actions.move_selection_next, -- move to next result ["<C-j>"] = actions.move_selection_next, -- move to next result
["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist ["<C-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
} },
} },
} },
} })
pcall(telescope.load_extension, "fzf") pcall(telescope.load_extension, "fzf")
end, end,
}, },
} }

View file

@ -2,94 +2,94 @@
-- https://github.com/BirdeeHub/nixCats-nvim/blob/3c9bc4d7123e1b48d92f25ba505b889af541e897/templates/example/lua/myLuaConf/plugins/treesitter.lua -- https://github.com/BirdeeHub/nixCats-nvim/blob/3c9bc4d7123e1b48d92f25ba505b889af541e897/templates/example/lua/myLuaConf/plugins/treesitter.lua
return { return {
{ {
"nvim-treesitter", "nvim-treesitter",
lazy = false, lazy = false,
after = function (plugin) after = function(plugin)
--@param buf integer --@param buf integer
--@param language string --@param language string
local function treesitter_try_attach(buf, language) local function treesitter_try_attach(buf, language)
--check if parser exists and load it --check if parser exists and load it
if not vim.treesitter.language.add(language) then if not vim.treesitter.language.add(language) then
return return
end end
-- enables syntax highlight and other treesitter features -- enables syntax highlight and other treesitter features
vim.treesitter.start(buf, language) vim.treesitter.start(buf, language)
-- enables treesitter based folds -- enables treesitter based folds
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
-- enables treesiter based indentation -- enables treesiter based indentation
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end end
local available_parsers = require("nvim-treesitter").get_available() local available_parsers = require("nvim-treesitter").get_available()
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
callback = function(args) callback = function(args)
local buf, filetype = args.buf, args.match local buf, filetype = args.buf, args.match
local language = vim.treesitter.language.get_lang(filetype) local language = vim.treesitter.language.get_lang(filetype)
if not language then if not language then
return return
end end
local installed_parsers = require("nvim-treesitter").get_installed("parsers") local installed_parsers = require("nvim-treesitter").get_installed("parsers")
if vim.tbl_contains(installed_parsers, language) then if vim.tbl_contains(installed_parsers, language) then
-- enable the parser if it is installed -- enable the parser if it is installed
treesitter_try_attach(buf, language) treesitter_try_attach(buf, language)
elseif vim.tbl_contains(available_parsers, language) then elseif vim.tbl_contains(available_parsers, language) then
-- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed -- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed
require("nvim-treesitter").install(language):await(function() require("nvim-treesitter").install(language):await(function()
treesitter_try_attach(buf, language) treesitter_try_attach(buf, language)
end) end)
else else
-- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter`
treesitter_try_attach(buf, language) treesitter_try_attach(buf, language)
end end
end, end,
}) })
end, end,
},
{
"nvim-treesitter-textobjects",
lazy = false,
before = function(plugin)
vim.g.no_plugin_maps = true
end,
after = function(plugin)
require("nvim-treesitter-textobjects").setup {
select = {
lookahead = true,
selection_modes = {
['@parameter.outer'] = 'v', -- charwise
['@function.outer'] = 'V', -- linewise
},
include_surrounding_whitespace = false,
}, },
} {
"nvim-treesitter-textobjects",
lazy = false,
before = function(plugin)
vim.g.no_plugin_maps = true
end,
after = function(plugin)
require("nvim-treesitter-textobjects").setup({
select = {
lookahead = true,
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
},
include_surrounding_whitespace = false,
},
})
-- keymaps -- keymaps
vim.keymap.set({ "x", "o" }, "am", function() vim.keymap.set({ "x", "o" }, "am", function()
require "nvim-treesitter-textobjects.select".select_textobject("@function.outer", "textobjects") require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects")
end) end)
vim.keymap.set({ "x", "o" }, "im", function() vim.keymap.set({ "x", "o" }, "im", function()
require "nvim-treesitter-textobjects.select".select_textobject("@function.inner", "textobjects") require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects")
end) end)
vim.keymap.set({ "x", "o" }, "ac", function() vim.keymap.set({ "x", "o" }, "ac", function()
require "nvim-treesitter-textobjects.select".select_textobject("@class.outer", "textobjects") require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects")
end) end)
vim.keymap.set({ "x", "o" }, "ic", function() vim.keymap.set({ "x", "o" }, "ic", function()
require "nvim-treesitter-textobjects.select".select_textobject("@class.inner", "textobjects") require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects")
end) end)
-- You can also use captures from other query groups like `locals.scm` -- You can also use captures from other query groups like `locals.scm`
vim.keymap.set({ "x", "o" }, "as", function() vim.keymap.set({ "x", "o" }, "as", function()
require "nvim-treesitter-textobjects.select".select_textobject("@local.scope", "locals") require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals")
end) end)
-- NOTE: for more textobjects options, see the following link. -- NOTE: for more textobjects options, see the following link.
-- This template is using the new `main` branch of the repo. -- This template is using the new `main` branch of the repo.
-- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main
end, end,
}, },
} }

View file

@ -58,14 +58,17 @@ in
lang = with pkgs; { lang = with pkgs; {
lua = [ lua = [
lua-language-server lua-language-server
stylua
]; ];
nix = [ nix = [
nil nil
nix-doc nix-doc
nixfmt
]; ];
rust = with pkgs; [ rust = with pkgs; [
cargo cargo
rust-analyzer rust-analyzer
rustfmt
]; ];
haskell = with pkgs; [ haskell = with pkgs; [
haskell-language-server haskell-language-server
@ -82,7 +85,6 @@ in
nvim-web-devicons nvim-web-devicons
base16-nvim base16-nvim
mini-nvim mini-nvim
orgmode
(pkgs.vimUtils.buildVimPlugin { (pkgs.vimUtils.buildVimPlugin {
pname = "candyland-nvim"; pname = "candyland-nvim";
@ -100,28 +102,29 @@ in
nvim-treesitter.withAllGrammars nvim-treesitter.withAllGrammars
]; ];
}; };
optionalPlugins = { optionalPlugins = with pkgs.vimPlugins; {
general = with pkgs.vimPlugins; [ general = [
orgmode
]; ];
ui = with pkgs.vimPlugins; [ ui = [
dressing-nvim dressing-nvim
]; ];
qol = with pkgs.vimPlugins; [ qol = [
undotree undotree
mini-hipatterns mini-hipatterns
]; ];
telescope = with pkgs.vimPlugins; [ telescope = [
telescope-nvim telescope-nvim
telescope-fzf-native-nvim telescope-fzf-native-nvim
telescope-ui-select-nvim telescope-ui-select-nvim
]; ];
fyler = with pkgs.vimPlugins; [ fyler = [
fyler-nvim fyler-nvim
]; ];
lsp = with pkgs.vimPlugins; [ lsp = [
nvim-lspconfig nvim-lspconfig
]; ];
completion = with pkgs.vimPlugins; [ completion = [
blink-cmp blink-cmp
nvim-cmp nvim-cmp
luasnip luasnip
@ -136,7 +139,13 @@ in
cmp-cmdline-history cmp-cmdline-history
lspkind-nvim lspkind-nvim
]; ];
lang = with pkgs.vimPlugins; { format = [
conform-nvim
];
comment = [
comment-nvim
];
lang = {
}; };
}; };
@ -187,6 +196,8 @@ in
fyler = true; fyler = true;
lsp = true; lsp = true;
completion = true; completion = true;
format = true;
comment = true;
treesitter = true; treesitter = true;
lang = { lang = {