Browse Source

neovim reconfiguration

master
Juni Kim 1 week ago
parent
commit
b6e4b280e3
  1. 16
      .config/nvim/lua/junikim/bootstrap.lua
  2. 11
      .config/nvim/lua/junikim/plugins/luasnip.lua
  3. 25
      .config/nvim/lua/junikim/plugins/ufo.lua
  4. 446
      .config/nvim/lua/junikim/snippets/tex.snippets
  5. 1
      .config/nvim/lua/themes/.gitignore
  6. 62
      .config/nvim/lua/themes/catppuccin.lua
  7. 40
      .config/nvim/lua/themes/everforest.lua
  8. 62
      .config/nvim/lua/themes/gruvbox.lua
  9. 9
      .config/nvim/lua/themes/utils.lua

16
.config/nvim/lua/junikim/bootstrap.lua

@ -0,0 +1,16 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)

11
.config/nvim/lua/junikim/plugins/luasnip.lua

@ -0,0 +1,11 @@
return {
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*",
build = "make install_jsregexp",
config = function()
require("luasnip.loaders.from_snipmate").lazy_load({
paths = "./lua/junikim/snippets"
})
end
}

25
.config/nvim/lua/junikim/plugins/ufo.lua

@ -0,0 +1,25 @@
return {
'kevinhwang91/nvim-ufo',
dependencies = {
{ 'kevinhwang91/promise-async' },
},
config = function()
vim.o.foldcolumn = '1' -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
vim.o.foldenable = true
-- Using ufo provider need remap `zR` and `zM`. If Neovim is 0.6.1, remap yourself
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
-- Option 3: treesitter as a main provider instead
-- Only depend on `nvim-treesitter/queries/filetype/folds.scm`,
-- performance and stability are better than `foldmethod=nvim_treesitter#foldexpr()`
require('ufo').setup({
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end
})
end
}

446
.config/nvim/lua/junikim/snippets/tex.snippets

