commit 4861ac99f523bf1e459df026b6a31b27fe54d813 Author: Alexey Norets Date: Sun Sep 21 12:27:07 2025 +0300 NeoVim config with GruberDarker theme and with Obsidian Notes diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6830205 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/*.json diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..14af65d --- /dev/null +++ b/init.lua @@ -0,0 +1,50 @@ +require("config.remap") +require("config.lazy") +require("config.set") + +-- Change in Highlight gruber-darker-theme. In all themes, but for now it's ok.) +vim.api.nvim_create_autocmd({"ColorScheme", "VimEnter"}, { + group = vim.api.nvim_create_augroup('Color', {}), + pattern = "*", + callback = function () + vim.api.nvim_set_hl(0, "@keyword.directive.define", {fg = "#95a99f"}) + vim.api.nvim_set_hl(0, "@keyword.directive", {fg = "#95a99f"}) + vim.api.nvim_set_hl(0, "@keyword.conditional", {fg = "#ffdd33"}) + vim.api.nvim_set_hl(0, "@keyword.return", {fg = "#ffdd33"}) + vim.api.nvim_set_hl(0, "@keyword.import", {fg = "#95a99f"}) + vim.api.nvim_set_hl(0, "@type.builtin", {fg = "#95a99f"}) + vim.api.nvim_set_hl(0, "@constant.c", {fg = "#f4f4ff"}) + vim.api.nvim_set_hl(0, "@constant.macro.c", {fg = "#f4f4ff"}) + vim.api.nvim_set_hl(0, "@function.builtin", {fg = "#96a6c8"}) + -- vim.api.nvim_set_hl(0, "LspReferenceText", {fg = "#FF0000"}) + end +}) + +-- highlight yanked text +vim.api.nvim_create_autocmd("TextYankPost", { + pattern = "*", + command = "silent! lua vim.highlight.on_yank({ timeout = 500 })", +}) +-- jump to last edit position on opening file +vim.api.nvim_create_autocmd("BufReadPost", { + pattern = "*", + callback = function(ev) + if vim.fn.line("'\"") > 1 and vim.fn.line("'\"") <= vim.fn.line("$") then + -- except for in git commit messages + -- https://stackoverflow.com/questions/31449496/vim-ignore-specifc-file-in-autocommand + if not vim.fn.expand("%:p"):find(".git", 1, true) then + vim.cmd('exe "normal! g\'\\""') + end + end + end, +}) + +-- Установить 4 пробела для табуляции в C-файлах +vim.api.nvim_create_autocmd("FileType", { + pattern = "c", + callback = function() + vim.bo.tabstop = 4 + vim.bo.shiftwidth = 4 + vim.bo.expandtab = true + end, +}) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..40746f6 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,16 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup({ + spec = "plugins", + change_detection = { notify = false }, +}) diff --git a/lua/config/remap.lua b/lua/config/remap.lua new file mode 100644 index 0000000..741ca4e --- /dev/null +++ b/lua/config/remap.lua @@ -0,0 +1,67 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "dj", vim.cmd.Ex) + +vim.keymap.set("n", "", "mmyyp`mj") + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({ "n", "v" }, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({ "n", "v" }, "d", [["_d]]) + +-- This is going to get me cancelled +vim.keymap.set({ "i", "n", "v" }, "", "") + +-- vim.keymap.set("n", "q", "") +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") + +-- vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") +-- vim.keymap.set("n", "f", vim.lsp.buf.format) + +-- Disable highlight search result +-- vim.keymap.set({ "n", "v" }, "", ":nohlsearch", {}) +vim.keymap.set({ "n", "v" }, "z", ":nohlsearch", {}) + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") +vim.keymap.set("n", "co", "copen") + +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) + +vim.keymap.set("n", "", function() + vim.cmd("so") +end) + +vim.keymap.set("n", "vsl", ":lua vim.wo.wrap = not vim.wo.wrap") + +-- Navigate buffers +vim.keymap.set("n", "", ":bnext") +vim.keymap.set("n", "", ":bprevious") +vim.keymap.set("n", "bk", ":bdel") + +vim.keymap.set("n", "ns", ":ObsidianQuickSwitch") + +local keymap = vim.api.nvim_set_keymap +local opts = { noremap = true, silent = true } +keymap("i", "", "lua require'luasnip'.jump(1)", opts) +keymap("s", "", "lua require'luasnip'.jump(1)", opts) +keymap("i", "", "lua require'luasnip'.jump(-1)", opts) +keymap("s", "", "lua require'luasnip'.jump(-1)", opts) diff --git a/lua/config/set.lua b/lua/config/set.lua new file mode 100644 index 0000000..b1cc913 --- /dev/null +++ b/lua/config/set.lua @@ -0,0 +1,64 @@ +-- vim.opt.guicursor = "" +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.splitbelow = true +vim.opt.splitright = true + +vim.opt.foldenable = false +vim.opt.foldmethod = "manual" +vim.opt.foldlevelstart = 99 + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.virtualedit = "block" +vim.opt.inccommand = "split" +vim.opt.iskeyword:remove("_") + +vim.opt.smartindent = true +vim.opt.listchars = { + eol = "¬", -- Character at the end of each line + tab = "▸ ", -- Characters for tabs (requires two characters) + extends = "»", -- Character for lines extending beyond the window + precedes = "«", -- Character for lines preceding the window + trail = "·", -- Character for trailing spaces + space = "·", -- Character for regular spaces + nbsp = "‿", -- Character for non-breaking spaces + lead = "·", -- Character for leading spaces (can be an empty string) + multispace = "·", -- Character for two or more consecutive spaces +} +vim.opt.list = true +vim.cmd("hi Whitespace guifg=#282828") +vim.cmd("hi NonText guifg=#282828") +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = false + +vim.opt.hlsearch = true +vim.opt.incsearch = true +vim.opt.ignorecase = true +vim.opt.smartcase = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +-- vim.opt.colorcolumn = "80" + +vim.g.netrw_browse_split = 0 +vim.g.netrw_liststyle = 3 +vim.g.netrw_banner = 0 +vim.g.netrw_winsize = 25 +-- vim.g.netrw_hide = 0 + +-- ScrollOff diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..e072967 --- /dev/null +++ b/lua/plugins/colorscheme.lua @@ -0,0 +1,86 @@ +return { + { + -- "zenbones-theme/zenbones.nvim", + -- -- Optionally install Lush. Allows for more configuration or extending the colorscheme + -- -- If you don't want to install lush, make sure to set g:zenbones_compat = 1 + -- -- In Vim, compat mode is turned on as Lush only works in Neovim. + -- dependencies = "rktjmp/lush.nvim", + -- lazy = false, + -- priority = 1000, + -- -- you can set set configuration options here + -- config = function() + -- vim.opt.termguicolors = true + -- vim.opt.background = warm + -- vim.g.zenbones_darken_comments = 45 + -- vim.cmd.colorscheme('neobones') + -- end, + }, + { + -- "wincent/base16-nvim", + -- lazy = false, -- load at start + -- priority = 1000, -- load first + -- config = function() + -- vim.cmd([[colorscheme nord]]) + -- vim.o.background = "dark" + -- -- XXX: hi Normal ctermbg=NONE + -- -- Make comments more prominent -- they are important. + -- local bools = vim.api.nvim_get_hl(0, { name = "Boolean" }) + -- vim.api.nvim_set_hl(0, "Comment", bools) + -- -- Make it clearly visible which argument we're at. + -- local marked = vim.api.nvim_get_hl(0, { name = "PMenu" }) + -- vim.api.nvim_set_hl( + -- 0, + -- "LspSignatureActiveParameter", + -- { fg = marked.fg, bg = marked.bg, ctermfg = marked.ctermfg, ctermbg = marked.ctermbg, bold = true } + -- ) + -- -- XXX + -- -- Would be nice to customize the highlighting of warnings and the like to make + -- -- them less glaring. But alas + -- -- https://github.com/nvim-lua/lsp_extensions.nvim/issues/21 + -- -- call Base16hi("CocHintSign", g:base16_gui03, "", g:base16_cterm03, "", "", "") + -- end, + }, + { + "blazkowolf/gruber-darker.nvim", + opts = { + bold = false, + invert = { + signs = false, + tabline = false, + visual = false, + }, + italic = { + strings = true, + comments = true, + operators = false, + folds = true, + }, + undercurl = true, + underline = true, + }, + config = function() + vim.cmd.colorscheme("gruber-darker") + end, + }, + { + -- "sainnhe/gruvbox-material", + -- priority = 1000, + -- config = function() + -- vim.opt.termguicolors = true + -- vim.g.gruvbox_material_foreground = "original" -- original, mix, material + -- vim.g.gruvbox_material_background = "hard" + -- vim.g.gruvbox_material_better_performance = 1 + -- vim.g.gruvbox_material_enable_italic = 0 + -- vim.g.gruvbox_material_enable_bold = 0 + -- vim.cmd.colorscheme("gruvbox-material") + -- end, + }, + { + -- "sainnhe/everforest", + -- config = function() + -- vim.g.everforest_background = "hard" + -- vim.cmd.colorscheme("everforest") + -- -- vim.api.nvim_set_hl(0, "LspInlayHint", { fg = "#9DA9A0" }) + -- end, + }, +} diff --git a/lua/plugins/comment.lua b/lua/plugins/comment.lua new file mode 100644 index 0000000..e6b597d --- /dev/null +++ b/lua/plugins/comment.lua @@ -0,0 +1,7 @@ +return { + 'numToStr/Comment.nvim', + opts = { + -- add any options here + }, + lazy = false, +} diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua new file mode 100644 index 0000000..1b258a3 --- /dev/null +++ b/lua/plugins/completions.lua @@ -0,0 +1,102 @@ +return { + { + "hrsh7th/cmp-nvim-lsp", + -- "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets", + }, + }, + { + "hrsh7th/nvim-cmp", + config = function() + -- local has_words_before = function() + -- unpack = unpack or table.unpack + -- local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + -- return col ~= 0 + -- and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + -- end + -- + -- local luasnip = require("luasnip") + local cmp = require("cmp") + require("luasnip.loaders.from_vscode").lazy_load() + local cmp_select = { behavior = cmp.SelectBehavior.Select } + cmp.setup({ + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.select_prev_item(cmp_select), + [""] = cmp.mapping.select_next_item(cmp_select), + [""] = cmp.mapping.confirm({ select = true }), + -- [""] = cmp.mapping.abort(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.mapping({ + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }), + -- [""] = cmp.mapping("lua require'luasnip'.jump(1)", { "i", "s" }), + -- [""] = cmp.mapping("lua require'luasnip'.jump(-1)", { "i", "s" }), + -- !!! + -- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#no-snippet-plugin + -- !!! + -- [""] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- -- that way you will only jump inside the snippet region + -- elseif luasnip.expand_or_jumpable() then + -- luasnip.expand_or_jump() + -- elseif has_words_before() then + -- cmp.complete() + -- else + -- fallback() + -- end + -- end, { "i", "s" }), + -- + -- [""] = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_prev_item() + -- elseif luasnip.jumpable(-1) then + -- luasnip.jump(-1) + -- else + -- fallback() + -- end + -- end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, { + { name = "buffer" }, + }, { + { name = "nvim_lsp_signature_help" }, + }), + experimental = { + chost_text = true, + }, + }) + -- Enable completing paths in : + cmp.setup.cmdline(":", { + sources = cmp.config.sources({ + { name = "path" }, + }), + }) + end, + }, +} diff --git a/lua/plugins/crates.lua.bak b/lua/plugins/crates.lua.bak new file mode 100644 index 0000000..03aa7ff --- /dev/null +++ b/lua/plugins/crates.lua.bak @@ -0,0 +1,7 @@ +return { + "saecki/crates.nvim", + tag = "stable", + config = function() + require("crates").setup() + end, +} diff --git a/lua/plugins/eyeliner.lua b/lua/plugins/eyeliner.lua new file mode 100644 index 0000000..2b8e75f --- /dev/null +++ b/lua/plugins/eyeliner.lua @@ -0,0 +1,9 @@ +return { + "jinh0/eyeliner.nvim", + config = function() + require("eyeliner").setup({ + highlight_on_key = true, -- show highlights only after keypress + dim = true, -- dim all other characters if set to true (recommended!) + }) + end, +} diff --git a/lua/plugins/formating.lua b/lua/plugins/formating.lua new file mode 100644 index 0000000..10d2ef3 --- /dev/null +++ b/lua/plugins/formating.lua @@ -0,0 +1,39 @@ +return { + "stevearc/conform.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + javascript = { "prettier" }, + typescript = { "prettier" }, + javascriptreact = { "prettier" }, + typescriptreact = { "prettier" }, + svelte = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + json = { "prettier" }, + yaml = { "prettier" }, + markdown = { "prettier" }, + graphql = { "prettier" }, + lua = { "stylua" }, + python = { "isort", "black" }, + rust = { "rustfmt" }, + }, + format_on_save = { + lsp_fallback = true, + async = false, + timeout_ms = 500, + }, + }) + + vim.keymap.set({ "n", "v" }, "f", function() + conform.format({ + lsp_fallback = true, + async = false, + timeout_ms = 500, + }) + end, { desc = "Format file or range (in visual mode)" }) + end, +} diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 0000000..d04149b --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,6 @@ +return { + "tpope/vim-fugitive", + config = function() + vim.keymap.set("n", "gs", vim.cmd.Git) + end, +} diff --git a/lua/plugins/fzf.lua b/lua/plugins/fzf.lua new file mode 100644 index 0000000..024c0cd --- /dev/null +++ b/lua/plugins/fzf.lua @@ -0,0 +1,50 @@ +return { + -- auto-cd to root of git project + -- 'airblade/vim-rooter' + { + "notjedi/nvim-rooter.lua", + config = function() + require("nvim-rooter").setup() + end, + }, + { + "junegunn/fzf.vim", + dependencies = { + { "junegunn/fzf", dir = "~/.fzf", build = "./install --all" }, + }, + config = function() + -- stop putting a giant window over my editor + vim.g.fzf_layout = { down = "~20%" } + -- when using :Files, pass the file list through + -- + -- !!!! https://github.com/jonhoo/proximity-sort + -- + -- to prefer files closer to the current file. + function list_cmd() + local base = vim.fn.fnamemodify(vim.fn.expand("%"), ":h:.:S") + if base == "." then + -- if there is no current file, + -- proximity-sort can't do its thing + return "fd --type file --follow" + else + return vim.fn.printf( + "fd --type file --follow | proximity-sort %s", + vim.fn.shellescape(vim.fn.expand("%")) + ) + end + end + + -- vim.keymap.set("n", "ps", function() + -- builtin.grep_string({ search = vim.fn.input("Grep > ") }) + -- end) + vim.api.nvim_create_user_command("MyFiles", function(arg) + vim.fn["fzf#vim#files"](arg.qargs, { source = list_cmd(), options = "--tiebreak=index" }, arg.bang) + end, { bang = true, nargs = "?", complete = "dir" }) + + -- vim.keymap.set("n", "pf", "MyFiles") + -- vim.keymap.set("n", "fg", "GFiles") + -- vim.keymap.set("n", "bb", "Buffers") + -- vim.keymap.set("n", "ps", ":Rg ") + end, + }, +} diff --git a/lua/plugins/leap.lua b/lua/plugins/leap.lua new file mode 100644 index 0000000..72efbf1 --- /dev/null +++ b/lua/plugins/leap.lua @@ -0,0 +1,8 @@ +return { + "ggandor/leap.nvim", + config = function() + -- require("leap").create_default_mappings() + vim.keymap.set({ "n", "x", "o" }, "Z", "(leap-forward)") + vim.keymap.set({ "n", "x", "o" }, "X", "(leap-backward)") + end, +} diff --git a/lua/plugins/linting.lua b/lua/plugins/linting.lua new file mode 100644 index 0000000..1c6b45b --- /dev/null +++ b/lua/plugins/linting.lua @@ -0,0 +1,33 @@ +return { + "mfussenegger/nvim-lint", + event = { + "BufReadPre", + "BufNewFile", + }, + config = function() + local lint = require("lint") + + lint.linters_by_ft = { + javascript = { "eslint_d" }, + typescript = { "eslint_d" }, + javascriptreact = { "eslint_d" }, + typescriptreact = { "eslint_d" }, + svelte = { "eslint_d" }, + python = { "flake8" }, + rust = { "trivy" }, + } + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "l", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..4239515 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,85 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + vim.o.showmode = false + local hide_in_width = function() + return vim.fn.winwidth(0) > 80 + end + local lualine = require("lualine") + -- local spaces = function() + -- return "spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") + -- end + lualine.diagnostics = { + "diagnostics", + sources = { "nvim_diagnostic" }, + sections = { "error", "warn" }, + + -- symbols = { error = " ", warn = " " }, + colored = false, + update_in_insert = false, + always_visible = false, + } + lualine.diff = { + "diff", + colored = false, + -- symbols = { added = " ", modified = " ", removed = " " }, -- changes diff symbols + cond = hide_in_width, + } + lualine.mode = { + "mode", + fmt = function(str) + return "<" .. str:sub(1, 1) .. ">" + end, + } + lualine.filetype = { + "filetype", + icons_enabled = false, + icon = nil, + } + lualine.branch = { + "branch", + icons_enabled = true, + -- icon = "", + } + + lualine.location = { + "location", + padding = 0, + } + lualine.setup({ + options = { + -- theme = "nord", + -- theme = "everforest", + theme = "auto", + icons_enabled = true, + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { "alpha", "dashboard", "NvimTree", "Outline" }, + always_divide_middle = true, + }, + sections = { + lualine_a = { lualine.mode }, + lualine_b = { lualine.branch, "filename" }, + lualine_c = {}, + -- lualine_x = { "encoding", "fileformat", "filetype" }, + -- lualine_x = { lualine.diff, spaces, "encoding", lualine.filetype }, + lualine_x = { lualine.diagnostics, lualine.filetype }, + lualine_y = { "progress", "location" }, + -- lualine_z = { "tabnine" }, + lualine_z = {}, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + -- lualine_x = { "location" }, + lualine_x = {}, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + extensions = {}, + }) + end, +} diff --git a/lua/plugins/markdown.lua.bak b/lua/plugins/markdown.lua.bak new file mode 100644 index 0000000..cb2575a --- /dev/null +++ b/lua/plugins/markdown.lua.bak @@ -0,0 +1,128 @@ +return { + "MeanderingProgrammer/render-markdown.nvim", + opts = {}, + -- dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + dependencies = { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons" }, -- if you prefer nvim-web-devicons + config = function() + vim.opt.conceallevel = 2 + require("render-markdown").setup({ + heading = { + -- Turn on / off heading icon & background rendering + enabled = true, + -- Turn on / off any sign column related rendering + sign = true, + -- Determines how icons fill the available space: + -- inline: underlying '#'s are concealed resulting in a left aligned icon + -- overlay: result is left padded with spaces to hide any additional '#' + position = "overlay", + -- Replaces '#+' of 'atx_h._marker' + -- The number of '#' in the heading determines the 'level' + -- The 'level' is used to index into the array using a cycle + icons = { "󰲡 ", "󰲣 ", "󰲥 ", "󰲧 ", "󰲩 ", "󰲫 " }, + -- Added to the sign column if enabled + -- The 'level' is used to index into the array using a cycle + signs = { "󰫎 " }, + -- Width of the heading background: + -- block: width of the heading text + -- full: full width of the window + -- Can also be an array of the above values in which case the 'level' is used + -- to index into the array using a clamp + width = "full", + -- Amount of padding to add to the left of headings + left_pad = 0, + -- Amount of padding to add to the right of headings when width is 'block' + right_pad = 0, + -- Minimum width to use for headings when width is 'block' + min_width = 0, + -- Determins if a border is added above and below headings + border = false, + -- Highlight the start of the border using the foreground highlight + border_prefix = false, + -- Used above heading for border + above = "▄", + -- Used below heading for border + below = "▀", + -- The 'level' is used to index into the array using a clamp + -- Highlight for the heading icon and extends through the entire line + backgrounds = { + "RenderMarkdownH1Bg", + "RenderMarkdownH2Bg", + "RenderMarkdownH3Bg", + "RenderMarkdownH4Bg", + "RenderMarkdownH5Bg", + "RenderMarkdownH6Bg", + }, + -- The 'level' is used to index into the array using a clamp + -- Highlight for the heading and sign icons + foregrounds = { + "RenderMarkdownH1", + "RenderMarkdownH2", + "RenderMarkdownH3", + "RenderMarkdownH4", + "RenderMarkdownH5", + "RenderMarkdownH6", + }, + }, + -- require("render-markdown").setup({ + -- heading = { + -- -- Turn on / off heading icon & background rendering + -- enabled = true, + -- -- Turn on / off any sign column related rendering + -- sign = true, + -- -- Determines how icons fill the available space: + -- -- inline: underlying '#'s are concealed resulting in a left aligned icon + -- -- overlay: result is left padded with spaces to hide any additional '#' + -- position = "overlay", + -- -- Replaces '#+' of 'atx_h._marker' + -- -- The number of '#' in the heading determines the 'level' + -- -- The 'level' is used to index into the array using a cycle + -- icons = { "󰲡 ", "󰲣 ", "󰲥 ", "󰲧 ", "󰲩 ", "󰲫 " }, + -- -- Added to the sign column if enabled + -- -- The 'level' is used to index into the array using a cycle + -- signs = { "󰫎 " }, + -- -- Width of the heading background: + -- -- block: width of the heading text + -- -- full: full width of the window + -- -- Can also be an array of the above values in which case the 'level' is used + -- -- to index into the array using a clamp + -- width = "full", + -- -- Amount of padding to add to the left of headings + -- left_pad = 0, + -- -- Amount of padding to add to the right of headings when width is 'block' + -- right_pad = 0, + -- -- Minimum width to use for headings when width is 'block' + -- min_width = 0, + -- -- Determins if a border is added above and below headings + -- border = false, + -- -- Highlight the start of the border using the foreground highlight + -- border_prefix = false, + -- -- Used above heading for border + -- above = "▄", + -- -- Used below heading for border + -- below = "▀", + -- -- The 'level' is used to index into the array using a clamp + -- -- Highlight for the heading icon and extends through the entire line + -- backgrounds = { + -- "RenderMarkdownH1Bg", + -- "RenderMarkdownH2Bg", + -- "RenderMarkdownH3Bg", + -- "RenderMarkdownH4Bg", + -- "RenderMarkdownH5Bg", + -- "RenderMarkdownH6Bg", + -- }, + -- -- The 'level' is used to index into the array using a clamp + -- -- Highlight for the heading and sign icons + -- foregrounds = { + -- "RenderMarkdownH1", + -- "RenderMarkdownH2", + -- "RenderMarkdownH3", + -- "RenderMarkdownH4", + -- "RenderMarkdownH5", + -- "RenderMarkdownH6", + -- }, + -- }, + -- }), + }) + end, +} diff --git a/lua/plugins/md_preview.lua.bak b/lua/plugins/md_preview.lua.bak new file mode 100644 index 0000000..ad2d617 --- /dev/null +++ b/lua/plugins/md_preview.lua.bak @@ -0,0 +1,19 @@ +return { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + require("lazy").load({ plugins = { "markdown-preview.nvim" } }) + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + desc = "Markdown Preview", + }, + }, + config = function() + vim.cmd([[do FileType]]) + end, +} diff --git a/lua/plugins/nvim-tmux-nav.lua b/lua/plugins/nvim-tmux-nav.lua new file mode 100644 index 0000000..3de01d6 --- /dev/null +++ b/lua/plugins/nvim-tmux-nav.lua @@ -0,0 +1,15 @@ +return { + "alexghergh/nvim-tmux-navigation", + config = function() + local nvim_tmux_nav = require("nvim-tmux-navigation") + nvim_tmux_nav.setup({ + disable_when_zoomed = true, -- defaults to false + }) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateLeft) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateDown) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateUp) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateRight) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateLastActive) + vim.keymap.set("n", "", nvim_tmux_nav.NvimTmuxNavigateNext) + end, +} diff --git a/lua/plugins/obsidian.lua b/lua/plugins/obsidian.lua new file mode 100644 index 0000000..f5cd2dd --- /dev/null +++ b/lua/plugins/obsidian.lua @@ -0,0 +1,204 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", -- recommended, use latest release instead of latest commit + lazy = false, + ft = "markdown", + -- Replace the above line with this if you only want to load obsidian.nvim for markdown files in your vault: + -- event = { + -- -- If you want to use the home shortcut '~' here you need to call 'vim.fn.expand'. + -- -- E.g. "BufReadPre " .. vim.fn.expand "~" .. "/my-vault/*.md" + -- -- refer to `:h file-pattern` for more examples + -- "BufReadPre path/to/my-vault/*.md", + -- "BufNewFile path/to/my-vault/*.md", + -- }, + dependencies = { + -- Required. + "nvim-lua/plenary.nvim", + }, + opts = { + workspaces = { + { + name = "Main", + path = "/Users/norets/Library/Mobile Documents/iCloud~md~obsidian/Documents/Main/", + -- path = "~/Nextcloud/Notes/", + }, + }, + }, + config = function() + require("obsidian").setup({ + workspaces = { + { + name = "Main", + -- path = "/Users/norets/Library/Mobile Documents/iCloud~md~obsidian/Documents", + path = "/Users/norets/Library/Mobile Documents/iCloud~md~obsidian/Documents/Main/", + -- path = "~/Nextcloud/Notes/", + }, + }, + daily_notes = { + -- Optional, if you keep daily notes in a separate directory. + folder = "dailies/", + -- Optional, if you want to change the date format for the ID of daily notes. + date_format = "%Y-%m-%d", + -- Optional, if you want to change the date format of the default alias of daily notes. + alias_format = "%B %-d, %Y", + -- Optional, default tags to add to each new daily note created. + default_tags = { "daily-notes" }, + -- Optional, if you want to automatically insert a template from your template directory like 'daily.md' + template = nil, + }, + completion = { + -- Set to false to disable completion. + nvim_cmp = true, + -- Trigger completion at 2 chars. + min_chars = 2, + }, + + -- Optional, configure key mappings. These are the defaults. If you don't want to set any keymappings this + -- way then set 'mappings = {}'. + mappings = { + -- Overrides the 'gf' mapping to work on markdown/wiki links within your vault. + ["gf"] = { + action = function() + return require("obsidian").util.gf_passthrough() + end, + opts = { noremap = false, expr = true, buffer = true }, + }, + -- Toggle check-boxes. + ["ch"] = { + action = function() + return require("obsidian").util.toggle_checkbox() + end, + opts = { buffer = true }, + }, + -- Smart action depending on context, either follow link or toggle checkbox. + [""] = { + action = function() + return require("obsidian").util.smart_action() + end, + opts = { buffer = true, expr = true }, + }, + }, + picker = { + -- Set your preferred picker. Can be one of 'telescope.nvim', 'fzf-lua', or 'mini.pick'. + name = "telescope.nvim", + -- Optional, configure key mappings for the picker. These are the defaults. + -- Not all pickers support all mappings. + note_mappings = { + -- Create a new note from your query. + new = "", + -- Insert a link to the selected note. + insert_link = "", + }, + tag_mappings = { + -- Add tag(s) to current note. + tag_note = "", + -- Insert a tag at the current location. + insert_tag = "", + }, + }, + + -- Where to put new notes. Valid options are + -- * "current_dir" - put new notes in same directory as the current buffer. + -- * "notes_subdir" - put new notes in the default notes subdirectory. + new_notes_location = "notes_subdir", + + -- Optional, customize how note IDs are generated given an optional title. + ---@param title string|? + ---@return string + note_id_func = function(title) + -- Create note IDs in a Zettelkasten format with a timestamp and a suffix. + -- In this case a note with the title 'My new note' will be given an ID that looks + -- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md' + local suffix = "" + if title ~= nil then + -- If title is given, transform it into valid file name. + suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() + else + -- If title is nil, just add 4 random uppercase letters to the suffix. + for _ = 1, 4 do + suffix = suffix .. string.char(math.random(65, 90)) + end + end + return tostring(os.time()) .. "-" .. suffix + -- return tostring(os.date("%d%m%yT%H%M%S")) .. "-" .. suffix + end, + + -- Optional, customize how note file names are generated given the ID, target directory, and title. + ---@param spec { id: string, dir: obsidian.Path, title: string|? } + ---@return string|obsidian.Path The full path to the new note. + note_path_func = function(spec) + -- This is equivalent to the default behavior. + local path = spec.dir / tostring(spec.id) + return path:with_suffix(".md") + end, + ui = { + enable = false, --true, -- set to false to disable all additional syntax features + update_debounce = 200, -- update delay after a text change (in milliseconds) + max_file_length = 5000, -- disable UI features for files with more than this many lines + -- Define how various check-boxes are displayed + checkboxes = { + -- NOTE: the 'char' value has to be a single character, and the highlight groups are defined below. + -- [" "] = { char = "󰄱", hl_group = "ObsidianTodo" }, + -- ["x"] = { char = "", hl_group = "ObsidianDone" }, + -- [">"] = { char = "", hl_group = "ObsidianRightArrow" }, + -- ["~"] = { char = "󰰱", hl_group = "ObsidianTilde" }, + -- ["!"] = { char = "", hl_group = "ObsidianImportant" }, + -- Replace the above with this if you don't have a patched font: + [" "] = { char = "☐", hl_group = "ObsidianTodo" }, + ["x"] = { char = "✔", hl_group = "ObsidianDone" }, + + -- You can also add more custom ones... + }, + -- Use bullet marks for non-checkbox lists. + -- bullets = { char = "•", hl_group = "ObsidianBullet" }, + -- external_link_icon = { char = "", hl_group = "ObsidianExtLinkIcon" }, + -- Replace the above with this if you don't have a patched font: + -- external_link_icon = { char = "", hl_group = "ObsidianExtLinkIcon" }, + reference_text = { hl_group = "ObsidianRefText" }, + highlight_text = { hl_group = "ObsidianHighlightText" }, + tags = { hl_group = "ObsidianTag" }, + block_ids = { hl_group = "ObsidianBlockID" }, + hl_groups = { + -- The options are passed directly to `vim.api.nvim_set_hl()`. See `:help nvim_set_hl`. + ObsidianTodo = { bold = true, fg = "#f78c6c" }, + ObsidianDone = { bold = true, fg = "#89ddff" }, + ObsidianRightArrow = { bold = true, fg = "#f78c6c" }, + ObsidianTilde = { bold = true, fg = "#ff5370" }, + ObsidianImportant = { bold = true, fg = "#d73128" }, + ObsidianBullet = { bold = true, fg = "#89ddff" }, + ObsidianRefText = { underline = true, fg = "#c792ea" }, + ObsidianExtLinkIcon = { fg = "#c792ea" }, + ObsidianTag = { italic = true, fg = "#89ddff" }, + ObsidianBlockID = { italic = true, fg = "#89ddff" }, + ObsidianHighlightText = { bg = "#75662e" }, + }, + }, + + -- Specify how to handle attachments. + attachments = { + -- The default folder to place images in via `:ObsidianPasteImg`. + -- If this is a relative path it will be interpreted as relative to the vault root. + -- You can always override this per image by passing a full path to the command instead of just a filename. + img_folder = "assets/imgs", -- This is the default + + -- Optional, customize the default name or prefix when pasting images via `:ObsidianPasteImg`. + ---@return string + img_name_func = function() + -- Prefix image names with timestamp. + return string.format("%s-", os.time()) + end, + + -- A function that determines the text to insert in the note when pasting an image. + -- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file. + -- This is the default implementation. + ---@param client obsidian.Client + ---@param path obsidian.Path the absolute path to the image file + ---@return string + img_text_func = function(client, path) + path = client:vault_relative_path(path) or path + return string.format("![%s](%s)", path.name, path) + end, + }, + }) + end, +} diff --git a/lua/plugins/render-markdown.lua.bak b/lua/plugins/render-markdown.lua.bak new file mode 100644 index 0000000..f8fee6f --- /dev/null +++ b/lua/plugins/render-markdown.lua.bak @@ -0,0 +1,34 @@ +return { + "MeanderingProgrammer/render-markdown.nvim", + opts = { + file_types = { "markdown", "norg", "rmd", "org" }, + code = { + sign = false, + width = "block", + right_pad = 1, + }, + heading = { + sign = false, + icons = {}, + }, + }, + ft = { "markdown", "norg", "rmd", "org" }, + config = function(_, opts) + vim.opt.conceallevel = 2 + require("render-markdown").setup(opts) + -- vim.keymap.set.toggle.map("tq", { + -- name = "Render Markdown", + -- get = function() + -- return require("render-markdown.state").enabled + -- end, + -- set = function(enabled) + -- local m = require("render-markdown") + -- if enabled then + -- m.enable() + -- else + -- m.disable() + -- end + -- end, + -- }) + end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..757309f --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,124 @@ +local function normalize_path(path) + return path:gsub("\\", "/") +end + +local function normalize_cwd() + return normalize_path(vim.loop.cwd()) .. "/" +end + +local function is_subdirectory(cwd, path) + return string.lower(path:sub(1, #cwd)) == string.lower(cwd) +end + +local function split_filepath(path) + local normalized_path = normalize_path(path) + local normalized_cwd = normalize_cwd() + local filename = normalized_path:match("[^/]+$") + + if is_subdirectory(normalized_cwd, normalized_path) then + local stripped_path = normalized_path:sub(#normalized_cwd + 1, -(#filename + 1)) + return stripped_path, filename + else + local stripped_path = normalized_path:sub(1, -(#filename + 1)) + return stripped_path, filename + end +end + +local function path_display(_, path) + local stripped_path, filename = split_filepath(path) + if filename == stripped_path or stripped_path == "" then + return filename + end + return string.format("%-25s ~ %s", filename, stripped_path) +end + +return { + { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + dependencies = { + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + lazy = true, + }, + "nvim-lua/plenary.nvim", + }, + opts = {}, + config = function() + require("telescope").setup({ + defaults = { + path_display = path_display, + preview = false, + entry_prefix = " ", + initial_mode = "insert", + selection_strategy = "reset", + -- path_display = { "smart" }, + vimgrep_arguments = { + "rg", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + "--hidden", + "--glob=!.git/", + }, + }, + pickers = { + find_files = { theme = "dropdown" }, + git_files = { theme = "dropdown" }, + live_grep = { preview = true, theme = "dropdown" }, + buffers = { theme = "dropdown" }, + grep_string = { preview = true, theme = "dropdown" }, + help_tags = { theme = "dropdown" }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + }, + }, + }) + local builtin = require("telescope.builtin") + vim.keymap.set("n", "pp", ":Telescope projects theme=dropdown", {}) + vim.keymap.set("n", "ff", builtin.find_files, {}) + vim.keymap.set("n", "pf", builtin.git_files, {}) + vim.keymap.set("n", "bb", builtin.buffers, {}) + vim.keymap.set("n", "bi", ":Telescope buffers theme=ivy", {}) + vim.keymap.set("n", "pws", function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set("n", "pWs", function() + local word = vim.fn.expand("") + builtin.grep_string({ search = word }) + end) + vim.keymap.set("n", "ps", function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) + end) + -- vim.keymap.set("n", "pg", builtin.live_grep, {}) + vim.keymap.set("n", "vh", builtin.help_tags, {}) + end, + }, + -- { + -- "ahmedkhalf/project.nvim", + -- config = function() + -- require("project_nvim").setup({ + -- manual_mode = false, + -- detection_methods = { "lsp", "pattern" }, + -- patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + -- ignore_lsp = {}, + -- exclude_dirs = {}, + -- show_hidden = false, + -- silent_chdir = true, + -- scope_chdir = "global", + -- datapath = vim.fn.stdpath("data"), + -- }) + -- require("telescope").load_extension("projects") + -- end, + -- }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..c1645d9 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function () + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "elixir", "heex", "javascript", "html" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..c931e6d --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,23 @@ +return { + "folke/trouble.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + }, + config = function() + require("trouble").setup({ + icons = false, + }) + vim.keymap.set("n", "tt", function() + require("trouble").toggle() + end) + vim.keymap.set("n", "C-n", function() + require("trouble").next({ skip_groups = true, jump = true }) + end) + vim.keymap.set("n", "C-p", function() + require("trouble").previous({ skip_groups = true, jump = true }) + end) + end, +} diff --git a/lua/plugins/undotree.lua b/lua/plugins/undotree.lua new file mode 100644 index 0000000..097b621 --- /dev/null +++ b/lua/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + "mbbill/undotree", + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end, +}