diff options
Diffstat (limited to '.config/nvim/lua/plugins')
| -rw-r--r-- | .config/nvim/lua/plugins/colorscheme.lua | 44 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/dashboard.lua | 128 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/heirline.lua | 535 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/loclist.lua | 18 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 822 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-tree.lua | 430 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/quickfix.lua | 15 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/session.lua | 5 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/sniprun.lua | 57 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/telescope.lua | 513 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/trouble.lua | 88 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/web-devicons.lua | 33 |
12 files changed, 1524 insertions, 1164 deletions
diff --git a/.config/nvim/lua/plugins/colorscheme.lua b/.config/nvim/lua/plugins/colorscheme.lua index 14edbdf..be78ac8 100644 --- a/.config/nvim/lua/plugins/colorscheme.lua +++ b/.config/nvim/lua/plugins/colorscheme.lua @@ -1,19 +1,3 @@ --- Colorscheme --- Available colorschemes: --- [[ nightfly ayu onedark doom-one nvimgelion github_dark tokyonight ]] - --- Define default color scheme -local default_colorscheme = "tokyonight-night" -local fallback_colorscheme = "desert" - --- Attempt to set the default color scheme -local status_ok, _ = pcall(vim.cmd, "colorscheme " .. default_colorscheme) - --- If the default color scheme is not found, use the fallback color scheme -if not status_ok then - vim.cmd("colorscheme " .. fallback_colorscheme) -end - --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') @@ -30,20 +14,6 @@ end -- --setupMyColors() - -vim.api.nvim_command("syntax on") -vim.api.nvim_command("highlight Normal guibg=NONE") -vim.api.nvim_command("highlight NormalNC guibg=none") -vim.api.nvim_command("highlight SignColumn guibg=none") ---vim.api.nvim_command("highlight FoldColumn guibg=none") ---vim.api.nvim_command("highlight CursorLineSign guibg=none ctermbg=NONE") -vim.api.nvim_command("highlight TabLine guibg=#333842 gui=bold") -vim.api.nvim_command("highlight Title guibg=none gui=bold") -vim.api.nvim_command("highlight TabLineSel guibg=#333842 gui=bold") -vim.api.nvim_command("highlight TabLineFill guibg=none gui=bold") -vim.api.nvim_command("highlight WinBar guibg=none gui=bold") -vim.api.nvim_command("highlight NormalFloat guibg=none") -vim.api.nvim_command("highlight LineNr guibg=none") --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") @@ -52,20 +22,6 @@ vim.api.nvim_command("highlight LineNr guibg=none") --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") -vim.api.nvim_command("highlight WinSeparator guibg=none gui=bold") -vim.api.nvim_command("highlight MsgSeparator guibg=none") -vim.api.nvim_command("highlight PmenuSel guibg=none") -vim.api.nvim_command("highlight winblend guibg=none") -vim.api.nvim_command("highlight EndOfBuffer guibg=NONE guifg=Normal") --- Set different window separator colorscheme -vim.cmd [[ -au WinEnter * setl winhl=WinSeparator:WinSeparatorA -au WinLeave * setl winhl=WinSeparator:WinSeparator -]] - -require("notify").setup({ - background_colour = "#000000", -}) -- Custom colorscheme --vim.cmd([[ diff --git a/.config/nvim/lua/plugins/dashboard.lua b/.config/nvim/lua/plugins/dashboard.lua index b288f46..a78332b 100644 --- a/.config/nvim/lua/plugins/dashboard.lua +++ b/.config/nvim/lua/plugins/dashboard.lua @@ -1,4 +1,5 @@ -local db = require("dashboard") +local db = require('dashboard') + --vim.api.nvim_create_autocmd("VimEnter", { -- callback = function() -- -- disable line numbers @@ -7,69 +8,74 @@ local db = require("dashboard") -- -- always start in insert mode -- end, --}) + db.setup({ - theme = "hyper", - config = { - header = { - [[ ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗]], - [[ ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║]], - [[ ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║]], - [[ ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║]], - [[ ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║]], - [[ ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝]], - }, + 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", - }, - { + 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", + group = 'Number', + --group = "Label", action = ':edit ~/.config.nvim/init.lua', - key = "c", - }, - }, - }, - hide = { - statusline = false, - tabline = false, - winbar = false, - }, - -- preview = { --- command, -- preview command --- file_path, -- preview file path --- file_height, -- preview file height --- file_width, -- preview file width --- }, --- footer = {} --your footer + 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/heirline.lua b/.config/nvim/lua/plugins/heirline.lua index 5c3eb44..46e0ccc 100644 --- a/.config/nvim/lua/plugins/heirline.lua +++ b/.config/nvim/lua/plugins/heirline.lua @@ -1,44 +1,45 @@ -local conditions = require("heirline.conditions") -local utils = require("heirline.utils") +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", + 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, + warn = utils.get_highlight('DiagnosticSignWarn').fg, + error = utils.get_highlight('DiagnosticSignError').fg, + hint = utils.get_highlight('DiagnosticSignHint').fg, + info = utils.get_highlight('DiagnosticSignInfo').fg, }, git = { - del = "#e95678", - add = "#a6e22e", - change = "#ae81ff", + active = '#f34f29', + del = '#ff5555', + add = '#50fa7b', + change = '#ae81ff', }, } -require("heirline").load_colors(colors) +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 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) @@ -50,100 +51,104 @@ local ViMode = { 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", + 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] .. "%) " + return ' %2(' .. self.mode_names[self.mode] .. '%) ' + end, + hl = function(self) + return { fg = 'darkgray', bg = self.mode_color, bold = true } end, - hl = function(self) return { fg = "darkgray", bg = self.mode_color, bold = true } end, update = { - "ModeChanged", + 'ModeChanged', }, } -- LSP local LSPActive = { condition = conditions.lsp_attached, - update = { "LspAttach", "LspDetach" }, + 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 + if client.name ~= 'null-ls' then table.insert(buf_client_names, client.name) end end - return "⚙️ " .. table.concat(buf_client_names, "") + return '⚙️ ' .. table.concat(buf_client_names, '') end, hl = { fg = colors.lightgray, bold = false }, } local Navic = { - condition = function() return require("nvim-navic").is_available() end, + 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", + 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) @@ -155,10 +160,10 @@ local Navic = { local col = bit.band(bit.rshift(c, 6), 1023) local winnr = bit.band(c, 63) return line, col, winnr - end + end, }, init = function(self) - local data = require("nvim-navic").get_data() or {} + local data = require('nvim-navic').get_data() or {} local children = {} -- create a child for each level for i, d in ipairs(data) do @@ -171,7 +176,7 @@ local Navic = { }, { -- escape `%`s (elixir) and buggy default separators - provider = d.name:gsub("%%", "%%%%"):gsub("%s*->%s*", ''), + provider = d.name:gsub('%%', '%%%%'):gsub('%s*->%s*', ''), -- highlight icon only or location name as well -- hl = self.type_hl[d.type], @@ -183,14 +188,14 @@ local Navic = { local line, col, winnr = self.dec(minwid) vim.api.nvim_win_set_cursor(vim.fn.win_getid(winnr), { line, col }) end, - name = "heirline_navic", + name = 'heirline_navic', }, }, } -- add a separator only if needed if #data > 1 and i < #data then table.insert(child, { - provider = " > ", + provider = ' > ', hl = { fg = 'bright_fg' }, }) end @@ -203,18 +208,18 @@ local Navic = { provider = function(self) return self.child:eval() end, - hl = { fg = "gray" }, - update = 'CursorMoved' + 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, + 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 }) @@ -222,23 +227,23 @@ local Diagnostics = { 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" }, + 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 .. " ") + 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 .. " ") + 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 .. " ") + return self.info > 0 and (self.info_icon .. self.info .. ' ') end, hl = { fg = colors.diag.info, bg = colors.bg }, }, @@ -250,11 +255,11 @@ local Diagnostics = { }, on_click = { callback = function() - require("trouble").toggle({ mode = "document_diagnostics" }) + require('trouble').toggle({ mode = 'document_diagnostics' }) -- or -- vim.diagnostic.setqflist() end, - name = "heirline_diagnostics", + name = 'heirline_diagnostics', }, } @@ -266,29 +271,44 @@ local Git = { self.status_dict = vim.b.gitsigns_status_dict self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0 end, - --hl = { fg = "orange" }, - hl = { fg = colors.orange, bg = colors.bg }, + --{ + -- -- git branch name + -- provider = function(self) + -- --return ' ' .. self.status_dict.head + -- 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 + return self.status_dict.head end, - --hl = { bold = true }, - hl = { bold = true, bg = colors.bg }, + hl = { fg = colors.white, bg = colors.bg }, }, - -- You could handle delimiters, icons and counts similar to Diagnostics + { condition = function(self) return self.has_changes end, --provider = "(" - provider = " ", + provider = '', }, { provider = function(self) local count = self.status_dict.added or 0 --return count > 0 and ("+" .. count) - return count > 0 and (" " .. count) + return count > 0 and (' ' .. count) end, --hl = { fg = "git_add" }, hl = { fg = colors.git.add, bg = colors.bg }, @@ -297,7 +317,7 @@ local Git = { provider = function(self) local count = self.status_dict.removed or 0 --return count > 0 and ("-" .. count) - return count > 0 and (" " .. count) + return count > 0 and (' ' .. count) end, --hl = { fg = "git_del" }, hl = { fg = colors.git.del, bg = colors.bg }, @@ -306,7 +326,7 @@ local Git = { provider = function(self) local count = self.status_dict.changed or 0 --return count > 0 and ("~" .. count) - return count > 0 and (" 柳" .. count) + return count > 0 and (' ' .. count) end, --hl = { fg = "git_change" }, hl = { fg = colors.git.change, bg = colors.bg }, @@ -327,10 +347,10 @@ local Git = { -- opening of a floating window -- (this also applies to telescope) vim.defer_fn(function() - vim.cmd("Lazygit") + vim.cmd('Lazygit') end, 100) end, - name = "heirline_git", + name = 'heirline_git', }, } @@ -455,12 +475,11 @@ local FileNameBlock = { 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 }) + 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 .. " ") + return self.icon and (self.icon .. ' ') end, hl = function(self) return { fg = self.icon_color, bg = colors.bg } @@ -471,9 +490,9 @@ 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" + 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 @@ -491,7 +510,7 @@ local FileFlags = { { provider = function() if vim.bo.modified then - return " [+]" -- ±[+] + return ' [+]' -- ±[+] end end, hl = { fg = colors.green, bg = colors.bg }, @@ -499,7 +518,7 @@ local FileFlags = { { provider = function() if not vim.bo.modifiable or vim.bo.readonly then - return " " + return ' ' end end, --hl = { fg = colors.orange }, @@ -526,7 +545,7 @@ local FileType = { local FileEncoding = { Space, provider = function() - local enc = (vim.bo.fenc ~= "" and vim.bo.fenc) or vim.o.enc -- :h 'enc' + 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 }, @@ -537,34 +556,34 @@ local FileFormat = { provider = function() local fmt = vim.bo.fileformat --return fmt ~= "unix" and fmt:upper() - return fmt ~= "unix" and fmt:lower() + return fmt ~= 'unix' and fmt:lower() end, - hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + 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 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]) + 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 }, + 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) + return (ftime > 0) and os.date('%c', ftime) end, - hl = { fg = utils.get_highlight("Statusline").fg, bold = true, bg = colors.bg }, + hl = { fg = utils.get_highlight('Statusline').fg, bold = true, bg = colors.bg }, } -- Spell @@ -573,17 +592,17 @@ local Spell = { condition = function() return vim.wo.spell end, - provider = " 暈", + provider = ' 暈', hl = { bold = true, fg = colors.yellow }, } local HelpFileName = { condition = function() - return vim.bo.filetype == "help" + return vim.bo.filetype == 'help' end, provider = function() local filename = vim.api.nvim_buf_get_name(0) - return vim.fn.fnamemodify(filename, ":t") + return vim.fn.fnamemodify(filename, ':t') end, hl = { fg = colors.blue }, } @@ -600,37 +619,37 @@ local SearchCount = { end, provider = function(self) local search = self.search - return string.format("[%d/%d]", search.current, math.min(search.total, search.maxcount)) + 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 + return vim.fn.reg_recording() ~= '' and vim.o.cmdheight == 0 end, - provider = " ", - hl = { fg = "orange", bold = true }, - utils.surround({ "[", "]" }, nil, { + provider = ' ', + hl = { fg = 'orange', bold = true }, + utils.surround({ '[', ']' }, nil, { provider = function() return vim.fn.reg_recording() end, - hl = { fg = "green", bold = true }, + hl = { fg = 'green', bold = true }, }), update = { - "RecordingEnter", - "RecordingLeave", - } + 'RecordingEnter', + 'RecordingLeave', + }, } local ShowCmd = { condition = function() return vim.o.cmdheight == 0 end, - provider = ":%3.5(%S%)", + provider = ':%3.5(%S%)', } local cursor_location = { - { provider = " %1(%4l:%-3(%c%) %)%*", hl = { fg = colors.black, bold = true } }, + { provider = '%1(%4l:%-3(%c%)%) %*', hl = { fg = colors.black, bold = true } }, } local Ruler = { cursor_location } @@ -655,16 +674,16 @@ local WordCount = { condition = function() return conditions.buffer_matches({ filetype = { - "markdown", - "txt", - "vimwiki", + 'markdown', + 'txt', + 'vimwiki', }, }) end, Space, { provider = function() - return "W:" .. vim.fn.wordcount().words + return 'W:' .. vim.fn.wordcount().words end, }, } @@ -672,31 +691,31 @@ local WordCount = { -- Working Directory local WorkDir = { init = function(self) - self.icon = (vim.fn.haslocaldir(0) == 1 and "l" or "g") .. " " .. " " + self.icon = (vim.fn.haslocaldir(0) == 1 and 'l' or 'g') .. ' ' .. ' ' local cwd = vim.fn.getcwd(0) - self.cwd = vim.fn.fnamemodify(cwd, ":~") + self.cwd = vim.fn.fnamemodify(cwd, ':~') end, - hl = { fg = "colors.blue", bold = true }, + 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 .. " " + 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 .. " " + local trail = self.cwd:sub(-1) == '/' and '' or '/' + return self.icon .. cwd .. trail .. ' ' end, }, { -- evaluates to "", hiding the component - provider = "", - } + provider = '', + }, } -- Snippets Indicator @@ -720,7 +739,7 @@ FileNameBlock = utils.insert( 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 + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) local FileInfoBlock = { @@ -735,30 +754,32 @@ FileInfoBlock = utils.insert( Space, FileIcon, FileType, - { provider = "%<" } -- this means that the statusline is cut here when there's not enough space + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) -LeftSpace = utils.surround({ "", " " }, function(self) +LeftSpace = utils.surround({ '', '' }, function(self) return self:mode_color() -end, { LeftSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) +end, { LeftSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) -RightSpace = utils.surround({ "", "" }, function(self) +RightSpace = utils.surround({ '', '' }, function(self) return self:mode_color() -end, { RightSpace, hl = { fg = utils.get_highlight("statusline").bg, force = true } }) +end, { RightSpace, hl = { fg = utils.get_highlight('statusline').bg, force = true } }) -LSPActive = utils.surround({ "", "" }, function(self) +LSPActive = utils.surround({ '', '' }, function(self) return self:mode_color() end, { Space, LSPActive, hl = { bg = colors.darkgray, force = true } }) -FileInfoBlock = utils.surround({ "", "" }, function(self) +FileInfoBlock = utils.surround({ '', '' }, function(self) return self:mode_color() end, { FileInfoBlock, Space, hl = { bg = colors.gray, force = true } }) -Ruler = utils.surround({ "", "" }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } }) +Ruler = utils.surround({ '', '' }, colors.gray, { Ruler, hl = { fg = colors.gray, force = true } }) local left = { - { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, { 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 } }, @@ -779,15 +800,17 @@ local right = { { 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, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local sections = { left, middle, right } local DefaultStatusline = { sections } local specialleft = { - { ViMode, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, - { LeftSpace, hl = { bg = colors.nobg, force = true } }, + { RightSpace, hl = { bg = colors.nobg, force = true } }, + { ViMode, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local specialmiddle = { @@ -798,7 +821,8 @@ local specialmiddle = { local specialright = { { RightSpace, hl = { bg = colors.nobg, force = true } }, - { Ruler, hl = { fg = utils.get_highlight("statusline").bg, force = true } }, + { Ruler, hl = { fg = utils.get_highlight('statusline').bg, force = true } }, + { LeftSpace, hl = { bg = colors.nobg, force = true } }, } local specialsections = { specialleft, specialmiddle, specialright } @@ -807,26 +831,26 @@ local InactiveStatusline = { condition = conditions.is_not_active, --{ FileNameBlock, hl = { bg = colors.nobg, force = true } }, --{ Align, hl = { bg = colors.nobg, force = true } }, - specialsections + specialsections, } local SpecialStatusline = { condition = function() return conditions.buffer_matches({ - buftype = { "nofile", "prompt", "help", "quickfix" }, - filetype = { "^git.*", "fugitive", "dashboard", }, + buftype = { 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { '^git.*', 'fugitive', 'dashboard' }, }) end, - specialsections + specialsections, } --local InactiveStatusline = SpecialStatusline local TerminalStatusline = { condition = function() - return conditions.buffer_matches({ buftype = { "terminal" } }) + return conditions.buffer_matches({ buftype = { 'terminal' } }) end, - specialsections + specialsections, } local StatusLine = { @@ -851,7 +875,7 @@ local StatusLine = { no = colors.blue, nov = colors.blue, noV = colors.blue, - ["no\22"] = colors.blue, + ['no\22'] = colors.blue, niI = colors.blue, niR = colors.blue, niV = colors.blue, @@ -859,11 +883,11 @@ local StatusLine = { v = colors.purple, vs = colors.purple, V = colors.purple, - ["\22"] = colors.purple, - ["\22s"] = colors.purple, + ['\22'] = colors.purple, + ['\22s'] = colors.purple, s = colors.purple, S = colors.purple, - ["\19"] = colors.purple, + ['\19'] = colors.purple, i = colors.green, ix = colors.green, ic = colors.green, @@ -878,12 +902,12 @@ local StatusLine = { ce = colors.orange, r = colors.red, rm = colors.red, - ["r?"] = colors.red, - ["!"] = colors.orange, + ['r?'] = colors.red, + ['!'] = colors.orange, t = colors.orange, }, mode_color = function(self) - local mode = conditions.is_active() and vim.fn.mode() or "n" + local mode = conditions.is_active() and vim.fn.mode() or 'n' return self.mode_colors[mode] end, hl = function(self) @@ -898,7 +922,6 @@ local StatusLine = { DefaultStatusline, } - -- --- WinBar -- @@ -914,9 +937,9 @@ 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" + 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 @@ -935,15 +958,15 @@ WinbarFileNameBlock = utils.insert( 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 + { provider = '%<' } -- this means that the statusline is cut here when there's not enough space ) -vim.api.nvim_create_autocmd("User", { - pattern = "HeirlineInitWinbar", +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) + 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 @@ -970,11 +993,11 @@ local CloseButton = { end, -- a small performance improvement: -- re register the component callback only on layout/buffer changes. - update = { "WinNew", "WinClosed", "BufEnter" }, - { provider = " " }, + update = { 'WinNew', 'WinClosed', 'BufEnter' }, + { provider = ' ' }, { - provider = "", - hl = { fg = "gray" }, + provider = '', + hl = { fg = 'gray' }, On_click = { minwid = function() return vim.api.nvim_get_current_win() @@ -982,7 +1005,7 @@ local CloseButton = { callback = function(_, minwid) vim.api.nvim_win_close(minwid, true) end, - name = "heirline_winbar_close_button", + name = 'heirline_winbar_close_button', }, }, } @@ -993,8 +1016,8 @@ local Center = { -- 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", }, + buftype = { 'terminal', 'nofile', 'prompt', 'help', 'quickfix' }, + filetype = { 'dap-ui', 'NvimTree', '^git.*', 'fugitive', 'dashboard' }, }) end, init = function() @@ -1004,7 +1027,7 @@ local Center = { { -- A special winbar for terminals condition = function() - return conditions.buffer_matches({ buftype = { "terminal" } }) + return conditions.buffer_matches({ buftype = { 'terminal' } }) end, FileType, Space, @@ -1016,16 +1039,15 @@ local Center = { return not conditions.is_active() end, --utils.surround({ "", "" }, colors.nobg, { FileIcon, { WinbarFileName, hl = { fg = colors.gray } }, FileFlags } ), - utils.surround({ "", "" }, colors.nobg, { WinbarFileNameBlock }), + utils.surround({ '', '' }, colors.nobg, { WinbarFileNameBlock }), }, -- A winbar for regular files - utils.surround({ "", "" }, colors.nobg, { FileNameBlock }), + utils.surround({ '', '' }, colors.nobg, { FileNameBlock }), } --local WinBar = { Align, Center, Align } local WinBar = { Space, Center } - -- TabLine --local TablineBufnr = { -- provider = function(self) @@ -1040,7 +1062,7 @@ 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") + filename = filename == '' and 'No Name' or vim.fn.fnamemodify(filename, ':t') return filename end, hl = function(self) @@ -1052,7 +1074,7 @@ local TablineFileFlags = { { provider = function(self) if vim.bo[self.bufnr].modified then - return " [+] " + return ' [+] ' end end, hl = { fg = colors.green }, @@ -1060,22 +1082,21 @@ local TablineFileFlags = { { provider = function(self) if not vim.bo[self.bufnr].modifiable or vim.bo[self.bufnr].readonly then - return " " + return ' ' end end, - hl = { fg = "orange" }, + 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 }) + 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 .. " ") + return self.icon and (' ' .. self.icon .. ' ') end, hl = function(self) return { fg = self.icon_color } @@ -1089,17 +1110,17 @@ local TablineFileNameBlock = { end, hl = function(self) if self.is_active then - return "TabLineSel" + return 'TabLineSel' -- why not? --elseif not vim.api.nvim_buf_is_loaded(self.bufnr) then --return { fg = "gray", bg = colors.bg } else - return "TabLineFill" + return 'TabLineFill' end end, on_click = { callback = function(_, minwid, _, button) - if button == "m" then -- close on mouse middle click + 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) @@ -1108,7 +1129,7 @@ local TablineFileNameBlock = { minwid = function(self) return self.bufnr end, - name = "heirline_tabline_buffer_callback", + name = 'heirline_tabline_buffer_callback', }, --TablineBufnr, TablineFileIcon, @@ -1119,11 +1140,11 @@ local TablineFileNameBlock = { -- a nice "x" button to close the buffer local TablineCloseButton = { condition = function(self) - return not vim.api.nvim_buf_get_option(self.bufnr, "modified") + return not vim.api.nvim_buf_get_option(self.bufnr, 'modified') end, - { provider = " " }, + { provider = ' ' }, { - provider = " ", + provider = ' ', --hl = { fg = "red", bg = colors.bg }, hl = { fg = colors.red }, on_click = { @@ -1133,43 +1154,43 @@ local TablineCloseButton = { minwid = function(self) return self.bufnr end, - name = "heirline_tabline_close_buffer_callback", + name = 'heirline_tabline_close_buffer_callback', }, }, } -- The final touch! -local TablineBufferBlock = utils.surround({ "", "" }, function(self) +local TablineBufferBlock = utils.surround({ '', '' }, function(self) --local TablineBufferBlock = utils.surround({ "█", "█" }, function(self) if self.is_active then - return utils.get_highlight("TabLineSel").bg + return utils.get_highlight('TabLineSel').bg else - return utils.get_highlight("TabLineFill").bg + 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, ">") + { 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" + return '%' .. self.tabnr .. 'T ' .. self.tabnr .. ' %T' end, hl = function(self) if not self.is_active then - return "TabLineFill" + return 'TabLineFill' else - return "TabLineSel" + return 'TabLineSel' end end, } local TabpageClose = { - provider = "%999X %X", + provider = '%999X %X', --hl = "TabLine", hl = { fg = colors.red, bg = colors.bg }, } @@ -1180,7 +1201,7 @@ local TabPages = { return #vim.api.nvim_list_tabpages() >= 2 end, { - provider = "%=", + provider = '%=', }, utils.make_tablist(Tabpage), TabpageClose, @@ -1193,8 +1214,8 @@ local TabLineOffset = { 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" + if vim.api.nvim_buf_get_option(bufnr, 'filetype') == 'NvimTree' then + self.title = 'NvimTree' return true end end, @@ -1202,15 +1223,17 @@ local TabLineOffset = { local title = self.title local width = vim.api.nvim_win_get_width(self.winid) local pad = math.ceil((width - #title) / 2) - return string.rep(" ", pad) .. title .. string.rep(" ", pad) - end, - hl = function(self) - if vim.api.nvim_get_current_win() == self.winid then - return "TablineSel" - else - return "TablineFill" - end + 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 = { @@ -1219,7 +1242,7 @@ local TabLine = { TabPages, } -require("heirline").setup({ +require('heirline').setup({ statusline = StatusLine, winbar = WinBar, tabline = TabLine, @@ -1245,7 +1268,7 @@ local function goto_buf(index) end local function addKey(key, index) - vim.keymap.set("", "<A-" .. key .. ">", function() + vim.keymap.set('', '<A-' .. key .. '>', function() goto_buf(index) end, { noremap = true, silent = true }) end @@ -1253,4 +1276,4 @@ end for i = 1, 9 do addKey(i, i) end -addKey("0", 10) +addKey('0', 10) 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 index b875182..92278f3 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,140 +1,127 @@ ---local mason = require('mason') -require("mason").setup() -require("mason-null-ls").setup({ - handlers = {}, - ensure_installed = nil, - automatic_installation = true, - automatic_setup = true, -}) -local lspconfig = require("lspconfig") -local mason_lspconfig = require("mason-lspconfig") -local null_ls = require("null-ls") ---local lsp_lines = require('lsp_lines') +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" }, -} - -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 +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) ---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 = false, -- 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) + for _, client in ipairs(clients) do + client.stop() + end 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.formatting()<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", "[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()") + + 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 - 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() + -- 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.formatting()<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 -end --- Open float for diagnostics automatically -vim.cmd([[ + -- 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,}) @@ -142,337 +129,288 @@ augroup OpenFloat 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-16" } - -local function prefer_null_ls_fmt(client) - client.server_capabilities.documentHighlightProvider = true - client.server_capabilities.documentFormattingProvider = true - on_attach(client) -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-16' } -local servers = { - asm_lsp = {}, - bashls = {}, - clangd = {}, - 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 }, - }, + local function prefer_null_ls_fmt(client) + client.server_capabilities.documentHighlightProvider = true + client.server_capabilities.documentFormattingProvider = true + on_attach(client) + end + + local servers = { + asm_lsp = {}, + bashls = {}, + clangd = {}, + 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 } } }, }, - }, - rust_analyzer = { - settings = { - ["rust-analyzer"] = { - cargo = { allFeatures = true }, - checkOnSave = { - command = "clippy", - extraArgs = { "--no-deps" }, - }, + 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, + 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, }, - -- 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, + 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", + 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) + 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 - else - config.on_attach = prefer_null_ls_fmt + elseif not config.on_attach then + config.on_attach = on_attach end - elseif not config.on_attach then - config.on_attach = on_attach + + lspconfig[server].setup(config) end - lspconfig[server].setup(config) -end + -- null_ls setup + local builtins = null_ls.builtins + local augroup = vim.api.nvim_create_augroup('LspFormatting', {}) --- 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") + -- 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, + 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, - }), - 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, - 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.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, - }) + }) + + -- 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 - 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() + 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 --- 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, {}) diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua index e2298b5..cab6f1b 100644 --- a/.config/nvim/lua/plugins/nvim-tree.lua +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -1,106 +1,367 @@ -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end +----------------------------------------------------------- +-- Neovim File Tree Configuration +----------------------------------------------------------- -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then - return -end +--- To see mappings `g?` on nvim-tree +--- To see default mappings `:nvim-tree-default-mappings` -local tree_cb = nvim_tree_config.nvim_tree_callback +local icons = { + webdev_colors = true, + git_placement = 'signcolumn', + modified_placement = 'after', + padding = ' ', + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + modified = true, + }, --- To see mappings `g?` on nvim-tree --- To see default mappings `:nvim-tree-default-mappings` + glyphs = { + default = '', + symlink = '', + folder = { + arrow_open = '', + arrow_closed = '', + default = ' ', + open = ' ', + empty = ' ', + empty_open = ' ', + symlink = '', + symlink_open = '', + }, -nvim_tree.setup({ - update_focused_file = { - enable = true, - update_cwd = true, + git = { + deleted = '', + unmerged = '', + untracked = '', + unstaged = '', + staged = '', + renamed = '➜', + ignored = '◌', + }, }, - git = { - enable = true, - ignore = false, - timeout = 500, -}, - renderer = { - root_folder_modifier = ":t", - indent_markers = { + 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 = { - glyphs = { - default = "", - symlink = "", - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - untracked = "U", - deleted = "", - ignored = "◌", - }, - }, + 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, + hide_root_folder = false, + 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 = "", + hint = '⚑', + info = '', + warning = '▲', + error = '', }, }, - view = { - width = 30, - --height = 30, - side = "left", - --mappings = { - -- list = { - -- { key = { "l", "<CR>", "o" }, cb = tree_cb("edit") }, - -- { key = "h", cb = tree_cb("close_node") }, - -- { key = "v", cb = tree_cb("vsplit") }, - -- { key = "u", action = "dir_up" }, - -- }, - --}, - }, trash = { - cmd = "gio 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' }, + }, + }, + }, + }, }) -vim.api.nvim_create_autocmd("QuitPre", { - callback = function() - local invalid_win = {} - local wins = vim.api.nvim_list_wins() - for _, w in ipairs(wins) do - local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w)) - if bufname:match("NvimTree_") ~= nil then - table.insert(invalid_win, w) - end - end - if #invalid_win == #wins - 1 then - -- Should quit, so we close all invalid windows. - for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end - end +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") +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) @@ -128,16 +389,9 @@ vim.api.nvim_command("highlight NvimTreeNormal guibg=none") --vim.api.nvim_command("highlight NvimTreeGitNew ") --vim.api.nvim_command("highlight NvimTreeGitDeleted ") --vim.api.nvim_command("highlight NvimTreeGitIgnored ") --(Comment) ---vim.api.nvim_command("highlight NvimTreeWindowPicker ") --vim.api.nvim_command("highlight NvimTreeNormal ") --vim.api.nvim_command("highlight NvimTreeEndOfBuffer ") --(NonText) ---vim.api.nvim_command("highlight NvimTreeCursorLine ") --(CursorLine) ---vim.api.nvim_command("highlight NvimTreeCursorLineNr ") --(CursorLineNr) ---vim.api.nvim_command("highlight NvimTreeLineNr ") --(LineNr) ---vim.api.nvim_command("highlight NvimTreeWinSeparator ") --(WinSeparator) --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) @@ -145,10 +399,6 @@ vim.api.nvim_command("highlight NvimTreeNormal guibg=none") --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/quickfix.lua b/.config/nvim/lua/plugins/quickfix.lua index 4ea2374..4a76da0 100644 --- a/.config/nvim/lua/plugins/quickfix.lua +++ b/.config/nvim/lua/plugins/quickfix.lua @@ -1,18 +1,15 @@ local M = {} M.close = function() - vim.cmd.cclose() + 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 + 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/sniprun.lua b/.config/nvim/lua/plugins/sniprun.lua new file mode 100644 index 0000000..2556c24 --- /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/telescope.lua b/.config/nvim/lua/plugins/telescope.lua index 079f88b..0167aa3 100644 --- a/.config/nvim/lua/plugins/telescope.lua +++ b/.config/nvim/lua/plugins/telescope.lua @@ -1,91 +1,93 @@ local M = {} -- Shorten function names -local actions = require("telescope.actions") -local fb_actions = require("telescope").extensions.file_browser.actions +local actions = require('telescope.actions') +local fb_actions = require('telescope').extensions.file_browser.actions --local builtin = require("telescope.builtin") ---local themes = require("telescope.themes") --local utils = require("telescope.utils") ---local action_state = require("telescope.actions.state") --local layout_actions = require("telescope.actions.layout") ---local pickers = require("telescope.pickers") -local themes = require("telescope.themes") - +--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", + '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" }, + prompt_prefix = ' ', + selection_caret = ' ', + entry_prefix = ' ', + path_display = { 'tail' }, --path_display = { "truncate" }, --path_display = { "smart" }, file_ignore_patterns = { - "packer_compiled.lua", - "zcompdump", - "%.DS_Store", - "%.git/", - "%.spl", + '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/", + '%[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-n>'] = actions.cycle_history_next, + ['<C-p>'] = actions.cycle_history_prev, - ["<C-j>"] = actions.move_selection_next, - ["<C-k>"] = actions.move_selection_previous, + ['<C-j>'] = actions.move_selection_next, + ['<C-k>'] = actions.move_selection_previous, --["<C-c>"] = actions.close, - ["<Esc>"] = actions.close, -- close w/ one esc + ['<Esc>'] = actions.close, -- close w/ one esc --["<Esc>"] = "close", -- close w/ one esc - ["<?>"] = actions.which_key, -- keys from pressing <C-/> + ['<?>'] = actions.which_key, -- keys from pressing <C-/> - ["<Down>"] = actions.move_selection_next, - ["<Up>"] = actions.move_selection_previous, + ['<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, + ['<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, + ['<C-u>'] = actions.preview_scrolling_up, + ['<C-d>'] = actions.preview_scrolling_down, - ["<PageUp>"] = actions.results_scrolling_up, - ["<PageDown>"] = actions.results_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-/> + ['<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") @@ -102,36 +104,42 @@ require('telescope').setup({ -- -- 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, - - ["?"] = actions.which_key, + ['<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") @@ -146,9 +154,9 @@ require('telescope').setup({ filesize_limit = 3, timeout = 250, }, - selection_strategy = "reset", - sorting_strategy = "ascending", - scroll_strategy = "limit", + selection_strategy = 'reset', + sorting_strategy = 'ascending', + scroll_strategy = 'limit', color_devicons = true, layout_strategy = 'horizontal', layout_config = { @@ -156,14 +164,22 @@ require('telescope').setup({ height = 0.95, preview_cutoff = 70, width = 0.92, - preview_width = { 0.55, max = 50 } + preview_width = { 0.55, max = 50 }, }, bottom_pane = { height = 12, preview_cutoff = 70, - prompt_position = "bottom", + 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, @@ -208,13 +224,6 @@ require('telescope').setup({ -- prompt_prefix=' ', -- show_line = false, --}, - find_files = { - cwd = '%:p:h', - --cwd = vim.fn.getcwd(), - prompt_prefix = ' ', - hidden = true, - follow = true, - }, --keymaps = { prompt_prefix='? ' }, --oldfiles = { prompt_prefix=' ' }, --highlights = { prompt_prefix=' ' }, @@ -251,21 +260,21 @@ require('telescope').setup({ extensions = { file_browser = { - theme = "dropdown", + theme = 'dropdown', -- disables netrw and use telescope-file-browser in its place - hijack_netrw = true, + hijack_netrw = false, mappings = { -- your custom insert mode mappings - ["i"] = { - ["<C-w>"] = function() - vim.cmd("normal vbd") + ['i'] = { + ['<C-w>'] = function() + vim.cmd('normal vbd') end, - --["<C-h>"] = fb_actions.goto_parent_dir, + ['<C-h>'] = fb_actions.goto_parent_dir, }, - ["n"] = { + ['n'] = { -- your custom normal mode mappings - ["N"] = fb_actions.create, - --["<C-h>"] = fb_actions.goto_parent_dir, + ['N'] = fb_actions.create, + ['<C-h>'] = fb_actions.goto_parent_dir, --["/"] = function() -- vim.cmd("startinsert") --end, @@ -281,14 +290,15 @@ require('telescope').setup({ -- 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('file_browser') require('telescope').load_extension('changed_files') require('telescope').load_extension('media_files') ---require('telescope').extensions.notify.notify() 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('session-lens') +require('telescope').load_extension('flutter') +require('telescope').load_extension('recent_files') +--require('telescope').load_extension('projects') --M.curbuf = function(opts) -- opts = opts @@ -301,119 +311,174 @@ require("telescope").load_extension("flutter") --end function M.find_configs() - require("telescope.builtin").find_files { + require('telescope.builtin').find_files({ hidden = true, no_ignore = false, - prompt_title = " Find Configs", - results_title = "Config Files", - path_display = { "smart" }, + prompt_title = ' Find Configs', + results_title = 'Config Files', + path_display = { 'smart' }, search_dirs = { - "~/.config/nvim", - "~/.config/zsh", - "~/.config/tmux", - "~/.config/X11", - "~/.config/alacritty", - "~/.config/kitty", - "~/.config/wezterm", - "~/.config/bspwm", - "~/.config/sxhkd", - "~/.config/picom", - "~/.config/polybar", - "~/.bashrc", - "~/.ssh", - "~/.vim", - "~/.profile", - "~/.zprofile", - "~/README.md", + '~/.vim', + '~/.config/nvim', + '~/.config/zsh', + '~/.config/tmux', + '~/.config/X11', + '~/.config/alacritty', + '~/.config/kitty', + '~/.config/wezterm', + '~/.config/bspwm', + '~/.config/sxhkd', + '~/.config/picom', + '~/.config/polybar', + '~/.bashrc', + '~/.profile', + '~/.zprofile', + '~/.gitconfig', + '~/.gitsubtrees', + '~/.gitignore', + '~/.editorconfig', + '~/.prettierrc.yml', + '~/.ssh', + '~/README.md', }, - -- cwd = "~/.config/nvim/", file_ignore_patterns = { - "~/.config/nvim/startup.log", - "packer_compiled.lua", - "resurrect", - "tmux/plugins", + '/nvim/startup.log', + 'zsh/plugins', + 'packer_compiled.lua', + 'resurrect', + 'tmux/plugins', --"^~/.config/tmux/plugins", - "%.txt", - ".git", - "autoload/plugged", - "plug.vim", - "zcompdump", + '%.txt', + '.git/', + 'autoload/plugged', + 'plug.vim', + 'zcompdump', }, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end function M.find_scripts() - require("telescope.builtin").find_files { + require('telescope.builtin').find_files({ hidden = true, no_ignore = true, - prompt_title = " Find Scripts", - path_display = { "smart" }, + prompt_title = ' Find Scripts', + path_display = { 'smart' }, search_dirs = { - "~/.local/bin/scripts", + '~/.local/bin/scripts', }, - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) end +--function M.find_projects() -- aka Workspaces +-- require('telescope.builtin').find_files({ +-- hidden = true, +-- no_ignore = true, +-- prompt_title = ' Find Projects', +-- path_display = { 'smart' }, +-- search_dirs = { +-- '~/projects', +-- }, +-- layout_strategy = 'horizontal', +-- layout_config = { preview_width = 0.65, width = 0.75 }, +-- }) +--end + function M.find_projects() - require("telescope.builtin").find_files { - hidden = true, - no_ignore = true, - prompt_title = " Find Projects", - path_display = { "smart" }, - search_dirs = { - "~/projects", - }, - layout_strategy = "horizontal", - layout_config = { preview_width = 0.65, width = 0.75 }, - } + local search_dir = '~/projects' + pickers + .new({}, { + prompt_title = 'Change Directory', + 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/", + '~/documents/notes/', } - opts.prompt_prefix = " " - opts.prompt_title = " Grep Notes" - opts.path_display = { "smart" } - require("telescope.builtin").live_grep(opts) + 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 = false, - prompt_title = " Find Notes", - path_display = { "smart" }, + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Notes', + path_display = { 'smart' }, search_dirs = { - "~/documents/notes/private/", - "~/documents/notes", + '~/documents/notes/private/', + '~/documents/notes', + '~/notes/private', + '~/notes', }, - --cwd = "~documents/notes", - layout_strategy = "horizontal", + layout_strategy = 'horizontal', layout_config = { preview_width = 0.65, width = 0.75 }, - } + }) +end + +function M.find_books() + require('telescope.builtin').find_files({ + hidden = true, + no_ignore = false, + prompt_title = ' Find Books', + path_display = { 'smart' }, + search_dirs = { + '~/documents/books', + '~/books', + }, + layout_strategy = 'horizontal', + layout_config = { preview_width = 0.65, width = 0.75 }, + }) end function M.file_explorer() - require("telescope.builtin").file_browser({ - prompt_title = "File Browser", - cwd = "~", - layout_strategy = "horizontal", + require('telescope.builtin').file_browser({ + prompt_title = 'File Browser', + cwd = '~', + layout_strategy = 'horizontal', }) end function M.grep_current_dir() - local buffer_dir = require("telescope.utils").buffer_dir() + local buffer_dir = require('telescope.utils').buffer_dir() local opts = { - prompt_title = "Live Grep in " .. buffer_dir, + prompt_title = 'Live Grep in ' .. buffer_dir, cwd = buffer_dir, } - require("telescope.builtin").live_grep(opts) + require('telescope.builtin').live_grep(opts) end -------------------------------------------------------------------------------- @@ -427,7 +492,7 @@ local dropdown = require('telescope.themes').get_dropdown({ results_title = '', layout_config = { --anchor = "S", - prompt_position = 'top' + prompt_position = 'top', }, }) @@ -450,29 +515,22 @@ local with_title = function(opts, extra) end return vim.tbl_extend('force', opts, { - prompt_title = title + prompt_title = title, }, extra or {}) end ---vim.api.nvim_create_augroup('findhere', { clear = true }) ---vim.api.nvim_command('augroup findhere') ---vim.api.nvim_command('autocmd!') ---vim.api.nvim_command('autocmd VimEnter * lua require("plugins/telescope").findhere()') ---vim.api.nvim_command('augroup END') - - ---local findhere = function() +-- 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 + 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' }, --- })) + -- require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ + -- hidden = true, + -- results_title = '', + -- layout_config = { prompt_position = 'top' }, + -- })) end, 10) end end @@ -480,10 +538,57 @@ 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()') --- Merge the existing M table with the startup function table ---M = vim.tbl_extend('force', M, { findhere = 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 subdirs = vim.fn.readdir(root_path) + if subdirs then + for _, subdir in ipairs(subdirs) do + if vim.fn.isdirectory(root_path .. '/' .. subdir) == 1 then + table.insert(entries, subdir) + end + end + end + + pickers + .new({}, { + prompt_title = 'Change Directory', + 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_subdir = entry.value + actions.close(prompt_bufnr, false) + local selected_path = root_path .. '/' .. selected_subdir + vim.fn.chdir(selected_path) + vim.cmd('e .') + vim.cmd("echon ''") + print('cwd: ' .. vim.fn.getcwd()) + end + end) + return true + end, + }) + :find() +end return M diff --git a/.config/nvim/lua/plugins/trouble.lua b/.config/nvim/lua/plugins/trouble.lua index d4f50dc..7d74730 100644 --- a/.config/nvim/lua/plugins/trouble.lua +++ b/.config/nvim/lua/plugins/trouble.lua @@ -1,47 +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 = "workspace_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 +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 + 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 = "", - hint = "", - information = "", - other = "" + -- icons / text used for a diagnostic + error = '', + warning = '▲', + information = '', + hint = '⚑', + other = '', }, - use_diagnostic_signs = false -- enabling this will use the signs defined in your lsp client -} + 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 index 2f68275..06f2d1c 100644 --- a/.config/nvim/lua/plugins/web-devicons.lua +++ b/.config/nvim/lua/plugins/web-devicons.lua @@ -1,17 +1,22 @@ ---local status, icons = pcall(require, "nvim-web-devicons") ---if (not status) then return end ---icons.setup { -require'nvim-web-devicons'.setup { +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; + icon = '', + color = '#428850', + cterm_color = '65', + name = 'Zsh', + }, }, - -- globally enable default icons (default to false) - -- will get overriden by `get_icons` option - --default = true -} + color_icons = true, +}) |
