first version, bunch of plugins, keymaps and configuration

This commit is contained in:
Noah Håkansson 2024-01-29 10:08:59 +01:00
parent 2510c29d62
commit ec6733a0ea
30 changed files with 1425 additions and 96 deletions

39
lua/custom/keymaps.lua Normal file
View file

@ -0,0 +1,39 @@
--
-- Additional keymaps
--
local wk = require('which-key')
-- basic navigation
wk.register({
['<leader>w'] = { name = '<C-w>', _ = 'which_key_ignore' },
})
vim.keymap.set('n', '<leader>wh', '<C-w>h', { noremap = true, silent = true, desc = 'move to left window' })
vim.keymap.set('n', '<leader>wj', '<C-w>j', { noremap = true, silent = true, desc = 'move to bottom window' })
vim.keymap.set('n', '<leader>wk', '<C-w>k', { noremap = true, silent = true, desc = 'move to top window' })
vim.keymap.set('n', '<leader>wl', '<C-w>l', { noremap = true, silent = true, desc = 'move to right window' })
vim.keymap.set('n', '<leader>ws', '<C-w>s', { noremap = true, silent = true, desc = 'split window horizontally' })
vim.keymap.set('n', '<leader>wv', '<C-w>v', { noremap = true, silent = true, desc = 'split window vertically' })
vim.keymap.set('n', '<leader>wc', '<C-w>c', { noremap = true, silent = true, desc = 'close window' })
vim.keymap.set('n', '<leader>wq', '<C-w>q', { noremap = true, silent = true, desc = 'quit window' })
vim.keymap.set('n', '<leader>wo', '<C-w>o', { noremap = true, silent = true, desc = 'close all other windows' })
vim.keymap.set('n', '<leader>ww', '<C-w>w', { noremap = true, silent = true, desc = 'move to next window' })
vim.keymap.set('n', '<leader>w+', '<C-w>+', { noremap = true, silent = true, desc = 'increase window height' })
vim.keymap.set('n', '<leader>w-', '<C-w>-', { noremap = true, silent = true, desc = 'decrease window height' })
vim.keymap.set('n', '<leader>w>', '<C-w>>', { noremap = true, silent = true, desc = 'increase window width' })
vim.keymap.set('n', '<leader>w<', '<C-w><', { noremap = true, silent = true, desc = 'decrease window width' })
vim.keymap.set('n', '<leader>w=', '<C-w>=', { noremap = true, silent = true, desc = 'balance window sizes' })
-- Turn off highlight when pressing Esc
vim.keymap.set('n', '<Esc>', '<cmd>noh <CR>', { noremap = false, silent = true })
-- fugitive
vim.keymap.set('n', '<leader>gg', '<cmd>G<cr>', { desc = 'fugitive' })
-- magical base64 encoding/decoding
vim.keymap.set('n', '<M-e>', 'viWy:let @"=system("openssl base64 -A", @")<cr>gv""P', { noremap = true, silent = true })
vim.keymap.set('n', '<M-d>', 'viWy:let @"=system("openssl base64 -A -d", @")<cr>gv""P', { noremap = true, silent = true })
-- Center next/previous search
vim.keymap.set('n', 'n', 'nzzzv', { noremap = true, silent = true })
vim.keymap.set('n', 'N', 'Nzzzv', { noremap = true, silent = true })

5
lua/custom/options.lua Normal file
View file

@ -0,0 +1,5 @@
--
-- Additional options
--
vim.o.cursorline = true

View file

@ -0,0 +1,12 @@
return {
'windwp/nvim-autopairs',
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup({})
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}

View file

@ -0,0 +1,38 @@
local M = {
'kevinhwang91/nvim-bqf',
event = 'VeryLazy',
}
function M.config()
require('bqf').setup({
auto_enable = true,
magic_window = true,
auto_resize_height = false,
preview = {
auto_preview = true,
show_title = true,
delay_syntax = 50,
wrap = false,
},
func_map = {
tab = 't',
openc = 'o',
drop = 'O',
split = 's',
vsplit = 'v',
stoggleup = 'M',
stoggledown = 'm',
stogglevm = 'm',
filterr = 'f',
filter = 'F',
prevhist = '<',
nexthist = '>',
sclear = 'c',
ptoggleitem = 'p',
ptoggleauto = 'a',
ptogglemode = 'P',
},
})
end
return M

