diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..b243cc8 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,6 @@ +{ + "diagnostics.globals": [ + "vim", + "Snacks" + ] +} \ No newline at end of file diff --git a/ftdetect/beancount.vim b/ftdetect/beancount.vim new file mode 100644 index 0000000..2e8ccbb --- /dev/null +++ b/ftdetect/beancount.vim @@ -0,0 +1,7 @@ +function! s:setf(filetype) abort + if &filetype !=# a:filetypee + let &filetype = a:filetype + endif +endfunction + +au BufNewFile,BufRead *.bean call s:setf("beancount") diff --git a/lazy-lock.json b/lazy-lock.json index d9eb28a..422cd6f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -6,11 +6,17 @@ "gitsigns.nvim": { "branch": "main", "commit": "ee0606259ee5d5dd40398be26755048e8965086e" }, "gruvbox.nvim": { "branch": "main", "commit": "00e38a379bab3389e187b3953566d67d494dfddd" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lualine.nvim": { "branch": "master", "commit": "ecfcfee812ef4fee1e86ae8f315c4a045f7da719" }, "mason.nvim": { "branch": "main", "commit": "9eaedb864cdadc29c6eb7d761a6c0d8aee26c91b" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f481de16a0eb59c985abac8985e3f2e2f75b4875" }, + "nui.nvim": { "branch": "main", "commit": "f535005e6ad1016383f24e39559833759453564e" }, "nvim-autopairs": { "branch": "master", "commit": "4d74e75913832866aa7de35e4202463ddf6efd1b" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lspconfig": { "branch": "master", "commit": "ac1dfbe3b60e5e23a2cff90e3bd6a3bc88031a57" }, - "nvim-tree.lua": { "branch": "master", "commit": "be5b788f2dc1522c73fb7afad9092331c8aebe80" }, "nvim-treesitter": { "branch": "master", "commit": "066fd6505377e3fd4aa219e61ce94c2b8bdb0b79" }, "nvim-web-devicons": { "branch": "master", "commit": "1fb58cca9aebbc4fd32b086cb413548ce132c127" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "tiny-code-action.nvim": { "branch": "main", "commit": "dc0bcd1420124dfd82e625f28caee5a825ffa317" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lsp/gopls.lua b/lua/lsp/gopls.lua similarity index 100% rename from lsp/gopls.lua rename to lua/lsp/gopls.lua diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index a9b8eae..ac64ac0 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -13,4 +13,5 @@ return { }) vim.cmd.colorscheme("gruvbox") end, -} \ No newline at end of file +} + diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index 71e74e6..e91eb68 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -5,9 +5,7 @@ return { keys = { { "ff", - function() - require("conform").format() - end, + function() require("conform").format() end, mode = { "n", "v" }, desc = "Use Conform to format current buffer", }, @@ -26,7 +24,14 @@ return { javascript = { "prettier", stop_after_first = true }, sh = { "shfmt" }, }, - formatters = { injected = { options = { ignore_errors = true } } }, format_on_save = { timeout_ms = 500, lsp_format = "fallback" }, }, + config = function(_, opts) + local conform = require("conform") + conform.setup(opts) + + conform.formatters.stylua = { + prepend_args = { "--collapse-simple-statement", "Always" }, + } + end, } diff --git a/lua/plugins/fzf.lua b/lua/plugins/fzf.lua index aed45dd..c1feacd 100644 --- a/lua/plugins/fzf.lua +++ b/lua/plugins/fzf.lua @@ -7,10 +7,8 @@ return { local fzf_lua = require("fzf-lua") vim.keymap.set("n", "", fzf_lua.files, {}) - vim.keymap.set("n", "", function() - fzf_lua.diagnostics_workspace({ multiline = false }) - end, {}) - vim.keymap.set("n","fg",fzf_lua.live_grep,{}) + vim.keymap.set("n", "", function() fzf_lua.diagnostics_workspace({ multiline = false }) end, {}) + vim.keymap.set("n", "fg", fzf_lua.live_grep, {}) vim.keymap.set("n", "rg", fzf_lua.registers, {}) vim.keymap.set("n", "gs", fzf_lua.git_status, {}) diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua index d5dbc4d..c6b8ea6 100644 --- a/lua/plugins/gitsigns.lua +++ b/lua/plugins/gitsigns.lua @@ -1,10 +1,9 @@ return { - "lewis6991/gitsigns.nvim", - key = {}, - opts = { - current_line_blame = true, - current_line_blame_opts = {delay = 100}, - on_attach = function(bufnr) - end - }, + "lewis6991/gitsigns.nvim", + key = {}, + opts = { + current_line_blame = true, + current_line_blame_opts = { delay = 100 }, + on_attach = function(bufnr) end, + }, } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..4cea1b3 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,141 @@ +return { + "nvim-lualine/lualine.nvim", + event = "VeryLazy", + init = function() + vim.g.lualine_laststatus = vim.o.laststatus + if vim.fn.argc(-1) > 0 then + vim.o.statusline = " " + else + vim.o.laststatus = 0 + end + end, + opts = function() + local lualine = require("lualine") + + local conditions = { + buffer_not_empty = function() return vim.fn.empty(vim.fn.expand("%:t")) ~= 1 end, + hide_in_width = function() return vim.fn.winwidth(0) > 80 end, + check_git_workspace = function() + local filepath = vim.fn.expand("%:p:h") + local gitdir = vim.fn.finddir(".git", filepath .. ";") + return gitdir and #gitdir > 0 and #gitdir < #filepath + end, + } + + -- Config + local config = { + options = { + component_separators = "", + section_separators = "", + theme = "auto", + }, + sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + -- These will be filled later + lualine_c = {}, + lualine_x = {}, + }, + inactive_sections = { + -- these are to remove the defaults + lualine_a = {}, + lualine_b = {}, + lualine_y = {}, + lualine_z = {}, + lualine_c = {}, + lualine_x = {}, + }, + } + + -- Inserts a component in lualine_c at left section + local function ins_left(component) table.insert(config.sections.lualine_c, component) end + + -- Inserts a component in lualine_x ot right section + local function ins_right(component) table.insert(config.sections.lualine_x, component) end + + ins_left({ + -- mode component + function() return "▶" end, + }) + + ins_left({ + "filename", + cond = conditions.buffer_not_empty, + }) + + ins_left({ + "branch", + icon = " ", + }) + + ins_left({ + "diff", + -- Is it me or the symbol for modified us really weird + symbols = { + added = " ", + modified = " ", + removed = " ", + }, + cond = conditions.hide_in_width, + }) + + -- Insert mid section. You can make any number of sections in neovim :) + -- for lualine it"s any number greater then 2 + ins_left({ + function() return "%=" end, + }) + + ins_right({ + -- Lsp server name . + function() + local msg = "null" + local clients = vim.lsp.get_clients() + if next(clients) == nil then return msg end + local client_names = {} + for _, client in ipairs(clients) do + table.insert(client_names, client.name) + end + return table.concat(client_names, ",") + end, + icon = " LSP:", + }) + + ins_right({ + "diagnostics", + sources = { "nvim_diagnostic" }, + symbols = { + error = " ", + warn = " ", + info = " ", + hints = "󰛩 ", + }, + always_visible = true, + }) + + ins_right({ + "o:encoding", -- option component same as &encoding in viml + fmt = string.upper, + cond = conditions.hide_in_width, + }) + + ins_right({ + "fileformat", + fmt = string.upper, + icons_enabled = true, + }) + + ins_right({ + "location", + }) + + ins_right({ + "progress", + }) + + -- Now don"t forget to initialize lualine + lualine.setup(config) + end, +} diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 90c8fd6..7c74184 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -1,3 +1,4 @@ return { - "mason-org/mason.nvim", + "mason-org/mason.nvim", + opts = {}, } diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua new file mode 100644 index 0000000..a53a14c --- /dev/null +++ b/lua/plugins/neo-tree.lua @@ -0,0 +1,64 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + cmd = "Neotree", + keys = { + { + "n", + function() require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) end, + desc = "Explorer NeoTree", + }, + { + "ge", + function() require("nvim-tree.command").exceute({ source = "git_status", toggle = true }) end, + desc = "Git Explorer", + }, + }, + init = function() + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }), + desc = "Start Neo-Tree with directory", + once = true, + callback = function() + if package.loaded["neo-tree"] then + return + else + local stats = vim.uv.fs_stat(vim.fn.argv(0)) + if stats and stats.type == "directory" then require("neo-tree") end + end + end, + }) + end, + ---@module "neo-tree" + ---@type neotree.Config? + opts = { + sources = { "filesystem", "buffers", "git_status" }, + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, + filesystem = { + bind_to_cwd = false, + follow_current_file = { enabled = true }, + use_libuv_file_watcher = true, + }, + window = { + mappings = { + ["l"] = "open", + ["h"] = "close_node", + [""] = "none", + ["Y"] = { + function(state) + local node = state.tree:get_node() + local path = node:get_id() + vim.fn.setreg("+", path, "c") + end, + desc = "Copy Path to Clipboard", + }, + }, + }, + }, + config = function(_, opts) require("neo-tree").setup(opts) end, +} diff --git a/lua/plugins/nvim-colorizer.lua b/lua/plugins/nvim-colorizer.lua new file mode 100644 index 0000000..98afa7d --- /dev/null +++ b/lua/plugins/nvim-colorizer.lua @@ -0,0 +1,7 @@ +return { + "norcalli/nvim-colorizer.lua", + config = function(_) + require("colorizer").setup() + vim.defer_fn(function() require("colorizer").attach_to_buffer(0) end, 0) + end, +} diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua deleted file mode 100644 index bb43710..0000000 --- a/lua/plugins/nvim-tree.lua +++ /dev/null @@ -1,36 +0,0 @@ -return { - "nvim-tree/nvim-tree.lua", - version = "*", - lazy = false, - dependencies = { "nvim-tree/nvim-web-devicons" }, - keys = { - { - "n", - ":NvimTreeToggle", - mode = { "n" }, - desc = "Use Conform to format current buffer", - }, - }, - config = function() - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - vim.opt.termguicolors = true - - require("nvim-tree").setup({ - diagnostics = { - enable = true, - show_on_dirs = true, - }, - filters = { - git_ignored = false, - }, - renderer = { - indent_markers = { enable = true }, - }, - view = { - number = true, - relativenumber = true, - }, - }) - end, -} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua new file mode 100644 index 0000000..d0c5eef --- /dev/null +++ b/lua/plugins/snacks.lua @@ -0,0 +1,58 @@ +return { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + bigfile = { enabled = true }, + dashboard = { enabled = true }, + explorer = { enabled = true }, + indent = { enabled = true }, + input = { enabled = true }, + picker = { enabled = true }, + notifier = { enabled = true }, + quickfile = { enabled = true }, + scope = { enabled = true }, + scroll = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + }, + keys = { + { "", function() Snacks.picker.smart() end, desc = "Smart Find Files" }, + { "fg", function() Snacks.picker.git_files() end, desc = "Find Git Files" }, + { "fp", function() Snacks.picker.projects() end, desc = "Projects" }, + -- git + { "gb", function() Snacks.picker.git_branches() end, desc = "Git Branches" }, + { "gl", function() Snacks.picker.git_log() end, desc = "Git Log" }, + { "gL", function() Snacks.picker.git_log_line() end, desc = "Git Log Line" }, + { "gs", function() Snacks.picker.git_status() end, desc = "Git Status" }, + { "gS", function() Snacks.picker.git_stash() end, desc = "Git Stash" }, + { "gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (Hunks)" }, + { "gf", function() Snacks.picker.git_log_file() end, desc = "Git Log File" }, + -- Grep + { "sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" }, + { "sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" }, + { "sg", function() Snacks.picker.grep() end, desc = "Grep" }, + { + "sw", + function() Snacks.picker.grep_word() end, + desc = "Visual selection or word", + mode = { "n", "x" }, + }, + -- LSP + { "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition" }, + { "gD", function() Snacks.picker.lsp_declarations() end, desc = "Goto Declaration" }, + { "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" }, + { "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" }, + { "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" }, + { "ss", function() Snacks.picker.lsp_symbols() end, desc = "LSP Symbols" }, + { "sS", function() Snacks.picker.lsp_workspace_symbols() end, desc = "LSP Workspace Symbols" }, + -- Other + { "]]", function() Snacks.words.jump(vim.v.count1) end, desc = "Next Reference", mode = { "n", "t" } }, + { "[[", function() Snacks.words.jump(-vim.v.count1) end, desc = "Prev Reference", mode = { "n", "t" } }, + { "", function() Snacks.terminal() end, desc = "Toggle Terminal" }, + }, +} diff --git a/lua/plugins/tiny-code-action.lua b/lua/plugins/tiny-code-action.lua new file mode 100644 index 0000000..af280d9 --- /dev/null +++ b/lua/plugins/tiny-code-action.lua @@ -0,0 +1,20 @@ +return { + "rachartier/tiny-code-action.nvim", + dependencies = { + { "nvim-lua/plenary.nvim" }, + }, + keys = { + { + "ca", + function() require("tiny-code-action").code_action() end, + { "n" }, + }, + }, + event = "LspAttach", + opts = { + backend = "vim", + picker = { + "snacks", + }, + }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 547648a..e7757c4 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,33 +1,31 @@ return { "nvim-treesitter/nvim-treesitter", - build = function() - require("nvim-treesitter.install").update({ with_sync = true })() + build = function() require("nvim-treesitter.install").update({ with_sync = true })() end, + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = { + "html", + "json", + "cmake", + "make", + "python", + "go", + "rust", + "yaml", + "bash", + }, + highlight = { + enable = true, + disable = function(lang, buf) + local ok, stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > require("commons").constants.big_file_size_limit then + return true + end + end, + }, + incremental_selection = { enable = true }, + indent = { enable = true }, + }) end, - config = function() - local configs = require("nvim-treesitter.configs") - configs.setup({ - ensure_installed = { - 'html', - 'json', - 'cmake', - 'make', - 'python', - 'go', - 'rust', - 'yaml', - 'bash' - }, - highlight = { - enable = true, - disable = function(lang,buf) - local ok,stats = pcall(vim.uv.fs_stat, vim.api.nvim_buf_get_name(buf)) - if ok and stats and stats.size > require("commons").constants.big_file_size_limit then - return true - end - end, - }, - incremental_selection = {enable = true}, - indent = {enable = true}, - }) - end } diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index b3097d3..00d48d8 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -1,17 +1,17 @@ return { - "folke/which-key.nvim", - event = "VeryLazy", - opts = { - spec = { - {"", desc = "Decrement Selection", mode = "x"}, - {"", desc = "Increment Selection", mode = {"x", "n"}} - } - }, - keys = { - { - "?", - function() require("which-key").show({global = false}) end, - desc = "Buffer Local Keymaps (which-key)" - } - } + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + spec = { + { "", desc = "Decrement Selection", mode = "x" }, + { "", desc = "Increment Selection", mode = { "x", "n" } }, + }, + }, + keys = { + { + "?", + function() require("which-key").show({ global = false }) end, + desc = "Buffer Local Keymaps (which-key)", + }, + }, }