diff options
Diffstat (limited to '.config/nvim/lua/plugins')
36 files changed, 4865 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/autopairs.lua b/.config/nvim/lua/plugins/autopairs.lua new file mode 100644 index 0000000..90c6d35 --- /dev/null +++ b/.config/nvim/lua/plugins/autopairs.lua @@ -0,0 +1,42 @@ +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, + }, + map = "<M-e>", + pairs_map = { +['<'] = '>', +}, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + disable_in_macro = true, + disable_in_visualblock = true, + enable_moveright = true, + enable_afterquote = true, -- add bracket pairs after quote + enable_check_bracket_line = false, --- check bracket in same line + enable_bracket_in_quote = true, -- + break_undo = true, -- switch for basic rule break undo sequence + fast_wrap = { + 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/.config/nvim/lua/plugins/cmp-gh-source.lua b/.config/nvim/lua/plugins/cmp-gh-source.lua new file mode 100644 index 0000000..4990c35 --- /dev/null +++ b/.config/nvim/lua/plugins/cmp-gh-source.lua @@ -0,0 +1,70 @@ +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/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua new file mode 100644 index 0000000..edf57de --- /dev/null +++ b/.config/nvim/lua/plugins/cmp.lua @@ -0,0 +1,332 @@ + +-- 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, + expand = function(args) + local luasnip = require("luasnip") + if not luasnip then + return + end + 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(), + --}), + ["<C-e>"] = cmp.mapping({ + i = function() + if cmp.visible() then + cmp.abort() + require("user.mods").toggle_completion() + require("notify")("completion off") + else + cmp.complete() + require("user.mods").toggle_completion() + require("notify")("completion on") + end + end, + }), + --["<CR>"] = cmp.mapping({ + -- i = function(fallback) + -- if cmp.visible() then + -- cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) + -- require("user.mods").toggle_completion() + -- else + -- fallback() + -- end + -- end, + --}), + +-- ["<C-e>"] = cmp.mapping({ +-- i = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.abort() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- c = function() +-- if cmp.visible() then +-- require("notify")("visible") +-- cmp.close() +-- else +-- require("notify")("not visible") +-- cmp.complete() +-- end +-- end, +-- }), + --['<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 = "nvim_lua" }, + { name = "luasnip" }, + --{ name = 'luasnip', option = { use_show_condition = false } }, + { name = "gh_issues" }, + { name = "nvim_lsp", max_item_count = 6 }, + { name = "nvim_lua" }, + --{ name = "luasnip" }, + --{ name = "luasnip", keyword_length = 4 }, + --{ name = "buffer", keyword_length = 3 }, + { name = "path" }, + { name = "buffer", max_item_count = 6 }, + --{ name = "buffer", option = { get_bufnrs = function() + -- return vim.api.nvim_list_bufs() + --end + --}}, + { name = "cmp_git"}, + { name = "spell"}, + { name = "zsh" }, + { name = "treesitter" }, + { name = "calc" }, + { name = "nvim_lsp_signature_help" }, + --{ name = "cmdline" }, + --{ 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 = { + nvim_lsp = "[LSP]", + luasnip = "[snip]", + buffer = "[buf]", + nvim_lua = "[api]", + path = "[path]", + gh_issues = "[issues]", + spell = "[spell]", + zsh = "[zsh]", + treesitter = "[treesitter]", + calc = "[calc]", + nvim_lsp_signature_help = "[signature]", + cmdline = "[cmd]" + + }, + }, + --}, + + -- + -- + --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, -- this feature conflicts with copilot.vim's preview. + 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-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }), + ["<C-n>"] = 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/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..be78ac8 --- /dev/null +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,344 @@ +--local function MyHighlights() +-- vim.cmd('highlight Visual cterm=NONE ctermbg=76 ctermfg=16 gui=NONE guibg=#5fd700 guifg=#000000') +-- vim.cmd('highlight StatusLine cterm=NONE ctermbg=231 ctermfg=160 gui=NONE guibg=#ffffff guifg=#d70000') +-- vim.cmd('highlight Normal cterm=NONE ctermbg=17 gui=NONE guibg=#00005f') +-- vim.cmd('highlight NonText cterm=NONE ctermbg=17 gui=NONE guibg=#00005f') +--end +-- +--local function setupMyColors() +-- vim.cmd('augroup MyColors') +-- vim.cmd('autocmd!') +-- vim.cmd('autocmd ColorScheme * call v:lua.MyHighlights()') +-- vim.cmd('augroup END') +--end +-- +--setupMyColors() + +--vim.api.nvim_command("highlight FoldColumn guibg=none") + +--vim.api.nvim_command("highlight SignColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") +--vim.api.nvim_command("highlight ColorColumn guifg=none guibg=none cterm=NONE ctermfg=none ctermbg=NONE gui=NONE") +--vim.api.nvim_command("highlight TabLineSel guibg=none guifg=none gui=bold") +--vim.api.nvim_command("highlight TabLineNC guibg=none gui=bold") +--vim.api.nvim_command("highlight StatusLine guibg=#333842 gui=bold") +--vim.api.nvim_command("highlight StatusLineNC guibg=none ctermfg=Cyan guifg=#80a0ff gui=bold") + +-- Custom colorscheme +--vim.cmd([[ +-- let g:terminal_color_0 = '#2e3436' +-- let g:terminal_color_1 = '#cc0000' +-- let g:terminal_color_2 = '#4e9a06' +-- let g:terminal_color_3 = '#c4a000' +-- let g:terminal_color_4 = '#3465a4' +-- let g:terminal_color_5 = '#75507b' +-- let g:terminal_color_6 = '#0b939b' +-- let g:terminal_color_7 = '#d3d7cf' +-- let g:terminal_color_8 = '#555753' +-- let g:terminal_color_9 = '#ef2929' +-- let g:terminal_color_10 = '#8ae234' +-- let g:terminal_color_11 = '#fce94f' +-- let g:terminal_color_12 = '#729fcf' +-- let g:terminal_color_13 = '#ad7fa8' +-- let g:terminal_color_14 = '#00f5e9' +-- let g:terminal_color_15 = '#eeeeec' +-- +-- set background=dark +-- execute "silent! colorscheme base16-eighties" +-- highlight Comment guifg=#585858 +-- highlight Normal guifg=#999999 +-- "highlight TabLine guifg=#333333 guibg=#777777 +-- "highlight TabLineSel guifg=#FA7F7F +-- highlight MatchParen gui=bold guibg=black guifg=limegreen +--]]) +--local colors = { +-- background = '#1c1c1c', +-- foreground = '#cacaca', +-- accent = '#fe5186', +-- blue = '#61afef', +-- cyan = '#3e8fb0', +-- dark_green = '#5faf5f', +-- dark_grey = '#222222', +-- dark_orange = '#ff5d62', +-- dark_red = '#bf1131', +-- dark_yellow = '#ffaf00', +-- green = '#98c379', +-- grey = '#2a2a2a', +-- light_grey = '#727169', +-- light_orange = '#ffa066', +-- light_pink = '#e46876', +-- light_yellow = '#e6db74', +-- magenta = '#c678dd', +-- orange = '#ff8700', +-- purple = '#af87d7', +-- red = '#c4384b', +-- violet = '#a9a1e1', +-- white = '#e3e3e3', +-- yellow = '#d7af5f', +--} +---- Base highlights to override themes to my preferences +--local base = { +-- CursorLine = { bg = 'none', fg = 'none' }, +-- -- Avoid changing the foreground color from the main theme +-- MatchParen = { fg = colors.accent, bg = 'none', bold = true }, +-- Visual = { bg = colors.grey, fg = 'none' }, +-- ActionPreviewBorder = { link = 'XMenuBorder' }, +-- ActionPreviewNormal = { link = 'XMenu' }, +-- CallHierarchyBorder = { link = 'XMenuBorder' }, +-- CallHierarchyNormal = { link = 'XMenu' }, +-- CodeActionBorder = { link = 'XMenuBorder' }, +-- CodeActionNormal = { link = 'XMenu' }, +-- DefinitionBorder = { link = 'XMenuBorder' }, +-- DefinitionNormal = { link = 'XMenu' }, +-- EndOfBuffer = { fg = colors.background }, +-- FinderBorder = { link = 'XMenuBorder' }, +-- FinderNormal = { link = 'XMenu' }, +-- FloatBorder = { link = 'XMenuBorder' }, +-- FloatNormal = { link = 'XMenu' }, +-- HoverBorder = { link = 'XMenuBorder' }, +-- HoverNormal = { link = 'XMenu' }, +-- NormalFloat = { link = 'XMenu' }, +-- OutlinePreviewBorder = { link = 'XMenuBorder' }, +-- OutlinePreviewNormal = { link = 'XMenu' }, +-- Pmenu = { link = 'XMenu' }, +-- RenameBorder = { link = 'XMenuBorder' }, +-- RenameNormal = { link = 'XMenu' }, +-- TerminalBorder = { link = 'XMenuBorder' }, +-- TerminalNormal = { link = 'XMenu' }, +-- Todo = { fg = colors.orange, bold = true }, +-- SagaNormal = { link = 'XMenu' }, +-- SagaBorder = { link = 'XMenuBorder' }, +-- StatusLine = { bg = colors.background, fg = colors.foreground }, +-- TitleString = { link = 'XMenu' }, +-- TitleIcon = { link = 'XMenu' }, +-- ActionPreviewTitle = { link = 'XMenu' }, +-- -- Mason +-- MasonHeader = { link = 'XMenu' }, +-- MasonNormal = { link = 'XMenu' }, +-- NvimTreeCursorColumn = { bg = 'none', fg = 'none' }, +-- --NvimTreeCursorLine = { bg = colors.dark_grey, fg = colors.accent }, +-- -- Telescope +-- TelescopeBorder = { link = 'XMenuBorder' }, +-- TelescopePromptBorder = { link = 'XMenuBorder' }, +-- TelescopePromptNormal = { link = 'XMenu', fg = colors.foreground }, +-- TelescopePromptPrefix = { link = 'XMenu', fg = colors.foreground }, +-- TelescopeNormal = { bg = colors.background }, +-- TelescopePreviewBorder = { link = 'XMenuBorder' }, +-- TelescopePreviewNormal = { link = 'XMenu', fg = colors.foreground }, +-- TelescopePreviewTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopePreviewLine = { fg = colors.background, bg = colors.orange }, +-- TelescopePromptTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopeResultsTitle = { fg = colors.background, bg = colors.light_orange }, +-- TelescopeResultsBorder = { link = 'XMenuBorder' }, +-- TelescopeResultsNormal = { link = 'XMenu' }, +--} +-- +--local theme = { +-- -- Transparent background +-- Conceal = { bg = 'none', fg = colors.foreground }, +-- FoldCoumn = { bg = 'none' }, +-- LineNr = { bg = 'none', fg = colors.grey }, +-- MsgArea = { bg = 'none', fg = colors.foreground }, +-- NonText = { bg = 'none', fg = colors.light_grey }, +-- Normal = { bg = 'none', fg = colors.foreground }, +-- NormalNC = { bg = 'none', fg = colors.foreground }, +-- SignColumn = { bg = 'none' }, +-- WinSeparator = { bg = 'none', fg = colors.grey }, +-- -- Language Syntax +-- Boolean = { fg = colors.grey }, +-- Character = { fg = colors.yellow }, +-- Comment = { fg = colors.light_grey }, +-- Conditional = { fg = colors.blue }, +-- Constant = { fg = colors.grey }, +-- Debug = { fg = colors.green }, +-- Define = { fg = colors.green }, +-- Delimiter = { fg = colors.grey }, +-- Error = { fg = colors.red }, +-- Exception = { fg = colors.dark_orange }, +-- Float = { fg = colors.light_pink }, +-- Function = { fg = colors.foreground }, +-- Identifier = { fg = colors.foreground }, +-- Ignore = { fg = colors.light_grey }, +-- Include = { fg = colors.dark_orange }, +-- Keyword = { fg = colors.blue }, +-- Label = { fg = colors.grey }, +-- Macro = { fg = colors.dark_orange }, +-- Number = { fg = colors.light_pink }, +-- Operator = { fg = colors.purple }, +-- PreCondit = { fg = colors.dark_orange }, +-- PreProc = { fg = colors.dark_orange }, +-- Repeat = { fg = colors.blue }, +-- Special = { fg = colors.dark_orange }, +-- SpecialChar = { fg = colors.dark_orange }, +-- SpecialComment = { fg = colors.orange }, +-- Statement = { fg = colors.blue }, +-- StorageClass = { fg = colors.light_orange }, +-- String = { fg = colors.yellow }, +-- Structure = { fg = colors.light_orange }, +-- Tag = { fg = colors.orange }, +-- Todo = { fg = colors.orange, bold = true }, +-- Type = { fg = colors.light_orange }, +-- Typedef = { fg = colors.foreground }, +-- Underlined = { fg = colors.foreground }, +-- -- Rest +-- ColorColumn = { bg = colors.dark_grey }, +-- Cursor = { bg = colors.accent }, +-- CursorColumn = { bg = 'none', fg = colors.accent }, +-- CursorLine = { bg = 'none', fg = 'none' }, +-- CursorLineNr = { bg = 'none', fg = colors.light_pink }, +-- Directory = { fg = colors.cyan, bold = true }, +-- ErrorMsg = { bg = 'none', fg = colors.red }, +-- IncSearch = { bg = colors.accent, fg = colors.foreground }, +-- MatchParen = { fg = colors.accent, bg = 'none', bold = true }, +-- Search = { bg = colors.accent }, +-- SpellBad = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- SpellLocal = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- SpellRare = { bg = 'none', fg = 'none', undercurl = true, ctermbg = 'none', ctermfg = 'none' }, +-- StatusLine = { fg = colors.foreground, bg = 'none' }, +-- StatusLineNC = { fg = 'none', bg = 'none' }, +-- Title = { fg = colors.blue, bg = '', bold = true }, +-- VertSplit = { bg = 'none', fg = colors.grey }, +-- Visual = { bg = colors.grey, fg = 'none' }, +-- -- Diagnostic +-- DiagnosticBorder = { link = 'XMenuBorder' }, +-- DiagnosticNormal = { link = 'XMenu' }, +-- DiagnosticError = { fg = colors.red }, +-- DiagnosticFloatingError = { link = 'XMenu' }, +-- DiagnosticFloatingHint = { link = 'XMenu' }, +-- DiagnosticFloatingInfo = { link = 'XMenu' }, +-- DiagnosticFloatingWarn = { link = 'XMenu' }, +-- DiagnosticSignHint = { fg = colors.grey, bold = true, bg = 'none' }, +-- DiagnosticUnderlineError = { undercurl = true }, +-- DiagnosticVirtualTextHint = { bg = 'none' }, +-- DiagnosticWarn = { fg = colors.yellow }, +-- -- nvim cmp +-- CmpItemAbbr = { fg = colors.foreground }, +-- CmpItemAbbrMatch = { fg = colors.dark_orange }, +-- CmpItemAbbrMatchFuzzy = { fg = colors.dark_orange }, +-- CmpBorder = { link = 'FloatBorder' }, +-- CmpDocBorder = { link = 'FloatBorder' }, +-- CmpItemMenuDefault = { link = 'NormalFloat' }, +-- CmpMenu = { link = 'NormalFloat' }, +-- -- cmp item kinds +-- CmpItemKindConstant = { fg = colors.light_pink }, +-- CmpItemKindFunction = { fg = colors.blue }, +-- CmpItemKindIdentifier = { fg = colors.purple }, +-- CmpItemKindField = { fg = colors.dark_orange }, +-- CmpItemKindVariable = { fg = colors.purple }, +-- CmpItemKindSnippet = { fg = colors.light_pink }, +-- CmpItemKindText = { fg = colors.foreground }, +-- CmpItemKindStructure = { fg = colors.blue }, +-- CmpItemKindType = { fg = colors.orange }, +-- CmpItemKindKeyword = { fg = colors.blue }, +-- CmpItemKindMethod = { fg = colors.purple }, +-- CmpItemKindConstructor = { fg = colors.blue }, +-- CmpItemKindFolder = { fg = colors.blue }, +-- CmpItemKindModule = { fg = colors.dark_orange }, +-- CmpItemKindProperty = { fg = colors.dark_orange }, +-- CmpItemKindEnum = { fg = colors.blue }, +-- CmpItemKindUnit = { fg = colors.green }, +-- CmpItemKindClass = { fg = colors.blue }, +-- CmpItemKindFile = { fg = colors.blue }, +-- CmpItemKindInterface = { fg = colors.blue }, +-- CmpItemKindColor = { fg = colors.yellow }, +-- CmpItemKindReference = { fg = colors.blue }, +-- CmpItemKindEnumMember = { fg = colors.green }, +-- CmpItemKindStruct = { fg = colors.blue }, +-- -- CmpItemKindValue = { fg = "" }, +-- -- CmpItemKindEvent = { fg = "" }, +-- CmpItemKindOperator = { fg = colors.purple }, +-- CmpItemKindTypeParameter = { fg = colors.light_pink }, +-- CmpItemKindCopilot = { fg = colors.green }, +-- -- LSPSaga +-- OutlinePreviewBorder = { link = 'NormalFloat' }, +-- OutlinePreviewNormal = { link = 'FloatBorder' }, +-- -- Diffview +-- DiffViewSignColumn = { bg = 'none' }, +-- -- Treesitter +-- -- ['@string'] = { fg = colors.yellow, bg = '' }, +-- ['@boolean'] = { fg = colors.dark_yellow }, +-- ['@character'] = { fg = colors.foreground }, +-- ['@character.special'] = { fg = colors.dark_orange }, +-- ['@comment'] = { link = 'Comment' }, +-- ['@conditional'] = { fg = colors.blue }, +-- ['@constant'] = { fg = colors.foreground }, +-- ['@constant.builtin'] = { fg = colors.dark_yellow }, +-- ['@constant.macro'] = { fg = colors.dark_orange }, +-- ['@constructor'] = { fg = colors.blue }, +-- ['@debug'] = { link = 'Debug' }, +-- ['@define'] = { link = "Define" }, +-- ['@exception'] = { fg = colors.dark_orange }, +-- ['@field'] = { link = 'Identifier' }, +-- ['@field.yaml'] = { fg = colors.light_orange }, +-- ['@float'] = { fg = colors.light_pink }, +-- ['@function'] = { link = 'Function' }, +-- ['@function.builtin'] = { fg = colors.dark_green }, +-- ['@function.macro'] = { fg = colors.dark_orange }, +-- ['@include'] = { fg = colors.dark_orange }, +-- ['@keyword'] = { link = 'Keyword' }, +-- ['@keyword.operator'] = { fg = colors.purple }, +-- ['@keyword.return'] = { fg = colors.dark_orange }, +-- ['@label'] = { fg = colors.blue }, +-- ['@macro'] = { fg = colors.dark_orange }, +-- ['@method'] = { fg = colors.foreground }, +-- ['@namespace'] = { fg = colors.foreground }, +-- ['@number'] = { link = 'Number' }, +-- ['@operator'] = { link = 'Operator' }, +-- ['@parameter'] = { fg = colors.foreground }, +-- ['@preproc'] = { link = 'PreProc' }, +-- ['@property'] = { fg = colors.foreground }, +-- ['@punctuation.Special'] = { fg = colors.purple }, +-- ['@punctuation.bracket'] = { fg = colors.purple }, +-- ['@punctuation.delimiter'] = { fg = colors.purple }, +-- ['@repeat'] = { link = 'Repeat' }, +-- ['@storageclass'] = { link = 'StorageClass' }, +-- ['@string.escape'] = { fg = colors.dark_orange }, +-- ['@string.regex'] = { fg = colors.green }, +-- ['@string.special'] = { fg = colors.dark_orange }, +-- ['@structure'] = { link = 'Structure' }, +-- ['@tag'] = { link = 'Tag' }, +-- ['@tag.attribute'] = { fg = colors.foreground }, +-- ['@tag.delimiter'] = { fg = colors.purple }, +-- ['@text.danger'] = { fg = colors.dark_orange }, +-- ['@text.literal'] = { link = 'String' }, +-- ['@text.reference'] = { fg = colors.green }, +-- ['@text.strong'] = { bold = true }, +-- ['@text.title'] = { link = 'Title' }, +-- ['@text.todo'] = { link = 'Todo' }, +-- ['@text.underline'] = { link = 'Underlined' }, +-- ['@text.uri'] = { fg = colors.blue }, +-- ['@text.warning'] = { link = 'Todo' }, +-- ['@type'] = { link = 'Type' }, +-- ['@type.definition'] = { link = 'Typedef' }, +-- ['@variable'] = { fg = colors.foreground }, +-- ['@variable.builtin'] = { fg = colors.light_orange }, +--} +-- +--local M = {} +-- +--local function _load(config) +-- for group, hl in pairs(config) do +-- if not vim.tbl_isempty(hl) then +-- vim.api.nvim_set_hl(0, group, hl) +-- end +-- end +--end +-- +-- +--function M.setup() +-- vim.api.nvim_set_hl(0, 'XMenu', { bg = colors.dark_grey, default = true }) +-- vim.api.nvim_set_hl(0, 'XMenuBorder', { bg = colors.dark_grey, fg = colors.dark_grey, default = true }) +-- vim.g.terminal_color_0 = colors.dark_grey +--end +-- +----function M.load(full) +---- _load(base) +---- +---- if not full then +---- _load_diagnostics() +---- return +---- end +---- +---- _load(theme) +----end +-- +--return M diff --git a/.config/nvim/lua/plugins/dap.lua b/.config/nvim/lua/plugins/dap.lua new file mode 100644 index 0000000..3189f4f --- /dev/null +++ b/.config/nvim/lua/plugins/dap.lua @@ -0,0 +1,254 @@ +local dap = require('dap') + +-- options +dap.defaults.fallback.switchbuf = 'uselast' +dap.defaults.fallback.focus_terminal = true +dap.defaults.fallback.external_terminal = { + command = '/usr/bin/wezterm', + args = { '-e' }, +} + +-- Autocmds +vim.api.nvim_create_autocmd("FileType", { + pattern = { "dap-float" }, + callback = function(event) + vim.keymap.set("n", "<Tab>", "", { buffer = event.buf, silent = true }) + vim.keymap.set("n", "<S-Tab>", "", { buffer = event.buf, silent = true }) + end, +}) + +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + --command = vim.fn.stdpath('data') .. '/mason/bin/OpenDebugAD7', + command = os.getenv("HOME") .. '/apps/cpptools/extension/debugAdapters/bin/OpenDebugAD7', + --command = cpptools:get_install_path() .. '/extension/debugAdapters/bin/OpenDebugAD7' +} + +dap.adapters.codelldb = { + type = 'server', + port = '${port}', + --host = "localhost", + --host = '127.0.0.1', + --port = 13000, -- 💀 Use the port printed out or specified with `--port` + executable = { + --command = os.getenv("HOME") .. '/apps/codelldb/extension/adapter/codelldb', + command = os.getenv("HOME") .. "/.vscode-oss/extensions/vadimcn.vscode-lldb-1.9.0-universal/adapter/codelldb", + args = { '--port', '${port}' }, + }, + --detached = true, +} + +dap.adapters.lldb = { + type = 'executable', + command = '/usr/bin/lldb-vscode', + name = "lldb" +} +dap.configurations.cpp = { + { + name = "Debugger", + --type = "lldb", + --type = "cppdbg", + type = "codelldb", + request = "launch", + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + --program = '${file}', + --program = function() + -- -- First, check if exists CMakeLists.txt + -- local cwd = vim.fn.getcwd() + -- if (file.exists(cwd, "CMakeLists.txt")) then + -- -- Todo. Then invoke cmake commands + -- -- Then ask user to provide execute file + -- return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + -- else + -- local fileName = vim.fn.expand("%:t:r") + -- if (not file.exists(cwd, "bin")) then + -- -- create this directory + -- os.execute("mkdir " .. "bin") + -- end + -- local cmd = "!gcc -g % -o bin/" .. fileName + -- -- First, compile it + -- vim.cmd(cmd) + -- -- Then, return it + -- return "${fileDirname}/bin/" .. fileName + -- end + --end, + stopAtEntry = true, + args = {}, + --runInTerminal = true, + --runInTerminal = false, + --console = 'integratedTerminal', + + --MIMode = 'gdb', + --miDebuggerServerAddress = 'localhost:1234', + --miDebuggerPath = 'gdb-oneapi', + --miDebuggerPath = '/usr/bin/gdb', + externalConsole = true, + --setupCommands = { + -- { + -- text = '-enable-pretty-printing', + -- description = 'enable pretty printing', + -- ignoreFailures = false + -- } + --}, + }, +} + +-- If you want to use this for Rust and C, add something like this: +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + +-- javascript +--dap.adapters.node2 = { +-- type = 'executable', +-- command = 'node-debug2-adapter', +-- args = {}, +--} + +--dap.configurations.javascript = { +-- { +-- name = 'Launch', +-- type = 'node2', +-- request = 'attach', +-- program = '${file}', +-- cwd = vim.fn.getcwd(), +-- sourceMaps = true, +-- protocol = 'inspector', +-- console = 'integratedTerminal', +-- }, +--} + +dap.adapters.python = { + type = 'executable', + command = vim.trim(vim.fn.system('which python')), + args = { '-m', 'debugpy.adapter' }, +} + +dap.configurations.python = { + { + -- The first three options are required by nvim-dap + type = 'python', -- the type here established the link to the adapter definition: `dap.adapters.python` + request = 'launch', + name = "Launch file", + -- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options + program = "${file}", -- This configuration will launch the current file if used. + stopOnEntry = true, + }, +} + +local dapui = require('dapui') +--local dap_ui_status_ok, dapui = pcall(require, "dapui") +--if not dap_ui_status_ok then +-- return +--end + +-- setup repl +--dap.repl.commands = vim.tbl_extend('force', dap.repl.commands, { +-- exit = { 'q', 'exit' }, +-- custom_commands = { +-- ['.run_to_cursor'] = dap.run_to_cursor, +-- ['.restart'] = dap.run_last +-- } +--}) + +-- Load dapui configuration only if it hasn't been loaded before +if not vim.g.loaded_dapui then + require("dapui").setup({ + mappings = { + expand = "<CR>", + open = "o", + remove = "D", + edit = "e", + repl = "r", + toggle = "t", + }, + controls = { + enabled = true, + }, + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "watches", size = 0.25 }, + { id = "scopes", size = 0.25 }, + { id = "breakpoints", size = 0.25 }, + { id = "stacks", size = 0.25 }, + }, + size = 50, -- 40 columns + position = "left", + }, + { + elements = { + { id = "console", size = 0.6 }, + { id = "repl", size = 0.4 }, + }, + size = 0.3, + position = "bottom", + }, + }, + render = { + max_value_lines = 3, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "<Esc>" }, + }, + }, + --icons = { expanded = "-", collapsed = "$" }, + icons = { + expanded = "", + collapsed = "", + current_frame = "", + }, + }) + vim.g.loaded_dapui = true +end + + +-- Signs +local sign = vim.fn.sign_define +sign("DapBreakpoint", { text = "●", texthl = "DapBreakpoint", linehl = "", numhl = "" }) +sign("DapBreakpointCondition", { text = "◆", texthl = "DapBreakpointCondition", linehl = "", numhl = "" }) -- +sign("DapBreakpointRejected", { text = 'R', texthl = 'DiagnosticError', numhl = 'DiagnosticError' }) +sign("DapLogPoint", { text = "L", texthl = "DapLogPoint", linehl = "", numhl = "" }) +sign('DapStopped', { text = '', texthl = 'DiagnosticSignHint', numbhl = '', linehl = '' }) + +--sign('DapBreakpoint', { text = '', texthl = 'DiagnosticSignError', numbhl = '', linehl = '' }) +--sign("DapLogPoint", { text = '.>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapBreakpointCondition", { text = '?>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) +--vim.fn.sign_define("DapStopped", { text = '=>', texthl = 'DiagnosticWarn', numhl = 'DiagnosticWarn' }) +--vim.fn.sign_define("DapBreakpoint", { text = '<>', texthl = 'DiagnosticInfo', numhl = 'DiagnosticInfo' }) + +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.disconnect["dapui_config"] = function() + dapui.close() +end + +require("nvim-dap-virtual-text").setup { + enabled = true, + enabled_commands = true, + highlight_changed_variables = true, + highlight_new_as_changed = false, + show_stop_reason = true, + commented = true, + only_first_definition = true, + all_references = false, + filter_references_pattern = "<module", + virt_text_pos = "eol", + all_frames = false, + virt_text_win_col = nil +} diff --git a/.config/nvim/lua/plugins/dashboard.lua b/.config/nvim/lua/plugins/dashboard.lua new file mode 100644 index 0000000..e25d536 --- /dev/null +++ b/.config/nvim/lua/plugins/dashboard.lua @@ -0,0 +1,81 @@ +local db = require("dashboard") + +--vim.api.nvim_create_autocmd("VimEnter", { +-- callback = function() +-- -- disable line numbers +-- vim.opt_local.number = false +-- vim.opt_local.relativenumber = false +-- -- always start in insert mode +-- end, +--}) + +db.setup({ + theme = "hyper", + config = { + mru = { limit = 10, label = "" }, + project = { limit = 10 }, + header = { + [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], + [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], + [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], + [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], + [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], + [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], + }, + disable_move = false, + shortcut = { + { desc = " Plugins", group = "Number", action = "PackerStatus", key = "p" }, + --{ desc = " Plugins", group = "@property", action = "PackerStatus", key = "p" }, + { + desc = " Files", + group = "Number", + --group = "Label", + action = "Telescope find_files", + key = "f", + }, + { + desc = " Text", + group = "Number", + --group = "Label", + action = "enew", + key = "t", + }, + { + desc = " Grep", + group = "Number", + --group = "Label", + action = "Telescope live_grep", + key = "g", + }, + { + desc = " Scheme", + group = "Number", + --group = "Label", + action = "Telescope colorscheme", + key = "s", + }, + { + desc = " Config", + group = "Number", + --group = "Label", + action = ":edit ~/.config/nvim/init.lua", + key = "c", + }, + }, + footer = { "", "Hello World!" }, + }, + hide = { + statusline = false, + tabline = false, + winbar = false, + }, +}) + +--highlights +---- General +--DashboardHeader DashboardFooter +---- Hyper theme +--DashboardProjectTitle DashboardProjectTitleIcon DashboardProjectIcon +--DashboardMruTitle DashboardMruIcon DashboardFiles DashboardShotCutIcon +---- Doome theme +--DashboardDesc DashboardKey DashboardIcon DashboardShotCut diff --git a/.config/nvim/lua/plugins/fidget.lua b/.config/nvim/lua/plugins/fidget.lua new file mode 100644 index 0000000..d401c5f --- /dev/null +++ b/.config/nvim/lua/plugins/fidget.lua @@ -0,0 +1,34 @@ +require("fidget").setup({ + --event = "LspAttach", + text = { + --spinner = "pipe", -- (Default) animation shown when tasks are ongoing + --spinner = "hamburger", -- animation shown when tasks are ongoing + --spinner = "dots_pulse", -- animation shown when tasks are ongoing + spinner = "dots", -- animation shown when tasks are ongoing + done = "✔", -- character shown when all tasks are complete + commenced = "Started", -- message shown when task starts + completed = "Completed", -- message shown when task completes + }, + fmt = { + task = function(task_name, message, percentage) + if task_name == "diagnostics" then + return false + end + return string.format( + "%s%s [%s]", + message, + percentage and string.format(" (%s%%)", percentage) or "", + task_name + ) + end, + }, + --sources = { -- Sources to configure + --["null-ls"] = { -- Name of source + --ignore = true, -- Ignore notifications from this source + --}, + --}, + debug = { + logging = false, -- whether to enable logging, for debugging + strict = false, -- whether to interpret LSP strictly + }, +}) diff --git a/.config/nvim/lua/plugins/fzf.lua b/.config/nvim/lua/plugins/fzf.lua new file mode 100644 index 0000000..5675e9f --- /dev/null +++ b/.config/nvim/lua/plugins/fzf.lua @@ -0,0 +1,60 @@ +--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)) +--]]) diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua new file mode 100644 index 0000000..8fbdae1 --- /dev/null +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -0,0 +1,47 @@ +require("gitsigns").setup({ + signs = { + --add = { + -- hl = "GitSignsAdd", + -- text = "▍", --│ + -- numhl = "GitSignsAddNr", + -- linehl = "GitSignsAddLn", + --}, + --change = { + -- hl = "GitSignsChange", + -- text = "▍", --│ + -- numhl = "GitSignsChangeNr", + -- linehl = "GitSignsChangeLn", + --}, + delete = { + hl = "GitSignsDelete", + text = "▁", --_━─ + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + topdelete = { + hl = "GitSignsDelete", + text = "▔", --‾ + numhl = "GitSignsDeleteNr", + linehl = "GitSignsDeleteLn", + }, + changedelete = { + hl = "GitSignsDelete", + text = "~", + numhl = "GitSignsChangeNr", + linehl = "GitSignsChangeLn", + }, + }, + current_line_blame = true, + }) + +vim.api.nvim_command("highlight DiffAdd guibg=none guifg=#21c7a8") +vim.api.nvim_command("highlight DiffModified guibg=none guifg=#82aaff") +vim.api.nvim_command("highlight DiffDelete guibg=none guifg=#fc514e") +vim.api.nvim_command("highlight DiffText guibg=none guifg=#fc514e") +vim.cmd([[ +hi link GitSignsAdd DiffAdd +hi link GitSignsChange DiffModified +hi link GitSignsDelete DiffDelete +hi link GitSignsTopDelete DiffDelete +hi link GitSignsChangedDelete DiffDelete +]]) diff --git a/.config/nvim/lua/plugins/goto-preview.lua b/.config/nvim/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..d4d2c67 --- /dev/null +++ b/.config/nvim/lua/plugins/goto-preview.lua @@ -0,0 +1,18 @@ +require('goto-preview').setup { + width = 120; -- Width of the floating window + height = 15; -- Height of the floating window + border = {"↖", "─" ,"┐", "│", "┘", "─", "└", "│"}; -- Border characters of the floating window + default_mappings = false; -- Bind default mappings + debug = false; -- Print debug information + opacity = nil; -- 0-100 opacity level of the floating window where 100 is fully transparent. + resizing_mappings = false; -- Binds arrow keys to resizing the floating window. + post_open_hook = nil; -- A function taking two arguments, a buffer and a window to be ran as a hook. + references = { -- Configure the telescope UI for slowing the references cycling window. + telescope = require("telescope.themes").get_dropdown({ hide_preview = false }) + }; + -- These two configs can also be passed down to the goto-preview definition and implementation calls for one off "peak" functionality. + focus_on_open = true; -- Focus the floating window when opening it. + dismiss_on_move = false; -- Dismiss the floating window when moving the cursor. + force_close = true, -- passed into vim.api.nvim_win_close's second argument. See :h nvim_win_close + bufhidden = "wipe", -- the bufhidden option to set on the floating window. See :h bufhidden +} diff --git a/.config/nvim/lua/plugins/hardtime.lua b/.config/nvim/lua/plugins/hardtime.lua new file mode 100644 index 0000000..153411d --- /dev/null +++ b/.config/nvim/lua/plugins/hardtime.lua @@ -0,0 +1,20 @@ +local hardtime = require('hardtime') + +-- Function to toggle the hardtime state and echo a message +local hardtime_enabled = true + +function ToggleHardtime() + hardtime.toggle() + hardtime_enabled = not hardtime_enabled + local message = hardtime_enabled and 'hardtime on' or 'hardtime off' + vim.cmd('echo "' .. message .. '"') +end + +hardtime.setup({ + -- hardtime config here + disabled_filetypes = { 'qf', 'netrw', 'NvimTree', 'lazy', 'mason', 'oil', 'dashboard' }, +}) + +return { + ToggleHardtime = ToggleHardtime, +} diff --git a/.config/nvim/lua/plugins/harpoon.lua b/.config/nvim/lua/plugins/harpoon.lua new file mode 100644 index 0000000..784ee0b --- /dev/null +++ b/.config/nvim/lua/plugins/harpoon.lua @@ -0,0 +1,34 @@ +require("harpoon").setup({ + menu = { + width = vim.api.nvim_win_get_width(0) - 4, + }, + --keys = { + -- { "mt", function() require("harpoon.mark").toggle_file() end, desc = "Toggle File" }, + -- { "mm", function() require("harpoon.ui").toggle_quick_menu() end, desc = "Harpoon Menu" }, + -- { "mc", function() require("harpoon.cmd-ui").toggle_quick_menu() end, desc = "Command Menu" }, + -- --{ "<leader>1", function() require("harpoon.ui").nav_file(1) end, desc = "File 1" }, + -- --{ "<leader>2", function() require("harpoon.ui").nav_file(2) end, desc = "File 2" }, + -- --{ "<leader>3", function() require("harpoon.term").gotoTerminal(1) end, desc = "Terminal 1" }, + -- --{ "<leader>4", function() require("harpoon.term").gotoTerminal(2) end, desc = "Terminal 2" }, + -- --{ "<leader>5", function() require("harpoon.term").sendCommand(1,1) end, desc = "Command 1" }, + -- --{ "<leader>6", function() require("harpoon.term").sendCommand(1,2) end, desc = "Command 2" }, + --}, +}) +vim.api.nvim_set_keymap("n", "<leader>ma", ":lua require('harpoon.mark').add_file()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mt", ":lua require('harpoon.mark').toggle_file()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mq", ":lua require('harpoon.ui').toggle_quick_menu()<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mh", ":lua require('harpoon.ui').nav_file(1)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mj", ":lua require('harpoon.ui').nav_file(2)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>mk", ":lua require('harpoon.ui').nav_file(3)<CR>", {}) +vim.api.nvim_set_keymap("n", "<leader>ml", ":lua require('harpoon.ui').nav_file(4)<CR>", {}) + +--local mark = require("harpoon.mark") +--local ui = require("harpoon.ui") +-- +--vim.keymap.set("n", "<leader>a", mark.add_file) +--vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu) +-- +--vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end) +--vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end) +--vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end) +--vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end) diff --git a/.config/nvim/lua/plugins/heirline.lua b/.config/nvim/lua/plugins/heirline.lua new file mode 100644 index 0000000..c41aff3 --- /dev/null +++ b/.config/nvim/lua/plugins/heirline.lua @@ -0,0 +1,1290 @@ +local conditions = require('heirline.conditions') +local utils = require('heirline.utils') + +local colors = { + --bg = "#23232e", + bg = nil, + nobg = 'NONE', + 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 = { + active = '#f34f29', + del = '#ff5555', + add = '#50fa7b', + 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 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 = 'PENDING ', + nov = ' N? ', + noV = ' N? ', + ['no\22'] = ' N? ', + niI = ' Ni ', + niR = ' Nr ', + niV = ' Nv ', + nt = 'TERMINAL', + 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) + return { fg = 'colors.black', bg = self.mode_color, bold = true } + end, + update = { + 'ModeChanged', + 'VimEnter', + pattern = '*:*', + callback = vim.schedule_wrap(function() + vim.cmd('redrawstatus') + end), + }, +} + +-- 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 }, +} +local Navic = { + condition = function() + return require('nvim-navic').is_available() + end, + static = { + -- create a type highlight map + type_hl = { + File = 'Directory', + Module = '@include', + Namespace = '@namespace', + Package = '@include', + Class = '@structure', + Method = '@method', + Property = '@property', + Field = '@field', + Constructor = '@constructor', + Enum = '@field', + Interface = '@type', + Function = '@function', + Variable = '@variable', + Constant = '@constant', + String = '@string', + Number = '@number', + Boolean = '@boolean', + Array = '@field', + Object = '@type', + Key = '@keyword', + Null = '@comment', + EnumMember = '@field', + Struct = '@structure', + Event = '@keyword', + Operator = '@operator', + TypeParameter = '@type', + }, + -- bit operation dark magic, see below... + enc = function(line, col, winnr) + return bit.bor(bit.lshift(line, 16), bit.lshift(col, 6), winnr) + end, + -- line: 16 bit (65535); col: 10 bit (1023); winnr: 6 bit (63) + dec = function(c) + local line = bit.rshift(c, 16) + local col = bit.band(bit.rshift(c, 6), 1023) + local winnr = bit.band(c, 63) + return line, col, winnr + end, + }, + 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 + -- encode line and column numbers into a single integer + local pos = self.enc(d.scope.start.line, d.scope.start.character, self.winnr) + local child = { + { + provider = d.icon, + hl = self.type_hl[d.type], + }, + { + -- escape `%`s (elixir) and buggy default separators + provider = d.name:gsub('%%', '%%%%'):gsub('%s*->%s*', ''), + -- highlight icon only or location name as well + -- hl = self.type_hl[d.type], + + on_click = { + -- pass the encoded position through minwid + minwid = pos, + callback = function(_, minwid) + -- decode + local line, col, winnr = self.dec(minwid) + vim.api.nvim_win_set_cursor(vim.fn.win_getid(winnr), { line, col }) + end, + name = 'heirline_navic', + }, + }, + } + -- add a separator only if needed + if #data > 1 and i < #data then + table.insert(child, { + provider = ' > ', + hl = { fg = 'bright_fg' }, + }) + end + table.insert(children, child) + end + -- instantiate the new child, overwriting the previous one + self.child = self:new(children, 1) + end, + -- evaluate the children containing navic components + provider = function(self) + return self.child:eval() + end, + hl = { fg = 'gray' }, + update = 'CursorMoved', +} + +-- 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, + --{ + -- -- git branch name + -- provider = function(self) + -- --return ' ' .. self.status_dict.head + -- return ' ' .. self.status_dict.head + -- end, + -- --hl = { bold = true }, + -- hl = { fg = colors.git.active, bold = true, bg = colors.bg }, + --}, + -- You could handle delimiters, icons and counts similar to Diagnostics + { + -- git branch icon + provider = function() + return ' ' + end, + hl = { fg = colors.git.active, bg = colors.bg }, + }, + + { + -- git branch name + provider = function(self) + return self.status_dict.head + end, + hl = { fg = colors.white, bg = colors.bg }, + }, + + { + 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! +-- Note that we add spaces separately, so that only the icon characters will be clickable +--local DAPMessages = { +-- condition = function() +-- local session = require("dap").session() +-- return session ~= nil +-- end, +-- provider = function() +-- return " " .. require("dap").status() .. " " +-- end, +-- hl = "Debug", +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").step_into() +-- end, +-- name = "heirline_dap_step_into", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").step_out() +-- end, +-- name = "heirline_dap_step_out", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = " ", +-- on_click = { +-- callback = function() +-- require("dap").step_over() +-- end, +-- name = "heirline_dap_step_over", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "ﰇ", +-- on_click = { +-- callback = function() +-- require("dap").run_last() +-- end, +-- name = "heirline_dap_run_last", +-- }, +-- }, +-- { provider = " " }, +-- { +-- provider = "", +-- on_click = { +-- callback = function() +-- require("dap").terminate() +-- require("dapui").close({}) +-- end, +-- name = "heirline_dap_close", +-- }, +-- }, +-- { provider = " " }, +-- -- icons: ﰇ +--} + +-- 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 HelpFileName = { + 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 }, +} + +local SearchCount = { + condition = function() + return vim.v.hlsearch ~= 0 and vim.o.cmdheight == 0 + end, + init = function(self) + local ok, search = pcall(vim.fn.searchcount) + if ok and search.total then + self.search = search + end + end, + provider = function(self) + local search = self.search + return string.format('[%d/%d]', search.current, math.min(search.total, search.maxcount)) + end, +} + +local MacroRec = { + condition = function() + return vim.fn.reg_recording() ~= '' and vim.o.cmdheight == 0 + end, + provider = ' ', + hl = { fg = 'orange', bold = true }, + utils.surround({ '[', ']' }, nil, { + provider = function() + return vim.fn.reg_recording() + end, + hl = { fg = 'green', bold = true }, + }), + update = { + 'RecordingEnter', + 'RecordingLeave', + }, +} + +local ShowCmd = { + condition = function() + return vim.o.cmdheight == 0 + end, + provider = ':%3.5(%S%)', +} + +local cursor_location = { + { 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 = { + init = 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 }, + flexible = 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 +) + +LeftSpace = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { LeftSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) + +RightSpace = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { RightSpace, hl = { fg = utils.get_highlight('statusline').bg, 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.black, force = true } }) + +ViMode = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { ViMode, hl = { fg = colors.black, force = true } }) + +Ruler = utils.surround({ '', '' }, function(self) + return self:mode_color() +end, { Ruler, hl = { fg = colors.black, force = true } }) + +local left = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { bg = utils.get_highlight('statusline').bg, bold = false } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { FileNameBlock, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { Git, hl = { bg = colors.nobg, force = true } }, +} + +local middle = { + { Align, hl = { bg = colors.nobg, force = true } }, + --{ Navic, hl = { bg = colors.nobg, force = true } }, + --{ DAPMessages, hl = { bg = colors.nobg, force = true } }, + { Align, hl = { bg = colors.nobg, force = true } }, +} + +local right = { + --{ Space, hl = { bg = colors.nobg, force = true } }, + { Diagnostics, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { LSPActive, hl = { bg = colors.nobg, force = true } }, + { Space, hl = { bg = colors.nobg, force = true } }, + { FileInfoBlock, hl = { bg = colors.nobg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, bold = false } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local sections = { left, middle, right } +local DefaultStatusline = { sections } + +local specialleft = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { bg = utils.get_highlight('statusline').bg, bold = false } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local specialmiddle = { + { Align, hl = { bg = colors.nobg, force = true } }, + --{ DAPMessages, hl = { bg = colors.nobg, force = true } }, + { Align, hl = { bg = colors.nobg, force = true } }, +} + +local specialright = { + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, bold = false } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, +} + +local specialsections = { specialleft, specialmiddle, specialright } + +local InactiveStatusline = { + condition = conditions.is_not_active, + --{ FileNameBlock, hl = { bg = colors.nobg, force = true } }, + --{ Align, hl = { bg = colors.nobg, force = true } }, + specialsections, +} + +local SpecialStatusline = { + condition = function() + return conditions.buffer_matches({ + buftype = { 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { '^git.*', 'fugitive', 'dashboard' }, + }) + end, + specialsections, +} + +--local InactiveStatusline = SpecialStatusline + +local TerminalStatusline = { + condition = function() + return conditions.buffer_matches({ buftype = { 'terminal' } }) + end, + specialsections, +} + +local StatusLine = { + 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_colors = { + n = colors.blue, + no = colors.blue, + nov = colors.blue, + noV = colors.blue, + ['no\22'] = colors.blue, + niI = colors.blue, + niR = colors.blue, + niV = colors.blue, + nt = colors.blue, + v = colors.purple, + vs = colors.purple, + V = colors.purple, + ['\22'] = colors.purple, + ['\22s'] = colors.purple, + s = colors.purple, + S = colors.purple, + ['\19'] = colors.purple, + i = colors.green, + ix = colors.green, + ic = colors.green, + R = colors.red, + Rc = colors.red, + Rx = colors.red, + Rv = colors.red, + Rvc = colors.red, + Rvx = colors.red, + c = colors.orange, + cv = colors.orange, + ce = colors.orange, + r = colors.red, + rm = 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) + -- 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 = { 'terminal', 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { 'dap-ui', 'NvimTree', '^git.*', 'fugitive', 'dashboard' }, + }) + 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 }, +---- hl = "Comment", +--} + +-- 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 = { fg = colors.white, bg = '#333842', bold = true }, + + --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 = StatusLine, + winbar = WinBar, + tabline = TabLine, + --statuscolumn = StatusColumn +}) + +-- Yep, with heirline we're driving manual! +vim.o.showtabline = 2 +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/.config/nvim/lua/plugins/leetcode.lua b/.config/nvim/lua/plugins/leetcode.lua new file mode 100644 index 0000000..50369e1 --- /dev/null +++ b/.config/nvim/lua/plugins/leetcode.lua @@ -0,0 +1,68 @@ +---@alias lc.lang +---| "cpp" +---| "java" +---| "python" +---| "python3" +---| "c" +---| "csharp" +---| "javascript" +---| "typescript" +---| "php" +---| "swift" +---| "kotlin" +---| "dart" +---| "golang" +---| "ruby" +---| "scala" +---| "rust" +---| "racket" +---| "erlang" +---| "elixir" + +---@alias lc.sql_lang +---| "pythondata" +---| "mysql" +---| "mssql" +---| "oraclesql" + +---@alias lc.domain +---| "com" +---| "cn" + +---@class lc.UserConfig +local M = { + ---@type lc.domain + domain = 'com', -- For now "com" is the only one supported + + ---@type string + arg = 'leetcode.nvim', + + ---@type lc.lang + lang = 'cpp', + + ---@type lc.sql_lang + sql = 'mysql', + + ---@type string + directory = vim.fn.stdpath('data') .. '/leetcode/', + + ---@type boolean + logging = true, + + console = { + ---@type boolean + open_on_runcode = false, + + size = { + width = '75%', ---@type string | integer + height = '75%', ---@type string | integer + }, + dir = 'row', ---@type "col" | "row" + }, + + description = { + width = '40%', ---@type string | integer + }, +} + +return M diff --git a/.config/nvim/lua/plugins/loclist.lua b/.config/nvim/lua/plugins/loclist.lua new file mode 100644 index 0000000..9b72a94 --- /dev/null +++ b/.config/nvim/lua/plugins/loclist.lua @@ -0,0 +1,18 @@ +local M = {} + +function M.loclist_toggle() + for _, info in ipairs(vim.fn.getwininfo()) do + if info.loclist == 1 then + vim.cmd('lclose') + return + end + end + + if next(vim.fn.getloclist(0)) == nil then + print('loc list empty') + return + end + vim.cmd('lopen') +end + +return M diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..b081cb4 --- /dev/null +++ b/.config/nvim/lua/plugins/lsp.lua @@ -0,0 +1,440 @@ +local lspconfig = require('lspconfig') +local mason_lspconfig = require('mason-lspconfig') +local null_ls = require('null-ls') +-- local lsp_lines = require('lsp_lines') +require('mason').setup() +require('mason-null-ls').setup({ handlers = {}, ensure_installed = nil, automatic_installation = true, automatic_setup = true }) + +local keymap = vim.keymap +local cmd = vim.cmd + +local border = { { '┌', 'FloatBorder' }, { '─', 'FloatBorder' }, { '┐', 'FloatBorder' }, { '│', 'FloatBorder' }, { '┘', 'FloatBorder' }, { '─', 'FloatBorder' }, { '└', 'FloatBorder' }, { '│', 'FloatBorder' } } + +-- Set up LSP servers if not done before +if not vim.g.lsp_setup_done then + -- Clear existing LSP clients + for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do + local clients = require('user.mods').get_lsp_clients(bufnr) + + for _, client in ipairs(clients) do + client.stop() + end + end + + 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 = hl }) + end + + -- lsp_lines.setup() + + -- vim.keymap.set("n", "g?", function() + -- local lines_enabled = not vim.diagnostic.config().virtual_lines + -- vim.diagnostic.config( + -- { + -- virtual_lines = lines_enabled, + -- virtual_text = not lines_enabled + -- } + -- ) + -- end, { noremap = true, silent = true }) + + vim.diagnostic.config({ + underline = false, + signs = true, + virtual_text = true, -- virtual_lines = { only_current_line = true }, + virtual_lines = false, + float = { + show_header = true, + source = 'if_many', -- border = 'rounded', + border = border, + focusable = true, + }, + update_in_insert = false, -- default to false + severity_sort = true, -- default to false + }) + + vim.lsp.handlers['textDocument/publishDiagnostics'] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { underline = false, virtual_text = false, signs = true, update_in_insert = false }) + + 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' }) + + -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer + local on_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') + 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 + -- Mappings + map('n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>') + -- map("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<CR>") + map('n', 'gd', "<cmd>lua require('goto-preview').goto_preview_definition()<CR>") + -- map("n", "gi", "<Cmd>lua vim.lsp.buf.implementation()<CR>") + map('n', 'gi', "<cmd>lua require('goto-preview').goto_preview_implementation()<CR>") + -- map("n", "gr", "<Cmd>lua vim.lsp.buf.references()<CR>") + map('n', 'gr', "<cmd>lua require('goto-preview').goto_preview_references()<CR>") + map('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>') -- most lsp servers don't implement textDocument/Declaration, so gD is useless for now. + map('n', '<leader>k', '<Cmd>lua vim.lsp.buf.signature_help()<CR>') + -- map("n", "gt", "<Cmd>lua vim.lsp.buf.type_definition()<CR>") + map('n', 'gt', "<cmd>lua require('goto-preview').goto_preview_type_definition()<CR>") + map('n', 'gn', '<Cmd>lua vim.lsp.buf.rename()<CR>') + map('n', 'ga', '<Cmd>lua vim.lsp.buf.code_action()<CR>') + map('n', 'gf', '<Cmd>lua vim.lsp.buf.format()<CR>') + map('n', 'go', '<Cmd>lua vim.diagnostic.open_float()<CR>') + map('n', '<leader>go', ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") + map('n', 'gq', '<Cmd>lua vim.diagnostic.setloclist()<CR>') + map('n', '[d', '<Cmd>lua vim.diagnostic.goto_prev()<CR>') + map('n', ']d', '<Cmd>lua vim.diagnostic.goto_next()<CR>') + map('n', 'gs', '<Cmd>lua vim.lsp.buf.document_symbol()<CR>') + map('n', 'gw', '<Cmd>lua vim.lsp.buf.workspace_symbol()<CR>') + map('n', '<leader>wa', '<Cmd>lua vim.lsp.buf.add_workspace_folder()<CR>') + map('n', '<leader>wr', '<Cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>') + map('n', '<leader>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end) + + -- TODO: Use the nicer new API for autocommands + cmd('augroup lsp_aucmds') + if client.server_capabilities.documentHighlightProvider then + cmd('au CursorHold <buffer> lua vim.lsp.buf.document_highlight()') + cmd('au CursorMoved <buffer> lua vim.lsp.buf.clear_references()') + end + cmd('augroup END') + end + + -- Toggle diagnostics visibility + 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 + + -- Open float for diagnostics automatically + vim.cmd([[ + augroup OpenFloat + " autocmd CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focusable = false,}) + autocmd CursorHold * lua vim.diagnostic.open_float(nil, {focusable = false,}) + + augroup END + ]]) + + -- Suppress error messages from lang servers + vim.lsp.set_log_level('debug') + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities = require('cmp_nvim_lsp').default_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + capabilities.offsetEncoding = { 'utf-8', 'utf-16' } + + local function prefer_null_ls_fmt(client) + client.server_capabilities.documentHighlightProvider = true + client.server_capabilities.documentFormattingProvider = true + on_attach(client) + end + + --local cmp_nvim_lsp = require('cmp_nvim_lsp') + local servers = { + asm_lsp = {}, + bashls = {}, + clangd = { + on_attach = on_attach, + capabilites = capabilities, + cmd = { 'clangd', '--offset-encoding=utf-16', '--cross-file-rename', '--header-insertion=never', '--suggest-missing-includes' }, + init_options = { + clangdFileStatus = true, + }, + root_files = { + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', -- AutoTools + }, + }, + cssls = { filetypes = { 'css', 'scss', 'less', 'sass' }, root_dir = lspconfig.util.root_pattern('package.json', '.git') }, -- ghcide = {}, + html = {}, + jsonls = { prefer_null_ls = true, cmd = { '--stdio' } }, + intelephense = {}, + julials = { + on_new_config = function(new_config, _) + local julia = vim.fn.expand('~/.julia/environments/nvim-lspconfig/bin/julia') + if lspconfig.util.path.is_file(julia) then + new_config.cmd[1] = julia + end + end, + settings = { julia = { format = { indent = 2 } } }, + }, + pyright = { settings = { python = { formatting = { provider = 'yapf' }, linting = { pytypeEnabled = true } } } }, + rust_analyzer = { + settings = { + ['rust-analyzer'] = { cargo = { allFeatures = true }, checkOnSave = { command = 'clippy', extraArgs = { '--no-deps' } } }, + }, + }, + dartls = { + cmd = { 'dart', 'language-server', '--protocol=lsp' }, + filetypes = { 'dart' }, + init_options = { + closingLabels = true, + flutterOutline = true, + onlyAnalyzeProjectsWithOpenFiles = true, + outline = true, + suggestFromUnimportedLibraries = true, + }, -- root_dir = root_pattern("pubspec.yaml"), + settings = { dart = { completeFunctionCalls = true, showTodos = true } }, + on_attach = function(client, bufnr) end, + }, + lua_ls = { + on_attach = on_attach, + capabilities = capabilities, + debounce_text_changes = 500, + settings = { + Lua = { + runtime = { version = 'LuaJIT', path = vim.split(package.path, ';') }, + diagnostics = { enable = true, globals = { 'vim' } }, + workspace = { maxPreload = 2000, preloadFileSize = 50000, checkThirdParty = false }, + }, + }, + }, + sqlls = {}, + tsserver = { + capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()), + on_attach = function(client) + client.server_capabilities.document_formatting = false + client.server_capabilities.document_range_formatting = false + end, + filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx' }, + }, + vimls = {}, + yamlls = {}, + } + + mason_lspconfig.setup({ + ensure_installed = servers, -- will be installed by mason + automatic_installation = true, + }) + + -- Your other configurations ... + -- require("lspconfig").dartls.setup({ capabilities = capabilities }) + -- local installed_lsp = mason_lspconfig.ensure_installed + -- local mason_lspconfig = require("mason-lspconfig").ensure_installed + + -- require("lspconfig").setup({ + -- function() + -- for _, lsp in ipairs(installed_lsp) do + -- if + -- lsp ~= "sqls" + -- --and lsp ~= "sumneko_lua" + -- --and lsp ~= "stylelint_lsp" + -- --and lsp ~= "rust_analyzer" + -- --and lsp ~= "sourcekit" + -- and lsp ~= "dartls" + -- then + -- lspconfig[lsp].setup({ + -- on_attach = on_attach, + -- capabilities = capabilities, + -- }) + -- end + -- end + -- end, + -- }) + + for server, config in pairs(servers) do + if config.prefer_null_ls then + if config.on_attach then + local old_on_attach = config.on_attach + config.on_attach = function(client, bufnr) + old_on_attach(client, bufnr) + prefer_null_ls_fmt(client) + end + else + config.on_attach = prefer_null_ls_fmt + end + elseif not config.on_attach then + config.on_attach = on_attach + end + + lspconfig[server].setup(config) + end + + -- null_ls setup + local builtins = null_ls.builtins + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) + + -- local eslint_opts = { + -- -- condition = function(utils) + -- -- return utils.root_has_file ".eslintrc.js" or utils.root_has_file ".eslintrc" or utils.root_has_file ".eslintrc.json" + -- -- end, + -- -- diagnostics_format = "#{m} [#{c}]", + -- prefer_local = true, + -- } + + -- null_ls.setup({ + local sources = { + -- Diagnostics + builtins.diagnostics.chktex, + -- null_ls.builtins.code_actions.eslint_d, + -- null_ls.builtins.diagnostics.eslint_d, + -- null_ls.builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.cppcheck, + -- null_ls.builtins.diagnostics.proselint, + -- null_ls.builtins.diagnostics.pylint, + -- builtins.diagnostics.selene, + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ -- shell script diagnostics + diagnostic_config = { -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = '[#{c}] #{m} (#{s})', -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.zsh.with({ filetypes = 'zsh', 'sh' }), + builtins.diagnostics.todo_comments, + builtins.diagnostics.teal, + -- null_ls.builtins.diagnostics.vale, + builtins.diagnostics.vint, + builtins.diagnostics.tidy, + builtins.diagnostics.php, + builtins.diagnostics.phpcs, + builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ + condition = function(utils) + return utils.root_has_file('.eslintrc.json') + end, + }), + builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, + + -- Formatting + builtins.formatting.shfmt.with({ filetypes = { 'bash', 'zsh', 'sh' }, extra_args = { '-i', '2', '-ci' } }), + builtins.formatting.shellharden, + builtins.formatting.trim_whitespace.with({ filetypes = { 'tmux', 'teal', 'zsh' } }), -- builtins.formatting.beautysh, + builtins.formatting.beautysh.with({ filetypes = 'zsh' }), + builtins.formatting.clang_format.with({ + filetypes = { 'c', 'cpp', 'cs', 'java', 'cuda', 'proto' }, + extra_args = { + '--style', + '{BasedOnStyle: Google, IndentWidth: 4, BreakBeforeBinaryOperators: NonAssignment, AllowShortFunctionsOnASingleLine: None}', + }, + }), + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, + -- null_ls.builtins.formatting.cmake_format, + builtins.formatting.isort, + builtins.formatting.htmlbeautifier, -- null_ls.builtins.formatting.prettier, + builtins.formatting.prettierd, + builtins.formatting.prettier.with({ + filetypes = { 'javascript', 'javascriptreact', 'typescript', 'typescriptreact', 'json', 'yaml', 'markdown', 'html', 'css', 'scss', 'less', 'graphql', 'vue', 'svelte' }, + extra_args = { '--single-quote', '--tab-width 4', '--print-width 200' }, + }), + builtins.formatting.rustfmt, + -- builtins.formatting.stylua, + -- builtins.formatting.lua_format, + builtins.formatting.stylua.with({ + filetypes = { 'lua' }, + command = 'stylua', + args = { '--quote_style', 'AutoPreferSingle', '--indent-width', '2', '--column-width', '160', '--indent-type', 'Spaces', '-' }, + }), + -- builtins.formatting.dart_format, + builtins.formatting.dart_format.with({ filetypes = { 'dart' } }), + builtins.formatting.trim_whitespace, + builtins.formatting.yapf, + -- null_ls.builtins.formatting.black + + -- Code Actions + builtins.code_actions.shellcheck, -- shell script code actions + -- builtins.code_actions.eslint_d.with(eslint_opts), + -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, -- Hover + builtins.hover.dictionary, + builtins.hover.printenv, + } + -- }) + -- Linters/Formatters ensure installed + -- for _, pkg_name in ipairs({ + -- "dart-debug-Adaptor", + -- "stylua", + -- "prettier", + -- "prettierd", + -- }) do + + -- Import the builtins table from the null-ls module and store it in the null_ls_sources variable + null_ls.setup({ + sources = sources, + update_in_insert = true, + on_attach = function(client, bufnr) + if client.supports_method('textDocument/formatting') then + vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) + vim.api.nvim_create_autocmd('BufWritePre', { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format() + end, + }) + end + end, + }) + + -- Install all the null-ls sources using Mason + local registry = require('mason-registry') + for _, source_name in ipairs(sources) do + local ok, pkg = pcall(registry.get_package, source_name) + if ok then + if not pkg:is_installed() then + pkg:install() + end + end + end + -- Loop through the null_ls_sources table and install the packages + -- Install all sources for null-ls + -- local null_ls_sources = require("null-ls").builtins + + -- for _, source_name in ipairs(null_ls_sources) do + -- local ok, pkg = pcall(mason.get_package, source_name) + -- if ok then + -- if not pkg:is_installed() then + -- pkg:install() + -- end + -- end + -- end + vim.api.nvim_create_user_command('NullLsToggle', function() + -- you can also create commands to disable or enable sources + require('null-ls').toggle({}) + end, {}) + + local null_ls_stop = function() + local null_ls_client + local clients = require('user.mods').get_lsp_clients(bufnr) + + for _, client in ipairs(clients) do + if client.name == 'null-ls' then + null_ls_client = client + end + end + if not null_ls_client then + return + end + + null_ls_client.stop() + end + + vim.api.nvim_create_user_command('NullLsStop', null_ls_stop, {}) + + vim.g.lsp_setup_done = true +end diff --git a/.config/nvim/lua/plugins/modify-blend.lua b/.config/nvim/lua/plugins/modify-blend.lua new file mode 100644 index 0000000..1b2c6d5 --- /dev/null +++ b/.config/nvim/lua/plugins/modify-blend.lua @@ -0,0 +1,43 @@ +local ui = vim.api.nvim_list_uis()[1] + +local bufnr = vim.api.nvim_create_buf(true, true) +local win = vim.api.nvim_open_win(bufnr, true, { + relative = "editor", + --relative = "cursor", + width = ui.width, + height = ui.height, + anchor = "NE", + row = 10, + col = 10, + style = "minimal", + zindex = 50, +}) + +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/.config/nvim/lua/plugins/navic.lua b/.config/nvim/lua/plugins/navic.lua new file mode 100644 index 0000000..a95485d --- /dev/null +++ b/.config/nvim/lua/plugins/navic.lua @@ -0,0 +1,50 @@ +local navic = require("nvim-navic") +--local on_attach = function(client, bufnr) +-- if client.server_capabilities.documentSymbolProvider then +-- navic.attach(client, bufnr) +-- end +--end + +--require("lspconfig").clangd.setup { +-- on_attach = on_attach +--} + +navic.setup { + icons = { + 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 = " ", + }, + lsp = { + auto_attach = true, + --preference = nil, + }, + highlight = false, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true +} diff --git a/.config/nvim/lua/plugins/neodev.lua b/.config/nvim/lua/plugins/neodev.lua new file mode 100644 index 0000000..f820422 --- /dev/null +++ b/.config/nvim/lua/plugins/neodev.lua @@ -0,0 +1,29 @@ +require("neodev").setup({ + --library = { plugins = { "nvim-dap-ui" }, types = true }, + --library = { plugins = { "neotest" }, types = true }, + library = { + enabled = true, -- when not enabled, neodev will not change any settings to the LSP server + -- these settings will be used for your Neovim config directory + runtime = true, -- runtime path + types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others + --plugins = { "neotest" }, + --{ "nvim-dap-ui" }, + --plugins = true, -- installed opt or start plugins in packpath + -- you can also specify the list of plugins to make available as a workspace library + -- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }, + plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim", "neotest", "nvim-dap-ui" }, + }, + setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files + -- for your Neovim config directory, the config.library settings will be used as is + -- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled + -- for any other directory, config.library.enabled will be set to false + override = function(root_dir, options) + end, + -- With lspconfig, Neodev will automatically setup your lua-language-server + -- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init} + -- in your lsp start options + lspconfig = true, + -- much faster, but needs a recent built of lua-language-server + -- needs lua-language-server >= 3.6.0 + pathStrict = true, +}) diff --git a/.config/nvim/lua/plugins/neoscroll.lua b/.config/nvim/lua/plugins/neoscroll.lua new file mode 100644 index 0000000..d122584 --- /dev/null +++ b/.config/nvim/lua/plugins/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/.config/nvim/lua/plugins/neotest.lua b/.config/nvim/lua/plugins/neotest.lua new file mode 100644 index 0000000..aa73899 --- /dev/null +++ b/.config/nvim/lua/plugins/neotest.lua @@ -0,0 +1,11 @@ +require("neotest").setup({ + adapters = { + require("neotest-python")({ + dap = { justMyCode = false }, + }), + require("neotest-plenary"), + require("neotest-vim-test")({ + ignore_file_types = { "python", "vim", "lua" }, + }), + }, +}) diff --git a/.config/nvim/lua/plugins/notify.lua b/.config/nvim/lua/plugins/notify.lua new file mode 100644 index 0000000..dcb496a --- /dev/null +++ b/.config/nvim/lua/plugins/notify.lua @@ -0,0 +1,18 @@ +require('notify').setup({ + background_colour = '#000000', + icons = { + ERROR = '', + WARN = '', + INFO = '', + DEBUG = '', + TRACE = '✎', + }, +}) + +vim.api.nvim_command('hi default link NotifyERRORBody Normal') +vim.api.nvim_command('hi default link NotifyWARNBody Normal') +vim.api.nvim_command('hi default link NotifyINFOBody Normal') +vim.api.nvim_command('hi default link NotifyDEBUGBody Normal') +vim.api.nvim_command('hi default link NotifyTRACEBody Normal') +vim.api.nvim_command('hi default link NotifyLogTime Comment') +vim.api.nvim_command('hi default link NotifyLogTitle Special') diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..f82a327 --- /dev/null +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,403 @@ +----------------------------------------------------------- +-- Neovim File Tree Configuration +----------------------------------------------------------- + +--- To see mappings `g?` on nvim-tree +--- To see default mappings `:nvim-tree-default-mappings` + +local icons = { + webdev_colors = true, + git_placement = 'signcolumn', + modified_placement = 'after', + padding = ' ', + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + modified = true, + }, + + glyphs = { + default = '', + symlink = '', + folder = { + arrow_open = '', + arrow_closed = '', + default = ' ', + open = ' ', + empty = ' ', + empty_open = ' ', + symlink = '', + symlink_open = '', + }, + + git = { + deleted = '', + unmerged = '', + untracked = '', + unstaged = '', + staged = '', + renamed = '➜', + ignored = '◌', + }, + }, + web_devicons = { + folder = { + enable = true, + color = true, + }, + }, +} + +local renderer = { + group_empty = true, -- default: true. Compact folders that only contain a single folder into one node in the file tree. + highlight_git = false, + full_name = false, + highlight_opened_files = 'icon', -- "none" (default), "icon", "name" or "all" + highlight_modified = 'icon', -- "none", "name" or "all". Nice and subtle, override the open icon + root_folder_label = ':~:s?$?/..?', + indent_width = 2, + indent_markers = { + enable = true, + inline_arrows = true, + icons = { + corner = '└', + edge = '│', + item = '│', + bottom = '─', + none = ' ', + }, + }, + icons = icons, +} + +local system_open = { cmd = 'zathura' } + +local HEIGHT_RATIO = 0.8 +local WIDTH_RATIO = 0.15 + +local float = { + enable = false, + open_win_config = function() + local screen_w = vim.opt.columns:get() + local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get() + local window_w = screen_w * WIDTH_RATIO + local window_h = screen_h * HEIGHT_RATIO + local window_w_int = math.floor(window_w) + local window_h_int = math.floor(window_h) + local center_x = (screen_w - window_w) / 2 + local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get() + return { + border = 'rounded', + relative = 'editor', + row = center_y, + col = center_x, + width = window_w_int, + height = window_h_int, + } + end, +} + +local view = { + cursorline = true, + float = float, + --signcolumn = 'no', + width = function() + return math.floor(vim.opt.columns:get() * WIDTH_RATIO) + end, + side = 'left', +} + +local api = require('nvim-tree.api') +local function on_attach(bufnr) + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + local mappings = { + ['<C-]>'] = { api.tree.change_root_to_node, 'CD' }, + ['<C-e>'] = { api.node.open.replace_tree_buffer, 'Open: In Place' }, + ['<C-k>'] = { api.node.show_info_popup, 'Info' }, + ['<C-r>'] = { api.fs.rename_sub, 'Rename: Omit Filename' }, + ['<C-t>'] = { api.node.open.tab, 'Open: New Tab' }, + ['<C-v>'] = { api.node.open.vertical, 'Open: Vertical Split' }, + ['<C-x>'] = { api.node.open.horizontal, 'Open: Horizontal Split' }, + ['<BS>'] = { api.node.navigate.parent_close, 'Close Directory' }, + -- ["<CR>"] = { api.node.open.edit, "Open" }, + ['<Tab>'] = { api.node.open.preview, 'Open Preview' }, + ['>'] = { api.node.navigate.sibling.next, 'Next Sibling' }, + ['<'] = { api.node.navigate.sibling.prev, 'Previous Sibling' }, + ['.'] = { api.node.run.cmd, 'Run Command' }, + ['-'] = { api.tree.change_root_to_parent, 'Up' }, + ['a'] = { api.fs.create, 'Create' }, + ['bmv'] = { api.marks.bulk.move, 'Move Bookmarked' }, + ['B'] = { api.tree.toggle_no_buffer_filter, 'Toggle No Buffer' }, + ['c'] = { api.fs.copy.node, 'Copy' }, + -- ["C"] = { api.tree.toggle_git_clean_filter, "Toggle Git Clean" }, + ['[c'] = { api.node.navigate.git.prev, 'Prev Git' }, + [']c'] = { api.node.navigate.git.next, 'Next Git' }, + ['d'] = { api.fs.remove, 'Delete' }, + ['D'] = { api.fs.trash, 'Trash' }, + ['E'] = { api.tree.expand_all, 'Expand All' }, + ['e'] = { api.fs.rename_basename, 'Rename: Basename' }, + [']e'] = { api.node.navigate.diagnostics.next, 'Next Diagnostic' }, + ['[e'] = { api.node.navigate.diagnostics.prev, 'Prev Diagnostic' }, + ['F'] = { api.live_filter.clear, 'Clean Filter' }, + ['f'] = { api.live_filter.start, 'Filter' }, + ['g?'] = { api.tree.toggle_help, 'Help' }, + ['gy'] = { api.fs.copy.absolute_path, 'Copy Absolute Path' }, + ['H'] = { api.tree.toggle_hidden_filter, 'Toggle Dotfiles' }, + ['I'] = { api.tree.toggle_gitignore_filter, 'Toggle Git Ignore' }, + ['J'] = { api.node.navigate.sibling.last, 'Last Sibling' }, + ['K'] = { api.node.navigate.sibling.first, 'First Sibling' }, + ['m'] = { api.marks.toggle, 'Toggle Bookmark' }, + -- ["o"] = { api.node.open.edit, "Open" }, + ['O'] = { api.node.open.no_window_picker, 'Open: No Window Picker' }, + ['p'] = { api.fs.paste, 'Paste' }, + ['P'] = { api.node.navigate.parent, 'Parent Directory' }, + ['q'] = { api.tree.close, 'Close' }, + ['r'] = { api.fs.rename, 'Rename' }, + ['R'] = { api.tree.reload, 'Refresh' }, + ['s'] = { api.node.run.system, 'Run System' }, + ['S'] = { api.tree.search_node, 'Search' }, + ['U'] = { api.tree.toggle_custom_filter, 'Toggle Hidden' }, + ['W'] = { api.tree.collapse_all, 'Collapse' }, + ['x'] = { api.fs.cut, 'Cut' }, + ['y'] = { api.fs.copy.filename, 'Copy Name' }, + ['Y'] = { api.fs.copy.relative_path, 'Copy Relative Path' }, + ['<2-LeftMouse>'] = { api.node.open.edit, 'Open' }, + ['<2-RightMouse>'] = { api.tree.change_root_to_node, 'CD' }, + + -- Mappings migrated from view.mappings.list + ['l'] = { api.node.open.edit, 'Open' }, + ['<CR>'] = { api.node.open.edit, 'Open' }, + ['o'] = { api.node.open.edit, 'Open' }, + ['h'] = { api.node.navigate.parent_close, 'Close Directory' }, + ['v'] = { api.node.open.vertical, 'Open: Vertical Split' }, + ['C'] = { api.tree.change_root_to_node, 'CD' }, + } + for keys, mapping in pairs(mappings) do + vim.keymap.set('n', keys, mapping[1], opts(mapping[2])) + end +end +--api.events.subscribe(api.events.Event.FileCreated, function(file) +-- vim.cmd('edit' .. file.fname) +--end) + +require('nvim-tree').setup({ + --auto_reload_on_write = true, + --create_in_closed_folder = false, + --hijack_cursor = true, + --disable_netrw = true, + --hijack_netrw = true, + --hijack_unnamed_buffer_when_opening = false, + --ignore_buffer_on_setup = false, + update_focused_file = { + enable = true, + update_cwd = true, + update_root = true, + ignore_list = {}, + }, + root_dirs = {}, + --prefer_startup_root = true, + --hijack_directories = { + -- enable = false, + --}, + --respect_buf_cwd = false, + sync_root_with_cwd = true, + --reload_on_bufenter = false, + view = view, + system_open = system_open, + renderer = renderer, + on_attach = on_attach, + notify = { + threshold = vim.log.levels.ERROR, + }, + git = { ignore = false }, + diagnostics = { + enable = true, + show_on_dirs = true, + icons = { + hint = '⚑', + info = '', + warning = '▲', + error = '', + }, + }, + trash = { + cmd = 'gio trash', + require_confirm = true, + }, + modified = { + enable = true, + show_on_dirs = true, + show_on_open_dirs = true, + }, + --filters = { + -- dotfiles = false, + -- git_clean = false, + -- no_buffer = false, + -- custom = {}, + -- exclude = {}, + --}, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + remove_file = { + close_window = true, + }, + open_file = { + quit_on_open = true, + --eject = true, + resize_window = false, + window_picker = { + enable = true, + chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890', + exclude = { + filetype = { 'notify', 'packer', 'qf', 'diff', 'fugitive', 'fugitiveblame' }, + buftype = { 'nofile', 'terminal', 'help' }, + }, + }, + }, + }, +}) + +local api = require('nvim-tree.api') +local event = api.events.Event +--api.events.subscribe(event.TreeOpen, function(_) +-- vim.cmd([[setlocal statuscolumn=\ ]]) +-- vim.cmd([[setlocal cursorlineopt=number]]) +-- vim.cmd([[setlocal fillchars+=vert:🮇]]) +-- vim.cmd([[setlocal fillchars+=horizup:🮇]]) +-- vim.cmd([[setlocal fillchars+=vertright:🮇]]) +--end) + +local function open_nvim_tree(data) + vim.cmd.cd(data.file:match('(.+)/[^/]*$')) + local directory = vim.fn.isdirectory(data.file) == 1 + if not directory then + return + end + require('nvim-tree.api').tree.open() +end +vim.api.nvim_create_autocmd({ 'VimEnter' }, { callback = open_nvim_tree }) + +-- Change Root To Global Current Working Directory +local function change_root_to_global_cwd() + local api = require('nvim-tree.api') + local global_cwd = vim.fn.getcwd(-1, -1) + api.tree.change_root(global_cwd) +end + +local function copy_file_to(node) + local file_src = node['absolute_path'] + -- The args of input are {prompt}, {default}, {completion} + -- Read in the new file path using the existing file's path as the baseline. + local file_out = vim.fn.input('COPY TO: ', file_src, 'file') + -- Create any parent dirs as required + local dir = vim.fn.fnamemodify(file_out, ':h') + vim.fn.system({ 'mkdir', '-p', dir }) + -- Copy the file + vim.fn.system({ 'cp', '-R', file_src, file_out }) +end + +local function edit_and_close(node) + api.node.open.edit(node, {}) + api.tree.close() +end + +--vim.api.nvim_create_augroup('NvimTreeRefresh', {}) +--vim.api.nvim_create_autocmd('BufEnter', { +-- pattern = 'NvimTree_1', +-- command = 'NvimTreeRefresh', +-- group = 'NvimTreeRefresh', +--}) + +vim.api.nvim_create_autocmd({ 'CursorHold' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 100, + }) + ) + vim.opt.guicursor:append('a:Cursor/lCursor') + end, +}) + +vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed', 'WinLeave' }, { + pattern = 'NvimTree*', + callback = function() + local def = vim.api.nvim_get_hl_by_name('Cursor', true) + vim.api.nvim_set_hl( + 0, + 'Cursor', + vim.tbl_extend('force', def, { + blend = 0, + }) + ) + vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20' + end, +}) + +-- Highlight Groups +vim.api.nvim_command('highlight NvimTreeNormal guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalNC guibg=NONE ctermbg=NONE guifg=NONE') +vim.api.nvim_command('highlight NvimTreeNormalFloat guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEndOfBuffer guibg=NONE ctermbg=NONE') --(NonText) +vim.api.nvim_command('highlight NvimTreeCursorLine guibg=#50fa7b guifg=#000000') +vim.api.nvim_command('highlight NvimTreeSymlinkFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeRootFolder guifg=#f8f8f2 guibg=NONE ctermbg=NONE') +vim.api.nvim_command('highlight NvimTreeEmptyFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFolderName guifg=#f8f8f2 guibg=NONE ctermbg=NONE') --(Directory) +vim.api.nvim_command('highlight NvimTreeOpenedFile guifg=#50fa7b guibg=NONE ctermbg=NONE') + +--vim.api.nvim_command("highlight NvimTreeSymlink ") +--vim.api.nvim_command("highlight NvimTreeSymlinkFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeRootFolder ") +--vim.api.nvim_command("highlight NvimTreeFolderIcon ") +--vim.api.nvim_command("highlight NvimTreeOpenedFolderIcon ") --(NvimTreeFolderIcon) +--vim.api.nvim_command("highlight NvimTreeClosedFolderIcon ") --(NvimTreeFolderIcon) +--vim.api.nvim_command("highlight NvimTreeFileIcon ") +--vim.api.nvim_command("highlight NvimTreeEmptyFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeOpenedFolderName ") --(Directory) +--vim.api.nvim_command("highlight NvimTreeExecFile ") +--vim.api.nvim_command("highlight NvimTreeOpenedFile ") +--vim.api.nvim_command("highlight NvimTreeModifiedFile ") +--vim.api.nvim_command("highlight NvimTreeSpecialFile ") +--vim.api.nvim_command("highlight NvimTreeImageFile ") +--vim.api.nvim_command("highlight NvimTreeIndentMarker ") +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsError ") --(DiagnosticError) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsWarning ") --(DiagnosticWarn) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsInformation ") --(DiagnosticInfo) +--vim.api.nvim_command("highlight NvimTreeLspDiagnosticsHint ") --(DiagnosticHint) +--vim.api.nvim_command("highlight NvimTreeGitDirty ") +--vim.api.nvim_command("highlight NvimTreeGitStaged ") +--vim.api.nvim_command("highlight NvimTreeGitMerge ") +--vim.api.nvim_command("highlight NvimTreeGitRenamed ") +--vim.api.nvim_command("highlight NvimTreeGitNew ") +--vim.api.nvim_command("highlight NvimTreeGitDeleted ") +--vim.api.nvim_command("highlight NvimTreeGitIgnored ") --(Comment) +--vim.api.nvim_command("highlight NvimTreeNormal ") +--vim.api.nvim_command("highlight NvimTreeEndOfBuffer ") --(NonText) +--vim.api.nvim_command("highlight NvimTreeCursorColumn ") --(CursorColumn) +--vim.api.nvim_command("highlight NvimTreeFileDirty ") --(NvimTreeGitDirty) +--vim.api.nvim_command("highlight NvimTreeFileStaged ") --(NvimTreeGitStaged) +--vim.api.nvim_command("highlight NvimTreeFileMerge ") --(NvimTreeGitMerge) +--vim.api.nvim_command("highlight NvimTreeFileRenamed ") --(NvimTreeGitRenamed) +--vim.api.nvim_command("highlight NvimTreeFileNew ") --(NvimTreeGitNew) +--vim.api.nvim_command("highlight NvimTreeFileDeleted ") --(NvimTreeGitDeleted) +--vim.api.nvim_command("highlight NvimTreeFileIgnored ") --(NvimTreeGitIgnored) +--vim.api.nvim_command("highlight NvimTreeLiveFilterPrefix ") +--vim.api.nvim_command("highlight NvimTreeLiveFilterValue ") +--vim.api.nvim_command("highlight NvimTreeBookmark ") diff --git a/.config/nvim/lua/plugins/overseer.lua b/.config/nvim/lua/plugins/overseer.lua new file mode 100644 index 0000000..6319d36 --- /dev/null +++ b/.config/nvim/lua/plugins/overseer.lua @@ -0,0 +1 @@ +require('overseer').setup() diff --git a/.config/nvim/lua/plugins/quickfix.lua b/.config/nvim/lua/plugins/quickfix.lua new file mode 100644 index 0000000..4a76da0 --- /dev/null +++ b/.config/nvim/lua/plugins/quickfix.lua @@ -0,0 +1,15 @@ +local M = {} + +M.close = function() + vim.cmd.cclose() +end + +M.open = function() + if vim.tbl_count(vim.fn.getqflist()) == 0 then + vim.notify('Nothing in quickfix list; not opening.', vim.log.levels.WARN) + else + vim.cmd.copen() + end +end + +return M diff --git a/.config/nvim/lua/plugins/session.lua b/.config/nvim/lua/plugins/session.lua new file mode 100644 index 0000000..0c84625 --- /dev/null +++ b/.config/nvim/lua/plugins/session.lua @@ -0,0 +1,5 @@ +require('auto-session').setup({ + log_level = 'error', + auto_session_suppress_dirs = { '~/', '~/projects', '~/downloads', '/' }, +}) +require('session-lens').setup({}) diff --git a/.config/nvim/lua/plugins/snippets.lua b/.config/nvim/lua/plugins/snippets.lua new file mode 100644 index 0000000..7df6b2f --- /dev/null +++ b/.config/nvim/lua/plugins/snippets.lua @@ -0,0 +1,68 @@ +local ls = require "luasnip" -- + +require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) +--local options = { +ls.config.set_config { + history = true, + updateevents = "TextChanged,TextChangedI", + -- Autosnippets: + enable_autosnippets = true, -- + region_check_events = "InsertEnter", + delete_check_events = "TextChanged", + update_events = "TextChanged,TextChangedI", + store_selection_keys = "<Tab>", + ext_opts = { -- + [require("luasnip.util.types").choiceNode] = { + active = { + virt_text = { { "«", "GruvboxOrange" } }, + }, + }, + }, +} + +--local keymap = vim.keymap +--local keymap = vim.api.nvim_set_keymap +local keymap = vim.keymap.set +--keymap('i', '<c-f>', 'luasnip#expand_or_jumpable() ? "<Plug>luasnip-expand-or-jump" : "<Tab>"', {expr = true, silent = true}) +keymap({ "i", "s"}, "<c-f>", function() + if ls.expand_or_jumpable() then + ls.expand() + end +end) + +keymap({ "i", "s"}, "<c-j>", function() + if ls.jumpable(1) then + ls.jump(1) + end +end) + +keymap({ "i", "s"}, "<c-k>", function() + if ls.jumpable(-1) then + ls.jump(-1) + end +end) + +keymap({ "i", "s"}, "<c-c>", function() + if ls.choice_active() then + ls.change_choice(1) + end +end) + +keymap({ "i", "s"}, "<a-c>", function() + if ls.choice_active() then + ls.change_choice(-1) + end +end) + +-- Character class Matching +-- %a letters (A-Z, a-z) +-- %c control characters (\n, \t, \r, ...) +-- %d digits (0-9) +-- %l lower-case letter (a-z) +-- %p punctuation characters (!, ?, &, ...) +-- %s space characters +-- %u upper-case letters +-- %w alphanumeric characters (A-Z, a-z, 0-9) +-- %x hexadecimal digits (\3, \4, ...) +-- %z the character with representation 0 +-- . Matches any character diff --git a/.config/nvim/lua/plugins/sniprun.lua b/.config/nvim/lua/plugins/sniprun.lua new file mode 100644 index 0000000..418e8cc --- /dev/null +++ b/.config/nvim/lua/plugins/sniprun.lua @@ -0,0 +1,57 @@ +local status_ok, sniprun = pcall(require, 'sniprun') +if not status_ok then + return +end + +sniprun.setup({ + -- selected_interpreters = {}, --# use those instead of the default for the current filetype + -- repl_enable = { "Python3_original" }, --# enable REPL-like behavior for the given interpreters + -- repl_disable = {}, --# disable REPL-like behavior for the given interpreters + + -- interpreter_options = { --# intepreter-specific options, see docs / :SnipInfo <name> + -- GFM_original = { + -- use_on_filetypes = { "markdown.pandoc" }, --# the 'use_on_filetypes' configuration key is + -- --# available for every interpreter + -- }, + -- }, + + --# you can combo different display modes as desired + display = { + -- "Classic", --# display results in the command-line area + --'VirtualTextOk', --# display ok results as virtual text (multiline is shortened) + -- "VirtualTextErr", --# display error results as virtual text + -- "TempFloatingWindow", --# display results in a floating window + -- "LongTempFloatingWindow", --# same as above, but only long results. To use with VirtualText__ + 'Terminal', --# display results in a vertical split + -- "TerminalWithCode", --# display results and code history in a vertical split + -- "NvimNotify", --# display with the nvim-notify plugin + -- "Api" --# return output to a programming interface + }, + + display_options = { + terminal_width = 45, --# change the terminal display option width + notification_timeout = 5, --# timeout for nvim_notify output + }, + + --# You can use the same keys to customize whether a sniprun producing + --# no output should display nothing or '(no output)' + show_no_output = { + 'Classic', + 'TempFloatingWindow', --# implies LongTempFloatingWindow, which has no effect on its own + }, + + --# customize highlight groups (setting this overrides colorscheme) + -- snipruncolors = { + -- SniprunVirtualTextOk = { bg = "NONE", fg = "#66eeff", ctermbg = "Black", cterfg = "Cyan" }, + -- SniprunFloatingWinOk = { fg = "NONE", ctermfg = "Cyan" }, + -- SniprunVirtualTextErr = { bg = "#881515", fg = "#000000", ctermbg = "DarkRed", cterfg = "Black" }, + -- SniprunFloatingWinErr = { fg = "#881515", ctermfg = "DarkRed" }, + -- }, + + --# miscellaneous compatibility/adjustement settings + inline_messages = 0, --# inline_message (0/1) is a one-line way to display messages + --# to workaround sniprun not being able to display anything + + borders = 'single', --# display borders around floating windows + --# possible values are 'none', 'single', 'double', or 'shadow' +}) diff --git a/.config/nvim/lua/plugins/statuscol.lua b/.config/nvim/lua/plugins/statuscol.lua new file mode 100644 index 0000000..24a2308 --- /dev/null +++ b/.config/nvim/lua/plugins/statuscol.lua @@ -0,0 +1,28 @@ +local status, statuscol = pcall(require, "statuscol") + +if not status then + vim.notify("statuscol not found") + return +end + +local builtin = require("statuscol.builtin") + +statuscol.setup({ + segments = { + { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, + { text = { "%s" }, click = "v:lua.ScSa" }, + { text = { builtin.foldfunc }, click = "v:lua.ScFa" }, + }, + ft_ignore = { + "NvimTree", + "packer", + "NeogitStatus", + "toggleterm", + "dapui_scopes", + "dapui_breakpoints", + "dapui_stacks", + "dapui_watches", + "dapui_console", + "dapui_repl", + }, +}) diff --git a/.config/nvim/lua/plugins/telescope.lua b/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..481cb7d --- /dev/null +++ b/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,618 @@ +local M = {} + +-- Shorten function names +local actions = require('telescope.actions') +local fb_actions = require('telescope').extensions.file_browser.actions +--local builtin = require("telescope.builtin") +--local utils = require("telescope.utils") +--local layout_actions = require("telescope.actions.layout") +--local themes = require('telescope.themes') +local actions_set = require('telescope.actions.set') +local actions_state = require('telescope.actions.state') +local finders = require('telescope.finders') +local pickers = require('telescope.pickers') +local config = require('telescope.config').values + +require('telescope').setup({ + defaults = { + vimgrep_arguments = { + 'rg', + '--color=never', + '--no-heading', + '--with-filename', + '--line-number', + '--column', + '--smart-case', + '--hidden', + '--fixed-strings', + '--trim', + }, + prompt_prefix = ' ', + selection_caret = ' ', + entry_prefix = ' ', + path_display = { 'tail' }, + --path_display = { "truncate" }, + --path_display = { "smart" }, + file_ignore_patterns = { + 'packer_compiled.lua', + '~/.config/zsh/plugins', + 'zcompdump', + '%.DS_Store', + '%.git/', + '%.spl', + --"%.log", + '%[No Name%]', -- new files / sometimes folders (netrw) + '/$', -- ignore folders (netrw) + 'node_modules', + '%.png', + '%.zip', + '%.pxd', + --"^.vim/", + '^.local/', + '^.cache/', + '^downloads/', + '^music/', + --"^node_modules/", + --"^undodir/", + }, + 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, + ['<Esc>'] = actions.close, -- close w/ one esc + --["<Esc>"] = "close", -- close w/ one esc + ['<?>'] = actions.which_key, -- keys from pressing <C-/> + + ['<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-/> + --["<C-o>"] = 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, + }, + n = { + --["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, + ['<esc>'] = actions.close, + ['<q>'] = actions.close, + ['<CR>'] = actions.select_default, + ['<C-x>'] = actions.select_horizontal, + ['<C-y>'] = 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, + ['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, + ['?'] = actions.which_key, + --["<C-o>"] = 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, + }, + }, + }, + preview = { + filesize_limit = 3, + timeout = 250, + }, + selection_strategy = 'reset', + sorting_strategy = 'ascending', + scroll_strategy = 'limit', + color_devicons = true, + layout_strategy = 'horizontal', + layout_config = { + horizontal = { + height = 0.95, + preview_cutoff = 70, + width = 0.92, + preview_width = { 0.55, max = 50 }, + }, + bottom_pane = { + height = 12, + preview_cutoff = 70, + prompt_position = 'bottom', + }, + }, + find_files = { + --cwd = '%:p:h', + cwd = vim.fn.getcwd(), + prompt_prefix = ' ', + --hidden = true, + --no_ignore = false, + follow = true, + }, + --pickers = { + -- live_grep = { + -- disable_coordinates = true, + -- layout_config = { + -- horizontal = { + -- preview_width = 0.55, + -- }, + -- }, + -- }, + --}, + --pickers = { + -- live_grep = { + -- mappings = { + -- i = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- n = { + -- ["<C-f>"] = ts_select_dir_for_grep, + -- }, + -- }, + -- }, + --}, + --pickers = { + --lsp_references = { + -- prompt_prefix='⬅️', + -- show_line=false, + -- trim_text=true, + -- include_declaration=false, + -- initial_mode = "normal", + --}, + --lsp_definitions = { + -- prompt_prefix='➡️', + -- show_line=false, + -- trim_text=true, + -- initial_mode = "normal", + --}, + --lsp_document_symbols = { + -- prompt_prefix='* ', + -- show_line = false, + --}, + --treesitter = { + -- prompt_prefix=' ', + -- show_line = false, + --}, + --keymaps = { prompt_prefix='? ' }, + --oldfiles = { prompt_prefix=' ' }, + --highlights = { prompt_prefix=' ' }, + --git_files = { + -- prompt_prefix=' ', + -- show_untracked = true, + -- path_display = { "tail" }, + --}, + --buffers = { + -- prompt_prefix=' ', + -- ignore_current_buffer = true, + -- initial_mode = "normal", + -- sort_mru = true, + --}, + --live_grep = { + -- cwd='%:p:h', + -- disable_coordinates=true, + -- prompt_title='Search in Folder', + -- prompt_prefix=' ', + --}, + --spell_suggest = { + -- initial_mode = "normal", + -- prompt_prefix = "暈", + -- theme = "cursor", + -- layout_config = { cursor = { width = 0.3 } } + --}, + --colorscheme = { + -- enable_preview = true, + -- prompt_prefix = '', + -- results_title = '', + -- layout_strategy = "bottom_pane", + --}, + --}, + + extensions = { + file_browser = { + theme = 'dropdown', + -- disables netrw and use telescope-file-browser in its place + hijack_netrw = false, + mappings = { + -- your custom insert mode mappings + ['i'] = { + ['<C-w>'] = function() + vim.cmd('normal vbd') + end, + ['<C-h>'] = fb_actions.goto_parent_dir, + }, + ['n'] = { + -- your custom normal mode mappings + ['N'] = fb_actions.create, + ['<C-h>'] = fb_actions.goto_parent_dir, + --["/"] = function() + -- vim.cmd("startinsert") + --end, + }, + }, + }, + }, +}) + +-------------------------------------------------------------------------------- + +-- Load extensions: +-- have to be loaded after telescope setup/config +require('telescope').load_extension('fzf') +require('telescope').load_extension('ui-select') +require('telescope').load_extension('file_browser') +require('telescope').load_extension('changed_files') +require('telescope').load_extension('media_files') +require('telescope').load_extension('notify') +require('telescope').load_extension('dap') +require('telescope').load_extension('session-lens') +require('telescope').load_extension('flutter') +require('telescope').load_extension('recent_files') +--require('telescope').load_extension('projects') + +--M.curbuf = function(opts) +-- opts = opts +-- or themes.get_dropdown({ +-- previewer = false, +-- shorten_path = false, +-- border = true, +-- }) +-- require("telescope.builtin").current_buffer_fuzzy_find(opts) +--end + +function M.find_configs() + -- Track dotfiles (bare git repository) + -- Inside shell config file: + -- alias config='git --git-dir=$HOME/.cfg --work-tree=$HOME' + -- cfg_files=$(config ls-tree --name-only -r HEAD) + -- export CFG_FILES="$cfg_files" + local tracked_files = {} + + for file in string.gmatch(os.getenv('CFG_FILES'), '[^\n]+') do + table.insert(tracked_files, os.getenv('HOME') .. '/' .. file) + end + + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Configs', + results_title = 'Config Files', + path_display = { 'smart' }, + search_dirs = tracked_files, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_scripts() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = true, + prompt_title = ' Find Scripts', + path_display = { 'smart' }, + search_dirs = { + '~/.scripts', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_projects() + local search_dir = '~/projects' + pickers + .new({}, { + prompt_title = 'Find Projects', + finder = finders.new_oneshot_job({ + 'find', + vim.fn.expand(search_dir), + '-type', + 'd', + '-maxdepth', + '1', + }), + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local dir = entry.value + actions.close(prompt_bufnr, false) + vim.fn.chdir(dir) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() +end + +function M.grep_notes() + local opts = {} + opts.hidden = false + opts.search_dirs = { + '~/documents/notes/', + } + opts.prompt_prefix = ' ' + opts.prompt_title = ' Grep Notes' + opts.path_display = { 'smart' } + require('telescope.builtin').live_grep(opts) +end + +function M.find_notes() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Notes', + path_display = { 'smart' }, + search_dirs = { + '~/documents/notes/private/', + '~/documents/notes', + '~/notes/private', + '~/notes', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) +end + +function M.find_books() + local search_dir = '~/documents/books' + vim.fn.jobstart('$HOME/.scripts/track-books.sh') + local recent_books_directory = vim.fn.stdpath('config') .. '/tmp/' + local recent_books_file = recent_books_directory .. 'recent_books.txt' + local search_cmd = 'find ' .. vim.fn.expand(search_dir) .. ' -type d -o -type f -maxdepth 1' + + local recent_books = vim.fn.readfile(recent_books_file) + local search_results = vim.fn.systemlist(search_cmd) + + local results = {} + + -- Section for Recent Books + table.insert(results, ' Recent Books') + for _, recent_book_path in ipairs(recent_books) do + local formatted_path = vim.fn.fnameescape(recent_book_path) + table.insert(results, formatted_path) + end + + -- Section for All Books + table.insert(results, ' All Books') + local directories = {} + local files = {} + + for _, search_result in ipairs(search_results) do + if vim.fn.isdirectory(search_result) == 1 then + table.insert(directories, search_result) + else + table.insert(files, search_result) + end + end + + table.sort(directories) + table.sort(files) + + for _, dir in ipairs(directories) do + table.insert(results, dir) + end + + for _, file in ipairs(files) do + table.insert(results, file) + end + + local picker = pickers.new({}, { + prompt_title = 'Find Books', + finder = finders.new_table({ + results = results, + }), + file_ignore_patterns = { + '%.git', + }, + previewer = require('telescope.previewers').vim_buffer_cat.new({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local path = entry.value + + actions.close(prompt_bufnr, false) + + -- Check if it's under "Recent Books" + if path == ' Recent Books' or path == ' All Books' then + vim.notify("Cannot select 'All Books'/'Recent Books', please select a book or directory.", vim.log.levels.WARN, { title = 'Find Books' }) + else + -- Determine whether it's a directory or a file + local is_directory = vim.fn.isdirectory(path) + if is_directory then + -- It's a directory, navigate to it in the current buffer + vim.cmd('e ' .. path) + else + -- It's a file, open it + vim.cmd('e ' .. path) + end + end + end + end) + return true + end, + }) + + picker:find() +end + +function M.grep_current_dir() + local buffer_dir = require('telescope.utils').buffer_dir() + local opts = { + prompt_title = 'Live Grep in ' .. buffer_dir, + cwd = buffer_dir, + } + require('telescope.builtin').live_grep(opts) +end + +-------------------------------------------------------------------------------- + +local dropdown = require('telescope.themes').get_dropdown({ + hidden = true, + no_ignore = true, + previewer = false, + prompt_title = '', + preview_title = '', + results_title = '', + layout_config = { + --anchor = "S", + prompt_position = 'top', + }, +}) + +-- File browser always relative to buffer +--local opts_file_browser = vim.tbl_extend('force', dropdown, { +-- path_display = { '%:p:h' }, +--}) + +-- Set current folder as prompt title +local with_title = function(opts, extra) + extra = extra or {} + local path = opts.cwd or opts.path or extra.cwd or extra.path or nil + local title = '' + local buf_path = vim.fn.expand('%:p:h') + local cwd = vim.fn.getcwd() + if path ~= nil and buf_path ~= cwd then + title = require('plenary.path'):new(buf_path):make_relative(cwd) + else + title = vim.fn.fnamemodify(cwd, ':t') + end + + return vim.tbl_extend('force', opts, { + prompt_title = title, + }, extra or {}) +end + +-- Find here +function M.findhere() + -- Open file browser if argument is a folder + local arg = vim.api.nvim_eval('argv(0)') + if arg and (vim.fn.isdirectory(arg) ~= 0 or arg == '') then + vim.defer_fn(function() + require('telescope.builtin').find_files(with_title(dropdown)) + -- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ + -- hidden = true, + -- results_title = '', + -- layout_config = { prompt_position = 'top' }, + -- })) + end, 10) + end +end + +-- Define the custom command findhere/startup +vim.cmd('command! Findhere lua require("plugins.telescope").findhere()') +--vim.cmd('command! Startup lua require("plugins.telescope").findhere()') +--vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') + +-- Find dirs +function M.find_dirs() + local root_dir = vim.fn.input('Enter the root directory: ') + + -- Check if root_dir is empty + if root_dir == '' then + print('No directory entered. Aborting.') + return + end + + local entries = {} + + -- Use vim.fn.expand() to get an absolute path + local root_path = vim.fn.expand(root_dir) + + local subentries = vim.fn.readdir(root_path) + if subentries then + for _, subentry in ipairs(subentries) do + local absolute_path = root_path .. '/' .. subentry + table.insert(entries, subentry) + end + end + + pickers + .new({}, { + prompt_title = 'Change Directory or Open File', + finder = finders.new_table({ + results = entries, + }), + previewer = config.file_previewer({}), + sorter = config.generic_sorter({}), + attach_mappings = function(prompt_bufnr, map) + actions_set.select:replace(function() + local entry = actions_state.get_selected_entry() + if entry ~= nil then + local selected_entry = entry.value + actions.close(prompt_bufnr, false) + local selected_path = root_path .. '/' .. selected_entry + if vim.fn.isdirectory(selected_path) == 1 then + vim.fn.chdir(selected_path) + vim.cmd('e .') + print('cwd: ' .. vim.fn.getcwd()) + else + vim.cmd('e ' .. selected_path) + end + end + end) + return true + end, + }) + :find() +end + +return M diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..e67bdec --- /dev/null +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -0,0 +1,179 @@ +local status_ok, toggleterm = pcall(require, 'toggleterm') +if not status_ok then + return +end +toggleterm.setup({ + --open_mapping = [[<leader>tt]], + autochdir = true, + hide_numbers = true, + shade_filetypes = {}, + shade_terminals = false, + --shading_factor = 1, + start_in_insert = true, + insert_mappings = true, + terminal_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", + --}, + --Normal = { guibg = 'Black', guifg = 'White' }, + --FloatBorder = { guibg = 'Black', guifg = 'DarkGray' }, + --NormalFloat = { guibg = 'Black' }, + float_opts = { + --winblend = 3, + }, + }, + size = function(term) + if term.direction == 'horizontal' then + return 7 + elseif term.direction == 'vertical' then + return math.floor(vim.o.columns * 0.4) + end + end, + float_opts = { + width = 70, + height = 15, + border = 'curved', + highlights = { + border = 'Normal', + --background = 'Normal', + }, + --winblend = 0, + }, +}) +local mods = require('user.mods') +local float_handler = function(term) + if not mods.empty(vim.fn.mapcheck('jk', 't')) then + vim.keymap.del('t', 'jk', { buffer = term.bufnr }) + vim.keymap.del('t', '<esc>', { buffer = term.bufnr }) + end +end + +function _G.set_terminal_keymaps() + local opts = { noremap = true } + --local opts = {buffer = 0} + --vim.api.nvim_buf_set_keymap(0, "i", ";to", "[[<Esc>]]<cmd>Toggleterm", opts) + vim.api.nvim_buf_set_keymap(0, 't', '<C-c>', [[<Esc>]], opts) + vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts) + vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<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 + +-- if you only want these mappings for toggle term use term://*toggleterm#* instead +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') +local Terminal = require('toggleterm.terminal').Terminal + +local horizontal_term = Terminal:new({ hidden = true, direction = 'horizontal' }) +local vertical_term = Terminal:new({ hidden = true, direction = 'vertical' }) + +function Horizontal_term_toggle() + horizontal_term:toggle(8, 'horizontal') +end + +function Vertical_term_toggle() + horizontal_term:toggle(math.floor(vim.o.columns * 0.5), 'vertical') +end + +local lazygit = Terminal:new({ + cmd = 'lazygit', + count = 5, + id = 1000, + dir = 'git_dir', + direction = 'float', + on_open = float_handler, + hidden = true, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40, + }, + + ---- Function to run on opening the terminal + --on_open = function(term) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', 'q', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<esc>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + -- vim.api.nvim_buf_set_keymap(term.bufnr, 'n', '<C-\\>', '<cmd>close<CR>', + -- {noremap = true, silent = true}) + --end, + ---- Function to run on closing the terminal + --on_close = function(term) + -- vim.cmd("startinsert!") + --end +}) + +function Lazygit_toggle() + -- cwd is the root of project. if cwd is changed, change the git. + local cwd = vim.fn.getcwd() + if cwd ~= Cur_cwd then + Cur_cwd = cwd + lazygit:close() + lazygit = Terminal:new({ + cmd = "zsh --login -c 'lazygit'", + dir = 'git_dir', + direction = 'float', + hidden = true, + on_open = float_handler, + float_opts = { + border = { '╒', '═', '╕', '│', '╛', '═', '╘', '│' }, + width = 150, + height = 40, + }, + }) + end + 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 + +function Gh_dash() + Terminal:new({ + cmd = 'gh dash', + hidden = true, + direction = 'float', + on_open = float_handler, + float_opts = { + height = function() + return math.floor(vim.o.lines * 0.8) + end, + width = function() + return math.floor(vim.o.columns * 0.95) + end, + }, + }) + Gh_dash:toggle() +end diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..7f481d3 --- /dev/null +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,31 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the four listed parsers should always be installed) + + 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 + sync_install = false, + auto_install = true, + highlight = { + enable = false, + disable = {}, + }, + indent = { + enable = true, + disable = {}, + --disable = { "python", "css" } + }, + autotag = { + 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/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua new file mode 100644 index 0000000..7d74730 --- /dev/null +++ b/.config/nvim/lua/plugins/trouble.lua @@ -0,0 +1,47 @@ +require('trouble').setup({ + position = 'bottom', -- position of the list can be: bottom, top, left, right + height = 10, -- height of the trouble list when position is top or bottom + width = 50, -- width of the list when position is left or right + icons = true, -- use devicons for filenames + mode = 'document_diagnostics', -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" + fold_open = '', -- icon used for open folds + fold_closed = '', -- icon used for closed folds + group = true, -- group results by file + padding = true, -- add an extra new line on top of the list + action_keys = { -- key mappings for actions in the trouble list + -- map to {} to remove a mapping, for example: + -- close = {}, + close = 'q', -- close the list + cancel = '<esc>', -- cancel the preview and get back to your last window / buffer / cursor + refresh = 'r', -- manually refresh + jump = { '<cr>', '<tab>' }, -- jump to the diagnostic or open / close folds + open_split = { '<c-x>' }, -- open buffer in new split + open_vsplit = { '<c-v>' }, -- open buffer in new vsplit + open_tab = { '<c-t>' }, -- open buffer in new tab + jump_close = { 'o' }, -- jump to the diagnostic and close the list + toggle_mode = 'm', -- toggle between "workspace" and "document" diagnostics mode + toggle_preview = 'P', -- toggle auto_preview + hover = 'K', -- opens a small popup with the full multiline message + preview = 'p', -- preview the diagnostic location + close_folds = { 'zM', 'zm' }, -- close all folds + open_folds = { 'zR', 'zr' }, -- open all folds + toggle_fold = { 'zA', 'za' }, -- toggle fold of current file + previous = 'k', -- previous item + next = 'j', -- next item + }, + indent_lines = true, -- add an indent guide below the fold icons + auto_open = false, -- automatically open the list when you have diagnostics + auto_close = false, -- automatically close the list when you have no diagnostics + auto_preview = true, -- automatically preview the location of the diagnostic. <esc> to close preview and go back to last window + auto_fold = false, -- automatically fold a file trouble list at creation + auto_jump = { 'lsp_definitions' }, -- for the given modes, automatically jump if there is only a single result + signs = { + -- icons / text used for a diagnostic + error = '', + warning = '▲', + information = '', + hint = '⚑', + other = '', + }, + use_diagnostic_signs = true, -- enabling this will use the signs defined in your lsp client +}) diff --git a/.config/nvim/lua/plugins/web-devicons.lua b/.config/nvim/lua/plugins/web-devicons.lua new file mode 100644 index 0000000..06f2d1c --- /dev/null +++ b/.config/nvim/lua/plugins/web-devicons.lua @@ -0,0 +1,22 @@ +local devicons = require('nvim-web-devicons') + +-- Set devicons overrides early. +devicons.setup({ + override = { + js = { icon = '', color = '#f5c06f', name = 'Js' }, + jsx = { icon = '', color = '#689fb6', name = 'Jsx' }, + ts = { icon = '', color = '#4377c1', name = 'Ts' }, + tsx = { icon = '', color = '#4377c1', name = 'Tsx' }, + png = { icon = '', color = '#d4843e', name = 'Png' }, + webp = { icon = '', color = '#3498db', name = 'Webp' }, + jpg = { icon = '', color = '#16a085', name = 'Jpg' }, + svg = { icon = '', color = '#3affdb', name = 'Svg' }, + zsh = { + icon = '', + color = '#428850', + cterm_color = '65', + name = 'Zsh', + }, + }, + color_icons = true, +}) diff --git a/.config/nvim/lua/plugins/which-key.lua b/.config/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..10c0c41 --- /dev/null +++ b/.config/nvim/lua/plugins/which-key.lua @@ -0,0 +1,60 @@ +require("which-key").setup { + plugins = { + marks = true, -- shows a list of your marks on ' and ` + registers = true, -- shows your registers on " in NORMAL or <C-r> in INSERT mode + spelling = { + enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions + suggestions = 9, -- how many suggestions should be shown in the list? + }, + -- the presets plugin, adds help for a bunch of default keybindings in Neovim + -- No actual key bindings are created + presets = { + operators = true, -- adds help for operators like d, y, ... and registers them for motion / text object completion + motions = true, -- adds help for motions + text_objects = true, -- help for text objects triggered after entering an operator + windows = true, -- default bindings on <c-w> + nav = true, -- misc bindings to work with windows + z = true, -- bindings for folds, spelling and others prefixed with z + g = true, -- bindings for prefixed with g + }, + }, + -- add operators that will trigger motion and text object completion + -- to enable all native operators, set the preset / operators plugin above + operators = { gc = "Comments" }, + key_labels = { + -- override the label used to display some keys. It doesn't effect WK in any other way. + -- For example: + -- ["<space>"] = "SPC", + -- ["<cr>"] = "RET", + -- ["<tab>"] = "TAB", + }, + icons = { + breadcrumb = "»", -- symbol used in the command line area that shows your active key combo + separator = "➜", -- symbol used between a key and it's label + group = "+", -- symbol prepended to a group + }, + window = { + border = "none", -- none, single, double, shadow + position = "bottom", -- bottom, top + margin = { 0, 0, 0, 0 }, -- extra window margin [top, right, bottom, left] + padding = { 1, 0, 1, 0 }, -- extra window padding [top, right, bottom, left] + }, + layout = { + height = { min = 1, max = 25 }, -- min and max height of the columns + width = { min = 20, max = 50 }, -- min and max width of the columns + spacing = 1, -- spacing between columns + align = "center", -- align columns left, center or right + }, + ignore_missing = false, -- enable this to hide mappings for which you didn't specify a label + hidden = { "<silent>", "<cmd>", "<Cmd>", "<CR>", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate + show_help = true, -- show help message on the command line when the popup is visible + triggers = "auto", -- automatically setup triggers + -- triggers = {"<leader>"} -- or specify a list manually + + triggers_blacklist = { + -- list of mode / prefixes that should never be hooked by WhichKey + -- this is mostly relevant for key maps that start with a native binding + -- most people should not need to change this + n = { "o", "O" }, + }, +} diff --git a/.config/nvim/lua/plugins/zen-mode.lua b/.config/nvim/lua/plugins/zen-mode.lua new file mode 100644 index 0000000..7e52854 --- /dev/null +++ b/.config/nvim/lua/plugins/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 }) |