View file

@ -0,0 +1,12 @@
local M = {
"LunarVim/breadcrumbs.nvim",
dependencies = {
{ "SmiteshP/nvim-navic" },
},
}
function M.config()
require("breadcrumbs").setup()
end
return M

View file

@ -0,0 +1,37 @@
local M = {
'NvChad/nvim-colorizer.lua',
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('colorizer').setup({
filetypes = { '*' },
user_default_options = {
RGB = true, -- #RGB hex codes #ABC
RRGGBB = true, -- #RRGGBB hex codes #777AAA
names = true, -- "Name" codes like Blue or blue
RRGGBBAA = false, -- #RRGGBBAA hex codes
AARRGGBB = false, -- 0xAARRGGBB hex codes
rgb_fn = true, -- CSS rgb() and rgba() functions
hsl_fn = true, -- CSS hsl() and hsla() functions
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn
-- Available modes for `mode`: foreground, background, virtualtext
mode = 'background', -- Set the display mode.
-- Available methods are false / true / "normal" / "lsp" / "both"
-- True is same as normal
tailwind = true, -- Enable tailwind colors
-- parsers can contain values used in |user_default_options|
sass = { enable = false, parsers = { 'css' } }, -- Enable sass colors
virtualtext = '',
-- update color values even if buffer is not focused
-- example use: cmp_menu, cmp_docs
always_update = false,
},
-- all the sub-options of filetypes apply to buftypes
buftypes = {},
})
end
return M

View file

@ -0,0 +1,29 @@
--
-- copilot setup config
--
local M = {
'zbirenbaum/copilot.lua',
event = 'BufRead',
}
-- Copilot setup
function M.config()
require('copilot').setup({
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 50,
keymap = {
accept = '<M-a>',
accept_word = '<M-w>',
accept_line = '<M-b>',
next = '<c-j>',
prev = '<c-k>',
dismiss = '<C-d>',
},
},
})
end
return M

View file

@ -0,0 +1,10 @@
local M = {
'nvim-tree/nvim-web-devicons',
event = 'VeryLazy',
}
function M.config()
require('nvim-web-devicons')
end
return M

View file

@ -0,0 +1,76 @@
--
-- dial.nvim
-- A plugin for incrementing and decrementing numbers, dates and switching booleans in Neovim.
--
local M = { 'monaqa/dial.nvim', event = 'VeryLazy' }
function M.config()
local status_ok, dial_config = pcall(require, 'dial.config')
if not status_ok then
return
end
local augend = require('dial.augend')
dial_config.augends:register_group({
default = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias['%Y/%m/%d'],
},
typescript = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.constant.new({ elements = { 'let', 'const' } }),
},
visual = {
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.date.alias['%Y/%m/%d'],
augend.constant.alias.alpha,
augend.constant.alias.Alpha,
},
mygroup = {
augend.constant.new({
elements = { 'and', 'or' },
word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc.
cyclic = true, -- "or" is incremented into "and".
}),
augend.constant.new({
elements = { 'True', 'False' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { 'public', 'private' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { 'sad', 'sad' },
word = true,
cyclic = true,
}),
augend.constant.new({
elements = { '&&', '||' },
word = false,
cyclic = true,
}),
augend.date.alias['%m/%d/%Y'], -- date (02/01/2022, etc.)
augend.constant.alias.bool, -- boolean value (true <-> false)
augend.integer.alias.decimal,
augend.integer.alias.hex,
augend.semver.alias.semver,
},
})
local map = require('dial.map')
-- change augends in VISUAL mode
vim.api.nvim_set_keymap('n', '<C-a>', map.inc_normal('mygroup'), { noremap = true })
vim.api.nvim_set_keymap('n', '<C-x>', map.dec_normal('mygroup'), { noremap = true })
vim.api.nvim_set_keymap('v', '<C-a>', map.inc_normal('visual'), { noremap = true })
vim.api.nvim_set_keymap('v', '<C-x>', map.dec_normal('visual'), { noremap = true })
end
return M

View file

