commit 4054030afcba482d84026a94c00b09e1ed474254 Author: Evie Litherland-Smith Date: Thu May 4 12:39:25 2023 +0100 Initial add Separate nvim config into separate project, to be used as submodule for main dotfile diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..3584200 --- /dev/null +++ b/init.lua @@ -0,0 +1,19 @@ +vim.g.mapleader = " " + +-- bootstrap lazy.nvim +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(require "config.lazy") + +-- Set vim options +require "config" diff --git a/lua/config/aerial.lua b/lua/config/aerial.lua new file mode 100644 index 0000000..b775f56 --- /dev/null +++ b/lua/config/aerial.lua @@ -0,0 +1,8 @@ +return { + -- optionally use on_attach to set keymaps when aerial has attached to a buffer + on_attach = function(bufnr) + -- Jump forwards/backwards with '{' and '}' + vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) + vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) + end, +} diff --git a/lua/config/barbar.lua b/lua/config/barbar.lua new file mode 100644 index 0000000..6f72577 --- /dev/null +++ b/lua/config/barbar.lua @@ -0,0 +1,6 @@ +return { + auto_hide = false, + hide = { extensions = true }, + modified = { button = "●" }, + pinned = { button = "車", filename = true, separator = { right = "" } }, +} diff --git a/lua/config/barbecue.lua b/lua/config/barbecue.lua new file mode 100644 index 0000000..7d6edb4 --- /dev/null +++ b/lua/config/barbecue.lua @@ -0,0 +1 @@ +return { theme = "catppuccin" } diff --git a/lua/config/catppuccin.lua b/lua/config/catppuccin.lua new file mode 100644 index 0000000..83912ee --- /dev/null +++ b/lua/config/catppuccin.lua @@ -0,0 +1,41 @@ +local M = { + flavour = "macchiato", + term_colors = true, + transparent_background = true, + integrations = { + barbar = true, + barbecue = { + dim_dirname = true, + }, + dashboard = true, + gitsigns = true, + hop = true, + indent_blankline = { + enabled = true, + colored_indent_levels = true, + }, + cmp = true, + mason = true, + native_lsp = { + enabled = true, + }, + neogit = true, + notify = true, + nvimtree = true, + navic = { + enabled = false, + custom_bg = "NONE", + }, + treesitter = true, + treesitter_context = true, + telescope = true, + lsp_trouble = true, + which_key = true, + }, +} + +if vim.g.neovide then + M.transparent_background = false +end + +return M diff --git a/lua/config/dashboard.lua b/lua/config/dashboard.lua new file mode 100644 index 0000000..7fe1dd7 --- /dev/null +++ b/lua/config/dashboard.lua @@ -0,0 +1,58 @@ +return { + theme = "hyper", + config = { + week_header = { + enable = true, + }, + shortcut = { + { icon = " ", desc = "Lazy", group = "@property", action = "Lazy", key = "l" }, + { + icon = " ", + icon_hl = "@variable", + desc = "Files", + group = "Files", + action = "Telescope find_files", + key = "f", + }, + { + icon = " ", + icon_hl = "@variable", + desc = "Projects", + group = "Files", + action = "Telescope projects", + key = "p", + }, + { + icon = " ", + icon_hl = "@variable", + desc = "Terminal", + group = "Files", + action = "ToggleTerm", + key = "t", + }, + { + icon = " ", + desc = "Neotree", + group = "Files", + action = "Neotree float reveal reveal_force_cwd", + key = "n", + }, + { + icon = " ", + icon_hl = "@variable", + desc = "Neogit", + group = "Label", + action = "Neogit", + key = "g", + }, + { + icon = " ", + icon_hl = "@variable", + desc = "Git commit", + group = "Label", + action = "Neogit commit", + key = "c", + }, + }, + }, +} diff --git a/lua/config/diffview.lua b/lua/config/diffview.lua new file mode 100644 index 0000000..0c4a90c --- /dev/null +++ b/lua/config/diffview.lua @@ -0,0 +1,6 @@ +return { + enhanced_diff_hl = true, + file_panel = { + listing_style = "list", + }, +} diff --git a/lua/config/feline.lua b/lua/config/feline.lua new file mode 100644 index 0000000..00f0b00 --- /dev/null +++ b/lua/config/feline.lua @@ -0,0 +1,2 @@ +local components = require("ui.feline_components").get() +return { components = components } diff --git a/lua/config/gitsigns.lua b/lua/config/gitsigns.lua new file mode 100644 index 0000000..d1a5b04 --- /dev/null +++ b/lua/config/gitsigns.lua @@ -0,0 +1,45 @@ +return { + signcolumn = true, + numhl = true, + linehl = false, + current_line_blame = true, + word_diff = false, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then return "]c" end + vim.schedule(function() gs.next_hunk() end) + return "" + end, { expr = true }) + + map("n", "[c", function() + if vim.wo.diff then return "[c" end + vim.schedule(function() gs.prev_hunk() end) + return "" + end, { expr = true }) + + -- Actions + map({ "n", "v" }, "hs", ":Gitsigns stage_hunk") + map({ "n", "v" }, "hr", ":Gitsigns reset_hunk") + map("n", "hS", gs.stage_buffer) + map("n", "hu", gs.undo_stage_hunk) + map("n", "hR", gs.reset_buffer) + map("n", "hp", gs.preview_hunk) + map("n", "hb", function() gs.blame_line { full = true } end) + map("n", "tb", gs.toggle_current_line_blame) + map("n", "hd", gs.diffthis) + map("n", "hD", function() gs.diffthis "~" end) + map("n", "td", gs.toggle_deleted) + + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk") + end, +} diff --git a/lua/config/indent_blankline.lua b/lua/config/indent_blankline.lua new file mode 100644 index 0000000..7e319d9 --- /dev/null +++ b/lua/config/indent_blankline.lua @@ -0,0 +1,4 @@ +return { + show_current_context = true, + show_current_context_start = false, +} diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..17fb4f2 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,23 @@ +-- Opt +vim.opt.laststatus = 3 +vim.opt.showtabline = 2 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.listchars = { lead = ".", trail = ".", tab = ">-" } +vim.opt.list = true +vim.opt.splitbelow = true +vim.opt.splitright = true + +if vim.g.neovide then + require "config.neovide" +end + +-- Global +-- vim.g.python3_host_prog = vim.fn.stdpath "config" .. "/.venv/bin/python" +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_perl_provider = 0 + +-- Keymaps +require "config.keymaps" diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua new file mode 100644 index 0000000..a816412 --- /dev/null +++ b/lua/config/keymaps.lua @@ -0,0 +1,102 @@ +vim.keymap.set("i", "jk", "") +vim.keymap.set("n", "l", "Lazy") +vim.keymap.set("n", "m", "Mason") +vim.keymap.set("n", "s", "Dashboard") +vim.keymap.set("n", "z", "ZenMode") +vim.keymap.set("n", "gf", "Neogit") +vim.keymap.set("n", "gg", "Neogit kind=split") +vim.keymap.set("n", "cc", "Neogit commit") +vim.keymap.set("n", "gp", "Neogit kind=split pull") +vim.keymap.set("n", "gP", "Neogit kind=split push") +vim.keymap.set("n", "tt", "ToggleTerm direction=horizontal") +vim.keymap.set({ "n", "t" }, "", "NavigatorLeft") +vim.keymap.set({ "n", "t" }, "", "NavigatorRight") +vim.keymap.set({ "n", "t" }, "", "NavigatorUp") +vim.keymap.set({ "n", "t" }, "", "NavigatorDown") +vim.keymap.set({ "n", "t" }, "", "NavigatorPrevious") + +-- Telescope +vim.keymap.set("n", ";", "Telescope builtin") +vim.keymap.set("n", "ff", "Telescope find_files") +vim.keymap.set("n", "fg", "Telescope live_grep") +vim.keymap.set("n", "fb", "Telescope buffers") +vim.keymap.set("n", "fl", "Telescope lsp_document_symbols") +vim.keymap.set("n", "fe", "Telescope diagnostics") +vim.keymap.set("n", "fs", "Telescope treesitter") +vim.keymap.set("n", "fz", "Telescope current_buffer_fuzzy_find") +vim.keymap.set("n", "fp", "Telescope projects") + +-- Hop +vim.keymap.set("n", "hw", "HopWord") +vim.keymap.set("n", "hl", "HopLine") + +-- Neotree +vim.keymap.set("n", "nn", "Neotree float reveal reveal_force_cwd") +vim.keymap.set("n", "nb", "Neotree toggle show buffers right") +vim.keymap.set("n", "ns", "Neotree float git_status") + +-- Aerial +vim.keymap.set("n", "a", "AerialToggle!") + +-- Trouble +vim.keymap.set("n", "xx", "TroubleToggle") +vim.keymap.set("n", "xw", "TroubleToggle workspace_diagnostics") +vim.keymap.set("n", "xd", "TroubleToggle document_diagnostics") +vim.keymap.set("n", "xq", "TroubleToggle quickfix") +vim.keymap.set("n", "xl", "TroubleToggle loclist") + +-- nvim-test +vim.keymap.set("n", "ts", "TestSuite") +vim.keymap.set("n", "tf", "TestFile") +vim.keymap.set("n", "te", "TestEdit") +vim.keymap.set("n", "tn", "TestNearest") +vim.keymap.set("n", "tl", "TestLast") +vim.keymap.set("n", "tv", "TestVisit") +vim.keymap.set("n", "ti", "TestInfo") + +-- barbar +-- local map = vim.api.nvim_set_keymap +local map = vim.keymap.set +local opts = { noremap = true, silent = true } + +-- Move to previous/next +map('n', '', 'BufferPrevious', opts) +map('n', '', 'BufferNext', opts) +-- Re-order to previous/next +map('n', '', 'BufferMovePrevious', opts) +map('n', '>', 'BufferMoveNext', opts) +-- Goto buffer in position... +map('n', '', 'BufferGoto 1', opts) +map('n', '', 'BufferGoto 2', opts) +map('n', '', 'BufferGoto 3', opts) +map('n', '', 'BufferGoto 4', opts) +map('n', '', 'BufferGoto 5', opts) +map('n', '', 'BufferGoto 6', opts) +map('n', '', 'BufferGoto 7', opts) +map('n', '', 'BufferGoto 8', opts) +map('n', '', 'BufferGoto 9', opts) +map('n', '', 'BufferLast', opts) +-- Pin/unpin buffer +map('n', '', 'BufferPin', opts) +-- Close buffer +map('n', '', 'BufferClose', opts) +map('n', '', 'BufferCloseAllButCurrentOrPinned', opts) +-- Wipeout buffer +-- :BufferWipeout +-- Close commands +-- :BufferCloseAllButCurrent +-- :BufferCloseAllButPinned +-- :BufferCloseAllButCurrentOrPinned +-- :BufferCloseBuffersLeft +-- :BufferCloseBuffersRight +-- Magic buffer-picking mode +map('n', '', 'BufferPick', opts) +-- Sort automatically by... +map('n', 'bb', 'BufferOrderByBufferNumber', opts) +map('n', 'bd', 'BufferOrderByDirectory', opts) +map('n', 'bl', 'BufferOrderByLanguage', opts) +map('n', 'bw', 'BufferOrderByWindowNumber', opts) + +-- Other: +-- :BarbarEnable - enables barbar (enabled by default) +-- :BarbarDisable - very bad command, should never be used diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..686e301 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,49 @@ +return { + root = vim.fn.stdpath "data" .. "/lazy", + spec = "plugins", + lockfile = vim.fn.stdpath "data" .. "/lazy-lock.json", + dev = { + path = "~/Projects/lua/nvim", + }, + install = { + colorscheme = { "catppuccin" }, + }, + ui = { + border = "rounded", + icons = { + cmd = "⌘", + config = "", + event = "", + ft = "", + init = "", + keys = "", + plugin = "", + runtime = "", + source = "", + start = "", + task = "", + lazy = " ", + }, + }, + diff = { + cmd = "diffview.nvim", + }, + checker = { + enabled = true, + frequency = 3600, + }, + performance = { + rtp = { + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +} diff --git a/lua/config/neogit.lua b/lua/config/neogit.lua new file mode 100644 index 0000000..18043ab --- /dev/null +++ b/lua/config/neogit.lua @@ -0,0 +1,6 @@ +return { + kind = "floating", + integrations = { + diffview = true, + }, +} diff --git a/lua/config/neotree.lua b/lua/config/neotree.lua new file mode 100644 index 0000000..79fe7e0 --- /dev/null +++ b/lua/config/neotree.lua @@ -0,0 +1,29 @@ +return { + close_if_last_window = true, + use_popups_for_input = false, + filesystem = { + window = { + mappings = { + ["Z"] = "expand_all_nodes", + [""] = "toggle_node", + }, + }, + filtered_items = { + hide_dotfiles = false, + }, + group_empty_dirs = true, + hijack_netrw_behavior = "open_current", + }, + buffers = { + bind_to_cwd = true, + follow_current_file = true, + group_empty_dirs = true, + }, + git_status = { + group_empty_dirs = true, + }, + source_selector = { + winbar = true, + statusline = false, + }, +} diff --git a/lua/config/neovide.lua b/lua/config/neovide.lua new file mode 100644 index 0000000..5a4ff39 --- /dev/null +++ b/lua/config/neovide.lua @@ -0,0 +1,13 @@ +vim.opt.winblend = 50 +vim.opt.pumblend = 50 + +vim.g.neovide_padding_top = 5 +vim.g.neovide_padding_bottom = 5 +vim.g.neovide_padding_left = 5 +vim.g.neovide_padding_right = 5 + +vim.g.neovide_floating_blur_amount_x = 2.0 +vim.g.neovide_floating_blur_amount_y = 2.0 + +vim.g.neovide_hide_mouse_when_typing = true +vim.g.neovide_remember_window_size = false diff --git a/lua/config/notify.lua b/lua/config/notify.lua new file mode 100644 index 0000000..a3360d7 --- /dev/null +++ b/lua/config/notify.lua @@ -0,0 +1,5 @@ +return { + background_colour = "#000000", + fps = 60, + render = "default", -- "minimal", "simple" +} diff --git a/lua/config/nvim-autopairs.lua b/lua/config/nvim-autopairs.lua new file mode 100644 index 0000000..51db88a --- /dev/null +++ b/lua/config/nvim-autopairs.lua @@ -0,0 +1,5 @@ +return { + disable_in_macro = true, + disable_in_visualblock = true, + check_ts = true, +} diff --git a/lua/config/nvim-navic.lua b/lua/config/nvim-navic.lua new file mode 100644 index 0000000..1a20551 --- /dev/null +++ b/lua/config/nvim-navic.lua @@ -0,0 +1 @@ +return { highlight = true } diff --git a/lua/config/nvim_test.lua b/lua/config/nvim_test.lua new file mode 100644 index 0000000..3790c29 --- /dev/null +++ b/lua/config/nvim_test.lua @@ -0,0 +1,6 @@ +return { + termOpts = { + direction = "horizontal", + keep_one = true, + }, +} diff --git a/lua/config/project.lua b/lua/config/project.lua new file mode 100644 index 0000000..51f7d3a --- /dev/null +++ b/lua/config/project.lua @@ -0,0 +1,5 @@ +return { + ignore_lsp = { "efm", "null-ls" }, + show_hidden = true, + silent_chdir = true, +} diff --git a/lua/config/telescope.lua b/lua/config/telescope.lua new file mode 100644 index 0000000..1e4baf1 --- /dev/null +++ b/lua/config/telescope.lua @@ -0,0 +1,18 @@ +local trouble = require "trouble.providers.telescope" +return { + defaults = { + layout_strategy = "flex", + mappings = { + i = { [""] = trouble.open_with_trouble }, + n = { [""] = trouble.open_with_trouble }, + }, + winblend = vim.o.winblend, + }, + 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 + }, + }, +} diff --git a/lua/config/treesitter.lua b/lua/config/treesitter.lua new file mode 100644 index 0000000..81c27e0 --- /dev/null +++ b/lua/config/treesitter.lua @@ -0,0 +1,32 @@ +return { + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "gnr", + scope_incremental = "gnc", + node_decremental = "gnm", + }, + }, + indent = { + enable = true, + }, + refactor = { + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr", + }, + }, + navigation = { + enable = true, + keymaps = { + goto_definition_lsp_fallback = "gnd", + }, + }, + }, +} diff --git a/lua/config/trouble.lua b/lua/config/trouble.lua new file mode 100644 index 0000000..9d8a209 --- /dev/null +++ b/lua/config/trouble.lua @@ -0,0 +1,7 @@ +return { + mode = "workspace_diagnostics", + auto_open = false, + auto_close = false, + auto_preview = true, + auto_jump = { "lsp_definitions", "lsp_references", "lsp_implementations" }, +} diff --git a/lua/config/twilight.lua b/lua/config/twilight.lua new file mode 100644 index 0000000..5230683 --- /dev/null +++ b/lua/config/twilight.lua @@ -0,0 +1,4 @@ +return { + context = 10, + treesitter = true, +} diff --git a/lua/config/zen_mode.lua b/lua/config/zen_mode.lua new file mode 100644 index 0000000..8916021 --- /dev/null +++ b/lua/config/zen_mode.lua @@ -0,0 +1,23 @@ +return { + window = { + options = { + signcolumn = "no", -- disable signcolumn + number = false, -- disable number column + relativenumber = false, -- disable relative numbers + cursorline = false, -- disable cursorline + cursorcolumn = false, -- disable cursor column + foldcolumn = "0", -- disable fold column + list = false, -- disable whitespace characters + }, + }, + plugins = { + options = { + enabled = true, + }, + twilight = { enabled = true }, + gitsigns = { enabled = true }, + tmux = { enabled = true }, + }, + on_open = function(win) vim.wo.scrolloff = 999 end, + on_close = function(win) vim.wo.scrolloff = 0 end, +} diff --git a/lua/lsp/attach.lua b/lua/lsp/attach.lua new file mode 100644 index 0000000..589b638 --- /dev/null +++ b/lua/lsp/attach.lua @@ -0,0 +1,23 @@ +-- Use an on_attach function to only map the following keys +-- after the language server attaches to the current buffer +local on_attach = function(_, bufnr) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.definition, bufopts) + vim.keymap.set("n", "gd", "Trouble lsp_definitions", bufopts) + vim.keymap.set("n", "gR", vim.lsp.buf.references, bufopts) + vim.keymap.set("n", "gr", "Trouble lsp_references", bufopts) + vim.keymap.set("n", "gI", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "gi", "Trouble lsp_implementations", bufopts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set("n", "wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) end, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "i", require "lsp.formatting", bufopts) +end +return on_attach diff --git a/lua/lsp/cmp.lua b/lua/lsp/cmp.lua new file mode 100644 index 0000000..97f3475 --- /dev/null +++ b/lua/lsp/cmp.lua @@ -0,0 +1,98 @@ +local cmp = require "cmp" +local luasnip = require "luasnip" +local cmp_autopairs = require "nvim-autopairs.completion.cmp" + +require("luasnip.loaders.from_vscode").lazy_load() + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = cmp.mapping.preset.insert { + [""] = cmp.mapping.scroll_docs(-4), -- Up + [""] = cmp.mapping.scroll_docs(4), -- Down + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + 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 = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, +} + +-- Set configuration for specific filetype. +cmp.setup.filetype("python", { + sources = { + { name = "nvim_lsp" }, + }, +}) + +cmp.setup.filetype("nix", { + sources = { + { name = "nvim_lsp" }, + }, +}) + +cmp.setup.filetype("gitcommit", { + sources = { + { name = "nvim_lsp" }, + { name = "git" }, + { name = "spell" }, + { name = "commit" }, + { name = "buffer" }, + { name = "luasnip" }, + { name = "latex_symbols" }, + }, +}) + +cmp.setup.filetype("markdown", { + sources = { + { name = "nvim_lsp" }, + { name = "spell" }, + { name = "buffer" }, + { name = "luasnip" }, + { name = "latex_symbols" }, + }, +}) + +cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "nvim_lsp" }, + { name = "buffer" }, + }, +}) + +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "nvim_lsp" }, + { name = "path" }, + { name = "cmdline" }, + }, +}) + +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) diff --git a/lua/lsp/config.lua b/lua/lsp/config.lua new file mode 100644 index 0000000..c4a4319 --- /dev/null +++ b/lua/lsp/config.lua @@ -0,0 +1,39 @@ +local M = {} + +-- Mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +local opts = { noremap = true, silent = true } +vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) +vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) + +local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } +for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) +end + +require("neodev").setup() + +M.on_attach = require "lsp.attach" +M.lsp_flags = require "lsp.flags" +M.capabilities = require("cmp_nvim_lsp").default_capabilities() + +local servers = { "jedi_language_server", "lua_ls", "rnix", "nil_ls", "fortls" } +for _, name in ipairs(servers) do + require("lspconfig")[name].setup { + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, + } +end + +require("null-ls").setup { + sources = require "lsp.null_ls_sources", + on_attach = M.on_attach, + flags = M.lsp_flags, + capabilities = M.capabilities, +} + +return M diff --git a/lua/lsp/flags.lua b/lua/lsp/flags.lua new file mode 100644 index 0000000..3f61fca --- /dev/null +++ b/lua/lsp/flags.lua @@ -0,0 +1,5 @@ +local lsp_flags = { + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, +} +return lsp_flags diff --git a/lua/lsp/formatting.lua b/lua/lsp/formatting.lua new file mode 100644 index 0000000..796a682 --- /dev/null +++ b/lua/lsp/formatting.lua @@ -0,0 +1,11 @@ +local lsp_formatting = function(bufnr) + vim.lsp.buf.format { + bufnr = bufnr, + timeout_ms = 2000, + async = true, + filter = function(client) + return client.name ~= "jedi_language_server" and client.name ~= "lua_ls" + end, + } +end +return lsp_formatting diff --git a/lua/lsp/null_ls_sources.lua b/lua/lsp/null_ls_sources.lua new file mode 100644 index 0000000..a3a5fbf --- /dev/null +++ b/lua/lsp/null_ls_sources.lua @@ -0,0 +1,13 @@ +local null_ls = require "null-ls" +return { + null_ls.builtins.code_actions.gitsigns, + null_ls.builtins.diagnostics.zsh, + null_ls.builtins.diagnostics.mypy, + null_ls.builtins.diagnostics.ruff, + null_ls.builtins.formatting.black, + null_ls.builtins.formatting.isort, + null_ls.builtins.formatting.stylua, + null_ls.builtins.formatting.prettier, + null_ls.builtins.formatting.trim_whitespace, + null_ls.builtins.hover.dictionary, +} diff --git a/lua/plugins/aerial.lua b/lua/plugins/aerial.lua new file mode 100644 index 0000000..5c1b505 --- /dev/null +++ b/lua/plugins/aerial.lua @@ -0,0 +1,17 @@ +return { + "stevearc/aerial.nvim", + name = "aerial", + cmd = { + "AerialOpen", + "AerialOpenAll", + "AerialNext", + "AerialPrev", + "AerialGo", + "AerialInfo", + "AerialToggle", + }, + config = function() + require("aerial").setup(require "config.aerial") + vim.keymap.set("n", "fa", "Telescope aerial") + end, +} diff --git a/lua/plugins/barbar.lua b/lua/plugins/barbar.lua new file mode 100644 index 0000000..459bdc0 --- /dev/null +++ b/lua/plugins/barbar.lua @@ -0,0 +1,9 @@ +return { + "romgrk/barbar.nvim", + dependencies = "nvim-tree/nvim-web-devicons", + event = { "BufReadPre", "BufNewFile" }, + init = function() vim.g.barbar_auto_setup = false end, + config = true, + opts = require "config.barbar", + version = "^1.0.0", -- optional: only update when a new 1.x version is released +} diff --git a/lua/plugins/barbecue.lua b/lua/plugins/barbecue.lua new file mode 100644 index 0000000..995b088 --- /dev/null +++ b/lua/plugins/barbecue.lua @@ -0,0 +1,12 @@ +return { + "utilyre/barbecue.nvim", + name = "barbecue", + version = "*", + dependencies = { + "SmiteshP/nvim-navic", + "nvim-tree/nvim-web-devicons", + }, + event = { "BufReadPre", "BufNewFile" }, + -- opts = require "config.barbecue", + config = function() require("barbecue").setup(require "config.barbecue") end, +} diff --git a/lua/plugins/catppuccin.lua b/lua/plugins/catppuccin.lua new file mode 100644 index 0000000..03e74a4 --- /dev/null +++ b/lua/plugins/catppuccin.lua @@ -0,0 +1,14 @@ +return { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, + priority = 1000, + init = function() + vim.opt.termguicolors = true + require "ui.fillchars" + end, + config = function() + require("catppuccin").setup(require "config.catppuccin") + vim.cmd.colorscheme "catppuccin" + end, +} diff --git a/lua/plugins/diffview.lua b/lua/plugins/diffview.lua new file mode 100644 index 0000000..98d7182 --- /dev/null +++ b/lua/plugins/diffview.lua @@ -0,0 +1,9 @@ +return { + "sindrets/diffview.nvim", + dependencies = { "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, + cmd = { + "DiffviewFileHistory", + "DiffviewOpen", + }, + config = function() require("diffview").setup(require "config.diffview") end, +} diff --git a/lua/plugins/direnv.lua b/lua/plugins/direnv.lua new file mode 100644 index 0000000..a15276b --- /dev/null +++ b/lua/plugins/direnv.lua @@ -0,0 +1,9 @@ +return { + "https://github.com/direnv/direnv.vim.git", + name = "direnv.vim", + lazy = false, + config = function() + vim.g.direnv_auto = 1 + vim.g.direnv_silent_load = 1 + end, +} diff --git a/lua/plugins/dressing.lua b/lua/plugins/dressing.lua new file mode 100644 index 0000000..0bb9abb --- /dev/null +++ b/lua/plugins/dressing.lua @@ -0,0 +1 @@ +return { "stevearc/dressing.nvim" } diff --git a/lua/plugins/feline.lua b/lua/plugins/feline.lua new file mode 100644 index 0000000..9f00cb6 --- /dev/null +++ b/lua/plugins/feline.lua @@ -0,0 +1,6 @@ +return { + "feline-nvim/feline.nvim", + dependencies = { require "plugins.catppuccin" }, + event = { "BufReadPre", "BufNewFile" }, + config = function() require("feline").setup(require "config.feline") end, +} diff --git a/lua/plugins/fugitive.lua b/lua/plugins/fugitive.lua new file mode 100644 index 0000000..fd2b49f --- /dev/null +++ b/lua/plugins/fugitive.lua @@ -0,0 +1,5 @@ +return { + "tpope/vim-fugitive", + cmd = { "G", "Git" }, + lazy = true, +} diff --git a/lua/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..9230535 --- /dev/null +++ b/lua/plugins/gitsigns.lua @@ -0,0 +1,5 @@ +return { + "lewis6991/gitsigns.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() require("gitsigns").setup(require "config.gitsigns") end, +} diff --git a/lua/plugins/hop.lua b/lua/plugins/hop.lua new file mode 100644 index 0000000..eb6c1b7 --- /dev/null +++ b/lua/plugins/hop.lua @@ -0,0 +1,5 @@ +return { + 'phaazon/hop.nvim', + cmd = {"HopWord", "HopLine"}, + config = true, +} diff --git a/lua/plugins/indent_blankline.lua b/lua/plugins/indent_blankline.lua new file mode 100644 index 0000000..b0ee0a9 --- /dev/null +++ b/lua/plugins/indent_blankline.lua @@ -0,0 +1,5 @@ +return { + "lukas-reineke/indent-blankline.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() require("indent_blankline").setup(require "config.indent_blankline") end, +} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua new file mode 100644 index 0000000..83c7a0a --- /dev/null +++ b/lua/plugins/init.lua @@ -0,0 +1,3 @@ +return { + { "folke/lazy.nvim", cmd = "Lazy" }, +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua new file mode 100644 index 0000000..ce9b98a --- /dev/null +++ b/lua/plugins/lspconfig.lua @@ -0,0 +1,41 @@ +return { + { + "neovim/nvim-lspconfig", + event = { "BufReadPre", "BufNewFile" }, + cmd = { + "LspLog", + "LspStop", + "LspStart", + "LspRestart", + "LspInfo", + }, + dependencies = { + { "hrsh7th/nvim-cmp" }, + { "rafamadriz/friendly-snippets" }, + { "windwp/nvim-autopairs" }, + }, + config = function() + require "lsp.config" + require "lsp.cmp" + end, + }, + { + "hrsh7th/nvim-cmp", + dependencies = { + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/cmp-cmdline" }, + { "f3fora/cmp-spell" }, + { "petertriho/cmp-git" }, + { "Dosx001/cmp-commit" }, + { "kdheepak/cmp-latex-symbols" }, + { "L3MON4D3/LuaSnip" }, + { "saadparwaiz1/cmp_luasnip" }, + }, + cmd = "CmpStatus", + }, + { "jose-elias-alvarez/null-ls.nvim", dependencies = { "neovim/nvim-lspconfig" }, lazy = true }, + { "mfussenegger/nvim-dap", dependencies = { "neovim/nvim-lspconfig" }, lazy = true }, + { "folke/neodev.nvim", dependencies = { "neovim/nvim-lspconfig", "hrsh7th/nvim-cmp" }, lazy = true }, +} diff --git a/lua/plugins/navigator.lua b/lua/plugins/navigator.lua new file mode 100644 index 0000000..3dc499f --- /dev/null +++ b/lua/plugins/navigator.lua @@ -0,0 +1,11 @@ +return { + "numToStr/Navigator.nvim", + cmd = { + "NavigatorUp", + "NavigatorDown", + "NavigatorLeft", + "NavigatorRight", + "NavigatorPrevious", + }, + config = function() require("Navigator").setup() end, +} diff --git a/lua/plugins/neogit.lua b/lua/plugins/neogit.lua new file mode 100644 index 0000000..f3cc6b1 --- /dev/null +++ b/lua/plugins/neogit.lua @@ -0,0 +1,9 @@ +return { + "TimUntersberger/neogit", + config = function() require("neogit").setup(require "config.neogit") end, + cmd = "Neogit", + dependencies = { + "nvim-lua/plenary.nvim", + "sindrets/diffview.nvim", + }, +} diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..38e19f4 --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,17 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v2.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + }, + cmd = "NeoTree", + event = { "BufEnter" }, + init = function() + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + vim.g.neo_tree_remove_legacy_commands = 1 + end, + config = function() require("neo-tree").setup(require "config.neotree") end, +} diff --git a/lua/plugins/notify.lua b/lua/plugins/notify.lua new file mode 100644 index 0000000..5d63ecd --- /dev/null +++ b/lua/plugins/notify.lua @@ -0,0 +1,7 @@ +return { + "rcarriga/nvim-notify", + config = function() + require("notify").setup(require "config.notify") + vim.notify = require "notify" + end, +} diff --git a/lua/plugins/nvim_autopairs.lua b/lua/plugins/nvim_autopairs.lua new file mode 100644 index 0000000..b8a1b3c --- /dev/null +++ b/lua/plugins/nvim_autopairs.lua @@ -0,0 +1,9 @@ +return { + "windwp/nvim-autopairs", + lazy = true, + dependencies = { + "nvim-treesitter/nvim-treesitter", + "hrsh7th/nvim-cmp", + }, + config = function() require("nvim-autopairs").setup(require "config.nvim-autopairs") end, +} diff --git a/lua/plugins/nvim_navic.lua b/lua/plugins/nvim_navic.lua new file mode 100644 index 0000000..d53de2f --- /dev/null +++ b/lua/plugins/nvim_navic.lua @@ -0,0 +1,6 @@ +return { + "SmiteshP/nvim-navic", + dependencies = "neovim/nvim-lspconfig", + lazy = true, + opts = require "config.nvim-navic", +} diff --git a/lua/plugins/nvim_test.lua b/lua/plugins/nvim_test.lua new file mode 100644 index 0000000..539b165 --- /dev/null +++ b/lua/plugins/nvim_test.lua @@ -0,0 +1,13 @@ +return { + "klen/nvim-test", + cmd = { + "TestFile", + "TestEdit", + "TestNearest", + "TestLast", + "TestVisit", + "TestInfo", + "TestSuite", + }, + config = function() require("nvim-test").setup(require "config.nvim_test") end, +} diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua new file mode 100644 index 0000000..e97cf62 --- /dev/null +++ b/lua/plugins/project.lua @@ -0,0 +1,5 @@ +return { + "ahmedkhalf/project.nvim", + event = { "BufReadPre", "BufNewFile" }, + config = function() require("project_nvim").setup(require "config.project") end, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..6fb34c2 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,46 @@ +return { + "nvim-telescope/telescope.nvim", + branch = "0.1.x", + cmd = "Telescope", + config = function() + require("telescope").setup(require "config.telescope") + require("telescope").load_extension "fzf" + require("telescope").load_extension "lazy" + require("telescope").load_extension "luasnip" + require("telescope").load_extension "git_diffs" + require("telescope").load_extension "command_center" + require("telescope").load_extension "http" + require("telescope").load_extension "advanced_git_search" + require("telescope").load_extension "projects" + end, + dependencies = { + { + "nvim-lua/plenary.nvim", + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + }, + { + "tsakirist/telescope-lazy.nvim", + dependencies = { "folke/lazy.nvim" }, + }, + { + "benfowler/telescope-luasnip.nvim", + dependencies = { "L3MON4D3/LuaSnip" }, + }, + { + "paopaol/telescope-git-diffs.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "sindrets/diffview.nvim", + }, + }, + "FeiyouG/command_center.nvim", + { + "barrett-ruth/telescope-http.nvim", + dependencies = { "savq/paq-nvim" }, + }, + "aaronhallaert/advanced-git-search.nvim", + }, + }, +} diff --git a/lua/plugins/toggleterm.lua b/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..51ed98e --- /dev/null +++ b/lua/plugins/toggleterm.lua @@ -0,0 +1,6 @@ +return { + "akinsho/toggleterm.nvim", + version = "*", + config = true, + cmd = { "ToggleTerm" }, +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..bdabfdc --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,16 @@ +return { + "nvim-treesitter/nvim-treesitter", + event = { "BufReadPre", "BufNewFile" }, + cmd = { + "TSToggle", + "TSBufEnable", + "TSBufToggle", + "TSInstall", + "TSUpdate", + "TSEnable", + }, + config = function() require("nvim-treesitter.configs").setup(require "config.treesitter") end, + dependencies = { + "nvim-treesitter/nvim-treesitter-refactor", + }, +} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua new file mode 100644 index 0000000..1db5241 --- /dev/null +++ b/lua/plugins/trouble.lua @@ -0,0 +1,6 @@ +return { + "folke/trouble.nvim", + dependencies = "nvim-tree/nvim-web-devicons", + cmd = "TroubleToggle", + config = function() require("trouble").setup(require "config.trouble") end, +} diff --git a/lua/plugins/which_key.lua b/lua/plugins/which_key.lua new file mode 100644 index 0000000..82b680d --- /dev/null +++ b/lua/plugins/which_key.lua @@ -0,0 +1,8 @@ +return { + "folke/which-key.nvim", + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + require("which-key").setup {} + end, +} diff --git a/lua/plugins/zen_mode.lua b/lua/plugins/zen_mode.lua new file mode 100644 index 0000000..4dcabd2 --- /dev/null +++ b/lua/plugins/zen_mode.lua @@ -0,0 +1,13 @@ +return { + "folke/zen-mode.nvim", + cmd = "ZenMode", + config = function() require("zen-mode").setup(require "config.zen_mode") end, + dependencies = { + "folke/twilight.nvim", + cmd = "Twilight", + config = function() require("twilight").setup(require "config.twilight") end, + dependencies = { + "nvim-treesitter", + }, + }, +} diff --git a/lua/ui/feline_components.lua b/lua/ui/feline_components.lua new file mode 100644 index 0000000..efced01 --- /dev/null +++ b/lua/ui/feline_components.lua @@ -0,0 +1,478 @@ +local M = {} + +local C = require("catppuccin.palettes").get_palette() +local lsp = require "feline.providers.lsp" + +local assets = { + left_separator = "", + right_separator = "", + mode_icon = "", + dir = "", + file = "", + lsp = { + server = "", + error = "", + warning = "", + info = "", + hint = "", + }, + git = { + branch = "", + added = "", + changed = "", + removed = "", + }, +} + +local sett = { + text = C.surface0, + bkg = C.surface0, + diffs = C.mauve, + extras = C.overlay1, + curr_file = C.maroon, + curr_dir = C.flamingo, + show_modified = false, +} + +if require("catppuccin").flavour == "latte" then + local latte = require("catppuccin.palettes").get_palette "latte" + sett.text = latte.base + sett.bkg = latte.crust +end + +if require("catppuccin").options.transparent_background then sett.bkg = "NONE" end + +local mode_colors = { + ["n"] = { "NORMAL", C.lavender }, + ["no"] = { "N-PENDING", C.lavender }, + ["i"] = { "INSERT", C.green }, + ["ic"] = { "INSERT", C.green }, + ["t"] = { "TERMINAL", C.green }, + ["v"] = { "VISUAL", C.flamingo }, + ["V"] = { "V-LINE", C.flamingo }, + [""] = { "V-BLOCK", C.flamingo }, + ["R"] = { "REPLACE", C.maroon }, + ["Rv"] = { "V-REPLACE", C.maroon }, + ["s"] = { "SELECT", C.maroon }, + ["S"] = { "S-LINE", C.maroon }, + [""] = { "S-BLOCK", C.maroon }, + ["c"] = { "COMMAND", C.peach }, + ["cv"] = { "COMMAND", C.peach }, + ["ce"] = { "COMMAND", C.peach }, + ["r"] = { "PROMPT", C.teal }, + ["rm"] = { "MORE", C.teal }, + ["r?"] = { "CONFIRM", C.mauve }, + ["!"] = { "SHELL", C.green }, +} + +function M.setup(opts) + if opts then + opts.assets = opts.assets or {} + opts.sett = opts.sett or {} + opts.mode_colors = opts.mode_colors or {} + else + opts = {} + end + assets = vim.tbl_deep_extend("force", assets, opts.assets) + sett = vim.tbl_deep_extend("force", sett, opts.sett) + mode_colors = vim.tbl_deep_extend("force", mode_colors, opts.mode_colors) +end + +function M.get() + local shortline = false + + local components = { + active = { {}, {} }, -- left, right + inactive = { {} }, + } + + local function is_enabled(min_width) + if shortline then return true end + + return vim.api.nvim_win_get_width(0) > min_width + end + + -- global components + local invi_sep = { + str = " ", + hl = { + fg = sett.bkg, + bg = sett.bkg, + }, + } + + -- helpers + local function any_git_changes() + local gst = vim.b.gitsigns_status_dict -- git stats + if gst then + if + gst["added"] and gst["added"] > 0 + or gst["removed"] and gst["removed"] > 0 + or gst["changed"] and gst["changed"] > 0 + then + return true + end + end + return false + end + + -- #################### STATUSLINE -> + + -- ######## Left + + -- Current vi mode ------> + local vi_mode_hl = function() + return { + fg = sett.text, + bg = mode_colors[vim.fn.mode()][2], + style = "bold", + } + end + + components.active[1][1] = { + provider = " " .. assets.mode_icon .. " ", + hl = function() + return { + fg = sett.text, + bg = mode_colors[vim.fn.mode()][2], + } + end, + } + + components.active[1][2] = { + provider = function() return mode_colors[vim.fn.mode()][1] .. " " end, + hl = vi_mode_hl, + } + + -- there is a dilema: we need to hide Diffs if ther is no git info. We can do that, but this will + -- leave the right_separator colored with purple, and since we can't change the color conditonally + -- then the solution is to create two right_separators: one with a mauve sett.bkg and the other one normal + -- sett.bkg; both have the same fg (vi mode). The mauve one appears if there is git info, else the one with + -- the normal sett.bkg appears. Fixed :) + + -- enable if git diffs are not available + components.active[1][3] = { + provider = assets.right_separator, + hl = function() + return { + fg = mode_colors[vim.fn.mode()][2], + bg = sett.bkg, + } + end, + enabled = function() return not any_git_changes() end, + } + + -- enable if git diffs are available + components.active[1][4] = { + provider = assets.right_separator, + hl = function() + return { + fg = mode_colors[vim.fn.mode()][2], + bg = sett.diffs, + } + end, + enabled = function() return any_git_changes() end, + } + -- Current vi mode ------> + + -- Diffs ------> + components.active[1][5] = { + provider = "git_diff_added", + hl = { + fg = sett.text, + bg = sett.diffs, + }, + icon = " " .. assets.git.added .. " ", + } + + components.active[1][6] = { + provider = "git_diff_changed", + hl = { + fg = sett.text, + bg = sett.diffs, + }, + icon = " " .. assets.git.changed .. " ", + } + + components.active[1][7] = { + provider = "git_diff_removed", + hl = { + fg = sett.text, + bg = sett.diffs, + }, + icon = " " .. assets.git.removed .. " ", + } + + components.active[1][8] = { + provider = " ", + hl = { + fg = sett.bkg, + bg = sett.diffs, + }, + enabled = function() return any_git_changes() end, + } + + components.active[1][9] = { + provider = assets.right_separator, + hl = { + fg = sett.diffs, + bg = sett.bkg, + }, + enabled = function() return any_git_changes() end, + } + -- Diffs ------> + + -- Extras ------> + + -- file progess + components.active[1][10] = { + provider = function() + local current_line = vim.fn.line "." + local total_line = vim.fn.line "$" + + if current_line == 1 then + return "Top" + elseif current_line == vim.fn.line "$" then + return "Bot" + end + local result, _ = math.modf((current_line / total_line) * 100) + return result .. "%%" + end, + -- enabled = shortline or function(winid) + -- return vim.api.nvim_win_get_width(winid) > 90 + -- end, + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + left_sep = invi_sep, + } + + -- position + components.active[1][11] = { + provider = "position", + -- enabled = shortline or function(winid) + -- return vim.api.nvim_win_get_width(winid) > 90 + -- end, + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + left_sep = invi_sep, + } + + -- macro + components.active[1][12] = { + provider = "macro", + enabled = function() return vim.api.nvim_get_option "cmdheight" == 0 end, + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + left_sep = invi_sep, + } + + -- search count + components.active[1][13] = { + provider = "search_count", + enabled = function() return vim.api.nvim_get_option "cmdheight" == 0 end, + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + left_sep = invi_sep, + } + -- Extras ------> + + -- ######## Left + -- treesitter position + -- components.active[1][14] = { + -- provider = function() + -- -- if not require("vim.treesitter.language").require_language("lua") then + -- -- return "" + -- -- end + -- local pos = require("nvim-treesitter").statusline { + -- indicator_size = 50, + -- transform_fn = function(line) return line:gsub("%s*[%[%(%{]+.*$", "") end, + -- } + -- if pos and pos ~= "" then return pos end + -- return "" + -- end, + -- hl = { + -- fg = sett.extras, + -- bg = sett.bkg, + -- }, + -- left_sep = invi_sep, + -- } + + -- ######## Right + + -- Diagnostics ------> + -- workspace loader + components.active[2][1] = { + provider = function() + local Lsp = vim.lsp.util.get_progress_messages()[1] + + if Lsp then + local msg = Lsp.message or "" + local percentage = Lsp.percentage + if not percentage then return "" end + local title = Lsp.title or "" + local spinners = { + "", + "", + "", + } + local success_icon = { + "", + "", + "", + } + local ms = vim.loop.hrtime() / 1000000 + local frame = math.floor(ms / 120) % #spinners + + if percentage >= 70 then + return string.format(" %%<%s %s %s (%s%%%%) ", success_icon[frame + 1], title, msg, percentage) + end + + return string.format(" %%<%s %s %s (%s%%%%) ", spinners[frame + 1], title, msg, percentage) + end + + return "" + end, + enabled = is_enabled(80), + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + right_sep = invi_sep, + } + + components.active[2][2] = { + provider = "git_branch", + enabled = is_enabled(70), + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + icon = assets.git.branch .. " ", + right_sep = invi_sep, + } + + components.active[2][3] = { + provider = function() + if next(vim.lsp.buf_get_clients()) ~= nil then + return assets.lsp.server .. " " .. "Lsp" + else + return "" + end + end, + hl = { + fg = sett.extras, + bg = sett.bkg, + }, + right_sep = invi_sep, + } + + -- genral diagnostics (errors, warnings. info and hints) + components.active[2][4] = { + provider = "diagnostic_errors", + enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.ERROR) end, + + hl = { + fg = C.red, + bg = sett.bkg, + }, + icon = " " .. assets.lsp.error .. " ", + right_sep = invi_sep, + } + + components.active[2][5] = { + provider = "diagnostic_warnings", + enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.WARN) end, + hl = { + fg = C.yellow, + bg = sett.bkg, + }, + icon = " " .. assets.lsp.warning .. " ", + right_sep = invi_sep, + } + + components.active[2][6] = { + provider = "diagnostic_info", + enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.INFO) end, + hl = { + fg = C.sky, + bg = sett.bkg, + }, + icon = " " .. assets.lsp.info .. " ", + right_sep = invi_sep, + } + + components.active[2][7] = { + provider = "diagnostic_hints", + enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.HINT) end, + hl = { + fg = C.rosewater, + bg = sett.bkg, + }, + icon = " " .. assets.lsp.hint .. " ", + right_sep = invi_sep, + } + -- Diagnostics ------> + + components.active[2][8] = { + provider = function() + local filename = vim.fn.expand "%:t" + local extension = vim.fn.expand "%:e" + local present, icons = pcall(require, "nvim-web-devicons") + local icon = present and icons.get_icon(filename, extension) or assets.file + return (sett.show_modified and "%m" or "") .. " " .. icon .. " " .. filename .. " " + end, + enabled = is_enabled(70), + hl = { + fg = sett.text, + bg = sett.curr_file, + }, + left_sep = { + str = assets.left_separator, + hl = { + fg = sett.curr_file, + bg = sett.bkg, + }, + }, + } + + components.active[2][9] = { + provider = function() + local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") + return " " .. assets.dir .. " " .. dir_name .. " " + end, + enabled = is_enabled(80), + hl = { + fg = sett.text, + bg = sett.curr_dir, + }, + left_sep = { + str = assets.left_separator, + hl = { + fg = sett.curr_dir, + bg = sett.curr_file, + }, + }, + } + -- ######## Right + + -- Inanctive components + components.inactive[1][1] = { + provider = function() return " " .. string.upper(vim.bo.ft) .. " " end, + hl = { + fg = C.overlay2, + bg = C.mantle, + }, + } + + return components +end + +return M diff --git a/lua/ui/fillchars.lua b/lua/ui/fillchars.lua new file mode 100644 index 0000000..61a2aa0 --- /dev/null +++ b/lua/ui/fillchars.lua @@ -0,0 +1,9 @@ +vim.opt.fillchars:append { + horiz = "━", + horizup = "┻", + horizdown = "┳", + vert = "┃", + vertleft = "┨", + vertright = "┣", + verthoriz = "╋", +}