aboutsummaryrefslogtreecommitdiff
path: root/lua/user
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2022-10-19 23:55:51 +0200
committersrdusr <trevorgray@srdusr.com>2022-10-19 23:55:51 +0200
commit27a7c25f0727b373b5d0e4693d5bb2cb4c9c3a88 (patch)
treee6a22147b9ff4bf1a4dbe30ae0072a569a6f1e4c /lua/user
parent8242c19f6427996a94e6f6079b11ccebdb003cf2 (diff)
downloaddotfiles-27a7c25f0727b373b5d0e4693d5bb2cb4c9c3a88.tar.gz
dotfiles-27a7c25f0727b373b5d0e4693d5bb2cb4c9c3a88.zip
Made Sourcing lua config easier
Diffstat (limited to 'lua/user')
-rw-r--r--lua/user/autopairs.lua33
-rw-r--r--lua/user/cmp-gh-source.lua72
-rw-r--r--lua/user/cmp.lua264
-rw-r--r--lua/user/colorizer.lua6
-rw-r--r--lua/user/colorscheme.lua33
-rw-r--r--lua/user/git.lua11
-rw-r--r--lua/user/gitsigns.lua1
-rw-r--r--lua/user/heirline.lua1203
-rw-r--r--lua/user/keys.lua531
-rw-r--r--lua/user/linecolor.lua112
-rw-r--r--lua/user/lsp-colors.lua9
-rw-r--r--lua/user/lsp.lua584
-rw-r--r--lua/user/lspkind.lua47
-rw-r--r--lua/user/lspsaga.lua145
-rw-r--r--lua/user/lualine.lua423
-rw-r--r--lua/user/luasnip.lua80
-rw-r--r--lua/user/mason.lua27
-rw-r--r--lua/user/modify-blend.lua40
-rw-r--r--lua/user/mods.lua138
-rw-r--r--lua/user/neoscroll.lua21
-rw-r--r--lua/user/null-ls.lua26
-rw-r--r--lua/user/nvim-tree.lua68
-rw-r--r--lua/user/opts.lua181
-rw-r--r--lua/user/pack.lua360
-rw-r--r--lua/user/prettier.lua19
-rw-r--r--lua/user/reload.lua50
-rw-r--r--lua/user/scripts/lsp-ext.lua48
-rw-r--r--lua/user/scripts/setcolors.lua121
-rw-r--r--lua/user/scripts/toggleLsp.lua40
-rw-r--r--lua/user/tabline.lua22
-rw-r--r--lua/user/telescope.lua223
-rw-r--r--lua/user/toggleterm.lua90
-rw-r--r--lua/user/treesitter.lua34
-rw-r--r--lua/user/utils.lua66
-rw-r--r--lua/user/web-devicons.lua12
-rw-r--r--lua/user/winbar.lua35
-rw-r--r--lua/user/zen-mode.lua7
37 files changed, 5182 insertions, 0 deletions
diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua
new file mode 100644
index 0000000..577e571
--- /dev/null
+++ b/lua/user/autopairs.lua
@@ -0,0 +1,33 @@
+-- Setup nvim-cmp.
+local status_ok, npairs = pcall(require, "nvim-autopairs")
+if not status_ok then
+ return
+end
+
+npairs.setup {
+ check_ts = true,
+ ts_config = {
+ lua = { "string", "source" },
+ javascript = { "string", "template_string" },
+ java = false,
+ },
+ disable_filetype = { "TelescopePrompt", "spectre_panel" },
+ fast_wrap = {
+ map = "<M-e>",
+ chars = { "{", "[", "(", '"', "'" },
+ pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
+ offset = 0, -- Offset from pattern match
+ end_key = "$",
+ keys = "qwertyuiopzxcvbnmasdfghjkl",
+ check_comma = true,
+ highlight = "PmenuSel",
+ highlight_grey = "LineNr",
+ },
+}
+
+local cmp_autopairs = require "nvim-autopairs.completion.cmp"
+local cmp_status_ok, cmp = pcall(require, "cmp")
+if not cmp_status_ok then
+ return
+end
+cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } })
diff --git a/lua/user/cmp-gh-source.lua b/lua/user/cmp-gh-source.lua
new file mode 100644
index 0000000..05bba55
--- /dev/null
+++ b/lua/user/cmp-gh-source.lua
@@ -0,0 +1,72 @@
+local ok, Job = pcall(require, "plenary.job")
+if not ok then
+ return
+end
+
+local source = {}
+
+source.new = function()
+ local self = setmetatable({ cache = {} }, { __index = source })
+
+ return self
+end
+
+source.complete = function(self, _, callback)
+ local bufnr = vim.api.nvim_get_current_buf()
+
+ -- This just makes sure that we only hit the GH API once per session.
+ --
+ -- You could remove this if you wanted, but this just makes it so we're
+ -- good programming citizens.
+ if not self.cache[bufnr] then
+ Job
+ :new({
+ -- Uses `gh` executable to request the issues from the remote repository.
+ "gh",
+ "issue",
+ "list",
+ "--limit",
+ "1000",
+ "--json",
+ "title,number,body",
+
+ on_exit = function(job)
+ local result = job:result()
+ local ok, parsed = pcall(vim.json.decode, table.concat(result, ""))
+ if not ok then
+ vim.notify "Failed to parse gh result"
+ return
+ end
+
+ local items = {}
+ for _, gh_item in ipairs(parsed) do
+ gh_item.body = string.gsub(gh_item.body or "", "\r", "")
+
+ table.insert(items, {
+ label = string.format("#%s", gh_item.number),
+ documentation = {
+ kind = "markdown",
+ value = string.format("# %s\n\n%s", gh_item.title, gh_item.body),
+ },
+ })
+ end
+
+ callback { items = items, isIncomplete = false }
+ self.cache[bufnr] = items
+ end,
+ })
+ :start()
+ else
+ callback { items = self.cache[bufnr], isIncomplete = false }
+ end
+end
+
+source.get_trigger_characters = function()
+ return { "#" }
+end
+
+source.is_available = function()
+ return vim.bo.filetype == "gitcommit"
+end
+
+require("cmp").register_source("gh_issues", source.new())
diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua
new file mode 100644
index 0000000..77a4943
--- /dev/null
+++ b/lua/user/cmp.lua
@@ -0,0 +1,264 @@
+
+-- Setup nvim-cmp.
+--vim.opt.completeopt = "menu,menuone,noselect"
+vim.g.completeopt = "menu,menuone,noselect,noinsert"
+local cmp_status_ok, cmp = pcall(require, "cmp")
+if not cmp_status_ok then
+ return
+end
+--local WIDE_HEIGHT = 40
+
+local opts = {
+ -- whether to highlight the currently hovered symbol
+ -- disable if your cpu usage is higher than you want it
+ -- or you just hate the highlight
+ -- default: true
+ highlight_hovered_item = true,
+ show_guides = true,
+}
+require("symbols-outline").setup(opts)
+
+
+--local snippets_paths = function()
+-- local plugins = { "friendly-snippets" }
+-- local paths = {}
+-- local path
+-- local root_path = vim.env.HOME .. "/.vim/plugged/"
+-- for _, plug in ipairs(plugins) do
+-- path = root_path .. plug
+-- if vim.fn.isdirectory(path) ~= 0 then
+-- table.insert(paths, path)
+-- end
+-- end
+-- return paths
+--end
+--
+--require("luasnip.loaders.from_vscode").lazy_load({
+-- paths = snippets_paths(),
+-- include = nil, -- Load all languages
+-- exclude = {},
+--})
+
+require("luasnip.loaders.from_vscode").lazy_load()
+local lspkind = require("lspkind")
+local kind_icons = {
+ Text = "",
+ Method = "m", --"",
+ Function = "",
+ Constructor = "", --"⚙️",
+ Field = "",
+ Variable = "",
+ Class = "",
+ Interface = "",
+ Module = "",
+ Property = "",
+ Unit = "",
+ Value = "",
+ Enum = "",
+ Keyword = "",
+ Snippet = "",
+ Color = "",
+ File = "",
+ Reference = "",
+ Folder = "",
+ EnumMember = "",
+ Constant = "",
+ Struct = "",
+ Event = "",
+ Operator = "",
+ TypeParameter = "",
+}
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ require("luasnip").lsp_expand(args.body)
+ end,
+ },
+ mapping = cmp.mapping.preset.insert({
+-- ["<CR>"] = cmp.mapping.confirm({
+-- behavior = cmp.ConfirmBehavior.Replace,
+-- select = true,
+-- }),
+ ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
+ ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
+ ['<C-y>'] = cmp.mapping.confirm({ select = true }),
+ --["<C-e>"] = cmp.mapping.close(),
+ ['<C-e>'] = cmp.mapping({
+ i = cmp.mapping.abort(),
+ c = cmp.mapping.close(),
+ }),
+ --['<CR>'] = cmp.config.disable,
+ ["<C-u>"] = cmp.mapping.scroll_docs(-4),
+ ["<C-d>"] = cmp.mapping.scroll_docs(4),
+ ["<C-Space>"] = cmp.mapping.complete(),
+ ['<C-o>'] = function(fallback)
+ if cmp.visible() then
+ cmp.mapping.confirm({ select = true })(fallback)
+ else
+ cmp.mapping.complete()(fallback)
+ end
+ end
+ }),
+
+ sources = cmp.config.sources({
+ { name = "path" },
+ { name = "nvim_lua" },
+ { name = "gh_issues" },
+ { name = "nvim_lsp", keyword_length = 3 },
+ { name = "luasnip", keyword_length = 4 },
+ --{ name = "buffer", keyword_length = 3 },
+ { name = "buffer", option = { get_bufnrs = function()
+ return vim.api.nvim_list_bufs()
+ end
+ }},
+ { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
+ { name = "cmp_git"},
+ --{ name = 'treesitter' },
+ --{ name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=] }, --exclamation mark hangs a bit without this
+ --{name = 'luasnip', keyword_length = 2},
+ }),
+ formatting = {
+ --formatting = {
+ --local icons = kind_icons
+ --format = function(entry, vim_item)
+ ----vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
+ ----vim_item.kind = lspkind.presets.default[vim_item.kind]
+ --vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
+ ----vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
+ --vim_item.menu = ({
+ ----nvim_lsp = "LSP",
+ ----luasnip = "snip",
+ ----buffer = "buf",
+ ----path = "path",
+ ----cmdline = "cmd",
+ --buffer = "[buf]",
+ --nvim_lsp = "[LSP]",
+ --nvim_lua = "[api]",
+ --path = "[path]",
+ --luasnip = "[snip]",
+ --cmdline = "[cmd]",
+ --gh_issues = "[issues]",
+ --})[entry.source.name]
+ --return vim_item
+ --end,
+ format = lspkind.cmp_format {
+ with_text = true,
+ menu = {
+ buffer = "[buf]",
+ nvim_lsp = "[LSP]",
+ nvim_lua = "[api]",
+ path = "[path]",
+ luasnip = "[snip]",
+ gh_issues = "[issues]",
+ },
+ },
+ --},
+
+ --
+ --
+ --fields = { "abbr", "kind", "menu" },
+ -- format = lspkind.cmp_format({
+ -- mode = 'symbol_text', -- show only symbol annotations
+ -- maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
+ -- })
+ --format = require('lspkind').cmp_format {
+ -- with_text = true,
+ -- menu = {
+ -- luasnip = "Snip",
+ -- buffer = "Buf",
+ -- nvim_lsp = "LSP",
+ -- path = "Path",
+ -- cmdline = "Cmd",
+ -- cmp_git = "Git",
+ -- },
+ --},
+ },
+ --format = function(entry, vim_item)
+ -- -- Kind icons
+ -- --vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
+ -- vim_item.kind = lspkind.presets.default[vim_item.kind]
+ -- -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
+ -- vim_item.menu = ({
+ -- nvim_lsp = "LSP",
+ -- luasnip = "Snip",
+ -- buffer = "Buf",
+ -- path = "Path",
+ -- cmdline = "Cmd",
+ -- })[entry.source.name]
+ -- return vim_item
+ --end,
+ confirm_opts = {
+ behavior = cmp.ConfirmBehavior.Replace,
+ select = false,
+ },
+
+
+ event = {},
+
+ experimental = {
+ ghost_text = true,
+ hl_group = 'Nontext',
+ native_menu = false,
+ },
+
+ view = {
+ entries = { name = 'custom', selection_order = 'top_down' },
+ },
+
+ window = {
+ --completion = cmp.config.window.bordered(),
+ completion = {
+ border = { '', '', '', ' ', '', '', '', ' ' },
+ --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
+ --border = { '', '', '', '', '', '', '', '' },
+ --border = "CmpBorder",
+ winhighlight = 'Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None',
+ --winhighlight = "Normal:CmpPmenu,CursorLine:PmenuSel,Search:None",
+ },
+ --documentation = cmp.config.window.bordered(),
+ documentation = {
+ --max_height = math.floor(WIDE_HEIGHT * (WIDE_HEIGHT / vim.o.lines)),
+ --max_width = math.floor((WIDE_HEIGHT * 2) * (vim.o.columns / (WIDE_HEIGHT * 2 * 16 / 9))),
+ border = { '', '', '', ' ', '', '', '', ' ' },
+ --border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
+ winhighlight = 'FloatBorder:NormalFloat',
+ },
+ },
+})
+
+
+cmp.setup.cmdline({ '/', '?' }, {
+ mapping = cmp.mapping.preset.cmdline(),
+ sources = {
+ { name = "buffer" },
+ },
+})
+
+cmp.setup.cmdline(":", {
+ mapping = {
+ ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
+ ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
+ ["<C-y>"] = cmp.mapping(cmp.mapping.confirm({ select = true }), { 'i', 'c' }),
+ ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { 'i', 'c' }),
+ ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
+ ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
+ ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
+ --["<C-k>"] = cmp.mapping.select_prev_item(),
+ --["<C-j>"] = cmp.mapping.select_next_item(),
+ --['<C-y>'] = cmp.mapping.confirm({ select = true }),
+ --["<C-e>"] = cmp.mapping.close(),
+ ----['<CR>'] = cmp.config.disable,
+ --["<C-u>"] = cmp.mapping.scroll_docs(-4),
+ --["<C-d>"] = cmp.mapping.scroll_docs(4),
+ --["<C-Space>"] = cmp.mapping.complete(),
+ },
+
+ sources = cmp.config.sources({
+ { name = "path" },
+ }, {
+ --{ name = "cmdline" },
+ { name = "cmdline", keyword_pattern = [=[[^[:blank:]\!]*]=], keyword_length = 3 },
+ })
+})
+
+
diff --git a/lua/user/colorizer.lua b/lua/user/colorizer.lua
new file mode 100644
index 0000000..14d25e2
--- /dev/null
+++ b/lua/user/colorizer.lua
@@ -0,0 +1,6 @@
+local status, colorizer = pcall(require, "colorizer")
+if (not status) then return end
+
+colorizer.setup({
+ '*';
+})
diff --git a/lua/user/colorscheme.lua b/lua/user/colorscheme.lua
new file mode 100644
index 0000000..3ded54c
--- /dev/null
+++ b/lua/user/colorscheme.lua
@@ -0,0 +1,33 @@
+-- Colorscheme
+-- ayu gruvbox molokai onedark srcery everblush vscode edge nightfly doom-one
+local colorscheme = "doom-one"
+local status_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
+if not status_ok then
+ vim.notify("colorscheme " .. colorscheme .. " not found!")
+ return
+end
+
+vim.api.nvim_command("syntax on")
+vim.api.nvim_command("highlight Normal guibg=none")
+vim.api.nvim_command("highlight SignColumn guibg=none")
+vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold")
+--vim.api.nvim_command("highlight TabLine guibg=none gui=bold")
+--vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold")
+--vim.api.nvim_command("highlight StatusLine guibg=#333842 guifg=#d6d3ea gui=bold")
+--vim.api.nvim_command("highlight StatusLine guibg=none gui=bold")
+--vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold")
+--vim.api.nvim_command("highlight TabLineSel guibg=#bd93f9 gui=bold")
+vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold")
+vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold")
+vim.api.nvim_command("highlight WinBar guibg=none gui=bold")
+vim.api.nvim_command("highlight NormalFloat guibg=none")
+vim.api.nvim_command("highlight MsgSeparator guibg=none")
+--vim.api.nvim_command("highlight PmenuSel guibg=none")
+--vim.api.nvim_command("highlight winblend guibg=none")
+--vim.api.nvim_command("highlight StatusLine guibg=none gui=bold")
+--vim.api.nvim_command("highlight StatusLineNC guibg=none gui=bold")
+--vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold")
+
+require("notify").setup({
+ background_colour = "#000000",
+})
diff --git a/lua/user/git.lua b/lua/user/git.lua
new file mode 100644
index 0000000..963f7f9
--- /dev/null
+++ b/lua/user/git.lua
@@ -0,0 +1,11 @@
+local status, git = pcall(require, "git")
+if (not status) then return end
+
+git.setup({
+ keymaps = {
+ -- Open blame window
+ blame = "<Leader>gb",
+ -- Open file/folder in git repository
+ browse = "<Leader>go",
+ }
+})
diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua
new file mode 100644
index 0000000..53d1a1e
--- /dev/null
+++ b/lua/user/gitsigns.lua
@@ -0,0 +1 @@
+require('gitsigns').setup {}
diff --git a/lua/user/heirline.lua b/lua/user/heirline.lua
new file mode 100644
index 0000000..f17f523
--- /dev/null
+++ b/lua/user/heirline.lua
@@ -0,0 +1,1203 @@
+local conditions = require("heirline.conditions")
+local utils = require("heirline.utils")
+
+local colors = {
+ --bg = "#23232e",
+ bg = nil,
+ nobg = nil,
+ white = "#f8f8f2",
+ black = "#000000",
+ darkgray = "#23232e",
+ gray = "#2d2b3a",
+ lightgray = "#d6d3ea",
+ pink = "#f92672",
+ green = "#50fa7b",
+ blue = "#39BAE6",
+ yellow = "#f1fa8c",
+ orange = "#ffb86c",
+ purple = "#BF40BF",
+ violet = "#7F00FF",
+ red = "#ff5555",
+ cyan = "#66d9eC",
+ diag = {
+ warn = utils.get_highlight("DiagnosticSignWarn").fg,
+ error = utils.get_highlight("DiagnosticSignError").fg,
+ hint = utils.get_highlight("DiagnosticSignHint").fg,
+ info = utils.get_highlight("DiagnosticSignInfo").fg,
+ },
+ git = {
+ del = "#e95678",
+ add = "#a6e22e",
+ change = "#ae81ff",
+ },
+}
+
+require("heirline").load_colors(colors)
+
+local Align = { provider = "%=", hl = { bg = colors.bg } }
+local Space = { provider = " ", hl = { bg = colors.bg } }
+local Tab = { provider = " " }
+local LeftSpace = { provider = "" }
+local RightSpace = { provider = "" }
+local RightSpace2 = { provider = "" }
+local RightSpace3 = { provider = "" }
+local Fill = { provider = "%=", hl = { bg = colors.nobg } }
+local LeftSep = { provider = "" }
+local RightSep = { provider = "" }
+
+local ViMode = {
+ init = function(self)
+ self.mode = vim.fn.mode(1)
+ if not self.once then
+ vim.cmd("au ModeChanged *:*o redrawstatus")
+ end
+ self.once = true
+ end,
+ static = {
+ mode_names = {
+ n = "NORMAL ",
+ no = "N·OPERATOR PENDING ",
+ nov = "N?",
+ noV = "N?",
+ ["no\22"] = "N? ",
+ niI = "Ni",
+ niR = "Nr",
+ niV = "Nv",
+ nt = "Nt",
+ v = "VISUAL ",
+ vs = "Vs",
+ V = "V·LINE ",
+ ["\22"] = "V·BLOCK ",
+ ["\22s"] = "V·BLOCK ",
+ s = "SELECT ",
+ S = "S·LINE ",
+ ["\19"] = "S·BLOCK ",
+ i = "INSERT ",
+ ix = "insert x ",
+ ic = "insert c ",
+ R = "REPLACE ",
+ Rc = "Rc",
+ Rx = "Rx",
+ Rv = "V·REPLACE ",
+ Rvc = "Rv",
+ Rvx = "Rv",
+ c = "COMMAND ",
+ cv = "VIM EX ",
+ ce = "EX ",
+ r = "PROMPT ",
+ rm = "MORE ",
+ ["r?"] = "CONFIRM ",
+ ["!"] = "SHELL ",
+ t = "TERMINAL ",
+ },
+ },
+ provider = function(self)
+ return " %2(" .. self.mode_names[self.mode] .. "%) "
+ end,
+ hl = function(self)
+ local color = self:mode_color()
+ return { fg = color, bold = true }
+ end,
+ update = {
+ "ModeChanged",
+ },
+}
+
+-- LSP
+local LSPActive = {
+ condition = conditions.lsp_attached,
+ update = { "LspAttach", "LspDetach" },
+
+ provider = function()
+ local buf_clients = vim.lsp.buf_get_clients()
+ local buf_client_names = {}
+
+ -- add client
+ for _, client in pairs(buf_clients) do
+ if client.name ~= "null-ls" then
+ table.insert(buf_client_names, client.name)
+ end
+ end
+ return "⚙️ " .. table.concat(buf_client_names, "")
+ end,
+ hl = { fg = colors.lightgray, bold = false },
+}
+
+-- Navic
+local Navic = {
+ condition = require("nvim-navic").is_available,
+ static = {
+ -- create a type highlight map
+ type_hl = {
+ File = "Directory",
+ Module = "Include",
+ Namespace = "TSNamespace",
+ Package = "Include",
+ Class = "Struct",
+ Method = "Method",
+ Property = "TSProperty",
+ Field = "TSField",
+ Constructor = "TSConstructor ",
+ Enum = "TSField",
+ Interface = "Type",
+ Function = "Function",
+ Variable = "TSVariable",
+ Constant = "Constant",
+ String = "String",
+ Number = "Number",
+ Boolean = "Boolean",
+ Array = "TSField",
+ Object = "Type",
+ Key = "TSKeyword",
+ Null = "Comment",
+ EnumMember = "TSField",
+ Struct = "Struct",
+ Event = "Keyword",
+ Operator = "Operator",
+ TypeParameter = "Type",
+ },
+ },
+ init = function(self)
+ local data = require("nvim-navic").get_data() or {}
+ local children = {}
+ -- create a child for each level
+ for i, d in ipairs(data) do
+ local child = {
+ {
+ provider = d.icon,
+ hl = self.type_hl[d.type],
+ },
+ {
+ provider = d.name,
+ -- highlight icon only or location name as well
+ -- hl = self.type_hl[d.type],
+ },
+ }
+ -- add a separator only if needed
+ if #data > 1 and i < #data then
+ table.insert(child, {
+ provider = " > ",
+ hl = { fg = colors.white },
+ })
+ end
+ table.insert(children, child)
+ end
+ -- instantiate the new child, overwriting the previous one
+ self[1] = self:new(children, 1)
+ end,
+ hl = { fg = colors.white },
+}
+
+-- Diagnostics
+local Diagnostics = {
+
+ condition = conditions.has_diagnostics,
+
+ static = {
+ error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text,
+ warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text,
+ info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text,
+ hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text,
+ },
+
+ init = function(self)
+ self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
+ self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
+ self.hints = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.HINT })
+ self.info = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.INFO })
+ end,
+
+ update = { "DiagnosticChanged", "BufEnter" },
+
+ {
+ provider = function(self)
+ -- 0 is just another output, we can decide to print it or not!
+ return self.errors > 0 and (self.error_icon .. self.errors .. " ")
+ end,
+ hl = { fg = colors.diag.error, bg = colors.bg },
+ },
+ {
+ provider = function(self)
+ return self.warnings > 0 and (self.warn_icon .. self.warnings .. " ")
+ end,
+ hl = { fg = colors.diag.warn, bg = colors.bg },
+ },
+ {
+ provider = function(self)
+ return self.info > 0 and (self.info_icon .. self.info .. " ")
+ end,
+ hl = { fg = colors.diag.info, bg = colors.bg },
+ },
+ {
+ provider = function(self)
+ return self.hints > 0 and (self.hint_icon .. self.hints)
+ end,
+ hl = { fg = colors.diag.hint, bg = colors.bg },
+ },
+ on_click = {
+ callback = function()
+ require("trouble").toggle({ mode = "document_diagnostics" })
+ -- or
+ -- vim.diagnostic.setqflist()
+ end,
+ name = "heirline_diagnostics",
+ },
+}
+
+-- Git
+-- For the ones who're not (too) afraid of changes! Uses gitsigns.
+local Git = {
+ condition = conditions.is_git_repo,
+
+ init = function(self)
+ self.status_dict = vim.b.gitsigns_status_dict
+ self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0
+ end,
+ --hl = { fg = "orange" },
+ hl = { fg = colors.orange, bg = colors.bg },
+ { -- git branch name
+ provider = function(self)
+ return " " .. self.status_dict.head
+ end,
+ --hl = { bold = true },
+ hl = { bold = true, bg = colors.bg },
+ },
+ -- You could handle delimiters, icons and counts similar to Diagnostics
+ {
+ condition = function(self)
+ return self.has_changes
+ end,
+ --provider = "("
+ provider = " ",
+ },
+ {
+ provider = function(self)
+ local count = self.status_dict.added or 0
+ --return count > 0 and ("+" .. count)
+ return count > 0 and ("  " .. count)
+ end,
+ --hl = { fg = "git_add" },
+ hl = { fg = colors.git.add, bg = colors.bg },
+ },
+ {
+ provider = function(self)
+ local count = self.status_dict.removed or 0
+ --return count > 0 and ("-" .. count)
+ return count > 0 and ("  " .. count)
+ end,
+ --hl = { fg = "git_del" },
+ hl = { fg = colors.git.del, bg = colors.bg },
+ },
+ {
+ provider = function(self)
+ local count = self.status_dict.changed or 0
+ --return count > 0 and ("~" .. count)
+ return count > 0 and (" 柳" .. count)
+ end,
+ --hl = { fg = "git_change" },
+ hl = { fg = colors.git.change, bg = colors.bg },
+ },
+ --{
+ -- condition = function(self)
+ -- return self.has_changes
+ -- end,
+ -- provider = ")",
+ --},
+ on_click = {
+ callback = function()
+ -- If you want to use Fugitive:
+ -- vim.cmd("G")
+
+ -- If you prefer Lazygit
+ -- use vim.defer_fn() if the callback requires
+ -- opening of a floating window
+ -- (this also applies to telescope)
+ vim.defer_fn(function()
+ vim.cmd("Lazygit")
+ end, 100)
+ end,
+ name = "heirline_git",
+ },
+}
+
+-- Debugger
+-- Display informations from nvim-dap!
+local DAPMessages = {
+ -- display the dap messages only on the debugged file
+ condition = function()
+ local session = require("dap").session()
+ if session then
+ local filename = vim.api.nvim_buf_get_name(0)
+ if session.config then
+ local progname = session.config.program
+ return filename == progname
+ end
+ end
+ return false
+ end,
+ provider = function()
+ return " " .. require("dap").status()
+ end,
+ hl = { fg = utils.get_highlight("Debug").fg },
+ -- Debugger on_click: step-over, step-into, next, previous, stop buttons
+ -- coming soon!
+}
+
+-- Tests
+-- This requires the great ultest.
+--local UltTest = {
+-- condition = function()
+-- return vim .api.nvim_call_function("ultest#is_test_file", {}) ~= 0
+-- end,
+-- static = {
+-- passed_icon = vim.fn.sign_getdefined("test_pass")[1].text,
+-- failed_icon = vim.fn.sign_getdefined("test_fail")[1].text,
+-- passed_hl = { fg = utils.get_highlight("UltestPass").fg },
+-- failed_hl = { fg = utils.get_highlight("UltestFail").fg },
+-- },
+-- init = function(self)
+-- self.status = vim.api.nvim_call_function("ultest#status", {})
+-- end,
+--
+-- -- again, if you'd like icons and numbers to be colored differently,
+-- -- just split the component in two
+-- {
+-- provider = function(self)
+-- return self.passed_icon .. self.status.passed .. " "
+-- end,
+-- hl = function(self)
+-- return self.passed_hl
+-- end,
+-- },
+-- {
+-- provider = function(self)
+-- return self.failed_icon .. self.status.failed .. " "
+-- end,
+-- hl = function(self)
+-- return self.failed_hl
+-- end,
+-- },
+-- {
+-- provider = function(self)
+-- return "of " .. self.status.tests - 1
+-- end,
+-- },
+--}
+
+-- FileNameBlock: FileIcon, FileName and friends
+local FileNameBlock = {
+ -- let's first set up some attributes needed by this component and it's children
+ init = function(self)
+ self.filename = vim.api.nvim_buf_get_name(0)
+ end,
+ --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg },
+ hl = { bg = colors.bg },
+}
+
+-- FileIcon, FileName, FileFlags and FileNameModifier
+local FileIcon = {
+ init = function(self)
+ local filename = self.filename
+ local extension = vim.fn.fnamemodify(filename, ":e")
+ self.icon, self.icon_color =
+ require("nvim-web-devicons").get_icon_color(filename, extension, { default = true })
+ end,
+ provider = function(self)
+ return self.icon and (self.icon .. " ")
+ end,
+ hl = function(self)
+ return { fg = self.icon_color, bg = colors.bg }
+ end,
+}
+
+local FileName = {
+ provider = function(self)
+ -- first, trim the pattern relative to the current directory. For other
+ -- options, see :h filename-modifers
+ local filename = vim.fn.fnamemodify(self.filename, ":.")
+ if filename == "" then
+ return "No Name"
+ end
+ -- now, if the filename would occupy more than 1/4th of the available
+ -- space, we trim the file path to its initials
+ -- See Flexible Components section below for dynamic truncation
+ if not conditions.width_percent_below(#filename, 0.25) then
+ filename = vim.fn.pathshorten(filename)
+ end
+ return filename
+ end,
+ --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg },
+ hl = { fg = colors.white, bold = false, bg = colors.bg },
+}
+
+local FileFlags = {
+ {
+ provider = function()
+ if vim.bo.modified then
+ return " [+]" -- ±[+]
+ end
+ end,
+ hl = { fg = colors.green, bg = colors.bg },
+ },
+ {
+ provider = function()
+ if not vim.bo.modifiable or vim.bo.readonly then
+ return " "
+ end
+ end,
+ --hl = { fg = colors.orange },
+ hl = { fg = colors.orange, bold = true, bg = colors.bg },
+ },
+}
+
+local FileNameModifier = {
+ hl = function()
+ if vim.bo.modified then
+ return { fg = colors.green, bold = false, force = true }
+ end
+ end,
+}
+
+-- FileType, FileEncoding and FileFormat
+local FileType = {
+ provider = function()
+ return vim.bo.filetype
+ end,
+ hl = { fg = colors.white, bold = false, bg = colors.bg },
+}
+
+local FileEncoding = {
+ Space,
+ provider = function()
+ local enc = (vim.bo.fenc ~= "" and vim.bo.fenc) or vim.o.enc -- :h 'enc'
+ return enc:lower()
+ end,
+ --hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg },
+ hl = { bg = colors.bg, bold = false },
+}
+
+local FileFormat = {
+ provider = function()
+ local fmt = vim.bo.fileformat
+ --return fmt ~= "unix" and fmt:upper()
+ return fmt ~= "unix" and fmt:lower()
+ end,
+ hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg },
+}
+
+-- FileSize and FileLastModified
+local FileSize = {
+ provider = function()
+ -- stackoverflow, compute human readable file size
+ local suffix = { "b", "k", "M", "G", "T", "P", "E" }
+ local fsize = vim.fn.getfsize(vim.api.nvim_buf_get_name(0))
+ fsize = (fsize < 0 and 0) or fsize
+ if fsize < 1024 then
+ return fsize .. suffix[1]
+ end
+ local i = math.floor((math.log(fsize) / math.log(1024)))
+ return string.format("%.2g%s", fsize / math.pow(1024, i), suffix[i + 1])
+ end,
+ hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg },
+}
+
+local FileLastModified = {
+ -- did you know? Vim is full of functions!
+ provider = function()
+ local ftime = vim.fn.getftime(vim.api.nvim_buf_get_name(0))
+ return (ftime > 0) and os.date("%c", ftime)
+ end,
+ hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg },
+}
+
+-- Spell
+-- Add indicator when spell is set!
+local Spell = {
+ condition = function()
+ return vim.wo.spell
+ end,
+ provider = " 暈",
+ hl = { bold = true, fg = colors.yellow },
+}
+
+local help_file_name = {
+ condition = function()
+ return vim.bo.filetype == "help"
+ end,
+ provider = function()
+ local filename = vim.api.nvim_buf_get_name(0)
+ return vim.fn.fnamemodify(filename, ":t")
+ end,
+ hl = { fg = colors.blue },
+}
+
+-- Cursor position: Ruler
+--local Ruler = {
+ -- %l = current line number
+ -- %L = number of lines in the buffer
+ -- %c = column number
+ -- %P = percentage through file of displayed window
+ --provider = "%P %(%l/%L%):%c ",
+ --provider = "%3(%2l%):%c %P ",
+ --provider = "%7(%l/%3L%):%2c%P ",
+ --provider = "%3(%P%)",
+ --provider = "%7(%l/%3L%):%2c %P",
+ --provider = "%7 %p%% Ln %l, Col %c",
+ --provider = "%9( %P %2l/%L :%2c %)",
+ --provider = "%9(%2l%2( : %c%)/%L %P %)",
+ --provider = "%7(%l:%c/%L%) ",
+ --provider = "%6(%l:%1.5c/%L%) %P ",
+ --provider = "%6(%l:%1.5c/%L%) ",
+ --provider = "%3(%l:%1.5c/%L%) ",
+ --provider = "%7(%l/%3L%):%2c ",
+-- provider = "%7(%l:%c%) ",
+ --provider = "%l:%c ",
+ --hl = { fg = utils.get_highlight("Statusline").fg, bold = true },
+-- hl = { fg = colors.darkgray, bold = true },
+--}
+local leftruler = { Space, Align }
+local rightruler = { Align, Space }
+local cursor_location = {
+ --{ provider = "", hl = { fg = utils.get_highlight("StatusLine").bg, bold = true } },
+-- { provider = "%<%-05.10(%l:%c%)", hl = { fg = colors.darkgray, bold = true } },
+-- { provider = " ", hl = { fg = colors.darkgray, bold = true } },
+ --{ provider = "%P %=%<%(%l,%c)" },
+ --{ provider = " %w%-8.(%l,%c%)%>" },
+ { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } },
+}
+local Ruler = { cursor_location }
+
+ --utils.make_flexible_component(
+ -- 3,
+ -- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ -- { provider = "%<" }
+ --),
+--local cursor_location = {
+-- { provider = "%7(%l:%c%) ", hl = { bold = true } },
+-- {
+-- provider = " ",
+-- hl = function(self)
+-- local color = self:mode_color()
+-- return { fg = color, bold = true }
+-- end,
+-- },
+--}
+
+local WordCount = {
+ condition = function()
+ return conditions.buffer_matches({
+ filetype = {
+ "markdown",
+ "txt",
+ "vimwiki",
+ },
+ })
+ end,
+ Space,
+ {
+ provider = function()
+ return "W:" .. vim.fn.wordcount().words
+ end,
+ },
+}
+
+-- Working Directory
+local WorkDir = {
+ provider = function(self)
+ self.icon = (vim.fn.haslocaldir(0) == 1 and "l" or "g") .. " " .. " "
+ local cwd = vim.fn.getcwd(0)
+ self.cwd = vim.fn.fnamemodify(cwd, ":~")
+ end,
+ hl = { fg = colors.blue, bold = true, bg = colors.bg },
+
+ utils.make_flexible_component(1, {
+ -- evaluates to the full-lenth path
+ provider = function(self)
+ local trail = self.cwd:sub(-1) == "/" and "" or "/"
+ return self.icon .. self.cwd .. trail .. " "
+ end,
+ }, {
+ -- evaluates to the shortened path
+ provider = function(self)
+ local cwd = vim.fn.pathshorten(self.cwd)
+ local trail = self.cwd:sub(-1) == "/" and "" or "/"
+ return self.icon .. cwd .. trail .. " "
+ end,
+ }, {
+ -- evaluates to "", hiding the component
+ provider = "",
+ }),
+}
+
+-- Snippets Indicator
+-- This requires ultisnips
+--local Snippets = {
+-- -- check that we are in insert or select mode
+-- condition = function()
+-- return vim.tbl_contains({'s', 'i'}, vim.fn.mode())
+-- end,
+-- provider = function()
+-- local forward = (vim.fn["UltiSnips#CanJumpForwards"]() == 1) and "" or ""
+-- local backward = (vim.fn["UltiSnips#CanJumpBackwards"]() == 1) and " " or ""
+-- return backward .. forward
+-- end,
+-- hl = { fg = "red", bold = true },
+--}
+
+-- let's add the children to our FileNameBlock component
+FileNameBlock = utils.insert(
+ FileNameBlock,
+ FileIcon,
+ utils.insert(FileNameModifier, FileName), -- a new table where FileName is a child of FileNameModifier
+ unpack(FileFlags), -- A small optimisation, since their parent does nothing
+ { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
+)
+
+local FileInfoBlock = {
+ -- let's first set up some attributes needed by this component and it's children
+ init = function(self)
+ self.filename = vim.api.nvim_buf_get_name(0)
+ end,
+}
+
+FileInfoBlock = utils.insert(
+ FileInfoBlock,
+ Space,
+ FileIcon,
+ FileType,
+ { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
+)
+
+--ViMode = utils.surround({ "", "" }, function(self)
+-- return self:mode_color()
+--end, { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } })
+--local mysurroundedcomponent = {
+--{provider='', hl = {...}},
+--{<your component>},
+--{provider = '>>>', hl = {...}}
+--}
+LeftSpace = utils.surround({ "", " " }, function(self)
+ return self:mode_color()
+end, { LeftSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } })
+
+RightSpace = utils.surround(
+ { "", "" },
+ colors.gray,
+ { RightSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } }
+)
+
+RightSpace2 = utils.surround(
+ { "█", "" },
+ colors.darkgray,
+ { RightSpace2, hl = { fg = colors.darkgray, force = true } }
+)
+
+RightSpace3 = utils.surround(
+ { "█", "" },
+ utils.get_highlight("statusline").bg,
+ { RightSpace3, hl = { fg = colors.darkgray, force = true } }
+)
+
+LSPActive = utils.surround({ "", "" }, function(self)
+ return self:mode_color()
+end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } })
+
+FileInfoBlock = utils.surround({ "", "" }, function(self)
+ return self:mode_color()
+end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } })
+
+Ruler = utils.surround({ "", "" }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } })
+
+local left = {
+ { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ --{ LeftSep, hl = function(self)
+ -- return { fg = self.mode_colors[self.mode], bg = utils.get_highlight("statusline").bg, bold = true, }
+ -- end,
+ --},
+ { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { FileNameBlock, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Git, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+}
+local middle = {
+ { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Navic, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { DAPMessages, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+}
+local right = {
+ { Diagnostics, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ {
+ RightSpace3,
+ hl = { bg = colors.darkgray, force = true },
+ },
+ { LSPActive, hl = { bg = colors.darkgray, force = true } },
+ { RightSpace2, hl = { bg = colors.gray, force = true } },
+ { FileInfoBlock, hl = { bg = colors.gray, force = true } },
+ { RightSpace, hl = { fg = colors.gray, force = true } },
+ --{ cursor_location, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ --utils.make_flexible_component(
+ -- 3,
+ -- { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ -- { provider = "%<" }
+ --),
+}
+--local Align = { provider = "%=", hl = { bg = colors.bg } }
+
+local sections = { left, middle, right }
+local DefaultStatusline = { sections }
+--LSPActive, Space, LSPMessages, Space, UltTest, Space, FileType, Space, Ruler, Space, ScrollBar
+
+local InactiveStatusline = {
+ condition = conditions.is_not_active,
+ { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { FileName, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+}
+
+local SpecialStatusline = {
+ condition = function()
+ return conditions.buffer_matches({
+ buftype = { "nofile", "prompt", "help", "quickfix" },
+ filetype = { "^git.*", "fugitive" },
+ })
+ end,
+
+ --FileType,
+ --Space,
+ --Align,
+ { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+}
+
+local TerminalStatusline = {
+
+ condition = function()
+ return conditions.buffer_matches({ buftype = { "terminal" } })
+ end,
+
+ --hl = { bg = colors.red },
+
+ -- Quickly add a condition to the ViMode to only show it when buffer is active!
+ --{ condition = conditions.is_active, ViMode, Space },
+ { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { LeftSpace, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { FileType, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Space, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { Align, hl = { bg = utils.get_highlight("statusline").bg, force = true } },
+ { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } },
+ --FileType,
+ --Space,
+ --TerminalName,
+ --Align,
+}
+
+local StatusLine = {
+
+ --hl = function()
+ -- if conditions.is_active() then
+ -- return "StatusLine"
+ -- else
+ -- return "StatusLineNC"
+ -- end
+ --end,
+ static = {
+ mode_colors = {
+ n = colors.blue,
+ i = colors.green,
+ v = colors.purple,
+ V = colors.purple,
+ ["\22"] = colors.purple,
+ c = colors.orange,
+ s = colors.purple,
+ S = colors.purple,
+ ["\19"] = colors.purple,
+ R = colors.red,
+ r = colors.red,
+ ["!"] = colors.orange,
+ t = colors.orange,
+ },
+ mode_color = function(self)
+ local mode = conditions.is_active() and vim.fn.mode() or "n"
+ return self.mode_colors[mode]
+ end,
+ hl = function(self)
+ local color = self:mode_color() -- here!
+ return { bg = color }
+ end,
+ },
+ fallthrough = false,
+
+ SpecialStatusline,
+ TerminalStatusline,
+ InactiveStatusline,
+ DefaultStatusline,
+}
+
+
+--
+--- WinBar
+--
+local WinbarFileNameBlock = {
+ -- let's first set up some attributes needed by this component and it's children
+ init = function(self)
+ self.filename = vim.api.nvim_buf_get_name(0)
+ end,
+ hl = { bg = colors.bg },
+}
+
+--local WinbarFileName = {
+-- provider = function(self)
+-- -- self.filename will be defined later, just keep looking at the example!
+-- local filename = self.filename
+-- filename = filename == "" and "No Name" or vim.fn.fnamemodify(filename, ":t")
+-- return filename
+-- end,
+-- hl = function()
+-- return { fg = colors.gray, italic = true }
+-- end,
+--}
+local WinbarFileName = {
+ provider = function(self)
+ -- first, trim the pattern relative to the current directory. For other
+ -- options, see :h filename-modifers
+ local filename = vim.fn.fnamemodify(self.filename, ":.")
+ if filename == "" then
+ return "No Name"
+ end
+ -- now, if the filename would occupy more than 1/4th of the available
+ -- space, we trim the file path to its initials
+ -- See Flexible Components section below for dynamic truncation
+ if not conditions.width_percent_below(#filename, 0.25) then
+ filename = vim.fn.pathshorten(filename)
+ end
+ return filename
+ end,
+ --hl = { fg = utils.get_highlight("Statusline").fg, bold = false, bg = colors.bg },
+ hl = { fg = colors.gray, bold = false, bg = colors.bg },
+}
+
+WinbarFileNameBlock = utils.insert(
+ WinbarFileNameBlock,
+ FileIcon,
+ utils.insert(WinbarFileName), -- a new table where FileName is a child of FileNameModifier
+ unpack(FileFlags), -- A small optimisation, since their parent does nothing
+ { provider = "%<" } -- this means that the statusline is cut here when there's not enough space
+)
+
+vim.api.nvim_create_autocmd("User", {
+ pattern = "HeirlineInitWinbar",
+ callback = function(args)
+ local buf = args.buf
+ local buftype = vim.tbl_contains({ "prompt", "nofile", "help", "quickfix" }, vim.bo[buf].buftype)
+ local filetype = vim.tbl_contains({ "gitcommit", "fugitive" }, vim.bo[buf].filetype)
+ if buftype or filetype then
+ vim.opt_local.winbar = nil
+ end
+ end,
+})
+
+On_click = {
+ -- get the window id of the window in which the component was evaluated
+ minwid = function()
+ return vim.api.nvim_get_current_win()
+ end,
+ callback = function(_, minwid)
+ -- winid is the window id of the window the component was clicked from
+ local winid = minwid
+ -- do something with the window id, e.g.:
+ local buf = vim.api.nvim_win_get_buf(winid)
+ -- ...
+ end,
+}
+
+local CloseButton = {
+ condition = function(self)
+ return not vim.bo.modified
+ end,
+ -- a small performance improvement:
+ -- re register the component callback only on layout/buffer changes.
+ update = { "WinNew", "WinClosed", "BufEnter" },
+ { provider = " " },
+ {
+ provider = "",
+ hl = { fg = "gray" },
+ On_click = {
+ minwid = function()
+ return vim.api.nvim_get_current_win()
+ end,
+ callback = function(_, minwid)
+ vim.api.nvim_win_close(minwid, true)
+ end,
+ name = "heirline_winbar_close_button",
+ },
+ },
+}
+
+local Center = {
+ fallthrough = false,
+ { -- Hide the winbar for special buffers
+ condition = function()
+ return conditions.buffer_matches({
+ buftype = { "nofile", "prompt", "help", "quickfix" },
+ filetype = { "^git.*", "fugitive" },
+ })
+ end,
+ init = function()
+ vim.opt_local.winbar = nil
+ end,
+ },
+ { -- A special winbar for terminals
+ condition = function()
+ return conditions.buffer_matches({ buftype = { "terminal" } })
+ end,
+ FileType,
+ Space,
+ --TerminalName,
+ },
+ { -- An inactive winbar for regular files
+ condition = function()
+ return not conditions.is_active()
+ end,
+ --utils.surround({ "", "" }, colors.nobg, { FileIcon, { WinbarFileName, hl = { fg = colors.gray } }, FileFlags } ),
+ utils.surround({ "", "" }, colors.nobg, { WinbarFileNameBlock } ),
+ },
+ -- A winbar for regular files
+ utils.surround({ "", "" }, colors.nobg, { FileNameBlock }),
+}
+
+--local WinBar = { Align, Center, Align }
+local WinBar = { Space, Center }
+
+
+-- TabLine
+local TablineBufnr = {
+ provider = function(self)
+ return tostring(self.bufnr) .. "."
+ end,
+ hl = { fg = colors.white, bold = false },
+}
+
+-- we redefine the filename component, as we probably only want the tail and not the relative path
+local TablineFileName = {
+ provider = function(self)
+ -- self.filename will be defined later, just keep looking at the example!
+ local filename = self.filename
+ filename = filename == "" and "No Name" or vim.fn.fnamemodify(filename, ":t")
+ return filename
+ end,
+ hl = function(self)
+ return { fg = colors.white, bold = self.is_active or self.is_visible, italic = true }
+ end,
+}
+
+local TablineFileFlags = {
+ {
+ provider = function(self)
+ if vim.bo[self.bufnr].modified then
+ return " [+] "
+ end
+ end,
+ hl = { fg = colors.green },
+ },
+ {
+ provider = function(self)
+ if not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly then
+ return "  "
+ end
+ end,
+ hl = { fg = "orange" },
+ },
+}
+
+local TablineFileIcon = {
+ init = function(self)
+ local filename = self.filename
+ local extension = vim.fn.fnamemodify(filename, ":e")
+ self.icon, self.icon_color =
+ require("nvim-web-devicons").get_icon_color(filename, extension, { default = true })
+ end,
+ provider = function(self)
+ return self.icon and (" " .. self.icon .. " ")
+ end,
+ hl = function(self)
+ return { fg = self.icon_color }
+ end,
+}
+
+-- Here the filename block finally comes together
+local TablineFileNameBlock = {
+ init = function(self)
+ self.filename = vim.api.nvim_buf_get_name(self.bufnr)
+ end,
+ hl = function(self)
+ if self.is_active then
+ return "TabLineSel"
+ -- why not?
+ --elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then
+ --return { fg = "gray", bg = colors.bg }
+ else
+ return "TabLineFill"
+ end
+ end,
+ on_click = {
+ callback = function(_, minwid, _, button)
+ if button == "m" then -- close on mouse middle click
+ vim.api.nvim_buf_delete(minwid, { force = false })
+ else
+ vim.api.nvim_win_set_buf(0, minwid)
+ end
+ end,
+ minwid = function(self)
+ return self.bufnr
+ end,
+ name = "heirline_tabline_buffer_callback",
+ },
+ TablineBufnr,
+ TablineFileIcon,
+ TablineFileName,
+ TablineFileFlags,
+}
+
+-- a nice "x" button to close the buffer
+local TablineCloseButton = {
+ condition = function(self)
+ return not vim.api.nvim_buf_get_option(self.bufnr, "modified")
+ end,
+ { provider = " " },
+ {
+ provider = " ",
+ --hl = { fg = "red", bg = colors.bg },
+ hl = { fg = colors.red },
+ on_click = {
+ callback = function(_, minwid)
+ vim.api.nvim_buf_delete(minwid, { force = false })
+ end,
+ minwid = function(self)
+ return self.bufnr
+ end,
+ name = "heirline_tabline_close_buffer_callback",
+ },
+ },
+}
+
+-- The final touch!
+local TablineBufferBlock = utils.surround({ "", "" }, function(self)
+ --local TablineBufferBlock = utils.surround({ "█", "█" }, function(self)
+ if self.is_active then
+ return utils.get_highlight("TabLineSel").bg
+ else
+ return utils.get_highlight("TabLineFill").bg
+ end
+end, { Tab, TablineFileNameBlock, TablineCloseButton })
+
+local BufferLine = utils.make_buflist(
+ TablineBufferBlock,
+ { provider = "􀰎 ", hl = { fg = colors.white } }, -- left truncation, optional (defaults to "<")
+ { provider = " 􀰓", hl = { fg = colors.white } } -- right trunctation, also optional (defaults to ...... yep, ">")
+ -- by the way, open a lot of buffers and try clicking them ;)
+)
+-- TabList
+local Tabpage = {
+ provider = function(self)
+ return "%" .. self.tabnr .. "T " .. self.tabnr .. " %T"
+ end,
+ hl = function(self)
+ if not self.is_active then
+ return "TabLineFill"
+ else
+ return "TabLineSel"
+ end
+ end,
+}
+
+local TabpageClose = {
+ provider = "%999X  %X",
+ --hl = "TabLine",
+ hl = { fg = colors.red, bg = colors.bg },
+}
+
+local TabPages = {
+ -- only show this component if there's 2 or more tabpages
+ condition = function()
+ return #vim.api.nvim_list_tabpages() >= 2
+ end,
+ {
+ provider = "%=",
+ },
+ utils.make_tablist(Tabpage),
+ TabpageClose,
+}
+
+-- TabLineOffset
+local TabLineOffset = {
+ condition = function(self)
+ local win = vim.api.nvim_tabpage_list_wins(0)[1]
+ local bufnr = vim.api.nvim_win_get_buf(win)
+ self.winid = win
+
+ if vim.api.nvim_buf_get_option(bufnr, "filetype") == "NvimTree" then
+ self.title = "NvimTree"
+ return true
+ end
+ end,
+
+ provider = function(self)
+ local title = self.title
+ local width = vim.api.nvim_win_get_width(self.winid)
+ local pad = math.ceil((width - #title) / 2)
+ return string.rep(" ", pad) .. title .. string.rep(" ", pad)
+ end,
+
+ hl = function(self)
+ if vim.api.nvim_get_current_win() == self.winid then
+ return "TablineSel"
+ else
+ return "TablineFill"
+ end
+ end,
+}
+
+local TabLine = {
+ TabLineOffset,
+ BufferLine,
+ TabPages,
+}
+
+require("heirline").setup(StatusLine, WinBar, TabLine)
+
+-- Yep, with heirline we're driving manual!
+--vim.cmd([[au FileType * if index(['wipe', 'delete', 'unload'], &bufhidden) >= 0 | set nobuflisted | endif]])
+--
+--local function get_bufs()
+-- return vim.tbl_filter(function(bufnr)
+-- return vim.api.nvim_buf_is_loaded(bufnr) and vim.bo[bufnr].buflisted
+-- end, vim.api.nvim_list_bufs())
+--end
+--
+--local function goto_buf(index)
+-- local bufs = get_bufs()
+-- if index > #bufs then
+-- index = #bufs
+-- end
+-- vim.api.nvim_win_set_buf(0, bufs[index])
+--end
+--
+--local function addKey(key, index)
+-- vim.keymap.set("", "<A-" .. key .. ">", function()
+-- goto_buf(index)
+-- end, { noremap = true, silent = true })
+--end
+--
+--for i = 1, 9 do
+-- addKey(i, i)
+--end
+--addKey("0", 10)
diff --git a/lua/user/keys.lua b/lua/user/keys.lua
new file mode 100644
index 0000000..4515cbc
--- /dev/null
+++ b/lua/user/keys.lua
@@ -0,0 +1,531 @@
+--[[ key.lua ]]
+
+-- Shorten function name
+local map = vim.api.nvim_set_keymap
+
+local function new_desc(d)
+ return { desc = d }
+end
+
+local d = new_desc
+
+local opts = { noremap = true, silent = true }
+
+local term_opts = { silent = true }
+
+--------------- Standard Operations ---------------
+-- Semi-colon as leader key
+vim.g.mapleader = ";"
+--vim.g.maplocalleader = ";"
+
+-- "jj" to exit insert-mode
+map("i", "jj", "<esc>", opts)
+
+-- save quickly
+--map("n", ";w", ":w<CR>", d("Save buffer"))
+
+--map("n", "<leader>so", ":luafile %<CR>", opts)
+
+--vim.cmd([[
+--let $my_vimrc = $localappdata.'/nvim/init.lua'
+--nnoremap <leader>so :source $my_vimrc<cr>
+--]])
+
+--vim.api.nvim_set_keymap("n", "<leader><CR>", "<cmd>lua ReloadConfig()<CR>", { noremap = true, silent = false })
+vim.api.nvim_set_keymap("n", "<leader><CR>", "<cmd>luafile ~/.config/nvim/init.lua<CR>", { noremap = true, silent = false })
+--vim.api.nvim_set_keymap('n', '<Leader>qr', '<cmd>:lua require("plugins.telescope").reload()<CR>', { noremap = true, silent = true })
+
+--Easier split navigations, just ctrl-j instead of ctrl-w then j
+map("n", "<C-J>", "<C-W><C-J>", opts)
+map("n", "<C-K>", "<C-W><C-K>", opts)
+map("n", "<C-L>", "<C-W><C-L>", opts)
+map("n", "<C-H>", "<C-W><C-H>", opts)
+
+-- Combine buffers list with buffer name
+map("n", "<Leader>b", ":buffers<CR>:buffer<Space>", opts)
+
+-- Map buffer next, prev and delete to <leader+(n/p/d)>
+map("n", "<leader>n", ":bn<cr>", opts)
+map("n", "<leader>p", ":bp<cr>", opts)
+map("n", "<leader>d", ":bd<cr>", opts)
+
+-- Disable default completion.
+map('i', '<C-n>', '<Nop>', opts)
+map('i', '<C-p>', '<Nop>', opts)
+
+-- Set alt + j/k to switch lines of texts or simply move them
+map("n", "<A-k>", ':let save_a=@a<Cr><Up>"add"ap<Up>:let @a=save_a<Cr>', opts)
+map("n", "<A-j>", ':let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>', opts)
+
+map("n", "<leader><C-l>", "<Cmd>!clear<CR>", opts)
+vim.cmd([[
+ inoremap <A-h> <left>
+ inoremap <A-j> <down>
+ inoremap <A-k> <up>
+ inoremap <A-l> <right>
+]])
+
+vim.cmd([[
+ cnoremap <A-h> <left>
+ cnoremap <A-j> <down>
+ cnoremap <A-k> <up>
+ cnoremap <A-l> <right>
+]])
+
+--vim.cmd([[
+-- cnoremap <C-A> <Home>
+-- cnoremap <C-F> <Right>
+-- cnoremap <C-B> <Left>
+-- cnoremap <C-E> <End>
+--]])
+
+vim.cmd([[
+ snoremap <A-h> <left>
+ snoremap <A-j> <down>
+ snoremap <A-k> <up>
+ snoremap <A-l> <right>
+]])
+
+-- move block easily
+map("n", "<", "<<", d("Decrease indent"))
+map("n", ">", ">>", d("Increase indent"))
+map("x", "<", "<gv", d("Increase indent"))
+map("x", ">", ">gv", d("Decrease indent"))
+
+-- Resize Panes
+map("n", "<Leader>+", ":resize +5<CR>", opts)
+map("n", "<Leader>-", ":resize -5<CR>", opts)
+map("n", "<Leader><", ":vertical resize +5<CR>", opts)
+map("n", "<Leader>>", ":vertical resize -5<CR>", opts)
+map("n", "<Leader>=", "<C-w>=", opts)
+
+-- New tab
+map("n", "<C-T>e", ":tabedit", opts)
+
+-- create tab like window
+map("n", "<C-T>h", ":tabprevious<CR>", d("Goto previous tab"))
+map("n", "<C-T>l", ":tabnext<CR>", d("Goto next tab"))
+map("n", "<C-T>n", ":tabnew<CR>", d("Create a new tab"))
+
+-- Vim TABs
+map("n", "<leader>1", "1gt<CR>", opts)
+map("n", "<leader>2", "2gt<CR>", opts)
+map("n", "<leader>3", "3gt<CR>", opts)
+map("n", "<leader>4", "4gt<CR>", opts)
+map("n", "<leader>5", "5gt<CR>", opts)
+map("n", "<leader>6", "6gt<CR>", opts)
+map("n", "<leader>7", "7gt<CR>", opts)
+map("n", "<leader>8", "8gt<CR>", opts)
+map("n", "<leader>9", "9gt<CR>", opts)
+map("n", "<leader>0", "10gt<CR>", opts)
+
+-- Split window
+map("n", "<leader>h", ":split<CR>", opts)
+map("n", "<leader>v", ":vsplit<CR>", opts)
+map("n", "<leader>c", "<C-w>c", opts)
+
+-- Toggle set number
+map("n", "<leader>$", ":NumbersToggle<CR>", opts)
+map("n", "<leader>%", ":NumbersOnOff<CR>", opts)
+
+-- Change mode to executable
+map("n", "<leader>x", ":!chmod +x %<CR>", opts)
+
+-- Paste without replace clipboard
+map("v", "p", '"_dP', opts)
+
+-- Paste end of line
+--map("n", ",", "$p", opts)
+vim.cmd([[
+ nmap , $p
+]])
+
+-- Select entire buffer
+map("v", "<aa>", "gg<S-v>G", opts)
+
+-- Delete without changing the registers
+--map('n', 'x', '"_x', opts)
+
+-- Select all text in current buffer
+--map('n', '<leader>a', ':keepjumps normal! ggVG<cr>')
+
+-- Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in
+-- visual mode to select text to swap with
+map("v", "<C-X>", "<Esc>`.``gvP``P", opts)
+
+-- Search and replace
+map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c', opts)
+--vnoremap ; :call Get_visual_selection()<cr>
+--
+--function! Get_visual_selection()
+-- " Why is this not a built-in Vim script function?!
+-- let [lnum1, col1] = getpos("'<")[1:2]
+-- let [lnum2, col2] = getpos("'>")[1:2]
+-- let lines = getline(lnum1, lnum2)
+-- let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)]
+-- let lines[0] = lines[0][col1 - 1:]
+-- let selection = join(lines,'\n')
+-- let change = input('Change the selection with: ')
+-- execute ":%s/".selection."/".change."/g"
+--endfunction
+vim.cmd([[
+let s:hidden_all = 0
+function! ToggleHiddenAll()
+ if s:hidden_all == 0
+ let s:hidden_all = 1
+ set noshowmode
+ set noruler
+ set laststatus=0
+ set noshowcmd
+ else
+ let s:hidden_all = 0
+ set showmode
+ set ruler
+ set laststatus=2
+ set showcmd
+ endif
+endfunction
+nnoremap <S-h> :call ToggleHiddenAll()<CR>
+]])
+
+vim.cmd([[
+ map <leader>s :up \| saveas! %:p:r-<C-R>=strftime("%y.%m.%d-%H:%M")<CR>-bak.<C-R>=expand("%:e")<CR> \| 3sleep \| e #<CR>
+]])
+
+-------------- Telescope --------------
+--Telescope find_files cwd=..
+map("n", "<leader>fc", "<cmd>lua require('telescope.builtin').commands()<cr>", opts)
+map(
+ "n",
+ "<leader>ft",
+ "<cmd>lua require('telescope.builtin').builtin(require('telescope.themes').get_dropdown({}))<cr>",
+ opts
+)
+
+map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>", opts)
+map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>", opts)
+
+ map("n", "<leader>fd", "<cmd>lua require('telescope.builtin').diagnostics()<cr>", opts)
+--map("n", "<leader>fz", ":FZF<CR>", opts)
+--map("t", [[<Esc><Esc>]], [[<C-\><C-N>]], opts)
+--map("n", "ff", ":NvimTreeToggle<CR>", {})
+map("n", "<leader>f", ":NvimTreeToggle<CR>", {})
+-- This <Esc><Esc> avoids crashing fzf menu running in TERMINAL MODE (:q if you do)
+-- Find files in config dirs
+--key_map("n", "<leader>e", ":lua require('plugins.telescope').find_configs()<CR>", opts)
+--map("n", "<leader>f.", "<cmd>lua require('plugins.telescope').find_configs({})<cr>", opts)
+map("n", "<leader>ft", "<cmd>lua require('plugins.telescope').file_explorer({})<cr>", opts)
+--map("n", "<leader>fd", "<cmd>lua require('plugins.telescope').find_notes({})<cr>", opts)
+map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>", opts)
+-- registers picker
+map("n", "<leader>r", "<cmd>lua require('telescope.builtin').registers({})<CR>", opts)
+-- find files including gitignored
+--keymap(
+-- "n",
+-- "<leader>fg",
+-- "<cmd>lua require('telescope.builtin').find_files({find_command={'fd','--no-ignore-vcs'}})<CR>", opts)
+-- open available commands & run it
+map("n", "<leader>fc", "<cmd>lua require('telescope.builtin').commands({results_title='Commands Results'})<CR>", opts)
+
+-------------- Autopairs --------------
+Toggle_autopairs = function()
+ local ok, autopairs = pcall(require, "nvim-autopairs")
+ if ok then
+ if autopairs.state.disabled then
+ autopairs.enable()
+ print("autopairs on")
+ else
+ autopairs.disable()
+ print("autopairs off")
+ end
+ else
+ print("autopairs not available")
+ end
+end
+map("n", "<leader>ww", ":lua Toggle_autopairs()<CR>", term_opts)
+
+-------------- Functions --------------
+-- Toggle transparency
+vim.cmd([[
+ let t:is_transparent = 0
+ function! Toggle_transparent_background()
+ if t:is_transparent == 0
+ hi Normal guibg=#111111 ctermbg=black
+ let t:is_transparent = 1
+ else
+ hi Normal guibg=NONE ctermbg=NONE
+ let t:is_transparent = 0
+ endif
+ endfunction
+ nnoremap <leader>tb :call Toggle_transparent_background()<CR>
+]])
+--keymap('n', '<leader>tb', ':Toggle_transparent_background<CR>', opts)
+
+-- Toggle zoom
+vim.cmd([[
+ function! s:ZoomToggle() abort
+ if exists('t:zoomed') && t:zoomed
+ execute t:zoom_winrestcmd
+ let t:zoomed = 0
+ else
+ let t:zoom_winrestcmd = winrestcmd()
+ resize
+ vertical resize
+ let t:zoomed = 1
+ endif
+ endfunction
+ command! ZoomToggle call s:ZoomToggle()
+ ]])
+map("n", "<leader>z", ":ZoomToggle<CR>", opts)
+-- "Zoom" a split window into a tab and/or close it
+--keymap('n', '<Leader>,', ':tabnew %<CR>', opts)
+--keymap('n', '<Leader>.', ':tabclose<CR>', opts)
+
+-- Open last closed buffer
+vim.cmd([[
+ function! OpenLastClosed()
+ let last_buf = bufname('#')
+ if empty(last_buf)
+ echo "No recently closed buffer found"
+ return
+ endif
+ let result = input("Open ". last_buf . " in (n)ormal (v)split, (t)ab or (s)plit ? (n/v/t/s) : ")
+ if empty(result) || (result !=# 'v' && result !=# 't' && result !=# 's' && result !=# 'n')
+ return
+ endif
+ if result ==# 't'
+ execute 'tabnew'
+ elseif result ==# 'v'
+ execute "vsplit"
+ elseif result ==# 's'
+ execute "split"
+ endif
+ execute 'b ' . last_buf
+ endfunction
+ ]])
+map("n", "<C-t>", ":call OpenLastClosed() <CR>", opts)
+
+-- Tabularize
+vim.cmd([[
+ vnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>"
+ nnoremap <expr> <Leader>mm ':Tabularize /^\s*\S.*\zs' . split(&commentstring, '%s')[0] . "<CR>"
+ "nnoremap <leader>i mc40A <esc>080lDgelD`cP
+ "vnoremap <leader>ii mc0f-20i<Space><Esc>`cdt=j
+]])
+
+vim.cmd([[
+ " Start interactive EasyAlign in visual mode (e.g. vipga)
+ xmap ga <Plug>(EasyAlign)
+ " Start interactive EasyAlign for a motion/text object (e.g. gaip)
+ nmap ga <Plug>(EasyAlign)
+ if !exists('g:easy_align_delimiters')
+ let g:easy_align_delimiters = {}
+ endif
+ let g:easy_align_delimiters['--'] = { 'pattern': '--', 'ignore_groups': ['String'] }
+ nnoremap <F1> 21A <Esc>d21\|
+ imap <F1> <Esc><F1>a
+]])
+--:'<,'>EasyAlign /--/
+--EasyAlign /--/
+--:'<,'>Tabularize /--
+
+map("n", "<leader>,", ":hide<CR>", opts)
+map("n", "<leader>.", ":unhide<CR>", opts)
+
+--" Clean trailing whitespace
+--nnoremap <leader>ww mz:%s/\s\+$//<cr>:let @/=''<cr>`z
+
+-- Save with root permission (not working for now)
+--vim.api.nvim_create_user_command('W', 'w !sudo tee > /dev/null %', {})
+
+-- Copy and Paste with <C-c> and <C-v>
+--keymap('n', '<expr> p', (v:register =--= '"' && &clipboard =~ 'unnamed' ? '"*p' : '"' . v:register . 'p')'', opts)
+-- Use command :Vb for Visual Block or <C-q> since <C-v> is used for Copy
+--command! Vb normal! <C-v>
+-- Map <w!!> to save/edit a root permission/read-only file, only works in
+-- traditional vim and not neovim
+--keymap('c', 'w!! %!sudo tee > /dev/null', opts)
+--" Copying text to the system clipboard.
+--"
+--" For some reason Vim no longer wants to talk to the OS X pasteboard through "*.
+--" Computers are bullshit.
+--function! g:FuckingCopyTheTextPlease()
+-- let old_z = @z
+-- normal! gv"zy
+-- call system('pbcopy', @z)
+-- let @z = old_z
+--endfunction
+--noremap <leader>p :silent! set paste<CR>"*p:set nopaste<CR>
+--" noremap <leader>p mz:r!pbpaste<cr>`z
+--vnoremap <leader>y :<c-u>call g:FuckingCopyTheTextPlease()<cr>
+
+--" Indent/dedent/autoindent what you just pasted.
+--nnoremap <lt>> V`]<
+--nnoremap ><lt> V`]>
+--nnoremap =- V`]=
+
+--" Keep the cursor in place while joining lines
+--nnoremap J mzJ`z
+
+--" Toggle [i]nvisible characters
+--nnoremap <leader>i :set list!<cr>
+--
+--" Unfuck my screen
+--nnoremap U :syntax sync fromstart<cr>:redraw!<cr>
+
+--" Ranger
+--nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
+--nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
+--
+--" Insert Mode Completion {{{
+--
+--inoremap <c-f> <c-x><c-f>
+--inoremap <c-]> <c-x><c-]>
+--inoremap <c-l> <c-x><c-l>
+---- Open the current file in the default program (on Mac this should just be just `open`)
+--keymap('n', '<leader>x', ':!xdg-open %<cr><cr>')
+
+map("n", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files()<cr>", opts)
+--keymap("n", "<leader>ff", "<cmd>lua require('telescope.builtin').find_files cwd=..()<cr>", opts)
+--keymap('n', '<leader>k', ':nohlsearch<CR>')
+--
+--"This unsets the "last search pattern" register by hitting return
+vim.cmd([[
+ nnoremap <silent> <CR> :noh<CR><CR>
+]])
+
+--keymap('n', '<leader>Q', ':bufdo bdelete<CR>')
+--
+---- Allow gf to open non-existent files
+--keymap('', 'gf', ':edit <cfile><CR>')
+--
+---- Reselect visual selection after indenting
+--keymap('v', '<', '<gv')
+--keymap('v', '>', '>gv')
+--
+---- Maintain the cursor position when yanking a visual selection
+---- http://ddrscott.github.io/blog/2016/yank-without-jank/
+--keymap('v', 'y', 'myy`y')
+--keymap('v', 'Y', 'myY`y')
+--keymap("n", "<C-q>", ":q<cr>", opts)
+--keymap("n", "<C-M-q>", ":qa!<cr>", opts)
+
+--" Sort lines
+--nnoremap <leader>s vip:!sort<cr>
+--vnoremap <leader>s :!sort<cr>
+--
+--" Tabs
+--nnoremap <leader>( :tabprev<cr>
+--nnoremap <leader>) :tabnext<cr>
+--
+--" Wrap
+--nnoremap <leader>W :set wrap!<cr>
+
+--set foldlevelstart=0
+--
+--" Space to toggle folds.
+--nnoremap <Space> za
+--vnoremap <Space> za
+--" Make zO recursively open whatever fold we're in, even if it's partially open.
+--nnoremap zO zczO
+
+-- Packer
+--maps.n["<leader>pc"] = { "<cmd>PackerCompile<cr>", desc = "Packer Compile" }
+--maps.n["<leader>pi"] = { "<cmd>PackerInstall<cr>", desc = "Packer Install" }
+--maps.n["<leader>ps"] = { "<cmd>PackerSync<cr>", desc = "Packer Sync" }
+--maps.n["<leader>pS"] = { "<cmd>PackerStatus<cr>", desc = "Packer Status" }
+--maps.n["<leader>pu"] = { "<cmd>PackerUpdate<cr>", desc = "Packer Update" }
+-- NeoTree
+--if is_available "neo-tree.nvim" then
+-- keymaps.n["<leader>e"] = { "<cmd>Neotree toggle<cr>", desc = "Toggle Explorer" }
+-- keymaps.n["<leader>o"] = { "<cmd>Neotree focus<cr>", desc = "Focus Explorer" }
+--end
+-- Alpha
+--if is_available "alpha-nvim" then maps.n["<leader>d"] = { "<cmd>Alpha<cr>", desc = "Alpha Dashboard" } end
+
+-- Package Manager
+-- TODO: v2 rework these key bindings to be more general
+--if is_available "mason.nvim" then maps.n["<leader>lI"] = { "<cmd>Mason<cr>", desc = "LSP installer" } end
+-- Telescope
+--if is_available "telescope.nvim" then
+-- maps.n["<leader>fw"] = { function() require("telescope.builtin").live_grep() end, desc = "Search words" }
+-- maps.n["<leader>fW"] = {
+-- function()
+-- require("telescope.builtin").live_grep {
+-- additional_args = function(args) return vim.list_extend(args, { "--hidden", "--no-ignore" }) end,
+-- }
+-- end,
+-- desc = "Search words in all files",
+-- }
+-- maps.n["<leader>gt"] = { function() require("telescope.builtin").git_status() end, desc = "Git status" }
+-- maps.n["<leader>gb"] = { function() require("telescope.builtin").git_branches() end, desc = "Git branches" }
+-- maps.n["<leader>gc"] = { function() require("telescope.builtin").git_commits() end, desc = "Git commits" }
+-- maps.n["<leader>ff"] = { function() require("telescope.builtin").find_files() end, desc = "Search files" }
+-- maps.n["<leader>fF"] = {
+-- function() require("telescope.builtin").find_files { hidden = true, no_ignore = true } end,
+-- desc = "Search all files",
+-- }
+-- maps.n["<leader>fb"] = { function() require("telescope.builtin").buffers() end, desc = "Search buffers" }
+-- maps.n["<leader>fh"] = { function() require("telescope.builtin").help_tags() end, desc = "Search help" }
+-- maps.n["<leader>fm"] = { function() require("telescope.builtin").marks() end, desc = "Search marks" }
+-- maps.n["<leader>fo"] = { function() require("telescope.builtin").oldfiles() end, desc = "Search history" }
+-- maps.n["<leader>fc"] =
+-- { function() require("telescope.builtin").grep_string() end, desc = "Search for word under cursor" }
+-- maps.n["<leader>sb"] = { function() require("telescope.builtin").git_branches() end, desc = "Git branches" }
+-- maps.n["<leader>sh"] = { function() require("telescope.builtin").help_tags() end, desc = "Search help" }
+-- maps.n["<leader>sm"] = { function() require("telescope.builtin").man_pages() end, desc = "Search man" }
+-- maps.n["<leader>sn"] =
+-- { function() require("telescope").extensions.notify.notify() end, desc = "Search notifications" }
+-- maps.n["<leader>sr"] = { function() require("telescope.builtin").registers() end, desc = "Search registers" }
+-- maps.n["<leader>sk"] = { function() require("telescope.builtin").keymaps() end, desc = "Search keymaps" }
+-- maps.n["<leader>sc"] = { function() require("telescope.builtin").commands() end, desc = "Search commands" }
+-- maps.n["<leader>ls"] = {
+-- function()
+-- local aerial_avail, _ = pcall(require, "aerial")
+-- if aerial_avail then
+-- require("telescope").extensions.aerial.aerial()
+-- else
+-- require("telescope.builtin").lsp_document_symbols()
+-- end
+-- end,
+-- desc = "Search symbols",
+-- }
+-- maps.n["<leader>lR"] = { function() require("telescope.builtin").lsp_references() end, desc = "Search references" }
+--end
+--
+---- Terminal
+--if is_available "toggleterm.nvim" then
+-- local toggle_term_cmd = astronvim.toggle_term_cmd
+-- maps.n["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" }
+-- maps.n["<leader>gg"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" }
+-- maps.n["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" }
+-- maps.n["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" }
+-- maps.n["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" }
+-- maps.n["<leader>tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" }
+-- maps.n["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" }
+-- maps.n["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" }
+-- maps.n["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" }
+-- maps.n["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" }
+--end
+--
+---- Stay in indent mode
+--maps.v["<"] = { "<gv", desc = "unindent line" }
+--maps.v[">"] = { ">gv", desc = "indent line" }
+--
+---- Improved Terminal Mappings
+--maps.t["<esc>"] = { "<C-\\><C-n>", desc = "Terminal normal mode" }
+--maps.t["jk"] = { "<C-\\><C-n>", desc = "Terminal normal mode" }
+--maps.t["<C-h>"] = { "<c-\\><c-n><c-w>h", desc = "Terminal left window navigation" }
+--maps.t["<C-j>"] = { "<c-\\><c-n><c-w>j", desc = "Terminal down window navigation" }
+--maps.t["<C-k>"] = { "<c-\\><c-n><c-w>k", desc = "Terminal up window navigation" }
+--maps.t["<C-l>"] = { "<c-\\><c-n><c-w>l", desc = "Terminal right window naviation" }
+-- LSP Installer
+--if is_available "mason-lspconfig.nvim" then maps.n["<leader>li"] = { "<cmd>LspInfo<cr>", desc = "LSP information" } end
+
+-- ALE: toggle _ALE activity
+--keymap('n', '<leader>a',[[:ALEToggle<CR>]])
+
+--keymap('n', '<Leader>cd', ':call fzf#run({'source': 'fd -t d -H . ~', 'sink': 'cd'})<CR>', opts)
+-- ":lua require('neogen').generate()<CR>", opts)
+--keymap("n", "<leader>ww", ":set wrap!<CR>", opts)
+--
diff --git a/lua/user/linecolor.lua b/lua/user/linecolor.lua
new file mode 100644
index 0000000..37550dd
--- /dev/null
+++ b/lua/user/linecolor.lua
@@ -0,0 +1,112 @@
+--local M = {}
+--M.theme = function()
+-- -- I know I could just set bg = nil but I'm leaving this here in case I want custom colors in the future
+-- local colors = {
+-- nobg = nil,
+-- blue = "#87b0f9",
+-- mauve = "#cba6f7",
+-- red = "#f38ba8",
+-- green = "#a6e3a1",
+-- peach = "#fab387",
+-- white = "#c6d0f5",
+-- gray = "#a1a8c9",
+-- black = "#1e1e2e",
+-- }
+-- return {
+-- inactive = {
+-- a = { fg = colors.blue, bg = colors.nobg, gui = "bold" },
+-- b = { fg = colors.white, bg = colors.black },
+-- c = { fg = colors.gray, bg = colors.nobg },
+-- },
+-- visual = {
+-- a = { fg = colors.black, bg = colors.mauve, gui = "bold" },
+-- b = { fg = colors.mauve, bg = colors.nobg },
+-- c = { fg = colors.white, bg = colors.nobg },
+-- },
+-- replace = {
+-- a = { fg = colors.black, bg = colors.red, gui = "bold" },
+-- b = { fg = colors.red, bg = colors.nobg },
+-- c = { fg = colors.white, bg = colors.nobg },
+-- },
+-- normal = {
+-- a = { fg = colors.black, bg = colors.blue, gui = "bold" },
+-- b = { fg = colors.black, bg = colors.green },
+-- c = { fg = colors.white, bg = colors.black },
+-- },
+-- insert = {
+-- a = { fg = colors.black, bg = colors.green, gui = "bold" },
+-- b = { fg = colors.teal, bg = colors.nobg },
+-- c = { fg = colors.white, bg = colors.nobg },
+-- },
+-- command = {
+-- a = { fg = colors.black, bg = colors.peach, gui = "bold" },
+-- b = { fg = colors.peach, bg = colors.nobg },
+-- c = { fg = colors.white, bg = colors.nobg },
+-- },
+-- modified = {
+-- a = { fg = colors.black, bg = colors.peach, gui = "bold" },
+-- b = { fg = colors.peach, bg = colors.peach },
+-- c = { fg = colors.white, bg = colors.peach },
+-- },
+-- }
+--end
+--return M
+local M = {}
+M.theme = function()
+ --local colors = {
+ -- darkgray = "#16161d",
+ -- gray = "#727169",
+ -- innerbg = nil,
+ -- outerbg = "#16161D",
+ -- normal = "#7e9cd8",
+ -- insert = "#98bb6c",
+ -- visual = "#ffa066",
+ -- replace = "#e46876",
+ -- command = "#e6c384",
+ --}
+ local colors = {
+ darkgray = "#16161d",
+ gray = "#727169",
+ innerbg = nil,
+ outerbg = "#16161D",
+ normal = "#39BAE6",
+ insert = "#AAD94C",
+ visual = "#FA8D3F",
+ replace = "#F07171",
+ command = "#F2AE49",
+ }
+ return {
+ inactive = {
+ a = { fg = colors.gray, bg = colors.outerbg, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ },
+ visual = {
+ a = { fg = colors.darkgray, bg = colors.visual, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ },
+ replace = {
+ a = { fg = colors.darkgray, bg = colors.replace, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ },
+ normal = {
+ a = { fg = colors.darkgray, bg = colors.normal, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ y = { fg = colors.gray, bg = colors.outerbg },
+ },
+ insert = {
+ a = { fg = colors.darkgray, bg = colors.insert, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ },
+ command = {
+ a = { fg = colors.darkgray, bg = colors.command, gui = "bold" },
+ b = { fg = colors.gray, bg = colors.outerbg },
+ c = { fg = colors.gray, bg = colors.innerbg },
+ },
+ }
+end
+return M
diff --git a/lua/user/lsp-colors.lua b/lua/user/lsp-colors.lua
new file mode 100644
index 0000000..1398123
--- /dev/null
+++ b/lua/user/lsp-colors.lua
@@ -0,0 +1,9 @@
+local status, colors = pcall(require, "lsp-colors")
+if (not status) then return end
+
+colors.setup {
+ Error = "#db4b4b",
+ Warning = "#e0af68",
+ Information = "#0db9d7",
+ Hint = "#10B981"
+}
diff --git a/lua/user/lsp.lua b/lua/user/lsp.lua
new file mode 100644
index 0000000..5d422a3
--- /dev/null
+++ b/lua/user/lsp.lua
@@ -0,0 +1,584 @@
+
+local fn = vim.fn
+local keymap = vim.keymap
+
+local utils = require("user.utils")
+
+local custom_attach = function(client, bufnr)
+ -- Enable completion triggered by <c-x><c-o>
+ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
+
+ -- Mappings.
+ local map = function(mode, l, r, opts)
+ opts = opts or {}
+ opts.silent = true
+ opts.noremap = true
+ opts.buffer = bufnr
+ keymap.set(mode, l, r, opts)
+ end
+--map("n", "gd", "<Cmd>Lspsaga lsp_finder<CR>") -- Press "o" to open the reference location
+--map("n", "gp", "<Cmd>Lspsaga peek_definition<CR>")
+-- --map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
+ map("n", "<C-]>", vim.lsp.buf.definition)
+-- map("n", "K", vim.lsp.buf.hover)
+-- map("n", "<C-k>", vim.lsp.buf.signature_help)
+-- map("n", "<leader>rn", vim.lsp.buf.rename, { desc = "varialble rename" })
+-- map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
+-- map("n", "[d", vim.diagnostic.goto_prev, { desc = "previous diagnostic" })
+-- map("n", "]d", vim.diagnostic.goto_next, { desc = "next diagnostic" })
+ map("n", "<leader>q", function()
+ vim.diagnostic.setqflist({ open = true })
+ end, { desc = "put diagnostic to qf" })
+-- --map.('n', '<space>q', vim.diagnostic.setloclist)
+-- map("n", "ga", vim.lsp.buf.code_action, { desc = "LSP code action" })
+-- map("n", "<leader>wa", vim.lsp.buf.add_workspace_folder, { desc = "add workspace folder" })
+-- map("n", "<leader>wr", vim.lsp.buf.remove_workspace_folder, { desc = "remove workspace folder" })
+-- map("n", "<leader>wl", function()
+-- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
+-- end, { desc = "list workspace folder" })
+-- map("n", "gs", "vim.lsp.buf.document_symbol()<cr>")
+-- map("n", "gw", "vim.lsp.buf.workspace_symbol()<cr>", { desc = "list workspace folder" })
+-- --map("n", "gs", ":lua vim.lsp.buf.document_symbol()<cr>")
+-- map("n", "gt", ":lua vim.lsp.buf.type_definition()<cr>")
+-- map("n", "gD", ":lua vim.lsp.buf.declaration()<cr>") -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now.
+-- map("n", "gi", ":lua vim.lsp.buf.implementation()<cr>")
+ map("n", "go", ":lua vim.diagnostic.open_float()<cr>")
+-- map("n", "gk", "<Cmd>Lspsaga diagnostic_jump_prev<CR>")
+-- map("n", "gj", "<Cmd>Lspsaga diagnostic_jump_next<CR>")
+--vim.api.nvim_set_keymap('n', '<leader>dd', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true })
+vim.g.diagnostics_visible = true
+function _G.toggle_diagnostics()
+ if vim.g.diagnostics_visible then
+ vim.g.diagnostics_visible = false
+ vim.diagnostic.disable()
+ else
+ vim.g.diagnostics_visible = true
+ vim.diagnostic.enable()
+ end
+end
+map('n', '<Leader>m', ':call v:lua.toggle_diagnostics()<CR>')
+--vim.g.diagnostics_active = true
+--function _G.toggle_diagnostics()
+-- if vim.g.diagnostics_active then
+-- vim.g.diagnostics_active = false
+-- vim.lsp.diagnostic.clear(0)
+-- vim.cmd([[exe "normal ii\<Esc>x"]])
+-- vim.lsp.handlers["textDocument/publishDiagnostics"] = function() end
+-- else
+-- vim.g.diagnostics_active = true
+-- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
+-- vim.lsp.diagnostic.on_publish_diagnostics, {
+-- virtual_text = true,
+-- signs = true,
+-- underline = true,
+-- update_in_insert = false,
+-- }
+-- )
+-- end
+--end
+--
+--map("n", "<leader>i", ":call v:lua.toggle_diagnostics()<CR>")
+
+
+ -- Set some key bindings conditional on server capabilities
+ if client.server_capabilities.documentFormattingProvider then
+ map("n", "<space>f", vim.lsp.buf.format, { desc = "format code" })
+ end
+
+ -- add rust specific keymappings
+ if client.name == "rust_analyzer" then
+ map("n", "<leader>rr", "<cmd>RustRunnables<CR>")
+ map("n", "<leader>ra", "<cmd>RustHoverAction<CR>")
+ end
+
+--For diagnostics for specific cursor position
+--vim.api.nvim_create_autocmd("CursorHold", {
+-- buffer = bufnr,
+-- callback = function()
+-- local opts = {
+-- focusable = false,
+-- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
+-- border = 'rounded',
+-- source = 'always',
+-- prefix = ' ',
+-- scope = 'cursor',
+-- }
+-- vim.diagnostic.open_float(nil, opts)
+-- end
+--})
+ -- Diagnostic position
+-- vim.api.nvim_create_autocmd("CursorHold", {
+-- buffer = bufnr,
+-- callback = function()
+-- local float_opts = {
+-- focusable = false,
+-- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
+-- border = "rounded",
+-- source = "always", -- show source in diagnostic popup window
+-- prefix = " ",
+-- }
+--
+-- if not vim.b.diagnostics_pos then
+-- vim.b.diagnostics_pos = { nil, nil }
+-- end
+--
+-- local cursor_pos = vim.api.nvim_win_get_cursor(0)
+-- if
+-- (cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
+-- and #vim.diagnostic.get() > 0
+-- then
+-- vim.diagnostic.open_float(nil, float_opts)
+-- end
+--
+-- vim.b.diagnostics_pos = cursor_pos
+-- end,
+-- })
+
+ -- The below command will highlight the current variable and its usages in the buffer.
+ if client.server_capabilities.documentHighlightProvider then
+ vim.cmd([[
+ hi! link LspReferenceRead Visual
+ hi! link LspReferenceText Visual
+ hi! link LspReferenceWrite Visual
+ augroup lsp_document_highlight
+ autocmd! * <buffer>
+ autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
+ autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
+ augroup END
+ ]])
+ end
+
+ if vim.g.logging_level == "debug" then
+ local msg = string.format("Language server %s started!", client.name)
+ vim.notify(msg, vim.log.levels.DEBUG, { title = "Server?" })
+ end
+end
+
+local capabilities = vim.lsp.protocol.make_client_capabilities()
+capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
+capabilities.textDocument.completion.completionItem.snippetSupport = true
+capabilities.offsetEncoding = { "utf-16" }
+
+local lspconfig = require("lspconfig")
+
+if utils.executable("pylsp") then
+ lspconfig.pylsp.setup({
+ settings = {
+ pylsp = {
+ plugins = {
+ pylint = { enabled = true, executable = "pylint" },
+ pyflakes = { enabled = false },
+ pycodestyle = { enabled = false },
+ jedi_completion = { fuzzy = true },
+ pyls_isort = { enabled = true },
+ pylsp_mypy = { enabled = true },
+ },
+ },
+ },
+ flags = {
+ debounce_text_changes = 200,
+ },
+ capabilities = capabilities,
+ })
+else
+ vim.notify("pylsp not found!", vim.log.levels.WARN, { title = "Server?" })
+end
+
+-- if utils.executable('pyright') then
+-- lspconfig.pyright.setup{
+-- on_attach = custom_attach,
+-- capabilities = capabilities
+-- }
+-- else
+-- vim.notify("pyright not found!", vim.log.levels.WARN, {title = 'Server?'})
+-- end
+
+if utils.executable("clangd") then
+ lspconfig.clangd.setup({
+ on_attach = custom_attach,
+ capabilities = capabilities,
+ filetypes = { "c", "cpp", "cc" },
+ flags = {
+ debounce_text_changes = 500,
+ },
+ })
+else
+ vim.notify("clangd not found!", vim.log.levels.WARN, { title = "Server?" })
+end
+
+-- set up vim-language-server
+if utils.executable("vim-language-server") then
+ lspconfig.vimls.setup({
+ on_attach = custom_attach,
+ flags = {
+ debounce_text_changes = 500,
+ },
+ capabilities = capabilities,
+ })
+else
+ vim.notify("vim-language-server not found!", vim.log.levels.WARN, { title = "Server?" })
+end
+
+-- set up bash-language-server
+if utils.executable("bash-language-server") then
+ lspconfig.bashls.setup({
+ on_attach = custom_attach,
+ capabilities = capabilities,
+ })
+end
+
+if utils.executable("lua-language-server") then
+ lspconfig.sumneko_lua.setup({
+ on_attach = custom_attach,
+ settings = {
+ Lua = {
+ runtime = {
+ -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
+ version = "LuaJIT",
+ },
+ diagnostics = {
+ -- Get the language server to recognize the `vim` global
+ globals = { "vim" },
+ },
+ workspace = {
+ -- Make the server aware of Neovim runtime files,
+ library = {
+ fn.stdpath("data") .. "/site/pack/packer/opt/emmylua-nvim",
+ fn.stdpath("config"),
+ },
+ maxPreload = 2000,
+ preloadFileSize = 50000,
+ },
+ },
+ },
+ capabilities = capabilities,
+ })
+end
+
+
+if utils.executable("rust-language-server") then
+require("lspconfig").rust_analyzer.setup{
+ cmd = { "rustup", "run", "nightly", "rust-analyzer" },
+ on_attach = custom_attach,
+ flags = {
+ debounce_text_changes = 500,
+ },
+ --[[
+ settings = {
+ rust = {
+ unstable_features = true,
+ build_on_save = false,
+ all_features = true,
+ },
+ }
+ --]]
+}
+end
+
+--vim.diagnostic.config({
+-- virtual_text = false,
+-- underline = true,
+--})
+vim.diagnostic.config({
+ underline = false,
+ signs = true,
+ virtual_text = false,
+ float = {
+ show_header = true,
+ source = 'if_many',
+ border = 'rounded',
+ focusable = false,
+ },
+ update_in_insert = false, -- default to false
+ severity_sort = false, -- default to false
+})
+-- Show line diagnostics automatically in hover window
+--vim.o.updatetime = 250
+--vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})]]
+--vim.cmd ([[ noremap <leader>a :autocmd! CursorHold,CursorHoldI <CR>]])
+
+--vim.cmd [[ noremap <leader>a :autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})<CR>]]
+--local diagnostics_active = true
+--local toggle_diagnostics = function()
+-- diagnostics_active = not diagnostics_active
+-- if diagnostics_active then
+-- vim.o.updatetime = 250
+-- vim.cmd ([[autocmd! CursorHold,CursorHoldI <CR>]])
+-- --vim.diagnostic.open_float(nil, {focus=false})
+-- else
+-- vim.o.updatetime = 250
+-- vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
+-- --vim.diagnostic.hide()
+-- --vim.diagnostic.disable()
+-- end
+--end
+--vim.keymap.set("n", "<leader>a", toggle_diagnostics)
+
+--function LspDiagnosticsFocus()
+-- vim.api.nvim_command('set eventignore=WinLeave')
+-- vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""')
+-- vim.diagnostic.open_float(nil, {focusable = false, scope = 'line', close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}})
+--end
+--vim.api.nvim_set_keymap('', '<Leader>a', '<Cmd>lua LspDiagnosticsFocus()<CR>', {silent = true})
+ --vim.o.updatetime = 250
+
+-- vim.o.updatetime = 250
+----vim.o.updatetime = 250
+----vim.cmd [[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})]]
+----local diagnostics_active = true
+--local toggle_diagnostics = function()
+-- --diagnostics_active = not diagnostics_active
+-- --if diagnostics_active then
+-- --if vim.diagnostic.open_float() == true then
+-- if vim.api.nvim_exec([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]]
+--, true) then
+-- vim.api.nvim_exec([[autocmd! CursorHold,CursorHoldI ]]
+--, true)
+-- else
+-- vim.o.updatetime = 250
+-- vim.api.nvim_exec([[autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]], true)
+-- end
+--end
+--vim.keymap.set("n", "<leader>a", toggle_diagnostics)
+--
+--vim.api.nvim_create_autocmd('CursorHold', {
+-- vim.diagnostic.open_float(nil, {focus=false})
+--
+--})
+
+vim.o.updatetime = 250
+vim.cmd[[
+augroup OpenFloat
+ autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,})
+
+augroup END
+]]
+vim.cmd([[
+function! ToggleDiagnosticsOpenFloat()
+ " Switch the toggle variable
+ let g:DiagnosticsOpenFloat = !get(g:, 'DiagnosticsOpenFloat', 1)
+
+ " Reset group
+ augroup OpenFloat
+ autocmd!
+ augroup END
+
+ " Enable if toggled on
+ if g:DiagnosticsOpenFloat
+ augroup OpenFloat
+ autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) print ("vim.diagnostic.open_float enabled . . .")
+ augroup END
+ endif
+endfunction
+nnoremap <leader>a :call ToggleDiagnosticsOpenFloat()<CR>\|:echom "vim.diagnostic.open_float disabled . . ."<CR>
+]])
+
+--vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(
+-- vim.lsp.handlers.hover, {
+-- signs = true,
+-- underline = false,
+-- virtual_text = false,
+-- show_diagnostic_autocmds = {'InsertLeave', 'TextChanged'},
+-- diagnostic_delay = 500
+-- })
+--vim.cmd [[autocmd CursorHold * lua vim.diagnostic.open_float(0, {scope="cursor", close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}})]]
+
+--function LspDiagnosticsFocus()
+-- vim.api.nvim_command('set eventignore=WinLeave')
+-- vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""')
+-- vim.diagnostic.open_float(nil, {focusable = false, scope = 'line', close_events = {"CursorMoved", "CursorMovedI", "BufHidden", "InsertCharPre", "WinLeave"}})
+--end
+--vim.api.nvim_set_keymap('', '<Leader>a', '<Cmd>lua LspDiagnosticsFocus()<CR>', {silent = true})
+
+--local diagnostics_active = true
+--map('n', '<leader>a', function()
+-- diagnostics_active = not diagnostics_active
+-- if diagnostics_active then
+-- vim.diagnostic.show()
+-- else
+-- vim.diagnostic.hide()
+-- end
+--end)
+
+-- Global config for diagnostic
+--vim.diagnostic.config({
+-- underline = false,
+-- virtual_text = false,
+-- signs = true,
+-- severity_sort = true,
+-- float = {
+-- focusable = true, --
+-- style = "minimal", --
+-- --border = "rounded",
+-- border = "shadow",
+-- source = "always",
+-- header = "",
+-- prefix = "",
+-- },
+--})
+
+vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ underline = true,
+ virtual_text = false,
+ signs = true,
+ update_in_insert = false,
+})
+
+--vim.lsp.buf.definition
+vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
+
+--vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "rounded" })
+
+vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "rounded" })
+
+--local signs = { Error = " ", Warn = " ", Info = "􀅴 ", Hint = " " }
+--local signs = { Error = "✘", Warn = "▲", Info = "🛈 ", Hint = "⚑" }
+local signs = { Error = "✘", Warn = "▲", Info = "􀅳", Hint = "⚑" }
+for type, icon in pairs(signs) do
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
+end
+
+
+---- Location information about the last message printed. The format is
+---- `(did print, buffer number, line number)`.
+--local last_echo = { false, -1, -1 }
+--
+---- The timer used for displaying a diagnostic in the commandline.
+--local echo_timer = nil
+--
+---- The timer after which to display a diagnostic in the commandline.
+--local echo_timeout = 250
+--
+---- The highlight group to use for warning messages.
+--local warning_hlgroup = 'WarningMsg'
+--
+---- The highlight group to use for error messages.
+--local error_hlgroup = 'ErrorMsg'
+--
+---- If the first diagnostic line has fewer than this many characters, also add
+---- the second line to it.
+--local short_line_limit = 20
+--
+---- Shows the current line's diagnostics in a floating window.
+--function show_line_diagnostics()
+-- vim
+-- .lsp
+-- .diagnostic
+-- .show_line_diagnostics({ severity_limit = 'Warning' }, vim.fn.bufnr(''))
+--end
+--
+---- Prints the first diagnostic for the current line.
+--function echo_diagnostic()
+-- if echo_timer then
+-- echo_timer:stop()
+-- end
+--
+-- echo_timer = vim.defer_fn(
+-- function()
+-- local line = vim.fn.line('.') - 1
+-- local bufnr = vim.api.nvim_win_get_buf(0)
+--
+-- if last_echo[1] and last_echo[2] == bufnr and last_echo[3] == line then
+-- return
+-- end
+--
+-- local diags = vim
+-- .lsp
+-- .diagnostic
+-- .get_line_diagnostics(bufnr, line, { severity_limit = 'Warning' })
+--
+-- if #diags == 0 then
+-- -- If we previously echo'd a message, clear it out by echoing an empty
+-- -- message.
+-- if last_echo[1] then
+-- last_echo = { false, -1, -1 }
+--
+-- vim.api.nvim_command('echo ""')
+-- end
+--
+-- return
+-- end
+--
+-- last_echo = { true, bufnr, line }
+--
+-- local diag = diags[1]
+-- local width = vim.api.nvim_get_option('columns') - 15
+-- local lines = vim.split(diag.message, "\n")
+-- local message = lines[1]
+-- local trimmed = false
+--
+-- if #lines > 1 and #message <= short_line_limit then
+-- message = message .. ' ' .. lines[2]
+-- end
+--
+-- if width > 0 and #message >= width then
+-- message = message:sub(1, width) .. '...'
+-- end
+--
+-- local kind = 'warning'
+-- local hlgroup = warning_hlgroup
+--
+-- if diag.severity == vim.lsp.protocol.DiagnosticSeverity.Error then
+-- kind = 'error'
+-- hlgroup = error_hlgroup
+-- end
+--
+-- local chunks = {
+-- { kind .. ': ', hlgroup },
+-- { message }
+-- }
+--
+-- vim.api.nvim_echo(chunks, false, {})
+-- end,
+-- echo_timeout
+-- )
+--end
+--vim.cmd([[
+-- autocmd CursorMoved * :lua echo_diagnostic()
+--]])
+-- Highlight line number instead of having icons in sign column
+
+-- See the properties of the signs with sign list.
+
+--vim.cmd [[
+-- highlight! DiagnosticLineNrError guibg=#51202A guifg=#FF0000 gui=bold
+-- highlight! DiagnosticLineNrWarn guibg=#51412A guifg=#FFA500 gui=bold
+-- highlight! DiagnosticLineNrInfo guibg=#1E535D guifg=#00FFFF gui=bold
+-- highlight! DiagnosticLineNrHint guibg=#1E205D guifg=#0000FF gui=bold
+--
+-- sign define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=DiagnosticLineNrError
+-- sign define DiagnosticSignWarn text= texthl=DiagnosticSignWarn linehl= numhl=DiagnosticLineNrWarn
+-- sign define DiagnosticSignInfo text= texthl=DiagnosticSignInfo linehl= numhl=DiagnosticLineNrInfo
+-- sign define DiagnosticSignHint text= texthl=DiagnosticSignHint linehl= numhl=DiagnosticLineNrHint
+--]]
+
+-- Highlight symbol under cursor
+
+-- Add the following to your on_attach (this allows checking server capabilities to avoid calling invalid commands.
+
+--if client.resolved_capabilities.document_highlight then
+-- vim.cmd [[
+-- hi! LspReferenceRead cterm=bold ctermbg=red guibg=LightYellow
+-- hi! LspReferenceText cterm=bold ctermbg=red guibg=LightYellow
+-- hi! LspReferenceWrite cterm=bold ctermbg=red guibg=LightYellow
+-- ]]
+-- vim.api.nvim_create_augroup('lsp_document_highlight', {
+-- clear = false
+-- })
+-- vim.api.nvim_clear_autocmds({
+-- buffer = bufnr,
+-- group = 'lsp_document_highlight',
+-- })
+-- vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
+-- group = 'lsp_document_highlight',
+-- buffer = bufnr,
+-- callback = vim.lsp.buf.document_highlight,
+-- })
+-- vim.api.nvim_create_autocmd('CursorMoved', {
+-- group = 'lsp_document_highlight',
+-- buffer = bufnr,
+-- callback = vim.lsp.buf.clear_references,
+-- })
+--end
+
diff --git a/lua/user/lspkind.lua b/lua/user/lspkind.lua
new file mode 100644
index 0000000..72ca5c2
--- /dev/null
+++ b/lua/user/lspkind.lua
@@ -0,0 +1,47 @@
+local status, lspkind = pcall(require, "lspkind")
+if (not status) then return end
+
+lspkind.init({
+ -- enables text annotations
+ --
+ -- default: true
+ mode = 'symbol',
+
+ -- default symbol map
+ -- can be either 'default' (requires nerd-fonts font) or
+ -- 'codicons' for codicon preset (requires vscode-codicons font)
+ --
+ -- default: 'default'
+ preset = 'codicons',
+
+ -- override preset symbols
+ --
+ -- default: {}
+ symbol_map = {
+ Text = "",
+ Method = "",
+ Function = "",
+ Constructor = "",
+ Field = "ﰠ",
+ Variable = "",
+ Class = "ﴯ",
+ Interface = "",
+ Module = "",
+ Property = "ﰠ",
+ Unit = "塞",
+ Value = "",
+ Enum = "",
+ Keyword = "",
+ Snippet = "",
+ Color = "",
+ File = "",
+ Reference = "",
+ Folder = "",
+ EnumMember = "",
+ Constant = "",
+ Struct = "פּ",
+ Event = "",
+ Operator = "",
+ TypeParameter = ""
+ },
+})
diff --git a/lua/user/lspsaga.lua b/lua/user/lspsaga.lua
new file mode 100644
index 0000000..0bf1ec7
--- /dev/null
+++ b/lua/user/lspsaga.lua
@@ -0,0 +1,145 @@
+require "lspsaga".init_lsp_saga {
+ -- "single" | "double" | "rounded" | "bold" | "plus"
+ border_style = "rounded",
+ --border_style = "single",
+ saga_winblend = 30,
+ move_in_saga = { next = '<C-n>', prev = '<C-p>' },
+ --move_in_saga = { prev = "k", next = "j" },
+ scroll_in_preview = {
+ scroll_down = "<C-d>",
+ scroll_up = "<C-u>",
+ },
+ diagnostic_header = { " ", " ", " ", " " },
+ -- add bracket or something with diagnostic source, just have 2 elements
+ -- use emoji lightbulb in default
+ code_action_icon = "",
+ --code_action_icon = "ﯦ ",
+ -- if true can press number to execute the codeaction in codeaction window
+ code_action_num_shortcut = true,
+ -- same as nvim-lightbulb but async
+ code_action_lightbulb = {
+ enable = false,
+ sign = false,
+ sign_priority = 20, --
+ virtual_text = false,
+ },
+ finder_icons = {
+ def = " ",
+ ref = " ",
+ link = " ",
+ },
+ -- preview lines of lsp_finder and definition preview
+ max_preview_lines = 5,
+ definition_action_keys = {
+ edit = '<CR>',
+ vsplit = '<C-y>',
+ split = '<C-x>',
+ tabe = '<C-t>',
+ quit = '<ESC>',
+ },
+ -- definition_preview_quit = '<ESC>',
+ -- finder_preview_hl_ns = 8,
+ finder_action_keys = {
+ open = { 'o', '<CR>' },
+ vsplit = "v",
+ split = "s",
+ tabe = "t",
+ quit = "<ESC>",
+ scroll_down = "<C-j>",
+ scroll_up = "<C-k>", -- quit can be a table
+ },
+ code_action_keys = {
+ quit = "<ESC>",
+ exec = "<CR>",
+ },
+ rename_action_quit = "<ESC>",
+ rename_in_select = true,
+ symbol_in_winbar = {
+ enable = true,
+ --in_custom = false,
+ in_custom = true,
+ separator = '  ',
+ --show_file = false,
+ show_file = true,
+ click_support = false,
+ --click_support = false,
+ },
+ --show_outline = {
+ -- win_position = 'right',
+ -- --set special filetype win that outline window split.like NvimTree neotree
+ -- -- defx, db_ui
+ -- min_with = '',
+ -- win_width = 40,
+ -- auto_enter = false,
+ -- auto_preview = true,
+ -- virt_text = 'x',
+ -- jump_key = 'l',
+ -- -- auto refresh when change buffer
+ -- auto_refresh = true,
+ --},
+ custom_kind = {
+ File = { " " },
+ Module = { " " },
+ Namespace = { "ﱕ " },
+ Package = { " " },
+ Class = { "ﴯ " },
+ Method = { "" },
+ Property = { "ﰠ " },
+ Field = { "ﰠ " },
+ Constructor = { " " },
+ Enum = { " " },
+ Interface = { " " },
+ Function = { " " },
+ Variable = { " " },
+ Constant = { " " },
+ String = { " " },
+ Number = { " " },
+ Boolean = { " " },
+ Array = { " " },
+ Object = { " " },
+ Key = { "- " },
+ Null = { " " },
+ EnumMember = { " " },
+ Struct = { " " },
+ Event = { " " },
+ Operator = { " " },
+ TypeParameter = { " " },
+ TypeAlias = { " " },
+ Parameter = { " " },
+ StaticMethod = { " " },
+ Macro = { "廓" },
+ },
+}
+
+ -- Mappings.
+local map = vim.api.nvim_set_keymap
+local opts = { noremap = true, silent = true }
+
+map("n", "gd", "<CMD>Lspsaga peek_definition<CR>", opts)
+--map("n", "gp", "<Cmd>Lspsaga peek_definition<CR>", opts)
+map("n", "gi", "<CMD>Lspsaga lsp_finder<CR>", opts)
+map("n", "gh", "<CMD>Lspsaga hover_doc<CR>", opts)
+map("n", "gs", "<CMD>Lspsaga signature_help<CR>", opts)
+map("n", "ga", "<CMD>Lspsaga code_action<CR>", opts)
+map("v", "ga", "<CMD><C-u>Lspsaga range_code_action<CR>", opts)
+map("n", "gl", "<CMD>Lspsaga show_line_diagnostics<CR>", opts)
+--map("n", "go", "<CMD>Lspsaga open_floaterm zsh<CR>", opts)
+map("n", ";D", "<CMD>Lspsaga show_cursor_diagnostics<CR>", opts)
+map("n", "<gr>", "<CMD>Lspsaga rename<CR>", opts)
+map("n", "gk", "<CMD>Lspsaga diagnostic_jump_prev<CR>", opts)
+map("n", "gj", "<CMD>Lspsaga diagnostic_jump_next<CR>", opts)
+map("n", "[d", "<Cmd>lua vim.lsp.diagnostic.goto_prev()<CR>", opts)
+map("n", "]d", "<Cmd>lua vim.lsp.diagnostic.goto_next()<CR>", opts)
+map("t", "<ESC>", "<CMD>Lspsaga close_floaterm<CR>", opts)
+
+--vim.api.nvim_command("highlight LspFloatWinNormal guibg=none ")
+--hi LspFloatWinNormal guibg=none
+
+
+-- vim.api.nvim_create_autocmd("BufEnter", {
+-- callback = function ()
+-- if #vim.api.nvim_list_wins() == 1 and vim.bo.filetype == "lspsagaoutline" then
+-- vim.cmd "quit"
+-- end
+-- end
+-- })
diff --git a/lua/user/lualine.lua b/lua/user/lualine.lua
new file mode 100644
index 0000000..9d86e21
--- /dev/null
+++ b/lua/user/lualine.lua
@@ -0,0 +1,423 @@
+local lualine_status_ok, lualine = pcall(require, "lualine")
+if not lualine_status_ok then
+ print("lualine.nvim is etiher broken or is not installed.")
+ return
+end
+
+--local colors = require('tokyonight.colors').setup()
+--local colors = {
+--bg_dark = "#1f2335",
+--bg = "#24283b",
+--fg = "#c0caf5",
+--fg_gutter = "#3b4261",
+--green = "#a6e3a1",
+--red = "#f38ba8",
+--}
+
+--local colors = {
+-- gray = '#23232e',
+-- lightgray = '#5f6a8e',
+-- orange = '#ffb86c',
+-- purple = '#bd93f9',
+-- red = '#ff5555',
+-- yellow = '#f1fa8c',
+-- green = '#50fa7b',
+-- white = '#f8f8f2',
+-- black = '#282a36',
+--}
+local colors = {
+ nobg = nil,
+ blue = "#87b0f9",
+ mauve = "#cba6f7",
+ red = "#f38ba8",
+ green = "#a6e3a1",
+ peach = "#fab387",
+ white = "#c6d0f5",
+ gray = "#a1a8c9",
+ black = "#1e1e2e",
+ innerbg = nil,
+ outerbg = "#16161D",
+}
+--require("lualine").setup({
+-- Your lua part of config goes here
+require("lualine").setup({
+ options = {
+ icons_enabled = true,
+ --theme = "auto",
+ theme = require("plugins.linecolor").theme(),
+ --theme = {
+ -- We are going to use lualine_c an lualine_x as left and
+ -- right section. Both are highlighte by c theme . So we
+ -- are just setting default looks o statusline
+ --normal = { c = { fg = colors.fg, bg = colors.bg } },
+ --inactive = { c = { fg = colors.fg, bg = colors.bg } },
+ --},
+ component_separators = { left = "", right = "" },
+ section_separators = { left = "", right = "" },
+ --component_separators = { left = '|', right = '|'},
+ --section_separators = { left = '', right = ''},
+ disabled_filetypes = {
+ statusline = {},
+ winbar = {},
+ },
+ ignore_focus = {},
+ always_divide_middle = true,
+ globalstatus = true,
+ refresh = {
+ statusline = 1000,
+ tabline = 1000,
+ winbar = 1000,
+ },
+ },
+ sections = {
+ lualine_a = { "mode" },
+ lualine_b = {
+ "branch",
+ {
+ "diff",
+ colored = true,
+ diff_color = {
+ added = "DiffAdd",
+ modified = "DiffChange",
+ removed = "DiffDelete",
+ },
+ },
+ {
+ "diagnostics",
+
+ sources = { "nvim_lsp" },
+ sections = { "error", "warn", "info" },
+
+ diagnostics_color = {
+ error = "DiagnosticError",
+ warn = "DiagnosticWarn",
+ info = "DiagnosticInfo",
+ },
+ colored = true,
+ update_in_insert = false,
+ always_visible = false,
+ },
+ },
+ --lualine_b = { "branch", "diff", "diagnostics" },
+ lualine_c = {
+ --{"filetype", padding={right=0}, icon_only = true, component_separators = {left = "", right = ""}},
+ --{"filename", padding={left=0}, color = {gui = "bold,italic"}},
+ --{ "filetype",
+ -- icon_only = true,
+ --},
+ {
+ "filename",
+ --color = {gui = "bold,italic", fg = '#ffaa88', bg = 'nil' },
+ --component_separators = {left = "", right = ""},
+ },
+ },
+ lualine_x = { "encoding", "fileformat", "filetype" },
+ --lualine_x = {
+ -- {"encoding", color = { bg = colors.black }, component_separators = {left = "", right = ""}},
+ -- {"fileformat", color = { bg = colors.black }, component_separators = {left = "", right = ""}},
+ -- {"filetype", color = { bg = colors.black }, component_separators = {left = "", right = ""}},
+ --},
+ lualine_y = { "progress" },
+ lualine_z = { "location" },
+ },
+ inactive_sections = {
+ lualine_a = {},
+ lualine_b = {},
+ lualine_c = { "filename" },
+ lualine_x = { "location" },
+ lualine_y = {},
+ lualine_z = {},
+ },
+ -- tabline = {},
+ tabline = {
+ --lualine_a = { "mode" },
+ --lualine_a = {custom_fname},
+ lualine_a = {
+ {
+ "buffers",
+ show_filename_only = false,
+ show_modified_status = true,
+ mode = 4,
+ buffers_color = {
+ active = { bg = colors.nobg, fg = colors.black }, -- color for active buffer
+ --inactive = { bg = colors.white, fg = colors.fg_gutter }, -- color for inactive buffer
+ --active = { bg = colors.bg, fg = colors.white }, -- color for active buffer
+ --inactive = { bg = colors.bg_dark, fg = colors.fg_gutter }, -- color for inactive buffer
+ ----color = function()
+ ---- return { bg = vim.bo.modified and '#aa3355' or '#33aa88' }
+ ----end,
+ },
+ symbols = {
+ modified = " ●", -- Text to show when the buffer is modified
+ alternate_file = "", -- Text to show to identify the alternate file
+ --directory = "", -- Text to show when the buffer is a directory
+ },
+ max_length = vim.o.columns * 5 / 6,
+ --{{function()
+ -- local bg = 'hi! lualine_buffers_color' -- not modified
+ -- if vim.bo.modified then bg = '#c70039' -- unsaved
+ -- elseif not vim.bo.readonly then bg = 'hi! lualine_buffers_color' end -- readonly
+ -- vim.cmd('hi! lualine_buffers_color guibg='..bg)
+ --end,
+ --color = 'hi! lualine_buffers_color',
+ --}},
+ },
+ },
+ lualine_b = {},
+ lualine_c = {},
+ lualine_x = {},
+ lualine_y = {},
+ lualine_z = {},
+ --lualine_z = { "tabs" },
+ },
+ --tabline = {
+ -- lualine_a = { "mode" },
+ -- lualine_b = { "buffers" },
+ -- lualine_c = { "branch" },
+ -- --lualine_c = { "branch", "diff", "diagnostics" },
+ -- lualine_x = {},
+ -- lualine_y = {},
+ -- lualine_z = { "tabs" },
+ --},
+ --winbar = {
+ -- lualine_a = {},
+ -- lualine_b = {},
+ -- lualine_c = {'filename'},
+ -- lualine_x = {},
+ -- lualine_y = {},
+ -- lualine_z = {}
+ --},
+ --inactive_winbar = {
+ -- lualine_a = {},
+ -- lualine_b = {},
+ -- lualine_c = {},
+ -- lualine_x = {},
+ -- lualine_y = {},
+ -- lualine_z = {}
+ --},
+ winbar = {},
+ inactive_winbar = {},
+ --extensions = {},
+ extensions = { "quickfix" },
+})
+--require("lualine").statusline()
+--require("lualine").tabline()
+--if not lualine_status_ok then
+-- print("lualine.nvim is etiher broken or is not installed.")
+-- return
+--end
+--local lualine_status_ok, lualine = pcall(require, "lualine")
+--if not lualine_status_ok then
+-- print("lualine.nvim is etiher broken or is not installed.")
+-- return
+--end
+--local utils = require("heirline.utils")
+
+--local M = {}
+
+-- stylua: ignore start
+--M.colours = {--{{{
+---- Color table for highlights
+---- stylua: ignore
+--local colors = {
+-- bg = '#2E3440',
+-- fg = '#E5E9F0',
+-- yellow = '#EBCB8B',
+-- cyan = '#88C0D0',
+-- darkblue = '#5E81AC',
+-- green = '#A3BE8C',
+-- orange = '#D08770',
+-- violet = '#B48EAD',
+-- magenta = '#B48EAD',
+-- blue = '#81A1C1',
+-- red = '#BF616A',
+--}
+--
+--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 = {
+--require('lualine').setup {
+-- options = {
+-- -- Disable sections and component separators
+-- component_separators = "",
+-- section_separators = "",
+-- theme = {
+-- -- We are going to use lualine_c an lualine_x as left and
+-- -- right section. Both are highlighte by c theme . So we
+-- -- are just setting default looks o statusline
+-- normal = { c = { fg = colors.fg, bg = colors.bg } },
+-- inactive = { c = { fg = colors.fg, bg = colors.bg } },
+-- },
+-- disabled_filetypes = { "NvimTree" },
+-- },
+-- 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(lualine.sections.lualine_c, component)
+--end
+--
+---- Inserts a component in lualine_x ot right section
+--local function ins_right(component)
+-- table.insert(lualine.sections.lualine_x, component)
+--end
+--
+--ins_left({
+-- function()
+-- return "▊"
+-- end,
+-- color = { fg = colors.green }, -- Sets highlighting of component
+-- padding = { left = 0, right = 1 }, -- We don't need space before this
+--})
+--
+--ins_left({
+-- -- mode component
+-- function()
+-- return ""
+-- end,
+-- color = function()
+-- -- auto change color according to neovims mode
+-- local mode_color = {
+-- n = colors.blue,
+-- i = colors.green,
+-- v = colors.violet,
+-- ["�"] = colors.blue,
+-- V = colors.blue,
+-- c = colors.magenta,
+-- no = colors.red,
+-- s = colors.orange,
+-- S = colors.orange,
+-- ic = colors.yellow,
+-- R = colors.violet,
+-- Rv = colors.violet,
+-- cv = colors.red,
+-- ce = colors.red,
+-- r = colors.cyan,
+-- rm = colors.cyan,
+-- ["r?"] = colors.cyan,
+-- ["!"] = colors.red,
+-- t = colors.red,
+-- }
+-- return { fg = mode_color[vim.fn.mode()] }
+-- end,
+-- padding = { right = 1 },
+--})
+--
+--ins_left({
+-- -- mode component
+-- "mode",
+-- color = function()
+-- -- auto change color according to neovims mode
+-- local mode_color = {
+-- n = colors.red,
+-- i = colors.green,
+-- v = colors.violet,
+-- ["�"] = colors.blue,
+-- V = colors.blue,
+-- c = colors.magenta,
+-- no = colors.red,
+-- s = colors.orange,
+-- S = colors.orange,
+-- ic = colors.yellow,
+-- R = colors.violet,
+-- Rv = colors.violet,
+-- cv = colors.red,
+-- ce = colors.red,
+-- r = colors.cyan,
+-- rm = colors.cyan,
+-- ["r?"] = colors.cyan,
+-- ["!"] = colors.red,
+-- t = colors.red,
+-- }
+-- return { fg = mode_color[vim.fn.mode()] }
+-- end,
+-- padding = { right = 1 },
+--})
+--
+--ins_left({
+-- "branch",
+-- icon = "",
+-- color = { fg = colors.violet, gui = "bold" },
+--})
+--
+--ins_left({
+-- "filename",
+-- cond = conditions.buffer_not_empty,
+-- color = { fg = colors.aqua, gui = "bold" },
+--})
+--
+--ins_left({
+-- -- filesize component
+-- "filesize",
+-- cond = conditions.buffer_not_empty,
+--})
+--
+---- Add components to right sections
+--ins_right({
+-- "o:encoding", -- option component same as &encoding in viml
+-- fmt = string.lower, -- I'm not sure why it's upper case either ;)
+-- cond = conditions.hide_in_width,
+-- color = { fg = colors.yellow },
+--})
+--
+--ins_right({
+-- "fileformat",
+-- fmt = string.upper,
+-- icons_enabled = true, -- I think icons are cool but Eviline doesn't have them. sigh
+-- color = { fg = colors.fg, gui = "bold" },
+--})
+--
+--ins_right({
+-- "filetype",
+--})
+--
+--ins_right({ "progress", color = { fg = colors.fg, gui = "bold" } })
+--
+--ins_right({
+-- "location",
+--})
+--
+--ins_right({
+-- function()
+-- return "▊"
+-- end,
+-- color = { fg = colors.green },
+-- padding = { left = 1 },
+--})
+--return M
+-- Now don't forget to initialize lualine
+--require("lualine").setup(config)
+--require"lualine".setup(config)
+--lualine.setup(config)
diff --git a/lua/user/luasnip.lua b/lua/user/luasnip.lua
new file mode 100644
index 0000000..12352e8
--- /dev/null
+++ b/lua/user/luasnip.lua
@@ -0,0 +1,80 @@
+if vim.g.snippets ~= "luasnip" or not pcall(require, "luasnip") then
+ return
+end
+--local luasnip = require("luasnip")
+local ls = require "luasnip" --
+local types = require "luasnip.util.types" --
+local options = {
+ history = true,
+ updateevents = "TextChanged,TextChangedI",
+ -- Autosnippets:
+ enable_autosnippets = true, --
+ ext_opts = { --
+ [types.choiceNode] = { --
+ active = { --
+ virt_text = { { " « ", "NonTest" } }, --
+ }, --
+ }, --
+ }, --
+}
+-- <c-k> is my expansion key
+-- this will expand the current item or jump to the next item within the snippet.
+vim.keymap.set({ "i", "s" }, "<c-.>", function()
+ if ls.expand_or_jumpable() then
+ ls.expand_or_jump()
+ end
+end, { silent = true })
+
+-- <c-j> is my jump backwards key.
+-- this always moves to the previous item within the snippet
+vim.keymap.set({ "i", "s" }, "<c-,>", function()
+ if ls.jumpable(-1) then
+ ls.jump(-1)
+ end
+end, { silent = true })
+
+-- <c-l> is selecting within a list of options.
+-- This is useful for choice nodes (introduced in the forthcoming episode 2)
+vim.keymap.set("i", "<c-l>", function()
+ if ls.choice_active() then
+ ls.change_choice(1)
+ end
+end)
+
+vim.keymap.set("i", "<c-c>", require "luasnip.extras.select_choice")
+
+-- shorcut to source my luasnips file again, which will reload my snippets
+vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/plugins/luasnip.lua<CR>")
+
+-- ls.parser.parse_snippet(<text>, <VS**** style snippet>)
+ls.snippets = {
+ all = {
+ -- Available in any filetype
+ ls.parser.parse_snippet("expand", "-- this is what was expanded!"),
+ },
+ lua = {
+ -- Lua specific snippets go here.
+ },
+}
+
+
+
+
+--luasnip.config.set_config(options)
+--require("luasnip.loaders.from_vscode").lazy_load()
+--require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" }
+--
+--vim.api.nvim_create_autocmd("InsertLeave", {
+-- callback = function()
+-- if
+-- require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
+-- and not require("luasnip").session.jump_active
+-- then
+-- require("luasnip").unlink_current()
+-- end
+-- end,
+--})
+
+
+
+
diff --git a/lua/user/mason.lua b/lua/user/mason.lua
new file mode 100644
index 0000000..69c61ba
--- /dev/null
+++ b/lua/user/mason.lua
@@ -0,0 +1,27 @@
+local status, mason = pcall(require, "mason")
+if (not status) then return end
+local status2, lspconfig = pcall(require, "mason-lspconfig")
+if (not status2) then return end
+
+mason.setup({
+
+})
+
+lspconfig.setup {
+ ensure_installed = { "sumneko_lua" },
+}
+local keymap = vim.api.nvim_set_keymap
+local opts = { noremap = true }
+
+
+keymap('n', 'gd', ':lua vim.lsp.buf.definition()<cr>', opts)
+keymap('n', 'gD', ':lua vim.lsp.buf.declaration()<cr>', opts)
+keymap('n', 'gi', ':lua vim.lsp.buf.implementation()<cr>', opts)
+keymap('n', 'gw', ':lua vim.lsp.buf.document_symbol()<cr>', opts)
+keymap('n', 'gw', ':lua vim.lsp.buf.workspace_symbol()<cr>', opts)
+keymap('n', 'gr', ':lua vim.lsp.buf.references()<cr>', opts)
+keymap('n', 'gt', ':lua vim.lsp.buf.type_definition()<cr>', opts)
+keymap('n', 'K', ':lua vim.lsp.buf.hover()<cr>', opts)
+keymap('n', '<c-k>', ':lua vim.lsp.buf.signature_help()<cr>', opts)
+keymap('n', '<leader>af', ':lua vim.lsp.buf.code_action()<cr>', opts)
+keymap('n', '<leader>rn', ':lua vim.lsp.buf.rename()<cr>', opts)
diff --git a/lua/user/modify-blend.lua b/lua/user/modify-blend.lua
new file mode 100644
index 0000000..7c48815
--- /dev/null
+++ b/lua/user/modify-blend.lua
@@ -0,0 +1,40 @@
+local ui = vim.api.nvim_list_uis()[1]
+
+local bufnr = vim.api.nvim_create_buf(false, true)
+local win = vim.api.nvim_open_win(bufnr, true, {
+ relative = "editor",
+ width = ui.width,
+ height = ui.height,
+ row = 10,
+ col = 10,
+ style = "minimal",
+})
+
+vim.api.nvim_win_set_option(win, "winblend", 1)
+
+local blend_start = 15
+local offset = 1
+
+CANCEL = false
+local timer = vim.loop.new_timer()
+timer:start(
+ 0,
+ 50,
+ vim.schedule_wrap(function()
+ blend_start = blend_start + offset
+
+ if blend_start > 90 then
+ offset = -1
+ elseif blend_start < 10 then
+ offset = 1
+ end
+
+ if CANCEL or not vim.api.nvim_win_is_valid(win) then
+ timer:close()
+ timer:stop()
+ return
+ end
+
+ vim.cmd([[highlight NormalFloat blend=]] .. tostring(blend_start))
+ end)
+)
diff --git a/lua/user/mods.lua b/lua/user/mods.lua
new file mode 100644
index 0000000..ec77173
--- /dev/null
+++ b/lua/user/mods.lua
@@ -0,0 +1,138 @@
+--vim.cmd([[
+-- function RandomColorScheme()
+-- let mycolors = split(globpath(&rtp,"**/colors/*.vim"),"\n")
+-- exe 'so ' . mycolors[localtime() % len(mycolors)]
+-- unlet mycolors
+-- endfunction
+--
+-- call RandomColorScheme()
+--
+-- :command NewColor call RandomColorScheme()
+--]])
+
+--vim.cmd([[
+-- function RandomColorSchemeMyPicks()
+-- let mypicks = ["pyte", "fokus", "github", "peachpuff", "morning", "simple256", "xcode", "gruvbox"]
+-- let mypick = mypicks[localtime() % len(mypicks)]
+-- echom mypick
+-- execute 'colo' mypick
+-- endfunction
+--
+-- command NewColor call RandomColorSchemeMyPicks()
+--
+-- let s:use_gui = exists('g:neovide') || has('gui_running') || (has('termguicolors') && &termguicolors)
+-- if (s:use_gui)
+-- call RandomColorSchemeMyPicks()
+-- endif
+--]])
+
+vim.cmd([[
+ let g:fzf_history_dir = '~/.local/share/fzf-history'
+ map <leader>z :FZF<CR>
+ map <leader>a :Files<CR>
+ map <leader>l :Lines<CR>
+ map <leader>L :BLines<CR>
+ map <leader>B :Buffers<CR>
+ map <leader>h :History:<CR>
+ nnoremap <leader>g :Rg<CR>
+ "nnoremap <leader>t :Tags<CR>
+ nnoremap <leader>m :Marks<CR>
+ " This is the default extra key bindings
+ let g:fzf_action = {
+ \ 'ctrl-t': 'tab split',
+ \ 'ctrl-x': 'split',
+ \ 'ctrl-y': 'vsplit' }
+ let g:fzf_tags_command = 'ctags -R'
+ " Border color
+ let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
+ let $FZF_DEFAULT_OPTS = '--layout=reverse --info=inline'
+ let $FZF_DEFAULT_COMMAND="rg --files --hidden"
+ " Customize fzf colors to match your color scheme
+ let g:fzf_colors =
+ \ { 'fg': ['fg', 'Normal'],
+ \ 'bg': ['bg', 'Normal'],
+ \ 'hl': ['fg', 'Comment'],
+ \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
+ \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
+ \ 'hl+': ['fg', 'Statement'],
+ \ 'info': ['fg', 'PreProc'],
+ \ 'border': ['fg', 'Ignore'],
+ \ 'prompt': ['fg', 'Conditional'],
+ \ 'pointer': ['fg', 'Exception'],
+ \ 'marker': ['fg', 'Keyword'],
+ \ 'spinner': ['fg', 'Label'],
+ \ 'header': ['fg', 'Comment'] }
+ " Get Files
+ command! -bang -nargs=? -complete=dir Files
+ \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
+ " Get text in files with Rg
+ command! -bang -nargs=* Rg
+ \ call fzf#vim#grep(
+ \ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
+ \ fzf#vim#with_preview(), <bang>0)
+ " Ripgrep advanced
+ function! RipgrepFzf(query, fullscreen)
+ let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
+ let initial_command = printf(command_fmt, shellescape(a:query))
+ let reload_command = printf(command_fmt, '{q}')
+ let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
+ call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
+ endfunction
+ command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
+ " Git grep
+ command! -bang -nargs=* GGrep
+ \ call fzf#vim#grep(
+ \ 'git grep --line-number '.shellescape(<q-args>), 0,
+ \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
+ command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0))
+]])
+
+vim.cmd([[
+ " Enable mouse scrollback
+ set mouse=a
+ tnoremap <Esc> <C-\><C-n>
+ tnoremap <c-b> <c-\><c-n>
+ function! ClearTerminal()
+ set scrollback=1
+ let &g:scrollback=1
+ echo &scrollback
+ call feedkeys("\i")
+ call feedkeys("clear\<CR>")
+ call feedkeys("\<C-\>\<C-n>")
+ call feedkeys("\i")
+ sleep 100m
+ let &scrollback=s:scroll_value
+ endfunction
+]])
+
+vim.cmd([[
+ " :Rename {newname}
+ function! RenameFile()
+ let old_name = expand('%')
+ let new_name = input('New file name: ', expand('%'), 'file')
+ if new_name != '' && new_name != old_name
+ exec ':saveas ' . new_name
+ exec ':silent !rm ' . old_name
+ redraw!
+ endif
+ endfunction
+ map <leader>re :call RenameFile()<cr>
+]])
+
+--vim.cmd([[
+-- " Markdown Settings
+-- autocmd BufNewFile,BufReadPost *.md set filetype=markdown
+-- let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'sql', 'pug']
+-- let g:markdown_minlines = 100
+-- let g:instant_markdown_autostart = 0
+--]])
+--
+--vim.cmd([[
+-- " On The Fly Table mode
+-- function! s:isAtStartOfLine(mapping)
+-- let text_before_cursor = getline('.')[0 : col('.')-1]
+-- let mapping_pattern = '\V' . escape(a:mapping, '\')
+-- let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
+-- return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
+-- endfunction
+--]])
diff --git a/lua/user/neoscroll.lua b/lua/user/neoscroll.lua
new file mode 100644
index 0000000..d122584
--- /dev/null
+++ b/lua/user/neoscroll.lua
@@ -0,0 +1,21 @@
+require("neoscroll").setup({
+ easing_function = "quadratic",
+})
+
+local t = {}
+-- Syntax: t[keys] = {function, {function arguments}}
+-- Use the "sine" easing function
+t["<C-u>"] = { "scroll", { "-vim.wo.scroll", "true", "20", [['cubic']] } }
+t["<C-d>"] = { "scroll", { "vim.wo.scroll", "true", "20", [['cubic']] } }
+-- Use the "circular" easing function
+t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
+t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "50", [['cubic']] } }
+-- Pass "nil" to disable the easing animation (constant scrolling speed)
+t["<C-y>"] = { "scroll", { "-0.10", "false", "100", nil } }
+t["<C-e>"] = { "scroll", { "0.10", "false", "100", nil } }
+-- When no easing function is provided the default easing function (in this case "quadratic") will be used
+t["zt"] = { "zt", { "10" } }
+t["zz"] = { "zz", { "10" } }
+t["zb"] = { "zb", { "10" } }
+
+require("neoscroll.config").set_mappings(t)
diff --git a/lua/user/null-ls.lua b/lua/user/null-ls.lua
new file mode 100644
index 0000000..7fc4377
--- /dev/null
+++ b/lua/user/null-ls.lua
@@ -0,0 +1,26 @@
+local null_ls_status_ok, null_ls = pcall(require, "null-ls")
+if not null_ls_status_ok then
+ return
+end
+
+-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting
+local formatting = null_ls.builtins.formatting
+-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics
+local diagnostics = null_ls.builtins.diagnostics
+
+--null_ls.setup({
+-- debug = false,
+-- sources = {
+-- formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }),
+-- formatting.black.with({ extra_args = { "--fast" } }),
+-- formatting.stylua,
+-- -- diagnostics.flake8
+-- },
+--})
+require("null-ls").setup({
+ sources = {
+ require("null-ls").builtins.formatting.stylua,
+ require("null-ls").builtins.diagnostics.eslint,
+ require("null-ls").builtins.completion.spell,
+ },
+})
diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua
new file mode 100644
index 0000000..74030cb
--- /dev/null
+++ b/lua/user/nvim-tree.lua
@@ -0,0 +1,68 @@
+local status_ok, nvim_tree = pcall(require, "nvim-tree")
+if not status_ok then
+ return
+end
+
+local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config")
+if not config_status_ok then
+ return
+end
+
+local tree_cb = nvim_tree_config.nvim_tree_callback
+
+nvim_tree.setup({
+ update_focused_file = {
+ enable = true,
+ update_cwd = true,
+ },
+ renderer = {
+ root_folder_modifier = ":t",
+ icons = {
+ glyphs = {
+ default = "",
+ symlink = "",
+ folder = {
+ arrow_open = "",
+ arrow_closed = "",
+ default = "",
+ open = "",
+ empty = "",
+ empty_open = "",
+ symlink = "",
+ symlink_open = "",
+ },
+ git = {
+ unstaged = "",
+ staged = "S",
+ unmerged = "",
+ renamed = "➜",
+ untracked = "U",
+ deleted = "",
+ ignored = "◌",
+ },
+ },
+ },
+ },
+ diagnostics = {
+ enable = true,
+ show_on_dirs = true,
+ icons = {
+ hint = "",
+ info = "",
+ warning = "",
+ error = "",
+ },
+ },
+ view = {
+ width = 30,
+ --height = 30,
+ side = "left",
+ mappings = {
+ list = {
+ { key = { "l", "<CR>", "o" }, cb = tree_cb("edit") },
+ { key = "h", cb = tree_cb("close_node") },
+ { key = "v", cb = tree_cb("vsplit") },
+ },
+ },
+ },
+})
diff --git a/lua/user/opts.lua b/lua/user/opts.lua
new file mode 100644
index 0000000..51b3628
--- /dev/null
+++ b/lua/user/opts.lua
@@ -0,0 +1,181 @@
+--[[ opts.lua ]]
+
+vim.cmd([[
+ "filetype plugin indent on " Load indent files, to automatically do language-dependent indenting.
+ "autocmd BufEnter * :syntax sync fromstart
+ "syntax enable
+ let g:clipbrdDefaultReg = '+'
+ "set nocompatible
+ "autocmd FileType lua set comments=s1:---,m:--,ex:--
+]])
+
+-- Environment
+vim.opt.shell = "zsh" --
+vim.scriptencoding = "utf-8" --
+vim.opt.encoding = "utf-8" --
+vim.opt.fileencoding = "utf-8" --
+vim.g.python3_host_prog = "/usr/bin/python3" --
+vim.g.loaded_python3_provider = 1 --
+vim.g.sh_noisk = 1 -- iskeyword word boundaries when editing a 'sh' file
+--vim.opt.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,resize,winpos,terminal,globals" --
+
+vim.opt.termguicolors = true
+-- Behaviour
+vim.opt.clipboard:append({ "unnamedplus" }) --
+vim.opt.backspace = { "start", "eol", "indent" } -- Make backspace work as you would expect.
+vim.opt.hidden = true -- Switch between buffers without having to save first.
+vim.opt.splitbelow = true -- make split put the new buffer below the current buffer
+vim.opt.splitright = true -- make vsplit put the new buffer on the right of the current buffer
+vim.opt.scrolloff = 8 --
+vim.opt.sidescrolloff = 8 -- how many lines to scroll when using the scrollbar
+vim.opt.autoread = true -- reload files if changed externally
+vim.opt.display = "lastline" -- Show as much as possible of the last line.
+vim.opt.inccommand = "split" --
+vim.opt.ttyfast = true -- Faster redrawing.
+vim.opt.lazyredraw = true -- Only redraw when necessary
+vim.opt.keywordprg = ":help" -- :help options
+vim.opt.ruler = true --
+vim.opt.errorbells = false --
+vim.opt.list = true -- Show non-printable characters.
+vim.opt.showmatch = true --
+vim.opt.matchtime = 3 --
+vim.opt.showbreak = "↪ " --
+vim.opt.linebreak = true --
+vim.opt.exrc = true --
+--vim.opt.autochdir = true -- or use this to use <:e> to create a file in current directory
+vim.opt.autoread = true -- if a file is changed outside of vim, automatically reload it without asking
+--vim.opt.notimeout = true -- Timeout on keycodes and not mappings
+vim.opt.ttimeout = true -- Makes terminal vim work sanely
+vim.opt.ttimeoutlen = 10 --
+--vim.opt.timeoutlen = 100 -- time to wait for a mapped sequence to complete (in milliseconds)
+--vim.cmd([[set diffopt = vertical = true]]) -- diffs are shown side-by-side not above/below
+
+-- Indent/tab
+vim.opt.breakindent = true --
+vim.opt.autoindent = true -- Indent according to previous line.
+vim.opt.smarttab = false --
+vim.opt.tabstop = 2 --
+vim.opt.expandtab = true -- Indent according to previous line.
+--vim.opt.expandtab = true -- Use spaces instead of tabs.
+vim.opt.softtabstop = 2 -- Tab key indents by 2 spaces.
+vim.opt.shiftwidth = 2 -- >> indents by 2 spaces.
+vim.opt.shiftround = true -- >> indents to next multiple of 'shiftwidth'.
+vim.opt.smartindent = true -- smart indent
+
+-- Column/statusline/Cl
+vim.opt.number = true --
+--vim.opt.title = true --
+--vim.opt.colorcolumn = "+1" --
+--vim.opt.signcolumn = "yes:1" -- always show the sign column
+vim.opt.signcolumn = "number"
+--vim.opt.signcolumn = "no" --
+vim.opt.laststatus = 3 -- " Always show statusline.
+vim.opt.showmode = true -- Show current mode in command-line, example: -- INSERT -- mode
+vim.opt.showcmd = true -- Show the command in the status bar
+vim.opt.cmdheight = 1 --
+--vim.opt.cmdheight = 0 --
+vim.opt.report = 0 -- Always report changed lines.
+--local autocmd = vim.api.nvim_create_autocmd
+--autocmd("bufenter", {
+-- pattern = "*",
+-- callback = function()
+-- if vim.bo.ft ~= "terminal" then
+-- vim.opt.statusline = "%!v:lua.require'ui.statusline'.run()"
+-- else
+-- vim.opt.statusline = "%#normal# "
+-- end
+-- end,
+--})
+
+-- Backup/undo
+vim.opt.backup = false --
+--vim.opt.noswapfile = true --
+--vim.opt.undofile = true --
+vim.opt.backupskip = { "/tmp/*", "/private/tmp/*" } --
+
+-- Format
+vim.opt.textwidth = 80 --
+vim.cmd([[let &t_Cs = "\e[4:3m"]]) -- Undercurl
+vim.cmd([[let &t_Ce = "\e[4:0m"]]) --
+vim.opt.path:append({ "**" }) -- Finding files - Search down into subfolder
+vim.cmd("set whichwrap+=<,>,[,],h,l") --
+vim.cmd([[set iskeyword+=-]]) --
+vim.cmd([[set formatoptions-=cro]]) -- TODO: this doesn't seem to work
+vim.opt.wrapscan = true -- " Searches wrap around end-of-file.
+--vim.wo.number = true --
+--vim.opt.wrap = false -- No Wrap lines
+--vim.opt.foldmethod = 'manual' --
+--vim.opt.foldmethod = "expr" --
+vim.opt.modeline = true --
+vim.opt.modelines = 3 -- modelines (comments that set vim options on a per-file basis)
+--vim.opt.nofoldenable = true -- turn folding off
+vim.opt.foldenable = false -- turn folding off
+
+-- Highlights
+vim.opt.incsearch = true -- Highlight while searching with / or ?.
+vim.opt.hlsearch = true -- Keep matches highlighted.
+vim.opt.ignorecase = true -- ignore case in search patterns UNLESS /C or capital in search
+vim.opt.smartcase = true -- smart case
+vim.opt.synmaxcol = 200 -- Only highlight the first 200 columns.
+vim.opt.winblend = 30
+--vim.opt.winblend = 5
+vim.opt.wildoptions = "pum" --
+vim.opt.pumblend = 5 --
+--vim.opt.pumblend=15
+vim.opt.pumheight = 10 -- pop up menu height
+
+-- Better Completion
+vim.opt.complete = { ".", "w", "b", "u", "t" } --
+--vim.opt.completeopt = { "longest,menuone,preview" } --
+vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
+--vim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmp
+--vim.opt.completeopt = { "menu", "menuone", "noselect" } --
+
+-- Wildmenu completion --
+vim.opt.wildmenu = true --
+vim.opt.wildmode = { "list:longest" } --
+vim.opt.wildignore:append({ ".hg", ".git", ".svn" }) -- Version control
+vim.opt.wildignore:append({ "*.aux", "*.out", "*.toc" }) -- LaTeX intermediate files
+vim.opt.wildignore:append({ "*.jpg", "*.bmp", "*.gif", "*.png", "*.jpeg" }) -- binary images
+vim.opt.wildignore:append({ "*.o", "*.obj", "*.exe", "*.dll", "*.manifest" }) -- compiled object files
+vim.opt.wildignore:append({ "*.spl" }) -- compiled spelling word lists
+vim.opt.wildignore:append({ "*.sw?" }) -- Vim swap files
+vim.opt.wildignore:append({ "*.DS_Store" }) -- OSX bullshit
+vim.opt.wildignore:append({ "*.luac" }) -- Lua byte code
+vim.opt.wildignore:append({ "migrations" }) -- Django migrations
+vim.opt.wildignore:append({ "*.pyc" }) -- Python byte code
+vim.opt.wildignore:append({ "*.orig" }) -- Merge resolution files
+vim.opt.wildignore:append({ "*/node_modules/*" }) --
+
+-- Cursorline
+vim.cmd([[ " Only show cursorline in the current window and in normal mode
+ augroup cline
+ au!
+ au WinLeave,InsertEnter * set nocursorline
+ au WinEnter,InsertLeave * set cursorline
+ augroup END
+]])
+vim.opt.cursorline = true --
+vim.opt.guicursor = "i:ver100,r:hor100" --
+
+-- Trailing whitespace
+vim.cmd([[ " Only show in insert mode
+ augroup trailing
+ au!
+ au InsertEnter * :set listchars-=trail:⌴
+ au InsertLeave * :set listchars+=trail:⌴
+ augroup END
+]])
+vim.opt.listchars = { tab = "▸ ", trail = "·" } --
+vim.opt.fillchars:append({ eob = " " }) -- remove the ~ from end of buffer
+
+-- Line Return
+vim.cmd([[ " Return to the same line when we reopen a file
+ augroup line_return
+ au!
+ au BufReadPost *
+ \ if line("'\"") > 0 && line("'\"") <= line("$") |
+ \ execute 'normal! g`"zvzz' |
+ \ endif
+ augroup END
+]])
diff --git a/lua/user/pack.lua b/lua/user/pack.lua
new file mode 100644
index 0000000..8df4216
--- /dev/null
+++ b/lua/user/pack.lua
@@ -0,0 +1,360 @@
+local fn = vim.fn
+
+-- Automatically install packer
+local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
+if fn.empty(fn.glob(install_path)) > 0 then
+ PACKER_BOOTSTRAP = fn.system({
+ "git",
+ "clone",
+ "--depth",
+ "1",
+ "https://github.com/wbthomason/packer.nvim",
+ install_path,
+ })
+ print("Installing packer close and reopen Neovim...")
+ vim.cmd([[packadd packer.nvim]])
+end
+
+-- Autocommand that reloads neovim whenever you save the plugins.lua file
+vim.cmd([[
+ augroup packer_user_config
+ autocmd!
+ autocmd BufWritePost pack.lua source <afile> | PackerSync
+ augroup end
+]])
+
+-- Use a protected call so we don't error out on first use
+local status_ok, packer = pcall(require, "packer")
+if not status_ok then
+ return
+end
+
+-- Have packer use a popup window
+packer.init({
+ auto_reload_compiled = true,
+ display = {
+ open_fn = function()
+ return require("packer.util").float({ border = "rounded" })
+ end,
+ },
+})
+
+-- Install your plugins here
+return packer.startup(function(use)
+ use("wbthomason/packer.nvim") -- Have packer manage itself
+
+ use("nvim-lua/plenary.nvim") -- Useful lua functions used ny lots of plugins
+ --use("jose-elias-alvarez/null-ls.nvim")
+
+ -- lsp
+ use {
+ "williamboman/mason.nvim",
+ "williamboman/mason-lspconfig.nvim",
+ "neovim/nvim-lspconfig",
+ }
+ require("mason").setup()
+ local mason_lspconfig = require("mason-lspconfig")
+ mason_lspconfig.setup({
+ ensure_installed = {
+ "pylsp",
+ "pyright",
+ "clangd",
+ --"vim-language-server",
+ --"bash-language-server",
+ --"lua-language-server",
+ "sumneko_lua",
+ }
+ })
+ use({ "j-hui/fidget.nvim",
+ config = function()
+ require("fidget").setup()
+ end
+ })
+ --use({ "folke/trouble.nvim",
+ -- config = function()
+ -- require("trouble").setup({ position = "right", })
+ -- end
+ --})
+ --use({
+ --"folke/trouble.nvim",
+ --requires = "kyazdani42/nvim-web-devicons",
+ --config = function()
+ -- require("trouble").setup({
+ -- postion = "top",
+ -- -- your configuration comes here
+ -- -- or leave it empty to use the default settings
+ -- -- refer to the configuration section below
+ -- })
+ --end,
+ --})
+
+ --use({
+ -- "https://git.sr.ht/~whynothugo/lsp_lines.nvim", -- See also: https://github.com/Maan2003/lsp_lines.nvim
+ -- config = function()
+ -- require("lsp_lines").setup()
+
+ -- -- disable virtual_text since it's redundant due to lsp_lines.
+ -- vim.diagnostic.config({
+ -- virtual_text = false,
+ -- })
+ -- end,
+ --})
+ use { "simrat39/symbols-outline.nvim",
+ config = function()
+ require("symbols-outline").setup({
+ auto_close = true,
+ })
+ end
+ }
+ use { "kosayoda/nvim-lightbulb", requires = { "antoinemadec/FixCursorHold.nvim" } }
+ --use("folke/lsp-colors.nvim")
+ use "mfussenegger/nvim-lint"
+ use "weilbith/nvim-code-action-menu"
+ use "simrat39/rust-tools.nvim"
+ use { "saecki/crates.nvim",
+ requires = { "nvim-lua/plenary.nvim" },
+ config = function()
+ require("crates").setup()
+ end,
+ }
+ --use "lvimuser/lsp-inlayhints.nvim" -- rust-tools already provides this feature, but gopls doesn't
+
+ -- null-ls
+ use({ "jose-elias-alvarez/null-ls.nvim",
+ config = function()
+ require("null-ls").setup({
+ sources = {
+ require("null-ls").builtins.diagnostics.checkmake, -- https://github.com/mrtazz/checkmake
+ }
+ })
+ end
+ })
+ use({
+ "SmiteshP/nvim-navic",
+ requires = "neovim/nvim-lspconfig",
+ })
+
+ -- nvimlsp plugins
+ --use({
+ -- "williamboman/mason.nvim",
+ -- config = function()
+ -- require("mason").setup()
+ -- require("mason-lspconfig").setup({
+ -- ensure_installed = { "sumneko_lua", "clangd", "rust_analyzer" },
+ -- })
+ -- end,
+ --})
+ --use("williamboman/mason.nvim")
+ --use("williamboman/mason-lspconfig.nvim")
+ --use("neovim/nvim-lspconfig")
+ --use("williamboman/nvim-lsp-installer")
+ --use("glepnir/lspsaga.nvim")
+ --use("nvim-lua/lsp-status.nvim")
+ --use({
+ -- "glepnir/lspsaga.nvim",
+ -- branch = "main",
+ -- config = function()
+ -- local saga = require("lspsaga")
+
+ -- saga.init_lsp_saga({
+ -- -- your configuration
+ -- })
+ -- end,
+ --})
+ -- use("nvim-lua/popup.nvim")
+ --use("SmiteshP/nvim-gps")
+ -- autocomplete plugins
+ use("hrsh7th/nvim-cmp")
+ use("hrsh7th/cmp-nvim-lsp")
+ use("hrsh7th/cmp-buffer")
+ use("hrsh7th/cmp-path")
+ use("petertriho/cmp-git")
+ use("hrsh7th/cmp-cmdline")
+ use("onsails/lspkind-nvim")
+ use("saadparwaiz1/cmp_luasnip")
+
+ -- snippets
+ use("L3MON4D3/LuaSnip") --snippet engine
+ use("rafamadriz/friendly-snippets") -- a bunch of snippets to use
+ --use("github/copilot.vim")
+ --use({
+ --"zbirenbaum/copilot.lua",
+ --event = { "VimEnter" },
+ --config = function()
+ --vim.defer_fn(function()
+ --require("plugins.copilot")
+ --end, 100)
+ --end,
+ --})
+ --use({
+ --"zbirenbaum/copilot-cmp",
+ --module = "copilot_cmp",
+ --})
+
+ -- treesitter plugins
+ use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate" }) --folding, jumping, refactoring...
+ use("nvim-treesitter/nvim-treesitter-refactor")
+ use("nvim-treesitter/nvim-treesitter-context")
+ --use({
+ -- "danymat/neogen",
+ -- config = function()
+ -- require("neogen").setup({ snippet_engine = "luasnip" })
+ -- end,
+ -- requires = "nvim-treesitter/nvim-treesitter",
+ --})
+ use({ "junegunn/fzf", run = ":call fzf#install()" })
+ -- telescope plugins
+ use("nvim-telescope/telescope.nvim")
+ use({ "nvim-telescope/telescope-fzf-native.nvim", run = "make" })
+ use("tami5/sqlite.lua")
+ use("nvim-telescope/telescope-frecency.nvim")
+ use("nvim-telescope/telescope-ui-select.nvim")
+ use("nvim-telescope/telescope-media-files.nvim")
+ use("nvim-telescope/telescope-file-browser.nvim")
+ -- search emoji and other symbols
+ use({ "nvim-telescope/telescope-symbols.nvim", after = "telescope.nvim" })
+ -- statusline plugins
+ --use("nvim-lualine/lualine.nvim")
+ --use({
+ -- "nvim-lualine/lualine.nvim",
+ -- requires = { "kyazdani42/nvim-web-devicons", opt = true },
+ --})
+ --use({
+ -- "folke/trouble.nvim",
+ -- requires = "kyazdani42/nvim-web-devicons",
+ -- config = function()
+ -- require("trouble").setup({
+ -- -- your configuration comes here
+ -- -- or leave it empty to use the default settings
+ -- -- refer to the configuration section below
+ -- })
+ -- end,
+ --})
+ use("rebelot/heirline.nvim")
+ --use({ "akinsho/bufferline.nvim", tag = "v2.*", requires = "kyazdani42/nvim-web-devicons" })
+ --use("itchyny/lightline.vim")
+ -- debug plugins
+ --use("puremourning/vimspector")
+ use("mfussenegger/nvim-dap")
+ use("rcarriga/nvim-dap-ui")
+ --use({
+ -- "rcarriga/neotest",
+ -- requires = {
+ -- "nvim-lua/plenary.nvim",
+ -- "nvim-treesitter/nvim-treesitter",
+ -- "antoinemadec/FixCursorHold.nvim",
+ -- "rcarriga/neotest-python",
+ -- "rcarriga/neotest-vim-test",
+ -- "rcarriga/neotest-plenary",
+ -- "vim-test/vim-test",
+ -- },
+ -- config = function()
+ -- require("plugins.neotest")
+ -- end,
+ --})
+ --use("vim-test/vim-test")
+ --use({
+ -- "rcarriga/vim-ultest",
+ -- requires = { "vim-test/vim-test" },
+ -- run = ":UpdateRemotePlugins",
+ -- config = function()
+ -- require("plugins.ultest")
+ -- end,
+ --})
+ -- UI
+ use("karb94/neoscroll.nvim")
+ use("folke/which-key.nvim")
+ use("MunifTanjim/prettier.nvim") -- Prettier plugin for Neovim's built-in LSP client
+ use("norcalli/nvim-colorizer.lua")
+ use("folke/zen-mode.nvim")
+ use("romainl/vim-cool")
+ --use("p00f/nvim-ts-rainbow")
+ --use("goolord/alpha-nvim")
+ --use("feline-nvim/feline.nvim")
+ --use({ "fgheng/winbar.nvim" })
+ --use("vim-airline/vim-airline")
+ --use("kdheepak/tabline.nvim")
+ -- use({
+ -- "kdheepak/tabline.nvim",
+ -- config = function()
+ -- require("tabline").setup({ enable = false })
+ -- end,
+ -- requires = { "hoob3rt/lualine.nvim", "kyazdani42/nvim-web-devicons" },
+ -- notification plugin
+ use("rcarriga/nvim-notify")
+ --use("lukas-reineke/indent-blankline.nvim")
+ use("kyazdani42/nvim-web-devicons")
+ -- Colorschemes
+ use("gruvbox-community/gruvbox")
+ use("srcery-colors/srcery-vim")
+ use("tomasr/molokai")
+ use("ayu-theme/ayu-vim")
+ --use("sjl/badwolf")
+ use("joshdick/onedark.vim")
+ use("everblush/everblush.nvim")
+ use("EdenEast/nightfox.nvim")
+ use("bluz71/vim-nightfly-guicolors")
+ --use({ "shaunsingh/oxocarbon.nvim", run = "./install.sh" })
+ use("jacoborus/tender.vim")
+ use("sainnhe/sonokai")
+ use("NTBBloodbath/doom-one.nvim")
+
+ -- Utilities
+ use("nathom/filetype.nvim")
+ use("christoomey/vim-tmux-navigator")
+ --use("preservim/vimux")
+ use("myusuf3/numbers.vim")
+ use("windwp/nvim-autopairs")
+ use("lewis6991/gitsigns.nvim")
+ use("dinhhuy258/git.nvim") -- For git blame & browse
+ use("kyazdani42/nvim-tree.lua")
+ use("numToStr/Comment.nvim")
+ use("akinsho/toggleterm.nvim")
+ --use("godlygeek/tabular")
+ --use("Vonr/align.nvim")
+ --use("junegunn/vim-easy-align")
+ --use("dstein64/vim-startuptime")
+ use("tweekmonster/startuptime.vim")
+ use("lewis6991/impatient.nvim")
+ -- use("luukvbaal/stabilize.nvim")
+ --use({
+ -- "ggandor/leap.nvim",
+ -- config = function()
+ -- require("leap").set_default_keymaps()
+ -- end,
+ --})
+ --use("Shatur/neovim-session-manager")
+ --use("rmagatti/auto-session")
+ --use("rmagatti/session-lens")
+ --use("ahmedkhalf/project.nvim")
+ --use("aserowy/tmux.nvim")
+ --use("wakatime/vim-wakatime")
+ --use("tpope/vim-eunuch")
+ -- Handy unix command inside Vim (Rename, Move etc.)
+ use({ "tpope/vim-eunuch", cmd = { "Rename", "Delete" } })
+ --use("tpope/vim-fugitive")
+ --use("tpope/vim-surround")
+ --use("tpope/vim-obsession")
+ --use("tpope/vim-unimpaired")
+ --use("voldikss/vim-floaterm")
+ --use("vimpostor/vim-tpipeline")
+ --use({
+ -- "vimwiki/vimwiki",
+ -- config = function()
+ -- vim.g.vimwiki_list = {
+ -- {
+ -- path = "~/",
+ -- syntax = "markdown",
+ -- ext = ".md",
+ -- },
+ -- }
+ -- vim.g.vimwiki_ext2syntax = {
+ -- [".md"] = "markdown",
+ -- [".markdown"] = "markdown",
+ -- [".mdown"] = "markdown",
+ -- Automatically set up your configuration after cloning packer.nvim
+ -- Put this at the end after all plugins
+ if PACKER_BOOTSTRAP then
+ require("packer").sync()
+ end
+end)
diff --git a/lua/user/prettier.lua b/lua/user/prettier.lua
new file mode 100644
index 0000000..05d4665
--- /dev/null
+++ b/lua/user/prettier.lua
@@ -0,0 +1,19 @@
+local status, prettier = pcall(require, "prettier")
+if (not status) then return end
+
+prettier.setup {
+ bin = 'prettierd',
+ filetypes = {
+ "c",
+ "lua",
+ "vim",
+ --"css",
+ --"javascript",
+ --"javascriptreact",
+ --"typescript",
+ --"typescriptreact",
+ --"json",
+ --"scss",
+ "less"
+ }
+}
diff --git a/lua/user/reload.lua b/lua/user/reload.lua
new file mode 100644
index 0000000..ecf5dd0
--- /dev/null
+++ b/lua/user/reload.lua
@@ -0,0 +1,50 @@
+--function _G.ReloadConfig()
+-- for name,_ in pairs(package.loaded) do
+-- if name:match('^lua') and not name:match('nvim-tree') then
+-- package.loaded[name] = nil
+-- end
+-- end
+--
+-- dofile(vim.env.MYVIMRC)
+-- vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)
+--end
+function _G.ReloadConfig()
+ --dofile(vim.env.MYVIMRC)
+ -- dofile(vim.fn.stdpath('config') .. '/init.lua')
+ --dofile(vim.fn.stdpath('user') .. '/init.lua')
+ require("plenary.reload").reload_module("user", true)
+ --dofile("/home/sxrdusr/.config/nvim/lua/user/keys.lua")
+ --dofile("/home/sxrdusr/.config/nvim/lua/user/mods.lua")
+ --dofile("/home/sxrdusr/.config/nvim/lua/user/opts.lua")
+ --dofile("/home/sxrdusr/.config/nvim/lua/user/pack.lua")
+ --dofile("/home/sxrdusr/.config/nvim/lua/user/utils.lua")
+ vim.notify("Nvim configuration reloaded!", vim.log.levels.INFO)
+end
+--P = function(v)
+-- print(vim.inspect(v))
+-- return v
+--end
+--
+--if pcall(require, "plenary") then
+-- RELOAD = require("plenary.reload").reload_module
+--
+-- R = function(name)
+-- RELOAD(name)
+-- return require(name)
+-- end
+--end
+-- r = reload vimrc
+
+
+local M = {}
+
+M['unload_lua_namespace'] = function(prefix)
+ local prefix_with_dot = prefix .. '.'
+ for key, value in pairs(package.loaded) do
+ if key == prefix or key:sub(1, #prefix_with_dot) == prefix_with_dot then
+ package.loaded[key] = nil
+ end
+ end
+end
+
+return M
diff --git a/lua/user/scripts/lsp-ext.lua b/lua/user/scripts/lsp-ext.lua
new file mode 100644
index 0000000..c4378c6
--- /dev/null
+++ b/lua/user/scripts/lsp-ext.lua
@@ -0,0 +1,48 @@
+--
+-- lsp-ext.lua
+
+
+M = {}
+
+function M.preview_location(location, context, before_context)
+ -- location may be LocationLink or Location (more useful for the former)
+ context = context or 15
+ before_context = before_context or 0
+ local uri = location.targetUri or location.uri
+ if uri == nil then
+ return
+ end
+ local bufnr = vim.uri_to_bufnr(uri)
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
+ vim.fn.bufload(bufnr)
+ end
+ local range = location.targetRange or location.range
+ local contents =
+ vim.api.nvim_buf_get_lines(bufnr, range.start.line - before_context, range["end"].line + 1 + context, false)
+ local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
+ return vim.lsp.util.open_floating_preview(contents, filetype)
+end
+
+function M.preview_location_callback(_, method, result)
+ local context = 15
+ if result == nil or vim.tbl_isempty(result) then
+ print("No location found: " .. method)
+ return nil
+ end
+ if vim.tbl_islist(result) then
+ M.floating_buf, M.floating_win = M.preview_location(result[1], context)
+ else
+ M.floating_buf, M.floating_win = M.preview_location(result, context)
+ end
+end
+
+function M.peek_definition()
+ if vim.tbl_contains(vim.api.nvim_list_wins(), M.floating_win) then
+ vim.api.nvim_set_current_win(M.floating_win)
+ else
+ local params = vim.lsp.util.make_position_params()
+ return vim.lsp.buf_request(0, "textDocument/definition", params, M.preview_location_callback)
+ end
+end
+
+return M
diff --git a/lua/user/scripts/setcolors.lua b/lua/user/scripts/setcolors.lua
new file mode 100644
index 0000000..605bc84
--- /dev/null
+++ b/lua/user/scripts/setcolors.lua
@@ -0,0 +1,121 @@
+vim.cmd([[
+" Change the color scheme from a list of color scheme names.
+" Version 2010-09-12 from http://vim.wikia.com/wiki/VimTip341
+" Press key:
+" F8 next scheme
+" Shift-F8 previous scheme
+" Alt-F8 random scheme
+" Set the list of color schemes used by the above (default is 'all'):
+" :SetColors all (all $VIMRUNTIME/colors/*.vim)
+" :SetColors my (names built into script)
+" :SetColors blue ayu ron (these schemes)
+" :SetColors (display current scheme names)
+" Set the current color scheme based on time of day:
+" :SetColors now
+if v:version < 700 || exists('loaded_setcolors') || &cp
+ finish
+endif
+
+let loaded_setcolors = 1
+let s:mycolors = ['everblush', 'ayu', 'gruvbox', 'molokai', 'onedark', 'srcery'] " colorscheme names that we use to set color
+
+" Set list of color scheme names that we will use, except
+" argument 'now' actually changes the current color scheme.
+function! s:SetColors(args)
+ if len(a:args) == 0
+ echo 'Current color scheme names:'
+ let i = 0
+ while i < len(s:mycolors)
+ echo ' '.join(map(s:mycolors[i : i+4], 'printf("%-14s", v:val)'))
+ let i += 5
+ endwhile
+ elseif a:args == 'all'
+ let paths = split(globpath(&runtimepath, 'colors/*.vim'), "\n")
+ let s:mycolors = uniq(sort(map(paths, 'fnamemodify(v:val, ":t:r")')))
+ echo 'List of colors set from all installed color schemes'
+ elseif a:args == 'my'
+ let c1 = 'default srcery everblush'
+ let c2 = 'gruvbox onedark'
+ let c3 = 'ayu molokai'
+ let s:mycolors = split(c1.' '.c2.' '.c3)
+ echo 'List of colors set from built-in names'
+ elseif a:args == 'now'
+ call s:HourColor()
+ else
+ let s:mycolors = split(a:args)
+ echo 'List of colors set from argument (space-separated names)'
+ endif
+endfunction
+
+command! -nargs=* SetColors call s:SetColors('<args>')
+
+" Set next/previous/random (how = 1/-1/0) color from our list of colors.
+" The 'random' index is actually set from the current time in seconds.
+" Global (no 's:') so can easily call from command line.
+function! NextColor(how)
+ call s:NextColor(a:how, 1)
+endfunction
+
+" Helper function for NextColor(), allows echoing of the color name to be
+" disabled.
+function! s:NextColor(how, echo_color)
+ if len(s:mycolors) == 0
+ call s:SetColors('all')
+ endif
+ if exists('g:colors_name')
+ let current = index(s:mycolors, g:colors_name)
+ else
+ let current = -1
+ endif
+ let missing = []
+ let how = a:how
+ for i in range(len(s:mycolors))
+ if how == 0
+ let current = localtime() % len(s:mycolors)
+ let how = 1 " in case random color does not exist
+ else
+ let current += how
+ if !(0 <= current && current < len(s:mycolors))
+ let current = (how>0 ? 0 : len(s:mycolors)-1)
+ endif
+ endif
+ try
+ execute 'colorscheme '.s:mycolors[current]
+ break
+ catch /E185:/
+ call add(missing, s:mycolors[current])
+ endtry
+ endfor
+ redraw
+ if len(missing) > 0
+ echo 'Error: colorscheme not found:' join(missing)
+ endif
+ if (a:echo_color)
+ echo g:colors_name
+ endif
+endfunction
+
+nnoremap <leader>cn :call NextColor(1)<CR>
+nnoremap <leader>cp :call NextColor(-1)<CR>
+nnoremap <leader>cc :call NextColor(0)<CR>
+
+" Set color scheme according to current time of day.
+function! s:HourColor()
+ let hr = str2nr(strftime('%H'))
+ if hr <= 3
+ let i = 0
+ elseif hr <= 7
+ let i = 1
+ elseif hr <= 14
+ let i = 2
+ elseif hr <= 18
+ let i = 3
+ else
+ let i = 4
+ endif
+ let nowcolors = 'srcery onedark molokai'
+ execute 'colorscheme '.split(nowcolors)[i]
+ redraw
+ echo g:colors_name
+endfunction
+]])
diff --git a/lua/user/scripts/toggleLsp.lua b/lua/user/scripts/toggleLsp.lua
new file mode 100644
index 0000000..28af698
--- /dev/null
+++ b/lua/user/scripts/toggleLsp.lua
@@ -0,0 +1,40 @@
+local M = {}
+
+local check_function = function(bufnr, _)
+ local ok, result = pcall(vim.api.nvim_buf_get_var, bufnr, 'lsp_enabled')
+ -- No buffer local variable set, so just enable by default
+ if not ok then
+ return true
+ end
+
+ return result
+end
+
+vim.lsp.handlers["textDocument/publishDiagnostics"] =
+ vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
+ underline = check_function,
+ virtual_text = check_function,
+ signs = check_function
+ })
+
+function M.Enable()
+ vim.b.lsp_enabled = true
+end
+
+function M.Disable()
+ vim.b.lsp_enabled = false
+end
+
+function M.Toggle()
+ if vim.b.lsp_enabled == false then
+ M.Enable()
+ else
+ M.Disable()
+ end
+end
+
+vim.cmd [[
+ command! -nargs=* ToggleLsp lua require'lsp.toggle'.Toggle()
+]]
+
+return M
diff --git a/lua/user/tabline.lua b/lua/user/tabline.lua
new file mode 100644
index 0000000..4e1c506
--- /dev/null
+++ b/lua/user/tabline.lua
@@ -0,0 +1,22 @@
+require("tabline").setup({
+ -- Defaults configuration options
+ enable = true,
+ options = {
+ -- If lualine is installed tabline will use separators configured in lualine by default.
+ -- These options can be used to override those settings.
+ section_separators = { "", "" },
+ component_separators = { "", "" },
+ max_bufferline_percent = 66, -- set to nil by default, and it uses vim.o.columns * 2/3
+ show_tabs_always = true, -- this shows tabs only when there are more than one tab or if the first tab is named
+ show_devicons = true, -- this shows devicons in buffer section
+ show_bufnr = true, -- this appends [bufnr] to buffer section,
+ show_filename_only = false, -- shows base filename only instead of relative path in filename
+ modified_icon = "+", -- change the default modified icon
+ modified_italic = true, -- set to true by default; this determines whether the filename turns italic if modified
+ show_tabs_only = false, -- this shows only tabs instead of tabs + buffers
+ },
+})
+vim.cmd([[
+ set guioptions-=e " Use showtabline in gui vim
+ set sessionoptions+=tabpages,globals " store tabpages and globals in session
+]])
diff --git a/lua/user/telescope.lua b/lua/user/telescope.lua
new file mode 100644
index 0000000..db065d7
--- /dev/null
+++ b/lua/user/telescope.lua
@@ -0,0 +1,223 @@
+local status_ok, telescope = pcall(require, "telescope")
+if not status_ok then
+ return
+end
+local actions = require("telescope.actions")
+local builtin = require("telescope.builtin")
+
+local function telescope_buffer_dir()
+ return vim.fn.expand("%:p:h")
+end
+
+telescope.load_extension("fzf")
+telescope.load_extension("file_browser")
+require("telescope").load_extension("file_browser")
+local fb_actions = require("telescope").extensions.file_browser.actions
+--telescope.load_extension('media_files')
+
+telescope.setup({
+ defaults = {
+ --
+ prompt_prefix = " ",
+ selection_caret = " ",
+ path_display = { "smart" },
+ --
+ mappings = {
+ i = {
+ ["<C-n>"] = actions.cycle_history_next,
+ ["<C-p>"] = actions.cycle_history_prev,
+
+ ["<C-j>"] = actions.move_selection_next,
+ ["<C-k>"] = actions.move_selection_previous,
+
+ ["<C-c>"] = actions.close,
+
+ ["<Down>"] = actions.move_selection_next,
+ ["<Up>"] = actions.move_selection_previous,
+
+ ["<CR>"] = actions.select_default,
+ ["<C-x>"] = actions.select_horizontal,
+ ["<C-y>"] = actions.select_vertical,
+ ["<C-t>"] = actions.select_tab,
+
+ ["<C-u>"] = actions.preview_scrolling_up,
+ ["<C-d>"] = actions.preview_scrolling_down,
+
+ ["<PageUp>"] = actions.results_scrolling_up,
+ ["<PageDown>"] = actions.results_scrolling_down,
+
+ ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+ ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+ ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+ ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
+ ["<C-l>"] = actions.complete_tag,
+ ["<C-_>"] = actions.which_key, -- keys from pressing <C-/>
+ },
+
+ n = {
+ ["<esc>"] = actions.close,
+ ["<CR>"] = actions.select_default,
+ ["<C-x>"] = actions.select_horizontal,
+ ["<C-v>"] = actions.select_vertical,
+ ["<C-t>"] = actions.select_tab,
+
+ ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse,
+ ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better,
+ ["<C-q>"] = actions.send_to_qflist + actions.open_qflist,
+ ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist,
+
+ ["j"] = actions.move_selection_next,
+ ["k"] = actions.move_selection_previous,
+ ["H"] = actions.move_to_top,
+ ["M"] = actions.move_to_middle,
+ ["L"] = actions.move_to_bottom,
+
+ ["<Down>"] = actions.move_selection_next,
+ ["<Up>"] = actions.move_selection_previous,
+ ["gg"] = actions.move_to_top,
+ ["G"] = actions.move_to_bottom,
+
+ ["<C-u>"] = actions.preview_scrolling_up,
+ ["<C-d>"] = actions.preview_scrolling_down,
+
+ ["<PageUp>"] = actions.results_scrolling_up,
+ ["<PageDown>"] = actions.results_scrolling_down,
+
+ ["?"] = actions.which_key,
+ ["cd"] = function(prompt_bufnr)
+ local selection = require("telescope.actions.state").get_selected_entry()
+ local dir = vim.fn.fnamemodify(selection.path, ":p:h")
+ require("telescope.actions").close(prompt_bufnr)
+ -- Depending on what you want put `cd`, `lcd`, `tcd`
+ vim.cmd(string.format("silent lcd %s", dir))
+ end,
+ },
+ },
+ },
+ pickers = {
+ -- Default configuration for builtin pickers goes here:
+ -- picker_name = {
+ -- picker_config_key = value,
+ -- ...
+ -- }
+ -- Now the picker_config_key will be applied every time you call this
+ -- builtin picker
+ },
+ extensions = {
+ file_browser = {
+ theme = "dropdown",
+ -- disables netrw and use telescope-file-browser in its place
+ hijack_netrw = true,
+ mappings = {
+ -- your custom insert mode mappings
+ ["i"] = {
+ ["<C-w>"] = function()
+ vim.cmd("normal vbd")
+ end,
+ },
+ ["n"] = {
+ -- your custom normal mode mappings
+ ["N"] = fb_actions.create,
+ ["h"] = fb_actions.goto_parent_dir,
+ ["/"] = function()
+ vim.cmd("startinsert")
+ end,
+ },
+ },
+ },
+
+ media_files = {
+ -- filetypes whitelist
+ -- defaults to {"png", "jpg", "mp4", "webm", "pdf"}
+ filetypes = { "png", "webp", "jpg", "jpeg" },
+ find_cmd = "rg", -- find command (defaults to `fd`)
+ },
+ -- Your extension configuration goes here:
+ -- extension_name = {
+ -- extension_config_key = value,
+ -- }
+ -- please take a look at the readme of the extension you want to configure
+ },
+})
+
+telescope.load_extension("file_browser")
+
+--vim.keymap.set("n", ";f", function()
+-- builtin.find_files({
+-- no_ignore = false,
+-- hidden = true,
+-- })
+--end)
+vim.keymap.set("n", ";r", function()
+ builtin.live_grep()
+end)
+vim.keymap.set("n", "\\\\", function()
+ builtin.buffers()
+end)
+vim.keymap.set("n", ";t", function()
+ builtin.help_tags()
+end)
+vim.keymap.set("n", ";;", function()
+ builtin.resume()
+end)
+vim.keymap.set("n", ";e", function()
+ builtin.diagnostics()
+end)
+--vim.keymap.set("n", "sf", function()
+-- telescope.extensions.file_browser.file_browser({
+-- path = "%:p:h",
+-- cwd = telescope_buffer_dir(),
+-- respect_gitignore = false,
+-- hidden = true,
+-- grouped = true,
+-- previewer = false,
+-- initial_mode = "normal",
+-- layout_config = { height = 40 },
+-- })
+--end)
+
+local M = {}
+
+function M.reload()
+ local function get_module_name(s)
+ local module_name;
+
+ module_name = s:gsub("%.lua", "")
+ module_name = module_name:gsub("%/", ".")
+ module_name = module_name:gsub("%.init", "")
+
+ return module_name
+ end
+
+ local prompt_title = "~ neovim modules ~"
+
+ -- sets the path to the lua folder
+ local path = "~/.config/nvim/lua"
+
+ local opts = {
+ prompt_title = prompt_title,
+ cwd = path,
+
+ attach_mappings = function(_, map)
+ -- Adds a new map to ctrl+e.
+ map("i", "<c-e>", function(_)
+ -- these two a very self-explanatory
+ local entry = require("telescope.actions.state").get_selected_entry()
+ local name = get_module_name(entry.value)
+
+ -- call the helper method to reload the module
+ -- and give some feedback
+ R(name)
+ P(name .. " RELOADED!!!")
+ end)
+
+ return true
+ end
+ }
+
+ -- call the builtin method to list files
+ require('telescope.builtin').find_files(opts)
+end
+
+return M;
+
diff --git a/lua/user/toggleterm.lua b/lua/user/toggleterm.lua
new file mode 100644
index 0000000..912729a
--- /dev/null
+++ b/lua/user/toggleterm.lua
@@ -0,0 +1,90 @@
+local status_ok, toggleterm = pcall(require, "toggleterm")
+if not status_ok then
+ return
+end
+
+toggleterm.setup({
+ size = function(term)
+ if term.direction == "horizontal" then
+ return 12
+ elseif term.direction == "vertical" then
+ return vim.o.columns * 0.3
+ end
+ end,
+ --size = 20,
+ open_mapping = [[<leader>to]],
+ hide_numbers = true,
+ shade_filetypes = {},
+ shade_terminals = false,
+ shading_factor = 1,
+ start_in_insert = true,
+ insert_mappings = true,
+ persist_size = true,
+ direction = "float",
+ --direction = "vertical",
+ --direction = "horizontal",
+ close_on_exit = true,
+ shell = vim.o.shell,
+ highlights = {
+ -- highlights which map to a highlight group name and a table of it's values
+ -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split
+ Normal = {
+ background = "#000000",
+ },
+ },
+ float_opts = {
+ width = 70,
+ height = 15,
+ winblend = 3,
+ border = "curved",
+ --winblend = 0,
+ highlights = {
+ border = "Normal",
+ background = "Normal",
+ },
+ },
+})
+
+function _G.set_terminal_keymaps()
+ local opts = { noremap = true }
+ --local opts = {buffer = 0}
+ vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts)
+ vim.api.nvim_buf_set_keymap(0, "t", "jj", [[<C-\><C-n>]], opts)
+ vim.api.nvim_buf_set_keymap(0, "t", "<C-h>", [[<C-\><C-n><C-W>h]], opts)
+ vim.api.nvim_buf_set_keymap(0, "t", "<C-j>", [[<C-\><C-n><C-W>j]], opts)
+ vim.api.nvim_buf_set_keymap(0, "t", "<C-k>", [[<C-\><C-n><C-W>k]], opts)
+ vim.api.nvim_buf_set_keymap(0, "t", "<C-l>", [[<C-\><C-n><C-W>l]], opts)
+end
+
+vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
+
+local Terminal = require("toggleterm.terminal").Terminal
+local lazygit = Terminal:new({ cmd = "lazygit", hidden = true })
+
+function _LAZYGIT_TOGGLE()
+ lazygit:toggle()
+end
+
+local node = Terminal:new({ cmd = "node", hidden = true })
+
+function _NODE_TOGGLE()
+ node:toggle()
+end
+
+local ncdu = Terminal:new({ cmd = "ncdu", hidden = true })
+
+function _NCDU_TOGGLE()
+ ncdu:toggle()
+end
+
+local htop = Terminal:new({ cmd = "htop", hidden = true })
+
+function _HTOP_TOGGLE()
+ htop:toggle()
+end
+
+local python = Terminal:new({ cmd = "python", hidden = true })
+
+function _PYTHON_TOGGLE()
+ python:toggle()
+end
diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua
new file mode 100644
index 0000000..b081ca3
--- /dev/null
+++ b/lua/user/treesitter.lua
@@ -0,0 +1,34 @@
+local status, treesitter = pcall(require, "nvim-treesitter.configs")
+if (not status) then return end
+
+treesitter.setup {
+ highlight = {
+ enable = true,
+ disable = {},
+ },
+ indent = {
+ enable = true,
+ disable = {},
+ --disable = { "python", "css" }
+ },
+ ensure_installed = {
+ "c",
+ "bash",
+ "lua",
+ "rust",
+ },
+ --ensure_installed = "all", -- one of "all" or a list of languages
+ --ignore_install = { "" }, -- List of parsers to ignore installing
+ autotag = {
+ enable = true,
+ },
+ efactor = {
+ highlight_definitions = { enable = true },
+ highlight_current_scope = { enable = true }
+ }
+}
+--vim.opt.foldmethod = "expr"
+--vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
+
+--local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
+--parser_config.tsx.filetype_to_parsername = { "javascript", "typescript.tsx" }
diff --git a/lua/user/utils.lua b/lua/user/utils.lua
new file mode 100644
index 0000000..ab1473f
--- /dev/null
+++ b/lua/user/utils.lua
@@ -0,0 +1,66 @@
+local fn = vim.fn
+
+local M = {}
+
+function M.executable(name)
+ if fn.executable(name) > 0 then
+ return true
+ end
+
+ return false
+end
+
+--- check whether a feature exists in Nvim
+--- @feat: string
+--- the feature name, like `nvim-0.7` or `unix`.
+--- return: bool
+M.has = function(feat)
+ if fn.has(feat) == 1 then
+ return true
+ end
+
+ return false
+end
+
+--- Create a dir if it does not exist
+function M.may_create_dir(dir)
+ local res = fn.isdirectory(dir)
+
+ if res == 0 then
+ fn.mkdir(dir, "p")
+ end
+end
+
+function M.get_nvim_version()
+ local actual_ver = vim.version()
+
+ local nvim_ver_str = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch)
+ return nvim_ver_str
+end
+
+--- Generate random integers in the range [Low, High], inclusive,
+--- adapted from https://stackoverflow.com/a/12739441/6064933
+--- @low: the lower value for this range
+--- @high: the upper value for this range
+function M.rand_int(low, high)
+ -- Use lua to generate random int, see also: https://stackoverflow.com/a/20157671/6064933
+ math.randomseed(os.time())
+
+ return math.random(low, high)
+end
+
+--- Select a random element from a sequence/list.
+--- @seq: the sequence to choose an element
+function M.rand_element(seq)
+ local idx = M.rand_int(1, #seq)
+
+ return seq[idx]
+end
+
+function M.add_pack(name)
+ local status, error = pcall(vim.cmd, "packadd " .. name)
+
+ return status
+end
+
+return M
diff --git a/lua/user/web-devicons.lua b/lua/user/web-devicons.lua
new file mode 100644
index 0000000..b8396bc
--- /dev/null
+++ b/lua/user/web-devicons.lua
@@ -0,0 +1,12 @@
+local status, icons = pcall(require, "nvim-web-devicons")
+if (not status) then return end
+
+icons.setup {
+ -- your personnal icons can go here (to override)
+ -- DevIcon will be appended to `name`
+ override = {
+ },
+ -- globally enable default icons (default to false)
+ -- will get overriden by `get_icons` option
+ default = true
+}
diff --git a/lua/user/winbar.lua b/lua/user/winbar.lua
new file mode 100644
index 0000000..1573828
--- /dev/null
+++ b/lua/user/winbar.lua
@@ -0,0 +1,35 @@
+require("winbar").setup({
+ enabled = true,
+
+ show_file_path = true,
+ show_symbols = true,
+
+ colors = {
+ path = "", -- You can customize colors like #c946fd
+ file_name = "",
+ symbols = "",
+ },
+
+ icons = {
+ file_icon_default = "",
+ seperator = ">",
+ editor_state = "●",
+ lock_icon = "",
+ },
+
+ exclude_filetype = {
+ "help",
+ "startify",
+ "dashboard",
+ "packer",
+ "neogitstatus",
+ "NvimTree",
+ "Trouble",
+ "alpha",
+ "lir",
+ "Outline",
+ "spectre_panel",
+ "toggleterm",
+ "qf",
+ },
+})
diff --git a/lua/user/zen-mode.lua b/lua/user/zen-mode.lua
new file mode 100644
index 0000000..7e52854
--- /dev/null
+++ b/lua/user/zen-mode.lua
@@ -0,0 +1,7 @@
+local status, zenMode = pcall(require, "zen-mode")
+if (not status) then return end
+
+zenMode.setup {
+}
+
+vim.keymap.set('n', '<C-w>o', '<cmd>ZenMode<cr>', { silent = true })