@ -0,0 +1,97 @@
local M = {
'stevearc/dressing.nvim',
event = 'VeryLazy',
}
function M.config()
require('dressing').setup({
input = {
-- Set to false to disable the vim.ui.input implementation
enabled = true,
-- Default prompt string
default_prompt = 'Input:',
-- Can be 'left', 'right', or 'center'
title_pos = 'left',
-- When true, <Esc> will close the modal
insert_only = false,
-- When true, input will start in insert mode.
start_in_insert = true,
-- These are passed to nvim_open_win
border = 'rounded',
-- 'editor' and 'win' will default to being centered
relative = 'cursor',
-- These can be integers or a float between 0 and 1 (e.g. 0.4 for 40%)
prefer_width = 40,
width = nil,
-- min_width and max_width can be a list of mixed types.
-- min_width = {20, 0.2} means "the greater of 20 columns or 20% of total"
max_width = { 140, 0.9 },
min_width = { 40, 0.2 },
buf_options = {},
win_options = {
-- Window transparency (0-100)
winblend = 0,
-- Disable line wrapping
wrap = false,
-- Indicator for when text exceeds window
list = true,
listchars = 'precedes:…,extends:…',
-- Increase this for more context when text scrolls off the window
sidescrolloff = 0,
},
-- Set to `false` to disable
mappings = {
n = {
['<Esc>'] = 'Close',
['<CR>'] = 'Confirm',
},
i = {
['<C-c>'] = 'Close',
['<CR>'] = 'Confirm',
['<Up>'] = 'HistoryPrev',
['<Down>'] = 'HistoryNext',
},
},
override = function(conf)
-- This is the config that will be passed to nvim_open_win.
-- Change values here to customize the layout
return conf
end,
-- see :help dressing_get_config
get_config = nil,
},
select = {
-- Set to false to disable the vim.ui.select implementation
enabled = true,
-- Priority list of preferred vim.select implementations
backend = { 'telescope', 'fzf_lua', 'fzf', 'builtin', 'nui' },
-- Trim trailing `:` from prompt
trim_prompt = true,
-- Options for telescope selector
-- These are passed into the telescope picker directly. Can be used like:
-- telescope = require('telescope.themes').get_ivy({...})
telescope = nil,
-- Used to override format_item. See :help dressing-format
format_item_override = {},
-- see :help dressing_get_config
get_config = nil,
},
})
end
return M

View file

@ -0,0 +1,13 @@
local M = {
'jinh0/eyeliner.nvim',
event = 'VeryLazy',
}
function M.config()
require('eyeliner').setup({
highlight_on_key = true,
dim = true,
})
end
return M

View file

@ -0,0 +1,21 @@
local M = {
'ThePrimeagen/harpoon',
event = 'VeryLazy',
dependencies = {
{ 'nvim-lua/plenary.nvim' },
},
}
function M.config()
local keymap = vim.keymap.set
local opts = { noremap = true, silent = true }
keymap('n', '<M-a>', "<cmd>lua require('harpoon.mark').add_file()<cr>", opts)
keymap('n', '<M-f>', "<cmd>lua require('harpoon.ui').toggle_quick_menu()<cr>", opts)
keymap('n', '<C-h>', "<cmd>lua require('harpoon.ui').nav_file(1)<cr>", opts)
keymap('n', '<C-j>', "<cmd>lua require('harpoon.ui').nav_file(2)<cr>", opts)
keymap('n', '<C-k>', "<cmd>lua require('harpoon.ui').nav_file(3)<cr>", opts)
keymap('n', '<C-l>', "<cmd>lua require('harpoon.ui').nav_file(4)<cr>", opts)
end
return M

View file

