mirror of https://github.com/zoomiti/dotfiles.git
Compare commits
No commits in common. '806bdcd0e647b94f2ecac9d02688ceed10029456' and '7b0c6abde7315aa14820c03242d24b7101a1bffc' have entirely different histories.
806bdcd0e6
...
7b0c6abde7
@ -0,0 +1,250 @@
|
||||
global !p
|
||||
def math():
|
||||
return vim.eval('vimtex#syntax#in_mathzone()') == '1'
|
||||
|
||||
def comment():
|
||||
return vim.eval('vimtex#syntax#in_comment()') == '1'
|
||||
|
||||
def env(name):
|
||||
[x,y] = vim.eval("vimtex#env#is_inside('" + name + "')")
|
||||
return x != '0' and x != '0'
|
||||
|
||||
endglobal
|
||||
|
||||
snippet fig "Figure environment" b
|
||||
\begin{figure}[${1:htpb}]
|
||||
\centering
|
||||
${2:\includegraphics[width=0.8\textwidth]{$3}}
|
||||
\caption{${4:$3}}
|
||||
\label{fig:${5:${3/\W+/-/g}}}
|
||||
\end{figure}
|
||||
endsnippet
|
||||
|
||||
snippet table "Table environment" b
|
||||
\begin{table}[${1:htpb}]
|
||||
\centering
|
||||
\caption{${2:caption}}
|
||||
\label{tab:${3:label}}
|
||||
\begin{tabular}{${5:c}}
|
||||
$0${5/((?<=.)c|l|r)|./(?1: & )/g}
|
||||
\end{tabular}
|
||||
\end{table}
|
||||
endsnippet
|
||||
|
||||
snippet beg "\begin{}...\end{}" bA
|
||||
\\begin{$1}
|
||||
$0
|
||||
\\end{$1}
|
||||
endsnippet
|
||||
|
||||
snippet enum "list"
|
||||
\begin{enumerate}[label=$1]
|
||||
\item $0
|
||||
\end{enumerate}
|
||||
endsnippet
|
||||
|
||||
snippet mk "Math" wA
|
||||
$${1}$`!p
|
||||
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
|
||||
snip.rv = ' '
|
||||
else:
|
||||
snip.rv = ''
|
||||
`$2
|
||||
endsnippet
|
||||
|
||||
snippet dm "Math" wA
|
||||
\[
|
||||
$2
|
||||
${1:.}\] $0
|
||||
endsnippet
|
||||
|
||||
snippet ali "Align" bA
|
||||
\begin{align*}
|
||||
${2:${VISUAL}}
|
||||
${1:.}\end{align*}
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet '([A-Za-z])(\d)' "auto subscript" wrA
|
||||
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet '([A-Za-z])_(\d\d)' "auto subscript2" wrA
|
||||
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`}
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet __ "subscript" iA
|
||||
_{$1}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet sr "^2" iA
|
||||
^2
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet cb "^3" iA
|
||||
^3
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet td "superscript" iA
|
||||
^{$1}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet // "Fraction" iA
|
||||
\\frac{$1}{$2}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet / "Fraction" i
|
||||
\\frac{${VISUAL}}{$1}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
|
||||
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
|
||||
endsnippet
|
||||
|
||||
priority 1000
|
||||
context "math()"
|
||||
snippet '^.*\)/' "() Fraction" wrA
|
||||
`!p
|
||||
stripped = match.string[:-1]
|
||||
depth = 0
|
||||
i = len(stripped) - 1
|
||||
while True:
|
||||
if stripped[i] == ')': depth += 1
|
||||
if stripped[i] == '(': depth -= 1
|
||||
if depth == 0: break;
|
||||
i -= 1
|
||||
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
|
||||
`{$1}$0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet () "left( right)" iA
|
||||
\left( ${1:${VISUAL}} \right)$0
|
||||
endsnippet
|
||||
|
||||
snippet lr "left( right)" i
|
||||
\left(${1:${VISUAL}}\right)$0
|
||||
endsnippet
|
||||
|
||||
snippet lr| "left| right|" i
|
||||
\left| ${1:${VISUAL}} \right|$0
|
||||
endsnippet
|
||||
|
||||
snippet lr{ "left\{ right\}" i
|
||||
\left\\{ ${1:${VISUAL}} \right\\}$0
|
||||
endsnippet
|
||||
|
||||
snippet lrb "left\{ right\}" i
|
||||
\left\\{ ${1:${VISUAL}} \right\\}$0
|
||||
endsnippet
|
||||
|
||||
snippet lr[ "left[ right]" i
|
||||
\left[ ${1:${VISUAL}} \right]$0
|
||||
endsnippet
|
||||
|
||||
snippet lra "leftangle rightangle" iA
|
||||
\left<${1:${VISUAL}} \right>$0
|
||||
endsnippet
|
||||
|
||||
snippet sum "sum" w
|
||||
\sum_{n=${1:1}}^{${2:\infty}} ${3:a_n z^n}
|
||||
endsnippet
|
||||
|
||||
snippet taylor "taylor" w
|
||||
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0
|
||||
endsnippet
|
||||
|
||||
snippet lim "limit" w
|
||||
\lim_{${1:n} \to ${2:\infty}}
|
||||
endsnippet
|
||||
|
||||
snippet limsup "limsup" w
|
||||
\limsup_{${1:n} \to ${2:\infty}}
|
||||
endsnippet
|
||||
|
||||
snippet prod "product" w
|
||||
\prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0
|
||||
endsnippet
|
||||
|
||||
snippet part "d/dx" w
|
||||
\frac{\partial ${1:V}}{\partial ${2:x}} $0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet sq "\sqrt{}" iA
|
||||
\sqrt{${1:${VISUAL}}} $0
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet sr "^2" iA
|
||||
^2
|
||||
endsnippet
|
||||
|
||||
snippet plot "Plot" w
|
||||
\begin{figure}[$1]
|
||||
\centering
|
||||
\begin{tikzpicture}
|
||||
\begin{axis}[
|
||||
xmin= ${2:-10}, xmax= ${3:10},
|
||||
ymin= ${4:-10}, ymax = ${5:10},
|
||||
axis lines = middle,
|
||||
]
|
||||
\addplot[domain=$2:$3, samples=${6:100}]{$7};
|
||||
\end{axis}
|
||||
\end{tikzpicture}
|
||||
\caption{$8}
|
||||
\label{${9:$8}}
|
||||
\end{figure}
|
||||
endsnippet
|
||||
|
||||
priority 100
|
||||
context "math()"
|
||||
snippet '(?<!\\)(sin|cos|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rwA
|
||||
\\`!p snip.rv = match.group(1)`
|
||||
endsnippet
|
||||
|
||||
priority 300
|
||||
context "math()"
|
||||
snippet dint "integral" wA
|
||||
\int_{${1:-\infty}}^{${2:\infty}} ${3:${VISUAL}} $0
|
||||
endsnippet
|
||||
|
||||
priority 200
|
||||
context "math()"
|
||||
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|pi|zeta|int)' "ln" rwA
|
||||
\\`!p snip.rv = match.group(1)`
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet case "cases" wA
|
||||
\begin{cases}
|
||||
$1
|
||||
\end{cases}
|
||||
endsnippet
|
||||
|
||||
snippet ooo "\infty" iA
|
||||
\infty
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet nn "hn" iA
|
||||
[n]
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet tt "ht" iA
|
||||
(t)
|
||||
endsnippet
|
||||
|
||||
context "math()"
|
||||
snippet ss "hs" iA
|
||||
(s)
|
||||
endsnippet
|
||||
@ -0,0 +1,31 @@
|
||||
let g:vimtex_compiler_latexmk = {
|
||||
\ 'backend': 'nvim',
|
||||
\ 'background' : 1,
|
||||
\ 'build_dir' : 'latex_build',
|
||||
\ 'continuous' : 1,
|
||||
\ 'options' : [
|
||||
\ '-verbose',
|
||||
\ '-file-line-error',
|
||||
\ '-synctex=1',
|
||||
\ '-interaction=nonstopmode',
|
||||
\ '-shell-escape',
|
||||
\ ],
|
||||
\}
|
||||
let g:vimtex_view_method = 'zathura'
|
||||
let g:vimtex_compiler_progname = 'nvr'
|
||||
let g:tex_flavor = 'latex'
|
||||
let g:tex_conceal='abdmg'
|
||||
let g:vimtex_syntax_conceal = {
|
||||
\ 'accents': 1,
|
||||
\ 'cites': 1,
|
||||
\ 'fancy': 1,
|
||||
\ 'greek': 1,
|
||||
\ 'math_bounds': 1,
|
||||
\ 'math_delimiters': 1,
|
||||
\ 'math_fracs': 1,
|
||||
\ 'math_super_sub': 1,
|
||||
\ 'math_symbols': 1,
|
||||
\ 'sections': 1,
|
||||
\ 'styles': 1,
|
||||
\}
|
||||
set textwidth=80
|
||||
@ -1,367 +0,0 @@
|
||||
vim.pack.add({
|
||||
{ src = "https://github.com/zoomiti/firewatch" },
|
||||
{ src = "https://github.com/echasnovski/mini.pick" },
|
||||
{ src = "https://github.com/echasnovski/mini.nvim" },
|
||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||
{ src = "https://github.com/mrcjkb/rustaceanvim" },
|
||||
{ src = 'https://github.com/folke/which-key.nvim' },
|
||||
{ src = 'https://github.com/LunarWatcher/auto-pairs' },
|
||||
{ src = 'https://github.com/tpope/vim-fugitive' },
|
||||
{ src = 'https://github.com/airblade/vim-gitgutter' },
|
||||
{ src = 'https://github.com/nvim-treesitter/nvim-treesitter' },
|
||||
{ src = 'https://github.com/rayliwell/tree-sitter-rstml' },
|
||||
{ src = 'https://github.com/Saghen/blink.cmp' },
|
||||
{ src = 'https://github.com/stevearc/oil.nvim' },
|
||||
})
|
||||
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.tabstop = 4
|
||||
vim.opt.shiftwidth = 4
|
||||
vim.opt.expandtab = false
|
||||
vim.opt.signcolumn = 'yes'
|
||||
vim.opt.smartindent = true
|
||||
vim.opt.title = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.laststatus = 3
|
||||
vim.g.completeopt = { 'menu', 'menuone', 'noselect', 'noinsert' }
|
||||
vim.g.encoding = 'utf-8'
|
||||
-- vim.opt.hidden = true
|
||||
|
||||
vim.opt.conceallevel = 2
|
||||
vim.opt.concealcursor = 'n'
|
||||
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
vim.keymap.set("x", "/", "<Esc>/\\%V", { desc = 'Search forward within visual selection' })
|
||||
vim.keymap.set("x", "?", "<Esc>?\\%V", { desc = 'Search forward within visual selection' })
|
||||
|
||||
require "mini.icons".setup()
|
||||
|
||||
require('oil').setup()
|
||||
vim.keymap.set("n", "-", vim.cmd.Oil, { desc = "Open Parent Directory" })
|
||||
|
||||
require "mini.pick".setup()
|
||||
vim.keymap.set('n', '<leader>b', '<CMD>Pick buffers<CR>', { desc = "Buffers" })
|
||||
vim.keymap.set('n', '<leader>f', '<CMD>Pick files<CR>')
|
||||
|
||||
vim.keymap.set('n', '<leader>s',
|
||||
'<CMD>update ~/.config/nvim/init.lua<CR><CMD>source ~/.config/nvim/init.lua<CR>', { desc = "Update Config" })
|
||||
vim.keymap.set('n', '<leader>w', '<CMD>write<CR>', { desc = "Write File" })
|
||||
|
||||
-- Terminal Mode
|
||||
vim.keymap.set('t', '<ESC>', '<C-\\><C-n>')
|
||||
vim.keymap.set('t', '<C-W>h', '<C-\\><C-n><C-W>h')
|
||||
vim.keymap.set('t', '<C-W>j', '<C-\\><C-n><C-W>j')
|
||||
vim.keymap.set('t', '<C-W>k', '<C-\\><C-n><C-W>k')
|
||||
vim.keymap.set('t', '<C-W>l', '<C-\\><C-n><C-W>l')
|
||||
vim.keymap.set('t', '<C-W><Left>', '<C-\\><C-n><C-W><Left>')
|
||||
vim.keymap.set('t', '<C-W><Down>', '<C-\\><C-n><C-W><Down>')
|
||||
vim.keymap.set('t', '<C-W><Up>', '<C-\\><C-n><C-W><Up>')
|
||||
vim.keymap.set('t', '<C-W><Right>', '<C-\\><C-n><C-W><Right>')
|
||||
vim.api.nvim_create_autocmd('BufEnter', { pattern = 'term://*', command = 'startinsert' })
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
pattern = 'term://*',
|
||||
callback = function(args)
|
||||
vim.keymap.set('n', '<C-c>', 'i<C-c><C-\\><C-n>', { buffer = args.buf })
|
||||
end
|
||||
})
|
||||
|
||||
-- Colorscheme
|
||||
vim.opt.termguicolors = true
|
||||
vim.g.dark_transp_bg = 1
|
||||
vim.cmd("colorscheme fire")
|
||||
|
||||
-- LSP
|
||||
vim.keymap.set('n', 'grd', vim.lsp.buf.definition, { desc = "vim.lsp.buf.definition" })
|
||||
vim.keymap.set({ 'n', 'v', 'x' }, 'grf', vim.lsp.buf.format, { desc = "LSP Format" })
|
||||
vim.lsp.inlay_hint.enable(true)
|
||||
vim.g.c_syntax_for_h = 1
|
||||
require('blink.cmp').setup({
|
||||
signature = { enabled = true }
|
||||
})
|
||||
vim.lsp.enable({ 'lua_ls', 'ccls' })
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
if not client then return end
|
||||
|
||||
if client:supports_method('textDocument/formatting', args.buf) then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = args.buf, id = client.id })
|
||||
end
|
||||
})
|
||||
end
|
||||
end
|
||||
})
|
||||
vim.diagnostic.config({
|
||||
jump = {
|
||||
virtual_lines = true
|
||||
},
|
||||
virtual_text = {
|
||||
prefix = '■',
|
||||
source = true,
|
||||
},
|
||||
severity_sort = true,
|
||||
float = {
|
||||
source = "if_many"
|
||||
},
|
||||
virtual_lines = {
|
||||
source = "if_many",
|
||||
current_line = true,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
-- Fugitive
|
||||
vim.keymap.set('n', '<leader>gs', '<CMD>G<CR>', { desc = "Git Status" })
|
||||
vim.keymap.set('n', '<leader>gp', '<CMD>G pull<CR>', { desc = "Git Pull" })
|
||||
vim.keymap.set('n', '<leader>gP', '<CMD>G push<CR>', { desc = "Git Push" })
|
||||
vim.keymap.set('n', '<leader>gP', '<CMD>G push<CR>', { desc = "Git Push" })
|
||||
|
||||
local wk = require "which-key"
|
||||
wk.add({
|
||||
{ "<leader>g", group = "git" },
|
||||
})
|
||||
|
||||
local statusline = {
|
||||
'%{%v:lua.StatuslineHighlight("Left")%}',
|
||||
'%{v:lua.StatuslineMode()}',
|
||||
'%{%v:lua.StatuslineHighlight("Secondary")%}',
|
||||
'%{v:lua.StatuslineBranch()}',
|
||||
' %{v:lua.StatuslineFilename()} ',
|
||||
'%{%v:lua.StatuslineReadOnly()%}',
|
||||
'%m',
|
||||
'%{%v:lua.StatuslineHighlight("Middle")%}',
|
||||
'%=',
|
||||
' ',
|
||||
'%{&ff}', -- File Format
|
||||
' | ',
|
||||
'%{&fenc!=#""?&fenc:&enc}', -- File Encoding
|
||||
' | ',
|
||||
'%{&ft!=#""?&ft:"no ft"}', -- File Type
|
||||
' ',
|
||||
'%{%v:lua.StatuslineHighlight("Secondary")%}',
|
||||
' ',
|
||||
'%3p%%', -- Percent
|
||||
' ',
|
||||
'%{%v:lua.StatuslineHighlight("Right")%}',
|
||||
' ',
|
||||
'%3l:%-2c', -- Line Info
|
||||
' ',
|
||||
}
|
||||
|
||||
local mode_map = {
|
||||
['n'] = 'NORMAL',
|
||||
['no'] = 'O-PENDING',
|
||||
['nov'] = 'O-PENDING',
|
||||
['noV'] = 'O-PENDING',
|
||||
['no\22'] = 'O-PENDING',
|
||||
['niI'] = 'NORMAL',
|
||||
['niR'] = 'NORMAL',
|
||||
['niV'] = 'NORMAL',
|
||||
['nt'] = 'NORMAL',
|
||||
['v'] = 'VISUAL',
|
||||
['vs'] = 'VISUAL',
|
||||
['V'] = 'V-LINE',
|
||||
['Vs'] = 'V-LINE',
|
||||
['\22'] = 'V-BLOCK',
|
||||
['\22s'] = 'V-BLOCK',
|
||||
['s'] = 'SELECT',
|
||||
['S'] = 'S-LINE',
|
||||
['\19'] = 'S-BLOCK',
|
||||
['i'] = 'INSERT',
|
||||
['ic'] = 'INSERT',
|
||||
['ix'] = 'INSERT',
|
||||
['R'] = 'REPLACE',
|
||||
['Rc'] = 'REPLACE',
|
||||
['Rx'] = 'REPLACE',
|
||||
['Rv'] = 'V-REPLACE',
|
||||
['Rvc'] = 'V-REPLACE',
|
||||
['Rvx'] = 'V-REPLACE',
|
||||
['c'] = 'COMMAND',
|
||||
['cv'] = 'EX',
|
||||
['ce'] = 'EX',
|
||||
['r'] = 'REPLACE',
|
||||
['rm'] = 'MORE',
|
||||
['r?'] = 'CONFIRM',
|
||||
['!'] = 'SHELL',
|
||||
['t'] = 'TERMINAL',
|
||||
}
|
||||
|
||||
local mode_map_hi = {
|
||||
['n'] = 'NORMAL',
|
||||
['no'] = 'NORMAL',
|
||||
['nov'] = 'NORMAL',
|
||||
['noV'] = 'NORMAL',
|
||||
['no\22'] = 'NORMAL',
|
||||
['niI'] = 'NORMAL',
|
||||
['niR'] = 'NORMAL',
|
||||
['niV'] = 'NORMAL',
|
||||
['nt'] = 'NORMAL',
|
||||
['v'] = 'VISUAL',
|
||||
['vs'] = 'VISUAL',
|
||||
['V'] = 'VISUAL',
|
||||
['Vs'] = 'VISUAL',
|
||||
['\22'] = 'VISUAL',
|
||||
['\22s'] = 'VISUAL',
|
||||
['s'] = 'VISUAL',
|
||||
['S'] = 'VISUAL',
|
||||
['\19'] = 'VISUAL',
|
||||
['i'] = 'INSERT',
|
||||
['ic'] = 'INSERT',
|
||||
['ix'] = 'INSERT',
|
||||
['R'] = 'REPLACE',
|
||||
['Rc'] = 'REPLACE',
|
||||
['Rx'] = 'REPLACE',
|
||||
['Rv'] = 'REPLACE',
|
||||
['Rvc'] = 'REPLACE',
|
||||
['Rvx'] = 'REPLACE',
|
||||
['c'] = 'NORMAL',
|
||||
['cv'] = 'NORMAL',
|
||||
['ce'] = 'NORMAL',
|
||||
['r'] = 'REPLACE',
|
||||
['rm'] = 'REPLACE',
|
||||
['r?'] = 'REPLACE',
|
||||
['!'] = 'TERMINAL',
|
||||
['t'] = 'TERMINAL',
|
||||
}
|
||||
|
||||
local fmt = string.format
|
||||
|
||||
vim.cmd [[
|
||||
hi StatusLine_NORMAL_Left guifg=#c8c6c5 guibg=#2e2828 gui=BOLD cterm=NONE
|
||||
hi StatusLine_NORMAL_Right guifg=#c8c6c5 guibg=#2e2828 gui=NONE cterm=NONE
|
||||
hi StatusLine_NORMAL_Secondary guifg=#807970 guibg=#423838 gui=NONE cterm=NONE
|
||||
hi StatusLine_NORMAL_Middle guifg=#423838 guibg=#807970 gui=NONE cterm=NONE
|
||||
|
||||
hi StatusLine_VISUAL_Left guifg=#8c9440 guibg=#2e2828 gui=BOLD cterm=NONE
|
||||
hi StatusLine_VISUAL_Right guifg=#8c9440 guibg=#2e2828 gui=NONE cterm=NONE
|
||||
hi StatusLine_VISUAL_Secondary guifg=#807970 guibg=#423838 gui=NONE cterm=NONE
|
||||
hi StatusLine_VISUAL_Middle guifg=#423838 guibg=#c8c6c5 gui=NONE cterm=NONE
|
||||
|
||||
hi StatusLine_INSERT_Left guifg=#f0b94e guibg=#2e2828 gui=BOLD cterm=NONE
|
||||
hi StatusLine_INSERT_Right guifg=#f0b94e guibg=#2e2828 gui=NONE cterm=NONE
|
||||
hi StatusLine_INSERT_Middle guifg=#423838 guibg=#c8c6c5 gui=NONE cterm=NONE
|
||||
hi StatusLine_INSERT_Secondary guifg=#423838 guibg=#807970 gui=NONE cterm=NONE
|
||||
|
||||
hi StatusLine_REPLACE_Left guifg=#de803f guibg=#2e2828 gui=BOLD cterm=NONE
|
||||
hi StatusLine_REPLACE_Right guifg=#de803f guibg=#2e2828 gui=NONE cterm=NONE
|
||||
hi StatusLine_REPLACE_Middle guifg=#423838 guibg=#c8c6c5 gui=NONE cterm=NONE
|
||||
hi StatusLine_REPLACE_Secondary guifg=#423838 guibg=#807970 gui=NONE cterm=NONE
|
||||
|
||||
hi StatusLine_TERMINAL_Left guifg=#8abeb7 guibg=#2e2828 gui=BOLD cterm=NONE
|
||||
hi StatusLine_TERMINAL_Right guifg=#8abeb7 guibg=#2e2828 gui=NONE cterm=NONE
|
||||
hi StatusLine_TERMINAL_Secondary guifg=#807970 guibg=#423838 gui=NONE cterm=NONE
|
||||
hi StatusLine_TERMINAL_Middle guifg=#423838 guibg=#807970 gui=NONE cterm=NONE
|
||||
]]
|
||||
|
||||
|
||||
function StatuslineHighlight(part)
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
local mode_name = mode_map_hi[mode] or mode
|
||||
return fmt('%%#StatusLine_%s_%s#', mode_name, part)
|
||||
end
|
||||
|
||||
function StatuslineMode()
|
||||
local mode = vim.api.nvim_get_mode().mode
|
||||
local mode_name = mode_map[mode] or mode
|
||||
return fmt(' %s ', mode_name)
|
||||
end
|
||||
|
||||
function SpecialBuffer()
|
||||
local pattern = '\v(help|fugitive|qf|Trouble)'
|
||||
return string.match(pattern, vim.bo.filetype) ~= nil and true or false
|
||||
end
|
||||
|
||||
function StatuslineReadOnly()
|
||||
return SpecialBuffer() and '' or '%r'
|
||||
end
|
||||
|
||||
function StatuslineBranch()
|
||||
local head = vim.fn.FugitiveHead()
|
||||
return SpecialBuffer() ~= true and head ~= '' and fmt(' %s |', head) or ''
|
||||
end
|
||||
|
||||
function StatuslineFilename()
|
||||
local special_files = {
|
||||
['help'] = "Help",
|
||||
['qf'] = 'QuickFix',
|
||||
['fugitive'] = vim.fn.FugitiveStatusline()
|
||||
}
|
||||
|
||||
local filename = vim.fn.expand('%:t')
|
||||
|
||||
return special_files[vim.bo.filetype] or filename == "" and '[No Name]' or filename
|
||||
end
|
||||
|
||||
vim.opt.statusline = table.concat(statusline, '')
|
||||
|
||||
require 'nvim-treesitter.configs'.setup {
|
||||
ensure_installed = { "c", "lua" },
|
||||
--ensure_installed = {},
|
||||
sync_install = false,
|
||||
auto_install = false,
|
||||
ignore_install = { "javascript" },
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
}
|
||||
|
||||
require("tree-sitter-rstml").setup()
|
||||
|
||||
local function create_floating_window(opts)
|
||||
opts = opts or {}
|
||||
local width = opts.width or math.floor(vim.o.columns * 0.8)
|
||||
local height = opts.height or math.floor(vim.o.lines * 0.8)
|
||||
|
||||
local col = math.floor((vim.o.columns - width) / 2)
|
||||
local row = math.floor((vim.o.lines - height) / 2)
|
||||
|
||||
local buf = nil
|
||||
if vim.api.nvim_buf_is_valid(opts.buf) then
|
||||
buf = opts.buf
|
||||
else
|
||||
buf = vim.api.nvim_create_buf(false, true)
|
||||
end
|
||||
|
||||
local win_config = {
|
||||
relative = "editor",
|
||||
width = width,
|
||||
height = height,
|
||||
col = col,
|
||||
row = row,
|
||||
style = "minimal",
|
||||
border = "single"
|
||||
}
|
||||
|
||||
local win = vim.api.nvim_open_win(buf, true, win_config)
|
||||
|
||||
return { buf = buf, win = win }
|
||||
end
|
||||
|
||||
local floaterm_state = {
|
||||
floating = {
|
||||
buf = -1,
|
||||
win = -1,
|
||||
}
|
||||
}
|
||||
|
||||
local toggle_terminal = function()
|
||||
if not vim.api.nvim_win_is_valid(floaterm_state.floating.win) then
|
||||
floaterm_state.floating = create_floating_window({ buf = floaterm_state.floating.buf })
|
||||
if vim.bo[floaterm_state.floating.buf].buftype ~= "terminal" then
|
||||
vim.cmd.terminal()
|
||||
vim.cmd.startinsert()
|
||||
end
|
||||
else
|
||||
vim.api.nvim_win_hide(floaterm_state.floating.win)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("Floaterminal", toggle_terminal, { desc = "Toggles a floating terminal" })
|
||||
vim.keymap.set({ "n", "t" }, "<leader>t", toggle_terminal, { desc = "Toggles a floating terminal" })
|
||||
Loading…
Reference in New Issue