neovim: update neovim config after a long time (i still use emacs
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
--i do not really maintain this anymore since emacs is my main editor now
|
-- i do not really maintain this anymore since emacs is my main editor now
|
||||||
|
|
||||||
vim.api.nvim_set_option("termguicolors", true)
|
vim.api.nvim_set_option("termguicolors", true)
|
||||||
local bind = vim.keymap.set
|
local bind = vim.keymap.set
|
||||||
|
|
||||||
--SETTINGS
|
-- SETTINGS
|
||||||
vim.o.cmdheight = 1
|
vim.o.cmdheight = 1
|
||||||
vim.o.modifiable = true
|
vim.o.modifiable = true
|
||||||
vim.o.cursorline = true
|
vim.o.cursorline = true
|
||||||
vim.o.hidden = true
|
vim.o.hidden = true
|
||||||
vim.o.encoding= "utf-8"
|
vim.o.encoding = "utf-8"
|
||||||
vim.o.pumheight = 10
|
vim.o.pumheight = 10
|
||||||
vim.o.fileencoding = "utf-8"
|
vim.o.fileencoding = "utf-8"
|
||||||
vim.o.ruler = true
|
vim.o.ruler = true
|
||||||
@@ -33,7 +32,7 @@ vim.o.clipboard = "unnamedplus"
|
|||||||
vim.o.completeopt = "menuone,noselect"
|
vim.o.completeopt = "menuone,noselect"
|
||||||
vim.o.cursorcolumn = true
|
vim.o.cursorcolumn = true
|
||||||
|
|
||||||
--KEYBINDS
|
-- KEYBINDS
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
A relic of the past
|
A relic of the past
|
||||||
@@ -67,92 +66,83 @@ bind('n', "<C-e>", "<C-w>k")
|
|||||||
bind('n', "<C-i>", "<C-w>l")
|
bind('n', "<C-i>", "<C-w>l")
|
||||||
bind('n', "<M-v>", ":vsplit<CR>")
|
bind('n', "<M-v>", ":vsplit<CR>")
|
||||||
bind('n', "<M-h>", ":split<CR>")
|
bind('n', "<M-h>", ":split<CR>")
|
||||||
]]--
|
]] --
|
||||||
|
|
||||||
--RUN AND REPL (using vim-floaterm)
|
|
||||||
|
|
||||||
function _G.CompileRun()
|
function _G.CompileRun()
|
||||||
|
local Terminal = require('toggleterm.terminal').Terminal
|
||||||
local file = vim.fn.expand('%:p')
|
local file = vim.fn.expand('%:p')
|
||||||
local noext = vim.fn.expand('%:p:r')
|
local noext = vim.fn.expand('%:p:r')
|
||||||
local commandMap = {
|
local commandMap = {
|
||||||
['java'] = 'java ' .. file,
|
['java'] = 'java ' .. file,
|
||||||
['lisp'] = 'clisp ' .. file,
|
['lisp'] = 'clisp ' .. file,
|
||||||
['python'] = 'python3 ' .. file,
|
['python'] = 'python3 ' .. file,
|
||||||
['c'] = 'gcc ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' .. ' && ' .. noext .. ' && rm ' .. noext,
|
['c'] = 'gcc ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' ..
|
||||||
['rust'] = 'rustc ' .. file .. ' -o ' .. noext .. ' && ' .. noext .. ' && rm ' .. noext,
|
' && ' .. noext .. ' && rm ' .. noext,
|
||||||
['cpp'] = 'g++ -std=c++17 ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' .. ' && ' .. noext .. ' && rm ' .. noext,
|
['rust'] = 'rustc ' .. file .. ' -o ' .. noext .. ' && ' .. noext ..
|
||||||
['haskell'] = 'runhaskell ' .. file,
|
' && rm ' .. noext,
|
||||||
['sh'] = 'sh ' .. file,
|
['cpp'] = 'g++ ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' ..
|
||||||
['javascript']= 'node ' .. file,
|
' && ' .. noext .. ' && rm ' .. noext,
|
||||||
['typescript']= 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' .. noext .. '.js'
|
['cc'] = 'g++ ' .. file .. ' -o ' .. noext .. ' -Wno-unused-result ' ..
|
||||||
|
' && ' .. noext .. ' && rm ' .. noext,
|
||||||
|
['haskell'] = 'runhaskell ' .. file,
|
||||||
|
['sh'] = 'sh ' .. file,
|
||||||
|
['javascript'] = 'node ' .. file,
|
||||||
|
['typescript'] = 'tsc ' .. file .. ' && node ' .. noext .. '.js && rm ' ..
|
||||||
|
noext .. '.js'
|
||||||
}
|
}
|
||||||
filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
if commandMap[filetype] ~= nil then vim.cmd("FloatermNew --autoclose=0 " .. commandMap[filetype]) end
|
if commandMap[filetype] ~= nil then
|
||||||
|
Terminal:new({cmd = commandMap[filetype], close_on_exit = false})
|
||||||
|
:toggle()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function _G.Repl()
|
function _G.Repl()
|
||||||
|
local Terminal = require('toggleterm.terminal').Terminal
|
||||||
local file = vim.fn.expand('%:p')
|
local file = vim.fn.expand('%:p')
|
||||||
local commandMap = {
|
local commandMap = {
|
||||||
['lisp'] = 'clisp',
|
['lisp'] = 'clisp',
|
||||||
['python'] = 'python3',
|
['python'] = 'python3',
|
||||||
['haskell'] = 'ghci ' .. file,
|
['haskell'] = 'ghci ' .. file,
|
||||||
['sh'] = 'sh',
|
['sh'] = 'sh',
|
||||||
['javascript']= 'node',
|
['javascript'] = 'node',
|
||||||
['typescript']= 'ts-node',
|
['typescript'] = 'ts-node',
|
||||||
['nix'] = 'nix repl',
|
['nix'] = 'nix repl',
|
||||||
['lua'] = 'lua'
|
['lua'] = 'lua'
|
||||||
}
|
}
|
||||||
filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
||||||
if commandMap[filetype] ~= nil then vim.cmd("FloatermNew " .. commandMap[filetype]) end
|
if commandMap[filetype] ~= nil then
|
||||||
|
Terminal:new({cmd = commandMap[filetype]}):toggle()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
bind('n', "<F5>", ":call v:lua.CompileRun()<CR>")
|
bind('n', "<F5>", ":call v:lua.CompileRun()<CR>")
|
||||||
bind('n', "<F6>", ":call v:lua.Repl()<CR>")
|
bind('n', "<F6>", ":call v:lua.Repl()<CR>")
|
||||||
|
|
||||||
|
-- PLUGINS CONFIG
|
||||||
|
|
||||||
|
-- nvim-tree.lua
|
||||||
--PLUGINS CONFIG
|
|
||||||
|
|
||||||
--nvim-tree.lua
|
|
||||||
require'nvim-tree'.setup {
|
require'nvim-tree'.setup {
|
||||||
diagnostics = {
|
diagnostics = {enable = true},
|
||||||
enable = true,
|
update_focused_file = {enable = true, update_root = true},
|
||||||
},
|
renderer = {highlight_opened_files = "all", highlight_git = true},
|
||||||
update_focused_file = {
|
git = {enable = true, ignore = true, show_on_dirs = true},
|
||||||
enable = true,
|
actions = {
|
||||||
update_root = true,
|
open_file = {
|
||||||
},
|
quit_on_open = true,
|
||||||
renderer = {
|
resize_window = true,
|
||||||
highlight_opened_files = "all",
|
window_picker = {
|
||||||
highlight_git = true
|
enable = true,
|
||||||
},
|
exclude = {
|
||||||
git = {
|
filetype = {
|
||||||
enable = true,
|
"notify", "packer", "qf", "diff", "fugitive",
|
||||||
ignore = true,
|
"fugitiveblame"
|
||||||
show_on_dirs = true,
|
},
|
||||||
},
|
buftype = {"nofile", "terminal", "help"}
|
||||||
actions = {
|
}
|
||||||
open_file = {
|
}
|
||||||
quit_on_open = true,
|
}
|
||||||
resize_window = true,
|
|
||||||
window_picker = {
|
|
||||||
enable = true,
|
|
||||||
exclude = {
|
|
||||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
|
||||||
buftype = { "nofile", "terminal", "help" },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
view = {
|
|
||||||
adaptive_size = true,
|
|
||||||
mappings = {
|
|
||||||
list = {
|
|
||||||
{ key = "e", action = "" },
|
|
||||||
{ key = "m", action = "" },
|
|
||||||
{ key = "f", action = "rename_basename" }
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
view = {adaptive_size = true}
|
||||||
}
|
}
|
||||||
|
|
||||||
bind('n', "<M-o>", ":NvimTreeToggle<CR>")
|
bind('n', "<M-o>", ":NvimTreeToggle<CR>")
|
||||||
@@ -160,162 +150,148 @@ bind('n', "<Space>r", ":NvimTreeRefresh<CR>")
|
|||||||
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
|
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
|
||||||
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
|
bind('n', "<Space>f", ":NvimTreeFindFile<CR>")
|
||||||
|
|
||||||
|
-- colorizer
|
||||||
|
require'colorizer'.setup()
|
||||||
|
|
||||||
--floaterm
|
-- toggleterm
|
||||||
vim.g.floaterm_keymap_toggle = '<F1>'
|
require("toggleterm").setup {
|
||||||
vim.g.floaterm_keymap_next = '<F2>'
|
size = function(term)
|
||||||
vim.g.floaterm_keymap_prev = '<F3>'
|
if term.direction == "horizontal" then
|
||||||
vim.g.floaterm_keymap_new = '<F4>'
|
return 25
|
||||||
vim.g.floaterm_gitcommit='floaterm'
|
elseif term.direction == "vertical" then
|
||||||
vim.g.floaterm_autoinsert=1
|
return vim.o.columns * 0.4
|
||||||
vim.g.floaterm_position="bottom"
|
end
|
||||||
vim.g.floaterm_width=0.99
|
end,
|
||||||
vim.g.floaterm_height=0.6
|
open_mapping = [[<c-t>]],
|
||||||
|
autochdir = true
|
||||||
|
}
|
||||||
|
|
||||||
--closetag
|
-- autoclose
|
||||||
vim.g.closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.erb,*.jsx"
|
require("autoclose").setup({
|
||||||
vim.g.closetag_xhtml_filenames = "*.xhtml,*.jsx,*.js,*.erb"
|
options = {disabled_filetypes = {"text", "markdown"}}
|
||||||
vim.g.closetag_emptyTags_caseSensitive = 1
|
})
|
||||||
vim.g.closetag_shortcut = '>'
|
|
||||||
|
|
||||||
--nerdcommenter
|
-- icons
|
||||||
bind('n',"<M-c>","<plug>NERDCommenterToggle")
|
require'nvim-web-devicons'.setup {default = true}
|
||||||
bind('n',"<M-d>","<plug>NERDCommenterSexy")
|
|
||||||
|
|
||||||
--barbar
|
-- barbar
|
||||||
bind('n', "<M-,>", ":BufferPrevious<CR>")
|
bind('n', "<M-,>", ":BufferPrevious<CR>")
|
||||||
bind('n', "<M-.>", ":BufferNext<CR>")
|
bind('n', "<M-.>", ":BufferNext<CR>")
|
||||||
bind('n', "<M-<>", ":BufferMovePrevious<CR>")
|
bind('n', "<M-<>", ":BufferMovePrevious<CR>")
|
||||||
bind('n', "<M->>", ":BufferMoveNext<CR>")
|
bind('n', "<M->>", ":BufferMoveNext<CR>")
|
||||||
bind('n', "<M-w>", ":BufferClose<CR>")
|
bind('n', "<M-w>", ":BufferClose<CR>")
|
||||||
for i = 1,8,1
|
for i = 1, 8, 1 do
|
||||||
do
|
|
||||||
bind('n', string.format("<M-%d>", i), string.format(":BufferGoto %d<CR>", i))
|
bind('n', string.format("<M-%d>", i), string.format(":BufferGoto %d<CR>", i))
|
||||||
end
|
end
|
||||||
|
|
||||||
--presence.nvim
|
-- presence.nvim
|
||||||
vim.g.presence_neovim_image_text = "Ballin"
|
vim.g.presence_neovim_image_text = "Ballin"
|
||||||
vim.g.presence_main_image = "file"
|
vim.g.presence_main_image = "file"
|
||||||
|
|
||||||
--treesitter-nvim
|
-- treesitter-nvim
|
||||||
require'nvim-treesitter.configs'.setup {
|
require'nvim-treesitter.configs'.setup {
|
||||||
ensure_install = "all",
|
ensure_install = "all",
|
||||||
highlight = {
|
highlight = {enable = true, additional_vim_regex_highlighting = true},
|
||||||
enable = true,
|
indent = {enable = true}
|
||||||
additional_vim_regex_highlighting = true,
|
|
||||||
},
|
|
||||||
indent = {
|
|
||||||
enable = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
--vim-latex-live-preview
|
|
||||||
vim.g.livepreview_previewer = "zathura"
|
|
||||||
|
|
||||||
require'colorizer'.setup()
|
|
||||||
|
|
||||||
local on_attach = function(client, bufnr)
|
local on_attach = function(client, bufnr)
|
||||||
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
local bufopts = {noremap = true, silent = true, buffer = bufnr}
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
bind('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
bind('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||||
vim.keymap.set('n', '<M-k>', vim.lsp.buf.hover, bufopts)
|
bind('n', '<M-k>', vim.lsp.buf.hover, bufopts)
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
bind('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
bind('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||||
vim.keymap.set('n', "<M-C-f>", function() vim.lsp.buf.format { async = true } end, bufopts)
|
bind('n', "<M-C-f>", function() vim.lsp.buf.format {async = true} end,
|
||||||
|
bufopts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local servers = { "clangd", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "rnix", "terraform_lsp", "html", "cssls", "jsonls", "svelte", "gopls" }
|
local servers = {
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
"clangd", "rust_analyzer", "tsserver", "hls", "pylsp", "texlab", "nixd",
|
||||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
"terraform_lsp", "html", "cssls", "jsonls", "svelte", "gopls"
|
||||||
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
|
||||||
properties = {
|
|
||||||
'documentation',
|
|
||||||
'detail',
|
|
||||||
'additionalTextEdits',
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||||||
|
properties = {'documentation', 'detail', 'additionalTextEdits'}
|
||||||
|
}
|
||||||
|
|
||||||
|
-- lspconfig
|
||||||
|
|
||||||
local nvimlsp = require('lspconfig')
|
local nvimlsp = require('lspconfig')
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
nvimlsp[lsp].setup { capabilities = capabilities, on_attach = on_attach }
|
nvimlsp[lsp].setup {capabilities = capabilities, on_attach = on_attach}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- luasnip
|
||||||
--luasnip
|
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
luasnip.snippets = {
|
luasnip.snippets = {html = {}}
|
||||||
html = {}
|
|
||||||
}
|
|
||||||
luasnip.snippets.javascript = luasnip.snippets.html
|
luasnip.snippets.javascript = luasnip.snippets.html
|
||||||
luasnip.snippets.javascriptreact = luasnip.snippets.html
|
luasnip.snippets.javascriptreact = luasnip.snippets.html
|
||||||
require("luasnip/loaders/from_vscode").lazy_load()
|
require("luasnip/loaders/from_vscode").lazy_load()
|
||||||
|
|
||||||
|
-- nvim cmp
|
||||||
local cmp = require 'cmp'
|
local cmp = require 'cmp'
|
||||||
cmp.setup {
|
cmp.setup {
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args) require('luasnip').lsp_expand(args.body) end
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
mapping = {
|
|
||||||
['<C-e>'] = cmp.mapping.select_prev_item(),
|
|
||||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
|
||||||
['<C-p>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
||||||
['<C-Space>'] = cmp.mapping.complete(),
|
|
||||||
['<C-q>'] = cmp.mapping.close(),
|
|
||||||
['<CR>'] = cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = true,
|
|
||||||
},
|
},
|
||||||
['<Tab>'] = function(fallback)
|
mapping = {
|
||||||
if cmp.visible() then
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
cmp.select_next_item()
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
elseif luasnip.expand_or_jumpable() then
|
['<C-k>'] = cmp.mapping.scroll_docs(-4),
|
||||||
luasnip.expand_or_jump()
|
['<C-j>'] = cmp.mapping.scroll_docs(4),
|
||||||
else
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
fallback()
|
['<C-q>'] = cmp.mapping.close(),
|
||||||
end
|
['<CR>'] = cmp.mapping.confirm {
|
||||||
end,
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
['<S-Tab>'] = function(fallback)
|
select = true
|
||||||
if cmp.visible() then
|
},
|
||||||
cmp.select_prev_item()
|
['<Tab>'] = function(fallback)
|
||||||
elseif luasnip.jumpable(-1) then
|
if cmp.visible() then
|
||||||
luasnip.jump(-1)
|
cmp.select_next_item()
|
||||||
else
|
elseif luasnip.expand_or_jumpable() then
|
||||||
fallback()
|
luasnip.expand_or_jump()
|
||||||
end
|
else
|
||||||
end
|
fallback()
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
['<S-Tab>'] = function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.select_prev_item()
|
||||||
|
elseif luasnip.jumpable(-1) then
|
||||||
|
luasnip.jump(-1)
|
||||||
|
else
|
||||||
|
fallback()
|
||||||
|
end
|
||||||
|
end
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp'},
|
{name = 'nvim_lsp'}, {name = 'path'}, {name = 'nvim_lua'},
|
||||||
{ name = 'path'},
|
{name = 'luasnip'}, {name = 'calc'}, {name = 'emoji'},
|
||||||
{ name = 'nvim_lua'},
|
{name = 'buffer'}, {name = 'look'}
|
||||||
{ name = 'luasnip'},
|
|
||||||
{ name = 'calc'},
|
|
||||||
{ name = 'emoji'},
|
|
||||||
{ name = 'buffer'},
|
|
||||||
{ name = 'look'},
|
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
format = require('lspkind').cmp_format({
|
format = require('lspkind').cmp_format({
|
||||||
with_text = true,
|
with_text = true,
|
||||||
menu = ({
|
menu = ({
|
||||||
buffer = "[Buffer]",
|
buffer = "[Buffer]",
|
||||||
nvim_lsp = "[LSP]",
|
nvim_lsp = "[LSP]",
|
||||||
luasnip = "[LuaSnip]",
|
luasnip = "[LuaSnip]",
|
||||||
nvim_lua = "[Lua]",
|
nvim_lua = "[Lua]",
|
||||||
latex_symbols = "[Latex]",
|
latex_symbols = "[Latex]"
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}),
|
}
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- telescope
|
||||||
|
require('telescope').setup()
|
||||||
|
|
||||||
vim.cmd("set shortmess+=c")
|
vim.cmd("set shortmess+=c")
|
||||||
|
|
||||||
--STATUSLINE
|
-- STATUSLINE
|
||||||
vim.cmd("set noruler")
|
vim.cmd("set noruler")
|
||||||
vim.o.laststatus = 2
|
vim.o.laststatus = 2
|
||||||
local function mode()
|
local function mode()
|
||||||
@@ -338,22 +314,17 @@ local function mode()
|
|||||||
return mode_map[m]
|
return mode_map[m]
|
||||||
end
|
end
|
||||||
|
|
||||||
--theming
|
-- theming
|
||||||
local dark = true
|
local dark = true
|
||||||
|
|
||||||
require("catppuccin").setup({
|
require("catppuccin").setup({
|
||||||
flavour = "mocha",
|
flavour = "mocha",
|
||||||
background = {
|
background = {light = "latte", dark = "mocha"}
|
||||||
light = "latte",
|
|
||||||
dark = "mocha",
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.cmd("colorscheme catppuccin")
|
vim.cmd("colorscheme catppuccin")
|
||||||
|
|
||||||
function hi(hi_var, hi_value)
|
function hi(hi_var, hi_value) vim.cmd("hi " .. hi_var .. " " .. hi_value) end
|
||||||
vim.cmd("hi " .. hi_var .. " " .. hi_value)
|
|
||||||
end
|
|
||||||
|
|
||||||
local colors = require("catppuccin.palettes").get_palette "latte"
|
local colors = require("catppuccin.palettes").get_palette "latte"
|
||||||
hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
||||||
@@ -361,50 +332,37 @@ hi("Misc", "guibg=" .. colors.pink .. " guifg=" .. colors.base)
|
|||||||
hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
||||||
|
|
||||||
local function git()
|
local function git()
|
||||||
local branch = io.popen([[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read("*a")
|
local branch = io.popen(
|
||||||
return string.len(branch) > 0 and ' '.. branch or ''
|
[[git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n']]):read(
|
||||||
|
"*a")
|
||||||
|
return string.len(branch) > 0 and ' ' .. branch or ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local statusline = {
|
local statusline = {
|
||||||
'%#Light# ',
|
'%#Light# ', mode():upper() .. ' ', '%#Misc#',
|
||||||
mode():upper() .. ' ',
|
string.len(git()) > 0 and ' ' .. git() .. ' ' or '', '%#Dark# ', '%f ',
|
||||||
'%#Misc#',
|
'%#Light#', '%=', '%#Dark# ', '%y ', '%#Light# ', '%p%% ', ' ', '%l/%L ',
|
||||||
string.len(git()) > 0 and ' ' .. git() .. ' ' or '',
|
' ', '%c '
|
||||||
'%#Dark# ',
|
|
||||||
'%f ',
|
|
||||||
'%#Light#',
|
|
||||||
'%=',
|
|
||||||
'%#Dark# ',
|
|
||||||
'%y ',
|
|
||||||
'%#Light# ',
|
|
||||||
'%p%% ',
|
|
||||||
' ',
|
|
||||||
'%l/%L ',
|
|
||||||
' ',
|
|
||||||
'%c '
|
|
||||||
}
|
}
|
||||||
vim.o.statusline = table.concat(statusline)
|
vim.o.statusline = table.concat(statusline)
|
||||||
|
|
||||||
|
|
||||||
function _G.ToggleTheme()
|
function _G.ToggleTheme()
|
||||||
if dark then
|
if dark then
|
||||||
vim.cmd("set background=light")
|
vim.cmd("set background=light")
|
||||||
local colors = require("catppuccin.palettes").get_palette "latte"
|
local colors = require("catppuccin.palettes").get_palette "latte"
|
||||||
hi("Light", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
hi("Light", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
||||||
hi("Misc", "guibg=" .. colors.peach .. " guifg=" .. colors.text)
|
hi("Misc", "guibg=" .. colors.peach .. " guifg=" .. colors.text)
|
||||||
hi("Dark", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
hi("Dark", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
||||||
vim.o.statusline = table.concat(statusline)
|
vim.o.statusline = table.concat(statusline)
|
||||||
else
|
else
|
||||||
vim.cmd("set background=dark")
|
vim.cmd("set background=dark")
|
||||||
local colors = require("catppuccin.palettes").get_palette "mocha"
|
local colors = require("catppuccin.palettes").get_palette "mocha"
|
||||||
hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
hi("Light", "guibg=" .. colors.text .. " guifg=" .. colors.crust)
|
||||||
hi("Misc", "guibg=" .. colors.pink .. " guifg=" .. colors.base)
|
hi("Misc", "guibg=" .. colors.pink .. " guifg=" .. colors.base)
|
||||||
hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
hi("Dark", "guibg=" .. colors.crust .. " guifg=" .. colors.text)
|
||||||
vim.o.statusline = table.concat(statusline)
|
vim.o.statusline = table.concat(statusline)
|
||||||
end
|
end
|
||||||
dark = not dark
|
dark = not dark
|
||||||
end
|
end
|
||||||
|
|
||||||
bind('n', "<F7>", ":call v:lua.ToggleTheme()<CR>")
|
bind('n', "<F7>", ":call v:lua.ToggleTheme()<CR>")
|
||||||
vim.g.tex_flavor = "latex"
|
|
||||||
|
Reference in New Issue
Block a user