@ -0,0 +1,100 @@
local M = {
'RRethy/vim-illuminate',
event = 'VeryLazy',
}
function M.config()
require('illuminate').configure({
-- providers: provider used to get references in the buffer, ordered by priority
providers = {
'lsp',
'treesitter',
'regex',
},
-- delay: delay in milliseconds
delay = 100,
-- filetype_overrides: filetype specific overrides.
-- The keys are strings to represent the filetype while the values are tables that
-- supports the same keys passed to .configure except for filetypes_denylist and filetypes_allowlist
filetype_overrides = {},
-- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist
filetypes_denylist = {
'mason',
'harpoon',
'DressingInput',
'NeogitCommitMessage',
'qf',
'dirvish',
'oil',
'minifiles',
'fugitive',
'alpha',
'NvimTree',
'lazy',
'NeogitStatus',
'Trouble',
'netrw',
'lir',
'DiffviewFiles',
'Outline',
'Jaq',
'spectre_panel',
'toggleterm',
'DressingSelect',
'TelescopePrompt',
},
-- filetypes_allowlist: filetypes to illuminate, this is overridden by filetypes_denylist
-- You must set filetypes_denylist = {} to override the defaults to allow filetypes_allowlist to take effect
filetypes_allowlist = {},
-- modes_denylist: modes to not illuminate, this overrides modes_allowlist
-- See `:help mode()` for possible values
modes_denylist = {},
-- modes_allowlist: modes to illuminate, this is overridden by modes_denylist
-- See `:help mode()` for possible values
modes_allowlist = {},
-- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist
-- Only applies to the 'regex' provider
-- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
providers_regex_syntax_denylist = {},
-- providers_regex_syntax_allowlist: syntax to illuminate, this is overridden by providers_regex_syntax_denylist
-- Only applies to the 'regex' provider
-- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
providers_regex_syntax_allowlist = {},
-- under_cursor: whether or not to illuminate under the cursor
under_cursor = true,
-- large_file_cutoff: number of lines at which to use large_file_config
-- The `under_cursor` option is disabled when this cutoff is hit
large_file_cutoff = nil,
-- large_file_config: config to use for large files (based on large_file_cutoff).
-- Supports the same keys passed to .configure
-- If nil, vim-illuminate will be disabled for large files.
large_file_overrides = nil,
-- min_count_to_highlight: minimum number of matches required to perform highlighting
min_count_to_highlight = 1,
-- should_enable: a callback that overrides all other settings to
-- enable/disable illumination. This will be called a lot so don't do
-- anything expensive in it.
should_enable = function(bufnr)
return true
end,
-- case_insensitive_regex: sets regex case sensitivity
case_insensitive_regex = false,
})
end
-- -- change the highlight style
-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' })
--
-- --- auto update the highlight style on colorscheme change
-- vim.api.nvim_create_autocmd({ 'ColorScheme' }, {
-- pattern = { '*' },
-- callback = function(ev)
-- vim.api.nvim_set_hl(0, 'IlluminatedWordText', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordRead', { link = 'Visual' })
-- vim.api.nvim_set_hl(0, 'IlluminatedWordWrite', { link = 'Visual' })
-- end,
-- })
return M

View file

@ -0,0 +1,20 @@
local M = {
'SmiteshP/nvim-navic',
}
function M.config()
local icons = require('utils.icons')
require('nvim-navic').setup({
icons = icons.kind,
highlight = true,
lsp = {
auto_attach = true,
},
click = true,
separator = ' ' .. icons.ui.ChevronRight .. ' ',
depth_limit = 0,
depth_limit_indicator = '..',
})
end
return M

View file

@ -0,0 +1,34 @@
local M = {
'nvimtools/none-ls.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
},
}
function M.config()
local null_ls = require('null-ls')
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
local code_actions = null_ls.builtins.code_actions
local completions = null_ls.builtins.completion
null_ls.setup({
debug = false,
sources = {
formatting.stylua,
formatting.black,
formatting.prettier.with({
extra_filetypes = { 'toml' },
-- extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" },
}),
formatting.eslint_d,
diagnostics.eslint_d,
null_ls.builtins.diagnostics.flake8,
-- diagnostics.flake8,
code_actions.eslint_d,
},
})
end
return M

View file

