mirror of
https://github.com/halfdan/dotfiles.git
synced 2025-09-10 19:56:24 +00:00
Update nvim
This commit is contained in:
@@ -16,7 +16,7 @@ else
|
||||
require('halfdan.colorscheme')
|
||||
require('halfdan.treesitter')
|
||||
require('halfdan.telescope')
|
||||
-- require('halfdan.lualine')
|
||||
require('halfdan.lualine')
|
||||
|
||||
require('halfdan.autocmds')
|
||||
|
||||
|
@@ -83,23 +83,39 @@ require("lazy").setup({
|
||||
|
||||
{'preservim/tagbar'},
|
||||
|
||||
{'f-person/git-blame.nvim'},
|
||||
-- Status Line and Bufferline
|
||||
-- {
|
||||
-- 'nvim-lualine/lualine.nvim',
|
||||
-- dependencies = {'kyazdani42/nvim-web-devicons'}
|
||||
-- },
|
||||
|
||||
{'rcarriga/nvim-notify'},
|
||||
|
||||
-- { "nvim-neorg/neorg" },
|
||||
-- {'nvim-neorg/neorg-telescope'},
|
||||
|
||||
{'justinmk/vim-sneak'},
|
||||
|
||||
{'machakann/vim-highlightedyank'},
|
||||
|
||||
-- LSP / Language Server Protocol
|
||||
{
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = {'kyazdani42/nvim-web-devicons'},
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
opts = function()
|
||||
local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim")
|
||||
return {
|
||||
float = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"),
|
||||
separator = "bubble", -- bubble | triangle
|
||||
---@type any
|
||||
colorful = true,
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local lualine_config = require("halfdan.lualine")
|
||||
lualine_config.setup(opts)
|
||||
lualine_config.load()
|
||||
end,
|
||||
},
|
||||
|
||||
{'rcarriga/nvim-notify'},
|
||||
|
||||
-- { "nvim-neorg/neorg" },
|
||||
-- {'nvim-neorg/neorg-telescope'},
|
||||
|
||||
{'justinmk/vim-sneak'},
|
||||
|
||||
{'machakann/vim-highlightedyank'},
|
||||
|
||||
-- LSP / Language Server Protocol
|
||||
{
|
||||
'neovim/nvim-lspconfig',
|
||||
'williamboman/nvim-lsp-installer',
|
||||
},
|
||||
@@ -176,6 +192,7 @@ require("lazy").setup({
|
||||
-- Debugging
|
||||
"mfussenegger/nvim-dap",
|
||||
"rcarriga/nvim-dap-ui",
|
||||
"nvim-neotest/nvim-nio",
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
|
||||
-- => Language Support
|
||||
@@ -190,10 +207,10 @@ require("lazy").setup({
|
||||
local elixirls = require("elixir.elixirls")
|
||||
--
|
||||
elixir.setup {
|
||||
nextls = {enable = false},
|
||||
nextls = {enable = true},
|
||||
credo = {},
|
||||
elixirls = {
|
||||
enable = true,
|
||||
enable = false,
|
||||
settings = elixirls.settings {
|
||||
dialyzerEnabled = false,
|
||||
enableTestLenses = false,
|
||||
|
@@ -1,52 +0,0 @@
|
||||
|
||||
local function formatted_status()
|
||||
local status = require'lsp-status'.status()
|
||||
status = string.gsub(status, "%%", "%%%%")
|
||||
return status
|
||||
end
|
||||
|
||||
|
||||
require 'lualine'.setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'monokai-pro',
|
||||
--component_separators = {'', ''},
|
||||
--section_separators = {'', ''},
|
||||
disabled_filetypes = {}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = {
|
||||
{"require'lsp-status'.status()", fmt = function (str)
|
||||
return string.gsub(str, "%%", "%%%%")
|
||||
end},
|
||||
'filetype'
|
||||
},
|
||||
lualine_y = { 'progress' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
winbar = {
|
||||
lualine_a = {
|
||||
},
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_c = { 'filename' },
|
||||
}
|
||||
}
|
160
.config/nvim/lua/halfdan/lualine/components.lua
Normal file
160
.config/nvim/lua/halfdan/lualine/components.lua
Normal file
@@ -0,0 +1,160 @@
|
||||
local config = require("halfdan.lualine.config").options
|
||||
local icons = require("halfdan.icons")
|
||||
|
||||
local M = {}
|
||||
|
||||
local hl_str = function(str, hl_cur, hl_after)
|
||||
if hl_after == nil then
|
||||
return "%#" .. hl_cur .. "#" .. str .. "%*"
|
||||
end
|
||||
return "%#" .. hl_cur .. "#" .. str .. "%*" .. "%#" .. hl_after .. "#"
|
||||
end
|
||||
|
||||
local function hide_in_width()
|
||||
return vim.fn.winwidth(0) > 85
|
||||
end
|
||||
|
||||
local prev_branch = ""
|
||||
M.branch = {
|
||||
"branch",
|
||||
icons_enabled = false,
|
||||
icon = hl_str("", "SLGitIcon", "SLBranchName"),
|
||||
colored = false,
|
||||
fmt = function(str)
|
||||
if vim.bo.filetype == "toggleterm" then
|
||||
str = prev_branch
|
||||
elseif str == "" or str == nil then
|
||||
str = "!=vcs"
|
||||
end
|
||||
prev_branch = str
|
||||
local icon = hl_str(" ", "SLGitIcon", "SLBranchName")
|
||||
return hl_str(config.separator_icon.left, "SLSeparator")
|
||||
.. hl_str(icon, "SLGitIcon")
|
||||
.. hl_str(str, "SLBranchName")
|
||||
.. hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
end,
|
||||
}
|
||||
|
||||
M.position = function()
|
||||
-- print(vim.inspect(config.separator_icon))
|
||||
local current_line = vim.fn.line(".")
|
||||
local current_column = vim.fn.col(".")
|
||||
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
|
||||
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
local str = "Ln " .. current_line .. ", Col " .. current_column
|
||||
return left_sep .. hl_str(str, "SLPosition", "SLPosition") .. right_sep
|
||||
end
|
||||
|
||||
M.spaces = function()
|
||||
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
|
||||
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
local str = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth")
|
||||
return left_sep .. hl_str(str, "SLShiftWidth", "SLShiftWidth") .. right_sep
|
||||
end
|
||||
|
||||
M.diagnostics = function()
|
||||
local function nvim_diagnostic()
|
||||
local diagnostics = vim.diagnostic.get(0)
|
||||
local count = { 0, 0, 0, 0 }
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
count[diagnostic.severity] = count[diagnostic.severity] + 1
|
||||
end
|
||||
return count[vim.diagnostic.severity.ERROR],
|
||||
count[vim.diagnostic.severity.WARN],
|
||||
count[vim.diagnostic.severity.INFO],
|
||||
count[vim.diagnostic.severity.HINT]
|
||||
end
|
||||
|
||||
local error_count, warn_count, info_count, hint_count = nvim_diagnostic()
|
||||
local error_hl = hl_str(icons.diagnostics.Error .. " " .. error_count, "SLError", "SLError")
|
||||
local warn_hl = hl_str(icons.diagnostics.Warn .. " " .. warn_count, "SLWarning", "SLWarning")
|
||||
local info_hl = hl_str(icons.diagnostics.Info .. " " .. info_count, "SLInfo", "SLInfo")
|
||||
local hint_hl = hl_str(icons.diagnostics.Hint .. " " .. hint_count, "SLInfo", "SLInfo")
|
||||
local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator")
|
||||
local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
return left_sep .. error_hl .. " " .. warn_hl .. " " .. hint_hl .. right_sep
|
||||
end
|
||||
|
||||
M.diff = {
|
||||
"diff",
|
||||
colored = true,
|
||||
diff_color = {
|
||||
added = "SLDiffAdd",
|
||||
modified = "SLDiffChange",
|
||||
removed = "SLDiffDelete",
|
||||
},
|
||||
symbols = {
|
||||
added = icons.git.added .. " ",
|
||||
modified = icons.git.modified .. " ",
|
||||
removed = icons.git.removed .. " ",
|
||||
}, -- changes diff symbols
|
||||
fmt = function(str)
|
||||
if str == "" then
|
||||
return ""
|
||||
end
|
||||
local left_sep = hl_str(config.thin_separator_icon.left, "SLSeparator")
|
||||
local right_sep = hl_str(config.thin_separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
return left_sep .. str .. right_sep
|
||||
end,
|
||||
cond = hide_in_width,
|
||||
}
|
||||
|
||||
M.mode = {
|
||||
"mode",
|
||||
fmt = function(str)
|
||||
local left_sep = hl_str(config.separator_icon.left, "SLSeparator", "SLPadding")
|
||||
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLPadding")
|
||||
return left_sep .. hl_str(str, "SLMode") .. right_sep
|
||||
end,
|
||||
}
|
||||
|
||||
local prev_filetype = ""
|
||||
M.filetype = {
|
||||
"filetype",
|
||||
icons_enabled = false,
|
||||
icons_only = false,
|
||||
fmt = function(str)
|
||||
local ui_filetypes = {
|
||||
"help",
|
||||
"packer",
|
||||
"neogitstatus",
|
||||
"NvimTree",
|
||||
"Trouble",
|
||||
"lir",
|
||||
"Outline",
|
||||
"spectre_panel",
|
||||
"toggleterm",
|
||||
"DressingSelect",
|
||||
"neo-tree",
|
||||
"",
|
||||
}
|
||||
local filetype_str = ""
|
||||
|
||||
if str == "toggleterm" then
|
||||
--
|
||||
filetype_str = "ToggleTerm " .. vim.api.nvim_buf_get_var(0, "toggle_number")
|
||||
elseif str == "TelescopePrompt" then
|
||||
filetype_str = ""
|
||||
elseif str == "neo-tree" or str == "neo-tree-popup" then
|
||||
if prev_filetype == "" then
|
||||
return
|
||||
end
|
||||
filetype_str = prev_filetype
|
||||
elseif str == "help" then
|
||||
filetype_str = ""
|
||||
elseif vim.tbl_contains(ui_filetypes, str) then
|
||||
return
|
||||
else
|
||||
prev_filetype = str
|
||||
filetype_str = str
|
||||
end
|
||||
local left_sep = hl_str(config.separator_icon.left, "SLSeparator")
|
||||
local right_sep = hl_str(config.separator_icon.right, "SLSeparator", "SLSeparator")
|
||||
-- Upper case first character
|
||||
filetype_str = filetype_str:gsub("%a", string.upper, 1)
|
||||
local filetype_hl = hl_str(filetype_str, "SLFiletype", "SLFiletype")
|
||||
return left_sep .. filetype_hl .. right_sep
|
||||
end,
|
||||
}
|
||||
|
||||
return M
|
40
.config/nvim/lua/halfdan/lualine/config.lua
Normal file
40
.config/nvim/lua/halfdan/lualine/config.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
local M = {}
|
||||
|
||||
---@class LualineConfig
|
||||
local default = {
|
||||
float = true,
|
||||
separator = "bubble", -- bubble | triangle
|
||||
---@type any
|
||||
colorful = true,
|
||||
separator_icon = { left = "", right = " " },
|
||||
thin_separator_icon = { left = "", right = " " },
|
||||
-- separator_icon = { left = "█", right = "█" },
|
||||
-- thin_separator_icon = { left = " ", right = " " },
|
||||
}
|
||||
|
||||
---@type LualineConfig
|
||||
M.options = {}
|
||||
|
||||
---@param type "bubble" | "triangle"
|
||||
local function make_separator(type)
|
||||
if type == "bubble" then
|
||||
M.options.separator_icon = { left = "█", right = "█" }
|
||||
M.options.thin_separator_icon = { left = " ", right = " " }
|
||||
elseif type == "triangle" then
|
||||
M.options.separator_icon = { left = "█", right = "█" }
|
||||
M.options.thin_separator_icon = { left = " ", right = " " }
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
M.setup = function(opts)
|
||||
M.options = vim.tbl_deep_extend("force", {}, default, opts or {})
|
||||
if M.options.float then
|
||||
make_separator(M.options.separator)
|
||||
end
|
||||
end
|
||||
|
||||
M.setup()
|
||||
|
||||
return M
|
111
.config/nvim/lua/halfdan/lualine/highlights.lua
Normal file
111
.config/nvim/lua/halfdan/lualine/highlights.lua
Normal file
@@ -0,0 +1,111 @@
|
||||
local M = {}
|
||||
local util = require("halfdan.util")
|
||||
|
||||
local function draw(groups)
|
||||
if groups == nil then
|
||||
return
|
||||
end
|
||||
for group, value in pairs(groups) do
|
||||
vim.api.nvim_set_hl(0, group, value)
|
||||
end
|
||||
end
|
||||
|
||||
local function generate(config, palette)
|
||||
local float = config.float
|
||||
local colorful = config.colorful
|
||||
if colorful then
|
||||
palette.yellow = util.get_highlight_value("String").foreground or "#ffff00"
|
||||
palette.white = util.get_highlight_value("Normal").foreground or "#ffffff"
|
||||
palette.red = util.get_highlight_value("DiagnosticError").foreground or "#ff0000"
|
||||
palette.orange = util.get_highlight_value("DiagnosticWarn").foreground or "#ff7700"
|
||||
palette.blue = util.get_highlight_value("DiagnosticHint").foreground or "#00ffff"
|
||||
palette.magenta = util.get_highlight_value("Statement").foreground or "#ff00ff"
|
||||
palette.green = util.get_highlight_value("healthSuccess").foreground or "#00ff00"
|
||||
end
|
||||
return {
|
||||
SLGitIcon = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.white or palette.statusbar_fg,
|
||||
},
|
||||
SLBranchName = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.yellow or palette.statusbar_fg,
|
||||
},
|
||||
SLError = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.red or palette.statusbar_fg,
|
||||
},
|
||||
SLWarning = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.orange or palette.statusbar_fg,
|
||||
},
|
||||
SLInfo = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.blue or palette.statusbar_fg,
|
||||
},
|
||||
SLDiffAdd = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.green or palette.statusbar_fg,
|
||||
},
|
||||
SLDiffChange = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.yellow or palette.statusbar_fg,
|
||||
},
|
||||
SLDiffDelete = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = colorful and palette.red or palette.statusbar_fg,
|
||||
},
|
||||
SLPosition = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.magenta or palette.statusbar_fg,
|
||||
},
|
||||
SLFiletype = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.blue or palette.statusbar_fg,
|
||||
},
|
||||
SLShiftWidth = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.yellow or palette.statusbar_fg,
|
||||
},
|
||||
SLEncoding = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.green or palette.statusbar_fg,
|
||||
},
|
||||
SLMode = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.green or palette.statusbar_fg,
|
||||
bold = true,
|
||||
},
|
||||
SLSeparatorUnused = {
|
||||
bg = float and palette.float_background or palette.statusbar_bg,
|
||||
fg = colorful and palette.editor_bg or palette.statusbar_fg,
|
||||
},
|
||||
SLSeparator = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = float and palette.float_background or palette.statusbar_bg,
|
||||
},
|
||||
SLPadding = {
|
||||
bg = float and palette.editor_bg or palette.statusbar_bg,
|
||||
fg = palette.editor_bg,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
---@param config LualineConfig
|
||||
M.custom = function(config)
|
||||
local statusline_hl = util.get_highlight_value("StatusLine")
|
||||
local palette = {
|
||||
float_background = util.get_highlight_value("CursorLine").background,
|
||||
editor_bg = util.get_highlight_value("Normal").background or "NONE",
|
||||
statusbar_bg = statusline_hl.background or "#000000",
|
||||
statusbar_fg = statusline_hl.foreground or "#505050",
|
||||
}
|
||||
local groups = generate(config, palette)
|
||||
|
||||
draw(groups)
|
||||
-- clear theme if float ortherwhise, make it auto
|
||||
local theme = config.float and { normal = { c = { bg = palette.editor_bg } } } or "auto"
|
||||
return theme
|
||||
end
|
||||
|
||||
return M
|
60
.config/nvim/lua/halfdan/lualine/init.lua
Normal file
60
.config/nvim/lua/halfdan/lualine/init.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
local config = require("halfdan.lualine.config")
|
||||
|
||||
local git_blame = require('gitblame')
|
||||
local M = {}
|
||||
|
||||
local function setup()
|
||||
local cpn = require("halfdan.lualine.components")
|
||||
local theme = require("halfdan.lualine.highlights").custom(config.options)
|
||||
|
||||
require("lualine").setup({
|
||||
options = {
|
||||
theme = theme,
|
||||
icons_enabled = true,
|
||||
component_separators = { left = "", right = "" },
|
||||
section_separators = { left = "", right = "" },
|
||||
disabled_filetypes = {
|
||||
statusline = { "dashboard", "lazy", "alpha" },
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = true,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
-- winbar = 100,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { cpn.branch },
|
||||
lualine_b = { cpn.diagnostics },
|
||||
lualine_c = {},
|
||||
lualine_x = { { git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available }, cpn.diff },
|
||||
lualine_y = { cpn.position, cpn.filetype },
|
||||
lualine_z = { cpn.spaces, cpn.mode },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { "filename" },
|
||||
lualine_x = { "location" },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {},
|
||||
})
|
||||
end
|
||||
|
||||
M.setup = config.setup
|
||||
|
||||
M.load = function()
|
||||
setup()
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = function()
|
||||
setup()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
@@ -63,3 +63,7 @@ vim.g.netrw_preview = 1 -- Split preview vertically
|
||||
vim.g.netrw_alo = 1 -- Show preview window to the right
|
||||
vim.g.netrw_winsize = 30 -- Have the preview window take up 70%
|
||||
-- vim.g.netrw_liststyle = 3 -- Use tree style
|
||||
--
|
||||
vim.g.gitblame_display_virtual_text = 0
|
||||
vim.g.gitblame_date_format = '%r'
|
||||
vim.g.gitblame_message_template = '<author> • <date>'
|
||||
|
Reference in New Issue
Block a user