Many changes

This commit is contained in:
Fabian Becker
2024-01-24 12:17:33 -05:00
parent 5782602a20
commit 49caa17eef
14 changed files with 566 additions and 102 deletions

View File

@@ -1,5 +1,5 @@
vim.cmd('let g:nvcode_termcolors=256')
vim.cmd('colorscheme ' .. O.colorscheme)
vim.cmd('colorscheme monokai-pro-classic')
-- vim.cmd('highlight Normal guibg=NONE ctermbg=NONE')

View File

@@ -6,7 +6,7 @@ O = {
clipboard = 'unnamedplus',
incsearch = true,
termguicolors = true,
colorscheme = 'monokaipro',
colorscheme = 'monokai-pro',
hidden_files = true,
wrap_lines = false,
number = true,

View File

@@ -0,0 +1,125 @@
return {
diagnostics = {
error = "",
warn = "",
hint = "",
info = "",
},
git = {
added = "",
modified = "",
removed = "",
renamed = "",
untracked = "",
ignored = "",
unstaged = "U",
staged = "",
conflict = "",
deleted = "",
},
gitsigns = {
add = "",
change = "",
delete = "",
topdelhfe = "",
changedelete = "",
untracked = "",
},
kinds = {
Array = "",
Boolean = "",
Class = "",
Color = "",
Constant = "",
Constructor = "",
Copilot = "",
Enum = "",
EnumMember = "",
Event = "",
Field = "",
File = "",
Folder = "",
Function = "",
Interface = "",
Key = "",
Keyword = "",
Method = "",
Module = "",
Namespace = "",
Null = "",
Number = "",
Object = "",
Operator = "",
Package = "",
Property = "",
Reference = "",
Snippet = "",
String = "",
Struct = "",
Text = "",
TypeParameter = "",
Unit = "",
Value = "",
Variable = "",
Macro = "", -- Macro
},
borders = {
--- @class BorderIcons
single = {
top = "",
right = "",
bottom = "",
left = "",
top_left = "",
top_right = "",
bottom_right = "",
bottom_left = "",
},
double = {
top = '',
right = "",
bottom = '',
left = "",
top_left = "",
top_right = "",
bottom_right = "",
bottom_left = "",
},
--- @class BorderIcons
thin = {
top = "",
right = "",
bottom = "",
left = "",
top_left = "🭽",
top_right = "🭾",
bottom_right = "🭿",
bottom_left = "🭼",
},
---@type BorderIcons
empty = {
top = " ",
right = " ",
bottom = " ",
left = " ",
top_left = " ",
top_right = " ",
bottom_right = " ",
bottom_left = " ",
},
---@type BorderIcons
thick = {
top = "",
right = "",
bottom = "",
left = "",
top_left = "",
top_right = "",
bottom_right = "",
bottom_left = "",
},
},
misc = {
codeium = "󰘦 ",
},
}

View File

@@ -9,14 +9,14 @@ else
require("halfdan.neogit")
-- require("halfdan.neorg")
require('halfdan.globals')
-- require('halfdan.globals')
require('halfdan.keymap')
require('halfdan.cmp')
-- require('halfdan.luasnip')
require('halfdan.colorscheme')
require('halfdan.treesitter')
require('halfdan.telescope')
require('halfdan.lualine')
-- require('halfdan.lualine')
require('halfdan.autocmds')

View File

@@ -16,5 +16,6 @@ M.nnoremap = bind("n")
M.vnoremap = bind("v")
M.xnoremap = bind("x")
M.inoremap = bind("i")
M.tnoremap = bind("t")
return M

View File

@@ -60,15 +60,34 @@ require("lazy").setup({
}
},
{"nvim-neotest/neotest-vim-test" },
{'akinsho/toggleterm.nvim', version = "*", config = function()
require('toggleterm').setup({
open_mapping = [[<C-\>]],
start_in_insert = true,
direction = "horizontal",
autochdir = false,
size = 20,
highlights = {
FloatBorder = { link = "ToggleTermBorder" },
Normal = { link = "ToggleTerm" },
NormalFloat = { link = "ToggleTerm" },
},
winbar = {
enabled = true,
name_formatter = function(term)
return term.name
end,
},
})
end},
{'preservim/tagbar'},
-- Status Line and Bufferline
{
'nvim-lualine/lualine.nvim',
dependencies = {'kyazdani42/nvim-web-devicons'}
},
-- {
-- 'nvim-lualine/lualine.nvim',
-- dependencies = {'kyazdani42/nvim-web-devicons'}
-- },
{'rcarriga/nvim-notify'},
@@ -88,7 +107,12 @@ require("lazy").setup({
{
'nvimdev/lspsaga.nvim',
config = function()
require('lspsaga').setup({})
require('lspsaga').setup({
symbol_in_winbar = {
enable = false,
},
})
end,
dependencies = {
'nvim-treesitter/nvim-treesitter', -- optional
@@ -188,13 +212,123 @@ require("lazy").setup({
},
{'tpope/vim-projectionist'},
-- themes & colorschemes
{'gruvbox-community/gruvbox'},
-- {'gruvbox-community/gruvbox'},
{'luisiacc/gruvbox-baby'},
{
'https://gitlab.com/__tpb/monokai-pro.nvim',
as = 'monokai-pro.nvim'
'https://github.com/loctvl842/monokai-pro.nvim',
as = 'monokai-pro.nvim',
config = function ()
local monokai = require("monokai-pro")
monokai.setup({
transparent_background = false,
terminal_colors = true,
devicons = true, -- highlight the icons of `nvim-web-devicons`
styles = {
comment = { italic = true },
keyword = { italic = true }, -- any other keyword
type = { italic = true }, -- (preferred) int, long, char, etc
storageclass = { italic = true }, -- static, register, volatile, etc
structure = { italic = true }, -- struct, union, enum, etc
parameter = { italic = true }, -- parameter pass in function
annotation = { italic = true },
tag_attribute = { italic = true }, -- attribute of tag in reactjs
},
filter = "classic", -- classic | octagon | pro | machine | ristretto | spectrum
-- Enable this will disable filter option
day_night = {
enable = false, -- turn off by default
day_filter = "classic", -- classic | octagon | pro | machine | ristretto | spectrum
night_filter = "spectrum", -- classic | octagon | pro | machine | ristretto | spectrum
},
inc_search = "background", -- underline | background
background_clear = {
"nvim-tree",
"neo-tree",
"bufferline",
"telescope",
"toggleterm",
},
plugins = {
bufferline = {
underline_selected = false,
underline_visible = false,
},
indent_blankline = {
context_highlight = "default", -- default | pro
context_start_underline = false,
},
},
override = function(c)
return {
ColorColumn = { bg = c.base.dimmed3 },
}
end,
})
monokai.load()
end
},
{'akinsho/bufferline.nvim', version = "*", dependencies = 'nvim-tree/nvim-web-devicons',
keys = {
{ "<C-1>", "<Cmd>BufferLineGoToBuffer 1<CR>", desc = "Go to buffer 1" },
{ "<C-2>", "<Cmd>BufferLineGoToBuffer 2<CR>", desc = "Go to buffer 2" },
{ "<C-3>", "<Cmd>BufferLineGoToBuffer 3<CR>", desc = "Go to buffer 3" },
{ "<C-4>", "<Cmd>BufferLineGoToBuffer 4<CR>", desc = "Go to buffer 4" },
{ "<C-5>", "<Cmd>BufferLineGoToBuffer 5<CR>", desc = "Go to buffer 5" },
{ "<C-6>", "<Cmd>BufferLineGoToBuffer 6<CR>", desc = "Go to buffer 6" },
{ "<C-7>", "<Cmd>BufferLineGoToBuffer 7<CR>", desc = "Go to buffer 7" },
{ "<C-8>", "<Cmd>BufferLineGoToBuffer 8<CR>", desc = "Go to buffer 8" },
{ "<C-9>", "<Cmd>BufferLineGoToBuffer 9<CR>", desc = "Go to buffer 9" },
{ "<S-l>", "<Cmd>BufferLineCycleNext<CR>", desc = "Next buffer" },
{ "<S-h>", "<Cmd>BufferLineCyclePrev<CR>", desc = "Previous buffer" },
{ "<A-S-l>", "<Cmd>BufferLineMoveNext<CR>", desc = "Move buffer right" },
{ "<A-S-h>", "<Cmd>BufferLineMovePrev<CR>", desc = "Move buffer left" },
},
opts = function()
local monokai_opts = require("halfdan.util").opts("monokai-pro.nvim")
return {
options = {
diagnostics = "nvim_lsp", -- | "nvim_lsp" | "coc",
-- separator_style = "", -- | "thick" | "thin" | "slope" | { 'any', 'any' },
separator_style = { "", "" }, -- | "thick" | "thin" | { 'any', 'any' },
-- separator_style = "slant", -- | "thick" | "thin" | { 'any', 'any' },
indicator = {
-- icon = " ",
-- style = 'icon',
style = "underline",
},
close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions"
diagnostics_indicator = function(count, _, _, _)
if count > 9 then
return "9+"
end
return tostring(count)
end,
numbers = function(opts)
return string.format('%s', opts.raise(opts.ordinal))
end,
offsets = {
{
filetype = "neo-tree",
text = "EXPLORER",
text_align = "center",
separator = vim.tbl_contains(monokai_opts.background_clear or {}, "neo-tree"), -- set to `true` if clear background of neo-tree
},
{
filetype = "NvimTree",
text = "EXPLORER",
text_align = "center",
separator = vim.tbl_contains(monokai_opts.background_clear or {}, "nvim-tree"), -- set to `true` if clear background of neo-tree
},
},
hover = {
enabled = true,
delay = 0,
reveal = { "close" },
},
},
}
end,
},
{
"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",

View File

@@ -9,7 +9,7 @@ end
require 'lualine'.setup {
options = {
icons_enabled = true,
theme = 'monokaipro',
theme = 'monokai-pro',
--component_separators = {'', ''},
--section_separators = {'', ''},
disabled_filetypes = {}

View File

@@ -54,8 +54,8 @@ vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
vim.o.laststatus = 3 -- Set global status bar
vim.b.did_ftplugin = 1
-- Enable telescope theme
vim.g.gruvbox_baby_telescope_theme = 1
vim.g.gruvbox_baby_background_color = "dark"
-- vim.g.gruvbox_baby_telescope_theme = 1
-- vim.g.gruvbox_baby_background_color = "dark"
vim.g.mapleader = ' '

View File

@@ -8,6 +8,7 @@ require('telescope').setup {
prompt_prefix = "",
selection_caret = "",
entry_prefix = " ",
-- borderchars = { "█", " ", "▀", "█", "█", " ", " ", "▀" },
file_sorter = require 'telescope'.extensions.fzf.get_fzf_sorter,
-- Developer configurations: Not meant for general override
mappings = {

View File

@@ -0,0 +1,245 @@
local M = {}
M.root_patterns = { ".git", "lua", "package.json", "mvnw", "gradlew", "pom.xml", "build.gradle", "release", ".project" }
M.augroup = function(name)
return vim.api.nvim_create_augroup("halfdan_" .. name, { clear = true })
end
M.has = function(plugin)
return require("lazy.core.config").plugins[plugin] ~= nil
end
function M.get_clients(...)
local fn = vim.lsp.get_clients or vim.lsp.get_active_clients
return fn(...)
end
--- @param on_attach fun(client, buffer)
M.on_attach = function(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end
M.get_highlight_value = function(group)
local found, hl = pcall(vim.api.nvim_get_hl_by_name, group, true)
if not found then
return {}
end
local hl_config = {}
for key, value in pairs(hl) do
_, hl_config[key] = pcall(string.format, "#%06x", value)
end
return hl_config
end
---@param name string
function M.opts(name)
local plugin = require("lazy.core.config").plugins[name]
if not plugin then
return {}
end
local Plugin = require("lazy.core.plugin")
return Plugin.values(plugin, "opts", false)
end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir
-- * root pattern of filename of the current buffer
-- * root pattern of cwd
---@return string
M.get_root = function()
---@type string?
local path = vim.api.nvim_buf_get_name(0)
path = path ~= "" and vim.loop.fs_realpath(path) or nil
---@type string[]
local roots = {}
if path then
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
local workspace = client.config.workspace_folders
local paths = workspace
and vim.tbl_map(function(ws)
return vim.uri_to_fname(ws.uri)
end, workspace)
or client.config.root_dir and { client.config.root_dir }
or {}
for _, p in ipairs(paths) do
local r = vim.loop.fs_realpath(p)
if path:find(r, 1, true) then
roots[#roots + 1] = r
end
end
end
end
table.sort(roots, function(a, b)
return #a > #b
end)
---@type string?
local root = roots[1]
if not root then
path = path and vim.fs.dirname(path) or vim.loop.cwd()
---@type string?
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
root = root and vim.fs.dirname(root) or vim.loop.cwd()
end
---@cast root string
return root
end
M.set_root = function(dir)
vim.api.nvim_set_current_dir(dir)
end
---@param type "ivy" | "dropdown" | "cursor" | nil
--- @param borderType "thin" | "thick" | "double" | "single" | "empty" | nil
M.telescope_theme = function(type, borderType)
if type == nil then
return {
borderchars = M.generate_borderchars(borderType),
layout_config = {
width = 80,
height = 0.5,
},
}
end
return require("telescope.themes")["get_" .. type]({
cwd = M.get_root(),
borderchars = M.generate_borderchars(borderType, nil, { top = "", top_left = "", top_right = "" }),
})
end
---@param builtin "find_files" | "live_grep" | "buffers"
---@param type "ivy" | "dropdown" | "cursor" | nil
M.telescope = function(builtin, type, opts)
local params = { builtin = builtin, type = type, opts = opts }
return function()
builtin = params.builtin
type = params.type
opts = params.opts
opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})
local theme
if vim.tbl_contains({ "ivy", "dropdown", "cursor" }, type) then
theme = M.telescope_theme(type)
else
theme = opts
end
require("telescope.builtin")[builtin](theme)
end
end
---@param name "autocmds" | "options" | "keymaps"
M.load = function(name)
local Util = require("lazy.core.util")
-- always load lazyvim, then user file
local mod = "halfdan.core." .. name
Util.try(function()
require(mod)
end, {
msg = "Failed loading " .. mod,
on_error = function(msg)
local modpath = require("lazy.core.cache").find(mod)
if modpath then
Util.error(msg)
end
end,
})
end
M.on_very_lazy = function(fn)
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = function()
fn()
end,
})
end
M.capabilities = function(ext)
return vim.tbl_deep_extend(
"force",
{},
ext or {},
require("cmp_nvim_lsp").default_capabilities(),
{ textDocument = { foldingRange = { dynamicRegistration = false, lineFoldingOnly = true } } }
)
end
M.notify = function(msg, level, opts)
opts = opts or {}
level = vim.log.levels[level:upper()]
if type(msg) == "table" then
msg = table.concat(msg, "\n")
end
local nopts = { title = "Nvim" }
if opts.once then
return vim.schedule(function()
vim.notify_once(msg, level, nopts)
end)
end
vim.schedule(function()
vim.notify(msg, level, nopts)
end)
end
--- @param type "thin" | "thick" | "double" | "single" | "empty" | nil
--- @param order "t-r-b-l-tl-tr-br-bl" | "tl-t-tr-r-br-b-bl-l" | nil
--- @param opts BorderIcons | nil
M.generate_borderchars = function(type, order, opts)
if order == nil then
order = "t-r-b-l-tl-tr-br-bl"
end
local border_icons = require("halfdan.icons").borders
--- @type BorderIcons
local border = vim.tbl_deep_extend("force", border_icons[type or "empty"], opts or {})
local borderchars = {}
local extractDirections = (function()
local index = 1
return function()
if index == nil then
return nil
end
-- Find the next occurence of `char`
local nextIndex = string.find(order, "-", index)
-- Extract the first direction
local direction = string.sub(order, index, nextIndex and nextIndex - 1)
-- Update the index to nextIndex
index = nextIndex and nextIndex + 1 or nil
return direction
end
end)()
local mappings = {
t = "top",
r = "right",
b = "bottom",
l = "left",
tl = "top_left",
tr = "top_right",
br = "bottom_right",
bl = "bottom_left",
}
local direction = extractDirections()
while direction do
if mappings[direction] == nil then
M.notify(string.format("Invalid direction '%s'", direction), "error")
end
borderchars[#borderchars + 1] = border[mappings[direction]]
direction = extractDirections()
end
if #borderchars ~= 8 then
M.notify(string.format("Invalid order '%s'", order), "error")
end
return borderchars
end
return M