@ -0,0 +1,113 @@
local M = {
'nvim-tree/nvim-tree.lua',
event = 'VeryLazy',
}
local function my_on_attach(bufnr)
local api = require('nvim-tree.api')
local function opts(desc)
return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- default mappings
api.config.mappings.default_on_attach(bufnr)
-- custom mappings
vim.keymap.set('n', 'l', api.node.open.edit, opts('Open'))
vim.keymap.set('n', 'o', api.node.open.edit, opts('Open'))
vim.keymap.set('n', '<CR>', api.node.open.edit, opts('Open'))
vim.keymap.set('n', 'v', api.node.open.vertical, opts('Open: Vertical Split'))
vim.keymap.set('n', 'h', api.node.open.horizontal, opts('Open: Horizontal Split'))
vim.keymap.set('n', 'h', api.node.navigate.parent_close, opts('Close Directory'))
end
function M.config()
local wk = require('which-key')
wk.register({
['<leader>e'] = { '<cmd>NvimTreeToggle<CR>', 'Explorer' },
})
local icons = require('utils.icons')
require('nvim-tree').setup({
hijack_netrw = false,
sync_root_with_cwd = true,
on_attach = my_on_attach,
renderer = {
add_trailing = false,
group_empty = false,
highlight_git = false,
full_name = false,
highlight_opened_files = 'none',
root_folder_label = ':t',
indent_width = 2,
indent_markers = {
enable = false,
inline_arrows = true,
icons = {
corner = '',
edge = '',
item = '',
none = ' ',
},
},
icons = {
git_placement = 'before',
padding = ' ',
symlink_arrow = '',
glyphs = {
default = icons.ui.Text,
symlink = icons.ui.FileSymlink,
bookmark = icons.ui.BookMark,
folder = {
arrow_closed = icons.ui.ChevronRight,
arrow_open = icons.ui.ChevronShortDown,
default = icons.ui.Folder,
open = icons.ui.FolderOpen,
empty = icons.ui.EmptyFolder,
empty_open = icons.ui.EmptyFolderOpen,
symlink = icons.ui.FolderSymlink,
symlink_open = icons.ui.FolderOpen,
},
git = {
unstaged = icons.git.FileUnstaged,
staged = icons.git.FileStaged,
unmerged = icons.git.FileUnmerged,
renamed = icons.git.FileRenamed,
untracked = icons.git.FileUntracked,
deleted = icons.git.FileDeleted,
ignored = icons.git.FileIgnored,
},
},
},
special_files = { 'Cargo.toml', 'Makefile', 'README.md', 'readme.md' },
symlink_destination = true,
},
update_focused_file = {
enable = true,
debounce_delay = 15,
update_root = true,
ignore_list = {},
},
diagnostics = {
enable = true,
show_on_dirs = false,
show_on_open_dirs = true,
debounce_delay = 50,
severity = {
min = vim.diagnostic.severity.HINT,
max = vim.diagnostic.severity.ERROR,
},
icons = {
hint = icons.diagnostics.BoldHint,
info = icons.diagnostics.BoldInformation,
warning = icons.diagnostics.BoldWarning,
error = icons.diagnostics.BoldError,
},
},
})
end
return M

View file

@ -0,0 +1,8 @@
local M = {
'b0o/schemastore.nvim',
lazy = true,
}
function M.config() end
return M

View file