@ -0,0 +1,446 @@
#version 1
#PREAMBLE
#documentclass without options
snippet dcl \documentclass{}
\\documentclass{${1:class}} ${0}
#documentclass with options
snippet dclo \documentclass[]{}
\\documentclass[${1:options}]{${2:class}} ${0}
snippet tmplt "Template"
\\documentclass{${1:article}}
\\usepackage{import}
\\usepackage{pdfpages}
\\usepackage{transparent}
\\usepackage{xcolor}
$2
\\newcommand{\incfig}[2][1]{%
\def\svgwidth{#1\columnwidth}
\import{./figures/}{#2.pdf_tex}
}
$3
\\pdfsuppresswarningpagegroup=1
\\begin{document}
$0
\\end{document}
#newcommand
snippet nc \newcommand
\\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0}
#usepackage
snippet up \usepackage
\\usepackage[${1:options}]{${2:package}} ${0}
#newunicodechar
snippet nuc \newunicodechar
\\newunicodechar{${1}}{${2:\\ensuremath}${3:tex-substitute}}} ${0}
#DeclareMathOperator
snippet dmo \DeclareMathOperator
\\DeclareMathOperator{${1}}{${2}} ${0}
#DOCUMENT
# \begin{}...\end{}
snippet begin \begin{} ... \end{} block
\\begin{${1:env}}
${0:${VISUAL}}
\\end{$1}
# Maketitle
snippet mkt maketitle
\\maketitle
# Tabular
snippet tab tabular (or arbitrary) environment
\\begin{${1:tabular}}{${2:c}}
${0:${VISUAL}}
\\end{$1}
snippet thm thm (or arbitrary) environment with optional argument
\\begin[${1:author}]{${2:thm}}
${0:${VISUAL}}
\\end{$2}
snippet center center environment
\\begin{center}
${0:${VISUAL}}
\\end{center}
# Align(ed)
snippet ali align(ed) environment
\\begin{align*}
${0:${VISUAL}}
\\end{align*}
# Gather(ed)
snippet gat gather(ed) environment
\\begin{gather${1:ed}}
${0:${VISUAL}}
\\end{gather$1}
# Equation
snippet eq equation environment
\\begin{equation}
${0:${VISUAL}}
\\end{equation}
# Equation
snippet eql Labeled equation environment
\\begin{equation}
\\label{eq:${2}}
${0:${VISUAL}}
\\end{equation}
# Equation
snippet eq* unnumbered equation environment
\\begin{equation*}
${0:${VISUAL}}
\\end{equation*}
# Unnumbered Equation
snippet \ unnumbered equation: \[ ... \]
\\[
${0:${VISUAL}}
\\]
# Equation array
snippet eqnarray eqnarray environment
\\begin{eqnarray}
${0:${VISUAL}}
\\end{eqnarray}
# Label
snippet lab \label
\\label{${1:eq:}${2:fig:}${3:tab:}${0}}
# Enumerate
snippet enum enumerate environment
\\begin{enumerate}
\\item ${0}
\\end{enumerate}
snippet enuma enumerate environment
\\begin{enumerate}[(a)]
\\item ${0}
\\end{enumerate}
snippet enumi enumerate environment
\\begin{enumerate}[(i)]
\\item ${0}
\\end{enumerate}
# Itemize
snippet item itemize environment
\\begin{itemize}
\\item ${0}
\\end{itemize}
snippet it \item
\\item ${1:${VISUAL}}
# Description
snippet desc description environment
\\begin{description}
\\item[${1}] ${0}
\\end{description}
# Endless new item
snippet ]i \item (recursive)
\\item ${1}
${0:]i}
# Matrix
snippet mat smart matrix environment
\\begin{${1:p/b/v/V/B/small}matrix}
${0:${VISUAL}}
\\end{$1matrix}
# Cases
snippet cas cases environment
\\begin{cases}
${1:equation}, &\\text{ if }${2:case}\\
${0:${VISUAL}}
\\end{cases}
# Split
snippet spl split environment
\\begin{split}
${0:${VISUAL}}
\\end{split}
# Part
snippet part document \part
\\part{${1:part name}} % (fold)%
\\label{prt:${2:$1}}
${0}
% part $2 (end)
# Chapter
snippet cha \chapter
\\chapter{${1:chapter name}}%
\\label{cha:${2:$1}}
${0}
# Section
snippet sec \section
\\section{${1:section name}}%
\\label{sec:${2:$1}}
${0}
# Section without number
snippet sec* \section*
\\section*{${1:section name}}%
\\label{sec:${2:$1}}
${0}
# Sub Section
snippet sub \subsection
\\subsection{${1:subsection name}}%
\\label{sub:${2:$1}}
${0}
# Sub Section without number
snippet sub* \subsection*
\\subsection*{${1:subsection name}}%
\\label{sub:${2:$1}}
${0}
# Sub Sub Section
snippet ssub \subsubsection
\\subsubsection{${1:subsubsection name}}%
\\label{ssub:${2:$1}}
${0}
# Sub Sub Section without number
snippet ssub* \subsubsection*
\\subsubsection*{${1:subsubsection name}}%
\\label{ssub:${2:$1}}
${0}
# Paragraph
snippet par \paragraph
\\paragraph{${1:paragraph name}}%
\\label{par:${2:$1}}
${0}
# Paragraph*
snippet par* \paragraph*
\\paragraph*{${1:paragraph name}}%
\\label{par:${2:$1}}
${0}
# Sub Paragraph
snippet subp \subparagraph
\\subparagraph{${1:subparagraph name}}%
\\label{subp:${2:$1}}
${0}
# Sub Paragraph*
snippet subp* \subparagraph*
\\subparagraph*{${1:subparagraph name}}%
\\label{subp:${2:$1}}
${0}
snippet ni \noindent
\\noindent
${0}
#References
snippet itd description \item
\\item[${1:description}] ${0:item}
snippet figure reference to a figure
${1:Figure}~\\ref{${2:fig:}}
snippet table reference to a table
${1:Table}~\\ref{${2:tab:}}
snippet listing reference to a listing
${1:Listing}~\\ref{${2:list}}
snippet section reference to a section
${1:Section}~\\ref{sec:${2}} ${0}
snippet page reference to a page
${1:page}~\\pageref{${2}} ${0}
snippet index \index
\\index{${1:index}} ${0}
#Citations
snippet citen \citen
\\citen{${1}} ${0}
# natbib citations
snippet citep \citep
\\citep{${1}} ${0}
snippet citet \citet
\\citet{${1}} ${0}
snippet cite \cite[]{}
\\cite[${1}]{${2}} ${0}
snippet citea \citeauthor
\\citeauthor{${1}} ${0}
snippet citey \citeyear
\\citeyear{${1}} ${0}
snippet fcite \footcite[]{}
\\footcite[${1}]{${2}}${0}
#Formating text: italic, bold, underline, small capital, emphase ..
snippet ita italic text
\\textit{${1:${VISUAL:text}}}${0}
snippet bf bold face text
\\textbf{${1:${VISUAL:text}}}${0}
snippet under underline text
\\underline{${1:${VISUAL:text}}}${0}
snippet over overline text
\\overline{${1:${VISUAL:text}}}${0}
snippet emp emphasize text
\\emph{${1:${VISUAL:text}}}${0}
snippet sc small caps text
\\textsc{${1:${VISUAL:text}}}${0}
#Choosing font
snippet sf sans serife text
\\textsf{${1:${VISUAL:text}}}${0}
snippet rm roman font text
\\textrm{${1:${VISUAL:text}}}${0}
snippet tt typewriter (monospace) text
\\texttt{${1:${VISUAL:text}}}${0}
snippet tsub subscripted text
\\textsubscript{${1:${VISUAL:text}}}${0}
snippet tsup superscripted text
\\textsuperscript{${1:${VISUAL:text}}}${0}
#Math font
snippet mf mathfrak
\\mathfrak{${1:${VISUAL:text}}}${0}
snippet mc mathcal
\\mathcal{${1:${VISUAL:text}}}${0}
snippet ms mathscr
\\mathscr{${1:${VISUAL:text}}}${0}
#misc
snippet ft \footnote
\\footnote{${1:${VISUAL:text}}}${0}
snippet fig figure environment (includegraphics)
\\begin{figure}
\\begin{center}
\\includegraphics[scale=${1}]{Figures/${2}}
\\end{center}
\\caption{${3}}
\\label{fig:${4}}
\\end{figure}
${0}
snippet tikz figure environment (tikzpicture)
\\begin{figure}[htpb]
\\begin{center}
\\begin{tikzpicture}[scale=${1:1}, transform shape]
${2}
\\end{tikzpicture}
\\end{center}
\\caption{${3}}%
\\label{fig:${4}}
\\end{figure}
${0}
snippet subfig subfigure environment
\\begin{subfigure}[${1}]{${2:\\textwidth}}
\\begin{center}
${3}
\\end{center}
\\caption{${4}}
\\label{fig:${5}}
\\end{subfigure}
${0}
snippet tikzcd tikzcd environment in equation
\\begin{equation}
\\begin{tikzcd}
${1}
\\end{tikzcd}
\\end{equation}
${0}
snippet tikzcd* tikzcd environment in equation*
\\begin{equation*}
\\begin{tikzcd}
${1}
\\end{tikzcd}
\\end{equation*}
${0}
#math
snippet stackrel \stackrel{}{}
\\stackrel{${1:above}}{${2:below}} ${0}
snippet frac \frac{}{}
\\frac{${1:num}}{${2:denom}} ${0}
snippet sum \sum^{}_{}
\\sum^{${1:n}}_{${2:i=1}} ${0}
snippet lim \lim_{}
\\lim_{${1:n \\to \\infty}} ${0}
snippet frame frame environment
\\begin{frame}[${1:t}]
\frametitle{${2:title}}
\framesubtitle{${3:subtitle}}
${0:${VISUAL}}
\\end{frame}
snippet block block environment
\\begin{block}{${1:title}}
${0:${VISUAL}}
\\end{block}
snippet alert alert text
\\alert{${1:${VISUAL:text}}} ${0}
snippet alertblock alertblock environment
\\begin{alertblock}{${1:title}}
${0:${VISUAL}}
\\end{alertblock}
snippet example exampleblock environment
\\begin{exampleblock}{${1:title}}
${0:${VISUAL}}
\\end{exampleblock}
snippet col2 two-column environment
\\begin{columns}
\\begin{column}{0.5\\textwidth}
${1}
\\end{column}
\\begin{column}{0.5\\textwidth}
${0}
\\end{column}
\\end{columns}
snippet multicol2 two-column environment with multicol
\\begin{multicols}{2}
${1}
\columnbreak
${0}
\\end{multicols}
snippet \{ \{ \}
\\{ ${0} \\}
#delimiter
snippet lr left right
\\left${1} ${0:${VISUAL}} \\right$1
snippet lr( left( right)
\\left( ${0:${VISUAL}} \\right)
snippet lr| left| right|
\\left| ${0:${VISUAL}} \\right|
snippet lr{ left\{ right\}
\\left\\{ ${0:${VISUAL}} \\right\\}
snippet lr[ left[ right]
\\left[ ${0:${VISUAL}} \\right]
snippet lra langle rangle
\\langle ${0:${VISUAL}} \\rangle
# Code listings
snippet lst
\\begin{listing}[language=${1:language}]
${0:${VISUAL}}
\\end{listing}
snippet lsi
\\lstinline|${1}| ${0}
# Hyperlinks
snippet url
\\url{${1}} ${0}
snippet href
\\href{${1}}{${2}} ${0}
# URL from Clipboard.
snippet urlc
\\url{`@+`} ${0}
snippet hrefc
\\href{`@+`}{${1}} ${0}
# enquote from package csquotes
snippet enq enquote
\\enquote{${1:${VISUAL:text}}} ${0}
# Time derivative
snippet ddt time derivative
\\frac{d}{dt} {$1} {$0}
# Limit
snippet lim limit
\\lim_{{$1}} {{$2}} {$0}
# Partial derivative
snippet pdv partial derivation
\\frac{\\partial {$1}}{\\partial {$2}} {$0}
# Second order partial derivative
snippet ppdv second partial derivation
\\frac{\\partial^2 {$1}}{\\partial {$2} \\partial {$3}} {$0}
# Ordinary derivative
snippet dv derivative
\\frac{d {$1}}{d {$2}} {$0}
# Summation
snippet summ summation
\\sum_{{$1}} {$0}
# Shorthand for time derivative
snippet dot dot
\\dot{{$1}} {$0}
# Shorthand for second order time derivative
snippet ddot ddot
\\ddot{{$1}} {$0}
# Vector
snippet vec vector
\\vec{{$1}} {$0}
# Bar
snippet bar bar
\\bar{{$1}} {$0}
# Cross product
snippet \x cross product
\\times {$0}
# Dot product
snippet . dot product
\\cdot {$0}
# Integral
snippet int integral
\\int_{{$1}}^{{$2}} {$3} \\: d{$4} {$0}
# Right arrow
snippet ra rightarrow
\\rightarrow {$0}
# Long right arrow
snippet lra longrightarrow
\\longrightarrow {$0}

1
.config/nvim/lua/themes/.gitignore

@ -0,0 +1 @@
init.lua

62
.config/nvim/lua/themes/catppuccin.lua

@ -0,0 +1,62 @@
return {
{
"catppuccin/nvim",
version = false,
lazy = false,
priority = 1000, -- make sure to load this before all the other start plugins
-- Optional; default configuration will be used if setup isn't called.
config = function()
require('catppuccin').setup {
transparent_background = true,
}
local day = 9
local night = 18
local hour = os.date("*t").hour
local themes = { "catppuccin-macchiato", "catppuccin-mocha" }
local theme = 1
if day <= hour and hour < night then
theme = 1
else
theme = 2
end
vim.cmd.colorscheme(themes[theme])
local function toggletheme()
if theme == 1 then
theme = 2
else
theme = 1
end
vim.cmd.colorscheme(themes[theme])
end
vim.api.nvim_create_user_command("ToggleTheme", toggletheme, {})
end,
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
init = function()
vim.opt.laststatus = 3
end,
opts = {
options = {
icons_enabled = true,
theme = 'auto',
section_separators = { left = '', right = '' },
component_separators = { left = '', right = '' },
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { require('themes.utils').getWords },
},
}
},
}

40
.config/nvim/lua/themes/everforest.lua

@ -0,0 +1,40 @@
return {
{
"neanias/everforest-nvim",
version = false,
lazy = false,
priority = 1000, -- make sure to load this before all the other start plugins
-- Optional; default configuration will be used if setup isn't called.
config = function()
require("everforest").setup({
-- Your config here
transparent_background_level = 1,
background = "medium",
})
vim.cmd.colorscheme 'everforest'
end,
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
init = function()
vim.opt.laststatus = 3
end,
opts = {
options = {
icons_enabled = true,
theme = 'auto',
section_separators = { left = '', right = '' },
component_separators = { left = '', right = '' },
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { require('themes.utils').getWords },
},
}
},
}

62
.config/nvim/lua/themes/gruvbox.lua

@ -0,0 +1,62 @@
return {
{
"ellisonleao/gruvbox.nvim",
version = false,
lazy = false,
priority = 1000, -- make sure to load this before all the other start plugins
-- Optional; default configuration will be used if setup isn't called.
config = function()
require('gruvbox').setup {
}
local day = 9
local night = 18
local hour = os.date("*t").hour
local themes = { "gruvbox", "gruvbox" }
local theme = 1
if day <= hour and hour < night then
theme = 1
else
theme = 2
end
vim.cmd.colorscheme(themes[theme])
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
local function toggletheme()
if theme == 1 then
theme = 2
vim.cmd('set background=dark')
else
theme = 1
vim.cmd('set background=light')
end
end
vim.api.nvim_create_user_command("ToggleTheme", toggletheme, {})
end,
},
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
init = function()
vim.opt.laststatus = 3
end,
opts = {
options = {
icons_enabled = true,
theme = 'auto',
},
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'fileformat', 'filetype' },
lualine_y = { require('themes.utils').getWords },
},
}
},
}

9
.config/nvim/lua/themes/utils.lua

@ -0,0 +1,9 @@
return {
getWords = function()
local wordcount = vim.fn.wordcount()
if wordcount.visual_words ~= nil then
return tostring(wordcount.visual_words) .. "/" .. tostring(wordcount.words) .. " W"
end
return tostring(wordcount.words) .. " W"
end
}
Loading…
Cancel
Save