mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-26 02:38:30 +02:00
fix: neovim
This commit is contained in:
257
home/base/desktop/neovim/lua/modules/completion/config.lua
Normal file
257
home/base/desktop/neovim/lua/modules/completion/config.lua
Normal file
@@ -0,0 +1,257 @@
|
||||
local config = {}
|
||||
|
||||
-- config language servers in this function
|
||||
-- https://github.com/williamboman/nvim-lsp-installer#available-lsps
|
||||
function config.nvim_lsp()
|
||||
local nvim_lsp = require("lspconfig")
|
||||
|
||||
-- Add additional capabilities supported by nvim-cmp
|
||||
-- nvim hasn't added foldingRange to default capabilities, users must add it manually
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
|
||||
--Change diagnostic symbols in the sign column (gutter)
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
local on_attach = function(bufnr)
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
local opts = {
|
||||
focusable = false,
|
||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
prefix = " ",
|
||||
scope = "line",
|
||||
}
|
||||
vim.diagnostic.show()
|
||||
vim.diagnostic.open_float(nil, opts)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- nix
|
||||
-- nvim_lsp.nixd.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- capabilities = capabilities,
|
||||
-- })
|
||||
--nvim_lsp.rnix.setup({
|
||||
-- on_attach = on_attach(),
|
||||
-- capabilities = capabilities,
|
||||
--})
|
||||
nvim_lsp.nil_ls.setup({
|
||||
on_attach = on_attach(),
|
||||
settings = {
|
||||
["nil"] = {
|
||||
nix = {
|
||||
flake = {
|
||||
autoArchive = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- GoLang
|
||||
nvim_lsp["gopls"].setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
gopls = {
|
||||
experimentalPostfixCompletions = true,
|
||||
analyses = {
|
||||
unusedparams = true,
|
||||
shadow = true,
|
||||
},
|
||||
staticcheck = true,
|
||||
},
|
||||
},
|
||||
init_options = {
|
||||
usePlaceholders = true,
|
||||
},
|
||||
})
|
||||
|
||||
nvim_lsp.clangd.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
|
||||
--Python
|
||||
nvim_lsp.pyright.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = "workspace",
|
||||
useLibraryCodeForTypes = true,
|
||||
typeCheckingMode = "off",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
--sumneko_lua
|
||||
nvim_lsp.lua_ls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
||||
version = "LuaJIT",
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
},
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized but unique identifier
|
||||
telemetry = {
|
||||
enable = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
nvim_lsp.rust_analyzer.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
})
|
||||
nvim_lsp.html.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-html-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.cssls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "vscode-css-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.tsserver.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "typescript-language-server", "--stdio" },
|
||||
})
|
||||
|
||||
nvim_lsp.bashls.setup({
|
||||
on_attach = on_attach(),
|
||||
capabilities = capabilities,
|
||||
cmd = { "bash-language-server", "start" },
|
||||
})
|
||||
end
|
||||
|
||||
function config.nvim_cmp()
|
||||
local cmp = require('cmp')
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
-- find more here: https://www.nerdfonts.com/cheat-sheet
|
||||
|
||||
cmp.setup({
|
||||
preselect = cmp.PreselectMode.Item,
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
|
||||
formatting = {
|
||||
fields = { "kind", "abbr", "menu" },
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format("%s", kind_icons[vim_item.kind])
|
||||
-- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
|
||||
vim_item.menu = ({
|
||||
path = "[Path]",
|
||||
nvim_lua = "[NVIM_LUA]",
|
||||
nvim_lsp = "[LSP]",
|
||||
luasnip = "[Snippet]",
|
||||
buffer = "[Buffer]",
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lua" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.lua_snip()
|
||||
local ls = require('luasnip')
|
||||
local types = require('luasnip.util.types')
|
||||
ls.config.set_config({
|
||||
history = true,
|
||||
enable_autosnippets = true,
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = { { '<- choiceNode', 'Comment' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
require('luasnip.loaders.from_lua').lazy_load({ paths = vim.fn.stdpath('config') .. '/snippets' })
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
require('luasnip.loaders.from_vscode').lazy_load({
|
||||
paths = { './snippets/' },
|
||||
})
|
||||
end
|
||||
|
||||
function config.lspsaga()
|
||||
require('lspsaga').setup({})
|
||||
end
|
||||
return config
|
||||
105
home/base/desktop/neovim/lua/modules/completion/package.lua
Normal file
105
home/base/desktop/neovim/lua/modules/completion/package.lua
Normal file
@@ -0,0 +1,105 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.completion.config')
|
||||
|
||||
package({
|
||||
'neovim/nvim-lspconfig',
|
||||
-- used filetype to lazyload lsp
|
||||
-- config your language filetype in here
|
||||
ft = { 'lua', 'rust', 'c', 'cpp', 'go', 'py', 'nix', 'c', 'cpp', 'js' },
|
||||
config = conf.nvim_lsp,
|
||||
})
|
||||
|
||||
package({
|
||||
'glepnir/lspsaga.nvim',
|
||||
event = 'BufRead',
|
||||
dev = false,
|
||||
config = conf.lspsaga,
|
||||
})
|
||||
|
||||
package({
|
||||
'hrsh7th/nvim-cmp',
|
||||
event = 'InsertEnter',
|
||||
config = conf.nvim_cmp,
|
||||
dependencies = {
|
||||
{ 'hrsh7th/cmp-nvim-lsp' },
|
||||
{ 'hrsh7th/cmp-path' },
|
||||
{ 'hrsh7th/cmp-buffer' },
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
},
|
||||
})
|
||||
|
||||
package({ 'L3MON4D3/LuaSnip', event = 'InsertCharPre', config = conf.lua_snip })
|
||||
|
||||
-- Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
|
||||
package({
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
require("null-ls").setup({
|
||||
sources = {
|
||||
-- you must download code formatter by yourself!
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.formatting.black, -- python
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
require("null-ls").builtins.formatting.gofmt, -- provide by go itself
|
||||
require("null-ls").builtins.formatting.nixpkgs_fmt,
|
||||
require("null-ls").builtins.formatting.beautysh,
|
||||
require("null-ls").builtins.formatting.rustfmt,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
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({ async = false })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- A super powerful autopair plugin for Neovim that supports multiple characters.
|
||||
package({
|
||||
"windwp/nvim-autopairs",
|
||||
dependencies = { "hrsh7th/nvim-cmp" },
|
||||
event = "InsertEnter",
|
||||
config = function()
|
||||
local status_ok, npairs = pcall(require, "nvim-autopairs")
|
||||
if not status_ok then
|
||||
return
|
||||
end
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { "string", "source" },
|
||||
javascript = { "string", "template_string" },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
fast_wrap = {
|
||||
map = "<M-e>",
|
||||
chars = { "{", "[", "(", '"', "'" },
|
||||
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""),
|
||||
offset = 0, -- Offset from pattern match
|
||||
end_key = "$",
|
||||
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||
check_comma = true,
|
||||
highlight = "PmenuSel",
|
||||
highlight_grey = "LineNr",
|
||||
},
|
||||
})
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if not cmp_status_ok then
|
||||
return
|
||||
end
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done({ map_char = { tex = "" } }))
|
||||
end,
|
||||
})
|
||||
26
home/base/desktop/neovim/lua/modules/editor/config.lua
Normal file
26
home/base/desktop/neovim/lua/modules/editor/config.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
local config = {}
|
||||
|
||||
function config.nvim_treesitter()
|
||||
vim.api.nvim_command('set foldmethod=expr')
|
||||
vim.api.nvim_command('set foldexpr=nvim_treesitter#foldexpr()')
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = 'all',
|
||||
ignore_install = { 'phpdoc' },
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return config
|
||||
12
home/base/desktop/neovim/lua/modules/editor/package.lua
Normal file
12
home/base/desktop/neovim/lua/modules/editor/package.lua
Normal file
@@ -0,0 +1,12 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.editor.config')
|
||||
|
||||
package({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
event = 'BufRead',
|
||||
run = ':TSUpdate',
|
||||
config = conf.nvim_treesitter,
|
||||
dependencies = {
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
},
|
||||
})
|
||||
25
home/base/desktop/neovim/lua/modules/tools/config.lua
Normal file
25
home/base/desktop/neovim/lua/modules/tools/config.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
local config = {}
|
||||
|
||||
function config.telescope()
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
layout_config = {
|
||||
horizontal = { prompt_position = 'top', results_width = 0.6 },
|
||||
vertical = { mirror = false },
|
||||
},
|
||||
sorting_strategy = 'ascending',
|
||||
file_previewer = require('telescope.previewers').vim_buffer_cat.new,
|
||||
grep_previewer = require('telescope.previewers').vim_buffer_vimgrep.new,
|
||||
qflist_previewer = require('telescope.previewers').vim_buffer_qflist.new,
|
||||
},
|
||||
extensions = {
|
||||
fzy_native = {
|
||||
override_generic_sorter = false,
|
||||
override_file_sorter = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
require('telescope').load_extension('fzy_native')
|
||||
end
|
||||
|
||||
return config
|
||||
27
home/base/desktop/neovim/lua/modules/tools/package.lua
Normal file
27
home/base/desktop/neovim/lua/modules/tools/package.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.tools.config')
|
||||
|
||||
package({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
cmd = 'Telescope',
|
||||
config = conf.telescope,
|
||||
dependencies = {
|
||||
{ 'nvim-lua/plenary.nvim' },
|
||||
{ 'nvim-telescope/telescope-fzy-native.nvim' },
|
||||
},
|
||||
})
|
||||
|
||||
package({
|
||||
'glepnir/hlsearch.nvim',
|
||||
event = 'BufRead',
|
||||
config = function()
|
||||
require('hlsearch').setup()
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- Copilot AI Assistant
|
||||
-- have no options, but need to run `:Copilot setup` after start neovim to login.
|
||||
package({
|
||||
'github/copilot.vim',
|
||||
})
|
||||
67
home/base/desktop/neovim/lua/modules/ui/config.lua
Normal file
67
home/base/desktop/neovim/lua/modules/ui/config.lua
Normal file
@@ -0,0 +1,67 @@
|
||||
local config = {}
|
||||
|
||||
function config.zephyr()
|
||||
vim.cmd('colorscheme zephyr')
|
||||
end
|
||||
|
||||
function config.dashboard()
|
||||
local db = require('dashboard')
|
||||
db.setup({
|
||||
theme = 'hyper',
|
||||
config = {
|
||||
week_header = {
|
||||
enable = true,
|
||||
},
|
||||
shortcut = {
|
||||
{ desc = ' Update', group = '@property', action = 'Lazy update', key = 'u' },
|
||||
{
|
||||
desc = ' Files',
|
||||
group = 'Label',
|
||||
action = 'Telescope find_files',
|
||||
key = 'f',
|
||||
},
|
||||
{
|
||||
desc = ' Apps',
|
||||
group = 'DiagnosticHint',
|
||||
action = 'Telescope app',
|
||||
key = 'a',
|
||||
},
|
||||
{
|
||||
desc = ' dotfiles',
|
||||
group = 'Number',
|
||||
action = 'Telescope dotfiles',
|
||||
key = 'd',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.nvim_bufferline()
|
||||
require('bufferline').setup({
|
||||
options = {
|
||||
modified_icon = '✥',
|
||||
buffer_close_icon = '',
|
||||
always_show_bufferline = true,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function config.indent_blankline()
|
||||
require('indent_blankline').setup({
|
||||
char = '│',
|
||||
use_treesitter_scope = true,
|
||||
show_first_indent_level = true,
|
||||
show_current_context = false,
|
||||
show_current_context_start = false,
|
||||
show_current_context_start_on_current_line = false,
|
||||
filetype_exclude = {
|
||||
'dashboard',
|
||||
'log',
|
||||
'TelescopePrompt',
|
||||
},
|
||||
buftype_exclude = { 'terminal', 'nofile', 'prompt' },
|
||||
})
|
||||
end
|
||||
|
||||
return config
|
||||
367
home/base/desktop/neovim/lua/modules/ui/package.lua
Normal file
367
home/base/desktop/neovim/lua/modules/ui/package.lua
Normal file
@@ -0,0 +1,367 @@
|
||||
local package = require('core.pack').package
|
||||
local conf = require('modules.ui.config')
|
||||
|
||||
package({ 'glepnir/zephyr-nvim', config = conf.zephyr })
|
||||
|
||||
package({ 'glepnir/dashboard-nvim', config = conf.dashboard })
|
||||
|
||||
package({
|
||||
'akinsho/nvim-bufferline.lua',
|
||||
config = conf.nvim_bufferline,
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
})
|
||||
|
||||
package({
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
event = 'BufRead',
|
||||
config = conf.indent_blankline,
|
||||
})
|
||||
|
||||
|
||||
--
|
||||
package({
|
||||
'nvim-neo-tree/neo-tree.nvim',
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("neo-tree").setup({
|
||||
default_component_configs = {
|
||||
icon = {
|
||||
folder_empty = "",
|
||||
folder_empty_open = "",
|
||||
},
|
||||
git_status = {
|
||||
symbols = {
|
||||
renamed = "",
|
||||
unstaged = "",
|
||||
},
|
||||
},
|
||||
},
|
||||
document_symbols = {
|
||||
kinds = {
|
||||
File = { icon = "", hl = "Tag" },
|
||||
Namespace = { icon = "", hl = "Include" },
|
||||
Package = { icon = "", hl = "Label" },
|
||||
Class = { icon = "", hl = "Include" },
|
||||
Property = { icon = "", hl = "@property" },
|
||||
Enum = { icon = "", hl = "@number" },
|
||||
Function = { icon = "", hl = "Function" },
|
||||
String = { icon = "", hl = "String" },
|
||||
Number = { icon = "", hl = "Number" },
|
||||
Array = { icon = "", hl = "Type" },
|
||||
Object = { icon = "", hl = "Type" },
|
||||
Key = { icon = "", hl = "" },
|
||||
Struct = { icon = "", hl = "Type" },
|
||||
Operator = { icon = "", hl = "Operator" },
|
||||
TypeParameter = { icon = "", hl = "Type" },
|
||||
StaticMethod = { icon = ' ', hl = 'Function' },
|
||||
}
|
||||
},
|
||||
-- Add this section only if you've configured source selector.
|
||||
source_selector = {
|
||||
sources = {
|
||||
{ source = "filesystem", display_name = " Files " },
|
||||
{ source = "git_status", display_name = " Git " },
|
||||
},
|
||||
},
|
||||
-- Other options ...
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
-- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
|
||||
package({
|
||||
"folke/noice.nvim",
|
||||
event = "VeryLazy",
|
||||
dependencies = {
|
||||
"MunifTanjim/nui.nvim",
|
||||
"rcarriga/nvim-notify",
|
||||
},
|
||||
config = function()
|
||||
require("noice").setup({
|
||||
routes = {
|
||||
{
|
||||
view = "notify",
|
||||
filter = { event = "msg_showmode" },
|
||||
},
|
||||
},
|
||||
views = {
|
||||
cmdline_popup = {
|
||||
position = {
|
||||
row = 5,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = "auto",
|
||||
},
|
||||
},
|
||||
popupmenu = {
|
||||
relative = "editor",
|
||||
position = {
|
||||
row = 8,
|
||||
col = "50%",
|
||||
},
|
||||
size = {
|
||||
width = 60,
|
||||
height = 10,
|
||||
},
|
||||
border = {
|
||||
style = "rounded",
|
||||
padding = { 0, 1 },
|
||||
},
|
||||
win_options = {
|
||||
winhighlight = { Normal = "Normal", FloatBorder = "DiagnosticInfo" },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- bottom statusline
|
||||
package({
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "BufWinEnter",
|
||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
||||
config = function()
|
||||
local lualine = require("lualine")
|
||||
|
||||
-- Color table for highlights
|
||||
-- stylua: ignore
|
||||
local colors = {
|
||||
-- Nordic - dark theme
|
||||
bg = '#3B4252',
|
||||
fg = '#D6DCE7',
|
||||
custom = '#B38DAC',
|
||||
|
||||
-- Catppuccin - dark pink theme
|
||||
-- bg = '#302D41',
|
||||
-- fg = '#bbc2cf',
|
||||
-- custom = '#b0c4de',
|
||||
|
||||
-- Light Theme
|
||||
-- bg = '#FAF4FC',
|
||||
-- fg = '#1E1E2E',
|
||||
-- custom = '#FF99CC',
|
||||
|
||||
yellow = '#ECBE7B',
|
||||
cyan = '#008080',
|
||||
darkblue = '#081633',
|
||||
green = '#98be65',
|
||||
orange = '#FF8800',
|
||||
violet = '#a9a1e1',
|
||||
magenta = '#c678dd',
|
||||
blue = '#51afef',
|
||||
red = '#ec5f67',
|
||||
}
|
||||
|
||||
|
||||
|
||||
local conditions = {
|
||||
buffer_not_empty = function()
|
||||
return vim.fn.empty(vim.fn.expand("%:t")) ~= 1
|
||||
end,
|
||||
hide_in_width = function()
|
||||
return vim.fn.winwidth(0) > 80
|
||||
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,
|
||||
}
|
||||
|
||||
-- Config
|
||||
local config = {
|
||||
options = {
|
||||
-- Disable sections and component separators
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
theme = {
|
||||
-- We are going to use lualine_c an lualine_x as left and
|
||||
-- right section. Both are highlighted by c theme . So we
|
||||
-- are just setting default looks o statusline
|
||||
normal = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
inactive = { c = { fg = colors.fg, bg = colors.bg } },
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
-- These will be filled later
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
inactive_sections = {
|
||||
-- these are to remove the defaults
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Inserts a component in lualine_c at left section
|
||||
local function ins_left(component)
|
||||
table.insert(config.sections.lualine_c, component)
|
||||
end
|
||||
|
||||
-- Inserts a component in lualine_x ot right section
|
||||
local function ins_right(component)
|
||||
table.insert(config.sections.lualine_x, component)
|
||||
end
|
||||
|
||||
ins_left({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue }, -- Sets highlighting of component
|
||||
padding = { left = 0, right = 1 }, -- We don't need space before this
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- mode component
|
||||
function()
|
||||
return ""
|
||||
end,
|
||||
color = function()
|
||||
-- auto change color according to neovims mode
|
||||
local mode_color = {
|
||||
n = colors.red,
|
||||
i = colors.green,
|
||||
v = colors.blue,
|
||||
[""] = colors.blue,
|
||||
V = colors.blue,
|
||||
c = colors.magenta,
|
||||
no = colors.red,
|
||||
s = colors.orange,
|
||||
S = colors.orange,
|
||||
[""] = colors.orange,
|
||||
ic = colors.yellow,
|
||||
R = colors.violet,
|
||||
Rv = colors.violet,
|
||||
cv = colors.red,
|
||||
ce = colors.red,
|
||||
r = colors.cyan,
|
||||
rm = colors.cyan,
|
||||
["r?"] = colors.cyan,
|
||||
["!"] = colors.red,
|
||||
t = colors.red,
|
||||
}
|
||||
return { fg = mode_color[vim.fn.mode()] }
|
||||
end,
|
||||
padding = { right = 1 },
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- filesize component
|
||||
"filesize",
|
||||
cond = conditions.buffer_not_empty,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
"filename",
|
||||
cond = conditions.buffer_not_empty,
|
||||
color = { fg = colors.magenta, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_left({ "location" })
|
||||
|
||||
ins_left({ "progress", color = { fg = colors.fg, gui = "bold" } })
|
||||
|
||||
ins_left({
|
||||
"diagnostics",
|
||||
sources = { "nvim_diagnostic" },
|
||||
symbols = { error = " ", warn = " ", info = " " },
|
||||
diagnostics_color = {
|
||||
color_error = { fg = colors.red },
|
||||
color_warn = { fg = colors.yellow },
|
||||
color_info = { fg = colors.cyan },
|
||||
},
|
||||
})
|
||||
|
||||
-- Insert mid section. You can make any number of sections in neovim :)
|
||||
-- for lualine it's any number greater then 2
|
||||
ins_left({
|
||||
function()
|
||||
return "%="
|
||||
end,
|
||||
})
|
||||
|
||||
ins_left({
|
||||
-- Lsp server name .
|
||||
function()
|
||||
local msg = "No Active Lsp"
|
||||
local buf_ft = vim.api.nvim_buf_get_option(0, "filetype")
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
if next(clients) == nil then
|
||||
return msg
|
||||
end
|
||||
for _, client in ipairs(clients) do
|
||||
local filetypes = client.config.filetypes
|
||||
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
|
||||
return client.name
|
||||
end
|
||||
end
|
||||
return msg
|
||||
end,
|
||||
icon = " LSP:",
|
||||
color = { fg = "#474E6D", gui = "bold" },
|
||||
})
|
||||
|
||||
-- Add components to right sections
|
||||
ins_right({
|
||||
"o:encoding", -- option component same as &encoding in viml
|
||||
fmt = string.upper, -- I'm not sure why it's upper case either ;)
|
||||
cond = conditions.hide_in_width,
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"fileformat",
|
||||
fmt = string.upper,
|
||||
icons_enabled = false, -- I think icons are cool but Eviline doesn't have them. sigh
|
||||
color = { fg = colors.custom, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"branch",
|
||||
icon = "",
|
||||
color = { fg = colors.violet, gui = "bold" },
|
||||
})
|
||||
|
||||
ins_right({
|
||||
"diff",
|
||||
-- Is it me or the symbol for modified us really weird
|
||||
symbols = { added = " ", modified = " ", removed = " " },
|
||||
diff_color = {
|
||||
added = { fg = colors.green },
|
||||
modified = { fg = colors.orange },
|
||||
removed = { fg = colors.red },
|
||||
},
|
||||
cond = conditions.hide_in_width,
|
||||
})
|
||||
|
||||
ins_right({
|
||||
function()
|
||||
return "▊"
|
||||
end,
|
||||
color = { fg = colors.blue },
|
||||
padding = { left = 1 },
|
||||
})
|
||||
|
||||
-- Now don't forget to initialize lualine
|
||||
lualine.setup(config)
|
||||
end
|
||||
})
|
||||
Reference in New Issue
Block a user