@ -0,0 +1,16 @@
local M = {
'gbprod/substitute.nvim',
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('substitute').setup()
end
vim.api.nvim_set_keymap('n', 's', "<cmd>lua require('substitute').operator()<cr>", { noremap = true })
vim.api.nvim_set_keymap('n', 'ss', "<cmd>lua require('substitute').line()<cr>", { noremap = true })
vim.api.nvim_set_keymap('n', 'S', "<cmd>lua require('substitute').eol()<cr>", { noremap = true })
vim.api.nvim_set_keymap('x', 's', "<cmd>lua require('substitute').visual()<cr>", { noremap = true })
return M

View file

@ -0,0 +1,14 @@
local M = {
'kylechui/nvim-surround',
version = '*', -- Use for stability; omit to use `main` branch for the latest features
lazy = true,
event = 'VeryLazy',
}
function M.config()
require('nvim-surround').setup({
-- Configuration here, or leave empty to use defaults
})
end
return M

View file

@ -0,0 +1,37 @@
local M = {
'pmizio/typescript-tools.nvim',
dependencies = { 'nvim-lua/plenary.nvim', 'neovim/nvim-lspconfig' },
opts = {},
}
function M.config()
require('typescript-tools').setup({
settings = {
-- spawn additional tsserver instance to calculate diagnostics on it
separate_diagnostic_server = true,
-- "change"|"insert_leave" determine when the client asks the server about diagnostic
publish_diagnostic_on = 'insert_leave',
-- array of strings("fix_all"|"add_missing_imports"|"remove_unused")
-- specify commands exposed as code_actions
expose_as_code_action = {},
-- string|nil - specify a custom path to `tsserver.js` file, if this is nil or file under path
-- not exists then standard path resolution strategy is applied
tsserver_path = nil,
-- specify a list of plugins to load by tsserver, e.g., for support `styled-components`
-- (see 💅 `styled-components` support section)
tsserver_plugins = {},
-- this value is passed to: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
-- memory limit in megabytes or "auto"(basically no limit)
tsserver_max_memory = 'auto',
-- described below
tsserver_format_options = {},
tsserver_file_preferences = {
-- importModuleSpecifierPreference = "project-relative",
},
-- mirror of VSCode's `typescript.suggest.completeFunctionCalls`
complete_function_calls = false,
},
})
end
return M

158
lua/utils/icons.lua Normal file
View file

@ -0,0 +1,158 @@
return {
kind = {
Array = '',
Boolean = '',
Class = '',
Color = '',
Constant = '',
Constructor = '',
Enum = '',
EnumMember = '',
Event = '',
Field = '',
File = '',
Folder = '󰉋 ',
Function = '',
Interface = '',
Key = '',
Keyword = '',
Method = '',
-- Module = " ",
Module = '',
Namespace = '',
Null = '󰟢 ',
Number = '',
Object = '',
Operator = '',
Package = '',
Property = '',
Reference = '',
Snippet = '',
String = '',
Struct = '',
Text = '',
TypeParameter = '',
Unit = '',
Value = '',
Variable = '',
},
git = {
LineAdded = '',
LineModified = '',
LineRemoved = '',
FileDeleted = '',
FileIgnored = '',
FileRenamed = '',
FileStaged = 'S',
FileUnmerged = '',
FileUnstaged = '',
FileUntracked = 'U',
Diff = '',
Repo = '',
Octoface = '',
Copilot = '',
Branch = '',
},
ui = {
ArrowCircleDown = '',
ArrowCircleLeft = '',
ArrowCircleRight = '',
ArrowCircleUp = '',
BoldArrowDown = '',
BoldArrowLeft = '',
BoldArrowRight = '',
BoldArrowUp = '',
BoldClose = '',
BoldDividerLeft = '',
BoldDividerRight = '',
BoldLineLeft = '',
BoldLineMiddle = '',
BoldLineDashedMiddle = '',
BookMark = '',
BoxChecked = '',
Bug = '',
Stacks = '',
Scopes = '',
Watches = '󰂥',
DebugConsole = '',
Calendar = '',
Check = '',
ChevronRight = '',
ChevronShortDown = '',
ChevronShortLeft = '',
ChevronShortRight = '',
ChevronShortUp = '',
Circle = '',
Close = '󰅖',
CloudDownload = '',
Code = '',
Comment = '',
Dashboard = '',
DividerLeft = '',
DividerRight = '',
DoubleChevronRight = '»',
Ellipsis = '',
EmptyFolder = '',
EmptyFolderOpen = '',
File = '',
FileSymlink = '',
Files = '',
FindFile = '󰈞',
FindText = '󰊄',
Fire = '',
Folder = '󰉋 ',
FolderOpen = '',
FolderSymlink = '',
Forward = '',
Gear = '',
History = '',
Lightbulb = '',
LineLeft = '',
LineMiddle = '',
List = '',
Lock = '',
NewFile = ' ',
Note = '',
Package = '',
Pencil = '󰏫 ',
Plus = '',
Project = '',
Search = '',
SignIn = '',
SignOut = '',
Tab = '󰌒 ',
Table = '',
Target = '󰀘 ',
Telescope = '',
Text = '',
Tree = '',
Triangle = '󰐊',
TriangleShortArrowDown = '',
TriangleShortArrowLeft = '',
TriangleShortArrowRight = '',
TriangleShortArrowUp = '',
},
diagnostics = {
BoldError = '',
Error = '',
BoldWarning = '',
Warning = '',
BoldInformation = '',
Information = '',
BoldQuestion = '',
Question = '',
BoldHint = '',
Hint = '󰌶',
Debug = '',
Trace = '',
},
misc = {
Robot = '󰚩 ',
Squirrel = '',
Tag = '',
Watch = '',
Smiley = '',
Package = '',
CircuitBoard = '',
},
}

View file

@ -0,0 +1,16 @@
local colors = {
bg = '#202328',
fg = '#bbc2cf',
yellow = '#ECBE7B',
cyan = '#008080',
darkblue = '#081633',
green = '#98be65',
orange = '#FF8800',
violet = '#a9a1e1',
magenta = '#c678dd',
purple = '#c678dd',
blue = '#51afef',
red = '#ec5f67',
}
return colors

View file

@ -0,0 +1,163 @@
--
-- This file contains the components that are used in the lualine configuration
--
local icons = require('utils.icons')
local conditions = require('utils.lualine.conditions')
local colors = require('utils.lualine.colors')
return {
branch = {
'b:gitsigns_head',
icon = icons.git.Branch,
color = { gui = 'bold' },
},
filename = {
'filename',
color = {},
cond = nil,
},
diff = {
'diff',
symbols = {
added = icons.git.LineAdded .. ' ',
modified = icons.git.LineModified .. ' ',
removed = icons.git.LineRemoved .. ' ',
},
padding = { left = 2, right = 1 },
diff_color = {
added = { fg = colors.green },
modified = { fg = colors.yellow },
removed = { fg = colors.red },
},
cond = nil,
},
diagnostics = {
'diagnostics',
sources = { 'nvim_diagnostic' },
symbols = {
error = icons.diagnostics.BoldError .. ' ',
warn = icons.diagnostics.BoldWarning .. ' ',
info = icons.diagnostics.BoldInformation .. ' ',
hint = icons.diagnostics.BoldHint .. ' ',
},
-- cond = conditions.hide_in_width,
},
treesitter = {
function()
return icons.ui.Tree
end,
color = function()
local buf = vim.api.nvim_get_current_buf()
local ts = vim.treesitter.highlighter.active[buf]
return { fg = ts and not vim.tbl_isempty(ts) and colors.green or colors.red }
end,
cond = conditions.hide_in_width,
},
copilot = {
function()
local client = require('copilot.client')
local copilot_active = client.buf_is_attached(vim.api.nvim_get_current_buf())
-- local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 })
-- local copilot_active = false
--
-- -- look for copilot client
-- for _, client in pairs(buf_clients) do
-- if client.name == 'copilot' then
-- copilot_active = true
-- end
-- end
--
if copilot_active then
return icons.git.Copilot
end
return ''
end,
color = function()
local api = require('copilot.api')
local status = api.status.data.status
if status == 'InProgress' then
return { gui = 'bold', fg = colors.yellow }
elseif status == 'Warning' then
return { gui = 'bold', fg = colors.red }
end
return { gui = 'bold', fg = colors.green }
end,
cond = conditions.hide_in_width,
},
lsp = {
function()
local buf_clients = vim.lsp.get_active_clients({ bufnr = 0 })
if #buf_clients == 0 then
return 'LSP Inactive'
end
local buf_ft = vim.bo.filetype
local buf_client_names = {}
-- add client
for _, client in pairs(buf_clients) do
if client.name ~= 'null-ls' and client.name ~= 'copilot' then
table.insert(buf_client_names, client.name)
end
end
-- add formatter
local formatters = require('utils.none-ls.formatters')
local supported_formatters = formatters.list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_formatters)
-- add linter
local linters = require('utils.none-ls.linters')
local supported_linters = linters.list_registered(buf_ft)
vim.list_extend(buf_client_names, supported_linters)
local unique_client_names = vim.fn.uniq(buf_client_names)
local language_servers = '[' .. table.concat(unique_client_names, ', ') .. ']'
return language_servers
end,
color = { gui = 'bold' },
cond = conditions.hide_in_width,
},
location = { 'location' },
progress = {
'progress',
fmt = function()
return '%P/%L'
end,
color = {},
},
spaces = {
function()
local shiftwidth = vim.api.nvim_buf_get_option(0, 'shiftwidth')
return icons.ui.Tab .. ' ' .. shiftwidth
end,
padding = 1,
},
encoding = {
'o:encoding',
fmt = string.upper,
color = {},
cond = conditions.hide_in_width,
},
filetype = { 'filetype', cond = nil, padding = { left = 1, right = 1 } },
scrollbar = {
function()
local current_line = vim.fn.line('.')
local total_lines = vim.fn.line('$')
local chars = { '__', '▁▁', '▂▂', '▃▃', '▄▄', '▅▅', '▆▆', '▇▇', '██' }
local line_ratio = current_line / total_lines
local index = math.ceil(line_ratio * #chars)
return chars[index]
end,
padding = { left = 0, right = 0 },
color = 'SLProgress',
cond = nil,
},
}

View file

@ -0,0 +1,17 @@
local window_width_limit = 100
local conditions = {
buffer_not_empty = function()
return vim.fn.empty(vim.fn.expand('%:t')) ~= 1
end,
hide_in_width = function()
return vim.o.columns > window_width_limit
end,
-- check_git_workspace = function()
-- local filepath = vim.fn.expand "%:p:h"
-- local gitdir = vim.fn.finddir(".git", filepath .. ";")
-- return gitdir and #gitdir > 0 and #gitdir < #filepath
-- end,
}
return conditions

View file

@ -0,0 +1,31 @@
local M = {}
local null_ls = require('null-ls')
local services = require('utils.none-ls.services')
local method = null_ls.methods.FORMATTING
function M.list_registered(filetype)
local registered_providers = services.list_registered_providers_names(filetype)
return registered_providers[method] or {}
end
function M.list_supported(filetype)
local s = require('null-ls.sources')
local supported_formatters = s.get_supported(filetype, 'formatting')
table.sort(supported_formatters)
return supported_formatters
end
function M.setup(formatter_configs)
if vim.tbl_isempty(formatter_configs) then
return
end
local registered = services.register_sources(formatter_configs, method)
if #registered > 0 then
vim.notify('Registered the following formatters: ' .. unpack(registered), vim.log.levels.DEBUG)
end
end
return M

View file

@ -0,0 +1,41 @@
local M = {}
local null_ls = require('null-ls')
local services = require('utils.none-ls.services')
local method = null_ls.methods.DIAGNOSTICS
local alternative_methods = {
null_ls.methods.DIAGNOSTICS,
null_ls.methods.DIAGNOSTICS_ON_OPEN,
null_ls.methods.DIAGNOSTICS_ON_SAVE,
}
function M.list_registered(filetype)
local registered_providers = services.list_registered_providers_names(filetype)
local providers_for_methods = vim.tbl_flatten(vim.tbl_map(function(m)
return registered_providers[m] or {}
end, alternative_methods))
return providers_for_methods
end
function M.list_supported(filetype)
local s = require('null-ls.sources')
local supported_linters = s.get_supported(filetype, 'diagnostics')
table.sort(supported_linters)
return supported_linters
end
function M.setup(linter_configs)
if vim.tbl_isempty(linter_configs) then
return
end
local registered = services.register_sources(linter_configs, method)
if #registered > 0 then
vim.notify('Registered the following linters: ' .. unpack(registered), vim.log.levels.DEBUG)
end
end
return M

View file

@ -0,0 +1,56 @@
local M = {}
function M.list_registered_providers_names(filetype)
local s = require('null-ls.sources')
local available_sources = s.get_available(filetype)
local registered = {}
for _, source in ipairs(available_sources) do
for method in pairs(source.methods) do
registered[method] = registered[method] or {}
table.insert(registered[method], source.name)
end
end
return registered
end
function M.register_sources(configs, method)
local null_ls = require('null-ls')
local is_registered = require('null-ls.sources').is_registered
local sources, registered_names = {}, {}
for _, config in ipairs(configs) do
local cmd = config.exe or config.command
local name = config.name or cmd:gsub('-', '_')
local type = method == null_ls.methods.CODE_ACTION and 'code_actions' or null_ls.methods[method]:lower()
local source = type and null_ls.builtins[type][name]
vim.notify(string.format('Received request to register [%s] as a %s source', name, type), vim.log.levels.DEBUG)
if not source then
vim.notify('Not a valid source: ' .. name, vim.log.levels.ERROR)
elseif is_registered({ name = source.name or name, method = method }) then
vim.notify(string.format('Skipping registering [%s] more than once', name), vim.log.levels.TRACE)
else
local command = M.find_command(source._opts.command) or source._opts.command
-- treat `args` as `extra_args` for backwards compatibility. Can otherwise use `generator_opts.args`
local compat_opts = vim.deepcopy(config)
if config.args then
compat_opts.extra_args = config.args or config.extra_args
compat_opts.args = nil
end
local opts = vim.tbl_deep_extend('keep', { command = command }, compat_opts)
vim.notify('Registering source ' .. name, vim.log.levels.DEBUG)
vim.notify(vim.inspect(opts), vim.log.levels.TRACE)
table.insert(sources, source.with(opts))
vim.list_extend(registered_names, { source.name })
end
end
if #sources > 0 then
null_ls.register({ sources = sources })
end
return registered_names
end
return M