Skip to content

Instantly share code, notes, and snippets.

@00sapo
Last active February 6, 2023 04:14
Show Gist options
  • Save 00sapo/8a79cef93c34ab39ba7264d582a0af15 to your computer and use it in GitHub Desktop.
Save 00sapo/8a79cef93c34ab39ba7264d582a0af15 to your computer and use it in GitHub Desktop.
-- GistID: 8a79cef93c34ab39ba7264d582a0af15
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile
-- +-----------------------------------------+
-- | General |
-- +-----------------------------------------+
-- default shell to avoid slow downs with fish
-- vim.opt.shell = "/bin/bash"
-- wrapping long lines into multiple lines
vim.cmd("set wrap linebreak nolist")
-- self-describing options
lvim.format_on_save = false
lvim.lint_on_save = true
lvim.colorscheme = "one-nvim"
vim.opt.backup = true
vim.cmd("set guicursor=n-v:block-blinkon100,i:ver100-blinkon0,o:hor100-blinkon100,c:hor100-blinkon100")
--- Relative numbers
vim.cmd("set relativenumber")
--- Live substituting
vim.cmd("set inccommand=nosplit")
-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = "space"
-- C-s to save
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
lvim.keys.insert_mode["<C-s>"] = "<esc>:w<cr>"
-- don't know why this doesn't work if it is put in the relative fugitive config
lvim.builtin.which_key.mappings["gh"] = { "<cmd>0Gclog<cr>", "Git buffer history" }
-- project files (avoid them as much as possible)
lvim.builtin.which_key.mappings["Ld"] = { "<cmd>luafile .nvimrc.lua<cr>",
"Load directory configuration file (`.nvimrc.lua`)" }
-- avoid insane quitting keymap
lvim.builtin.which_key.mappings["q"] = nil
-- disable debugger
lvim.builtin.dap.active = false
-- disable bufferline completely
lvim.builtin.bufferline.active = false
lvim.builtin.lualine['tabline'] = {
lualine_a = { function() return vim.fn.expand('%:p') end },
lualine_z = { 'tabs' }
}
--- Telescope
vim.cmd [[
augroup Folding
au!
au FileType TelescopeResults setlocal nofoldenable
augroup END
]]
lvim.builtin.which_key.mappings["b"] = { "<cmd>Telescope buffers<cr>", "Search buffers" }
lvim.builtin.which_key.mappings["sg"] = { "<cmd>Telescope git_files<cr>", "Search git files" }
lvim.builtin.which_key.mappings["sT"] = { "<cmd>Telescope tags<cr>", "Search tags" }
lvim.builtin.telescope.defaults.mappings["n"]["<c-d>"] = require('telescope.actions').delete_buffer
-- Other
lvim.builtin.alpha.active = true
vim.o.foldmethod = 'indent'
vim.o.foldlevel = 99
-- +---------------------------------+
-- | Tree-sitter |
-- +---------------------------------+
lvim.builtin.treesitter.highlight.enable = true
lvim.builtin.treesitter.enable = true
lvim.builtin.treesitter.highlight.disable = function(lang, bufnr) -- Disable in large buffers
return vim.api.nvim_buf_line_count(bufnr) > 1000
end
lvim.builtin.treesitter.indent = { enable = false }
lvim.builtin.treesitter.incremental_selection = { enable = false }
-- +---------------------------------+
-- | LSP |
-- +---------------------------------+
-- add lsp range_code_action
lvim.builtin.which_key.vmappings['a'] = { '<cmd>lua vim.lsp.buf.range_code_action()<CR>', "Lsp Code Action" }
-- disable default lsp
lvim.lsp.automatic_configuration.skipped_servers = { "pyright" }
lvim.lsp.automatic_servers_installation = false
-- enable new lsp
local manager = require("lvim.lsp.manager")
manager.setup("pylsp", {
settings = {
pylsp = {
plugins = {
jedi = {
extra_paths = { "__pypackages__/3.9/lib", "__pypackages__/3.10/lib", "__pypackages__/3.8/lib" }
},
jedi_completion = {
fuzzy = true,
cache_for = { "pandas", "numpy", "tensorflow", "matplotlib", "torch", "sklearn", "plotly" }
},
}
}
}
})
manager.setup("julials", {})
manager.setup("texlab", {
settings = {
latexFormatter = nil
}
})
manager.setup("ltex", {
on_attach = function(client, bufnr)
-- your other on_attach functions.
require("ltex_extra").setup{
load_langs = { "es-ES", "it-IT", "en-US" }, -- table <string> : languages for witch dictionaries will be loaded
init_check = true, -- boolean : whether to load dictionaries on startup
path = nil, -- string : path to store dictionaries. Relative path uses current working directory
log_level = "none", -- string : "none", "trace", "debug", "info", "warn", "error", "fatal"
}
end,
settings = {
ltex = {
language = "en-US",
additionalRules = {
enablePickyRules = true,
motherTongue = "it",
neuralNetworkModel = "/opt/languagetool/en/neuralnetwork"
}
}
}
})
lvim.builtin.project.detection_methods = { "pattern", "lsp" }
local formatters = require "lvim.lsp.null-ls.formatters"
formatters.setup({
{ exe = "yapf", filetypes = { "python" } },
{ exe = "latexindent", filetypes = { "tex", "bib" }, args = { "-l=latexindent.yaml", "-m" } }
})
vim.cmd [[
augroup MyColorScheme
au!
au ColorScheme * exe "hi! illuminatedCurWord gui=NONE"
au ColorScheme * exe "hi! illuminatedWord gui=NONE"
au ColorScheme * exe "hi! Visual gui=NONE guibg=" . g:visual_color
au ColorScheme * hi! LspReferenceRead gui=NONE
au ColorScheme * hi! LspReferenceWrite gui=NONE
au ColorScheme * hi! LspReferenceText gui=NONE
augroup END
]]
-- +-----------------------------------------+
-- | Additional Plugins |
-- +-----------------------------------------+
lvim.plugins = {
{
"xiyaowong/accelerated-jk.nvim",
config = function()
require('accelerated-jk').setup {
mappings = { j = 'gj', k = 'gk' },
-- If the interval of key-repeat takes more than `acceleration_limit` ms, the step is reset
acceleration_limit = 150,
-- acceleration steps
acceleration_table = { 4, 8, 12, 16, 20, 24 },
deceleration_table = { { 150, 9999 } },
}
end
},
{
"windwp/nvim-ts-autotag",
event = "InsertEnter",
config = function()
require("nvim-ts-autotag").setup()
end,
},
{
"andymass/vim-matchup",
event = "CursorMoved",
config = function()
vim.g.matchup_matchparen_offscreen = { method = "popup" }
end,
},
{
"lukas-reineke/indent-blankline.nvim",
event = "BufRead",
setup = function()
vim.g.indentLine_enabled = 1
vim.g.indent_blankline_char = "▏"
vim.g.indent_blankline_filetype_exclude = { "help", "terminal", "alpha" }
vim.g.indent_blankline_buftype_exclude = { "terminal" }
vim.g.indent_blankline_show_trailing_blankline_indent = false
vim.g.indent_blankline_show_first_indent_level = false
vim.g.indent_blankline_use_treesitter = false
end
},
{
"karb94/neoscroll.nvim",
event = "WinScrolled",
config = function()
require('neoscroll').setup({
-- All these keys will be mapped to their corresponding default scrolling animation
mappings = { '<C-u>', '<C-d>', '<C-b>', '<C-f>',
'<C-y>', '<C-e>', 'zt', 'zz', 'zb' },
hide_cursor = true, -- Hide cursor while scrolling
stop_eof = true, -- Stop at <EOF> when scrolling downwards
use_local_scrolloff = false, -- Use the local scope of scrolloff instead of the global scope
respect_scrolloff = false, -- Stop scrolling when the cursor reaches the scrolloff margin of the file
cursor_scrolls_alone = true, -- The cursor will keep on scrolling even if the window cannot scroll further
easing_function = nil, -- Default easing function
pre_hook = nil, -- Function to run before the scrolling animation starts
post_hook = nil, -- Function to run after the scrolling animation ends
})
end
},
{
"jaxbot/semantic-highlight.vim",
config = function()
vim.g.semanticEnableFileTypes = {
javascript = 'js',
vim = 'vim',
python = 'py',
c = 'c',
cpp = 'cpp',
java = 'java',
julia = 'jl',
r = 'r',
matlab = 'm',
lua = 'lua'
}
vim.g.semanticUseCache = 1
vim.g.semanticPersistCache = 1
end
},
{
'eugen0329/vim-esearch',
config = function()
lvim.builtin.which_key.mappings["f"] = {
name = "Esearch find",
f = { "<plug>(esearch)", "Everywhere" },
t = { "<plug>(operator-esearch-prefill)", "Text Object" },
i = { ":call esearch#init({'paths': expand('%:p')})<cr>", "In Current File" },
w = { "<cmd>set scrolloff=0<CR>VHoL<Esc><cmd>set scrolloff=1<CR>``<C-y>/\\%V", "Search current window" }
}
lvim.builtin.which_key.vmappings["f"] = {
name = "Esearch find",
f = { ":call esearch#init({'pattern': expand('*')})<cr>", "Everywhere" },
i = { ":call esearch#init({'pattern': expand('*'), 'paths': expand('%:p')})<cr>", "In Current File" },
}
vim.g.esearch = {
-- Start the search only when the enter is hit instead of updating the pattern while you're typing.
regex = 'pcre',
live_update = 1,
case = 'line',
adapter = 'rg'
}
-- Open the search window in a vertical split and reuse it for all further searches.
vim.cmd [[
let g:esearch.name = '[esearch]'
let g:esearch.win_new = {esearch -> esearch#buf#goto_or_open(esearch.name, 'vnew')}
]]
end
},
{
-- texlab is not enough good (can't get forward search and compilation working)
"lervag/vimtex",
config = function()
-- lvim.lang.tex.lsp.provider = nil
-- lvim.lang.latex.lsp.provider = nil
-- remove completion
vim.g.vimtex_complete_enabled = false
-- vim.g.latex_rpc_server = "/tmp/nvim-latex" -- to be used by other softwae, e.g. jabref
vim.cmd [[
augroup VimTex
au!
au FIleType tex setlocal spell spelllang=en_us
au FIleType tex set tw=80
augroup END
]]
vim.g.tex_flavor = 'latex'
vim.g.vimtex_quickfix_open_on_warning = 0
vim.g.vimtex_compiler_latexmk = { build_dir = 'build' }
vim.g.vimtex_format_enabled = 1
-- sioyek
vim.g.vimtex_view_method = 'sioyek'
-- okular
-- vim.g.vimtex_view_general_viewer = 'okular'
-- vim.g.vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex'
-- zathura
-- vim.g.vimtex_view_method = 'zathura'
end
},
{
'ludovicchabant/vim-gutentags',
config = function()
vim.g.gutentags_ctags_exclude = { '.venv', '.mypy_cache', '.git' }
vim.g.gutentags_project_root = { '.gutentags' }
vim.g.gutentags_modules = { 'ctags' }
vim.g.gutentags_cache_dir = '~/.cache/lvim/ctags/'
vim.g.gutentags_generate_on_new = true
vim.g.gutentags_generate_on_missing = true
vim.g.gutentags_generate_on_write = true
vim.g.gutentags_generate_on_empty_buffer = 0
vim.g.gutentags_ctags_extra_args = { '--fields=+ailmnS' }
end
},
{
'inkarkat/vim-mark',
config = function()
vim.g.mw_no_mappings = true
lvim.builtin.which_key.mappings["m"] = {
name = "Mark Words",
m = { "<Plug>MarkSet", "Mark this word" },
t = { "<Plug>MarkToggle", "Toggle All Marks" },
c = { "<Plug>MarkClear", "Clear this mark" },
l = { "<cmd>MarkLoad<cr>", "Load Previous Session Marks" },
s = { "<cmd>MarkSave<cr>", "Save Current Session Marks" },
C = { "<Plug>MarkConfirmAllClear", "Clear all marks" },
}
lvim.builtin.which_key.vmappings["m"] = {
name = "Mark Words",
m = { "<Plug>MarkSet", "Mark this word" },
c = { "<Plug>MarkClear", "Clear this mark" },
}
end,
requires = { 'inkarkat/vim-ingo-library' }
},
{
'Ron89/thesaurus_query.vim',
config = function()
vim.g.tq_map_keys = false
lvim.builtin.which_key.mappings["w"] = { "<cmd>ThesaurusQueryReplaceCurrentWord<cr>", "Thesaurus Replace Word" }
end
},
{
'nvim-telescope/telescope-symbols.nvim',
config = function()
vim.api.nvim_set_keymap(
"i",
"<c-u>",
"<cmd>lua require'telescope.builtin'.symbols{sources = {'math', 'gitmoji'}}<cr>",
{}
)
end
},
{
'kassio/neoterm',
config = function()
-- keys to setup function
lvim.builtin.which_key.mappings["x"] = {
name = "Execute in Terminal",
x = { "<cmd>Tmap<cr>", "Execute the `Tmap` command" },
s = { "<plug>(neoterm-repl-send)", "Send Object to Terminal" },
ss = { "<Plug>(neoterm-repl-send-line)", "Send line to terminal" },
}
lvim.builtin.which_key.vmappings["x"] = {
name = "Execute in Terminal",
s = { "<plug>(neoterm-repl-send)", "Send Selection to Terminal" },
}
-- Disable ToggleTerm
lvim.builtin.terminal.active = false
-- jk and kj to escape terminal mode
vim.api.nvim_set_keymap('t', 'jk', '<C-\\><C-n>', {})
vim.api.nvim_set_keymap('t', 'kj', '<C-\\><C-n>', {})
-- Toggle terminals on a temporary tab
function ToggleNeoTerm()
local bufnr = vim.fn.bufnr()
local count = vim.v.count
if vim.bo[bufnr].filetype == 'neoterm' then
vim.cmd("tabclose")
vim.cmd(vim.g.tab_prev_neoterm .. "tabnext")
else
vim.g.tab_prev_neoterm = vim.fn.tabpagenr()
vim.cmd("$tabnew %") -- this looks like a neovim bug: without % it doesn't work
vim.cmd(count .. "Topen")
end
end
vim.api.nvim_set_keymap('n', '<C-t>', "<cmd>lua ToggleNeoTerm()<cr>", {})
vim.api.nvim_set_keymap('i', '<C-t>', "<cmd>lua ToggleNeoTerm()<cr>", {})
vim.api.nvim_set_keymap('t', '<C-t>', "<cmd>lua ToggleNeoTerm()<cr>", {})
-- Put the standard terminal title in the buffer name of terminals
function SetTermName()
if vim.b.term_title ~= nil then
local new_name = 'term://' .. vim.b.term_title
if vim.bo.filetype == 'neoterm' then
new_name = new_name .. '; neoterm-' .. vim.b.neoterm_id
end
vim.cmd('file ' .. new_name)
end
end
vim.cmd [[
augroup TermInsert
au!
autocmd TermOpen,BufEnter term://* startinsert
autocmd BufLeave term://* stopinsert
augroup END
augroup TermName
autocmd!
autocmd TermEnter,TermLeave,BufLeave term://* lua SetTermName()
augroup END
]]
end
},
{
'anuvyklack/pretty-fold.nvim',
config = function()
require('pretty-fold').setup {
ft_ignore = { 'TelescopePrompt', 'TelescopeResults', 'terminal' },
}
-- require('pretty-fold.preview').setup()
end,
requires = { 'anuvyklack/nvim-keymap-amend' }
},
{
"iamcco/markdown-preview.nvim",
cmd = {"MarkdownPreview"},
config = function()
lvim.builtin.which_key.mappings['M'] = {
name = "MarkDown",
p = { "<cmd>MarkdownPreview<cr>", "Start Markdown Preview" },
s = { "<cmd>MarkdownPreviewStop<cr>", "Stop Markdown Preview" },
t = { "<cmd>MarkdownPreviewToggle<cr>", "Toggle Markdown Preview" },
}
end,
run = "cd app && npm install",
setup = function() vim.g.mkdp_filetypes = { "markdown" } end,
-- ft = { "markdown" }
},
{
"ray-x/lsp_signature.nvim",
event = "BufRead",
config = function() require "lsp_signature".on_attach() end,
},
{
"ThePrimeagen/refactoring.nvim",
config = function()
require('refactoring').setup {}
-- load refactoring Telescope extension
require("telescope").load_extension("refactoring")
-- remap to open the Telescope refactoring menu in visual mode
lvim.builtin.which_key.vmappings['r'] = {
"<Esc><cmd>lua require('telescope').extensions.refactoring.refactors()<CR>",
"Refactoring"
}
end,
requires = {
{ "nvim-lua/plenary.nvim" },
{ "nvim-treesitter/nvim-treesitter" }
}
},
{
'glacambre/firenvim',
run = function() vim.fn['firenvim#install'](0) end
},
{
'potamides/pantran.nvim',
config = function ()
require("pantran").setup{
default_engine = "google",
engines = {
argos = {
default_target = "it"
},
google = {
default_target = "it",
fallback = {
default_target = "it"
}
}
}
}
lvim.builtin.which_key.mappings['t'] = {"vip:Pantran<cr>vipJ", "Translate"}
lvim.builtin.which_key.vmappings['t'] = {":Pantran<cr>vipJ", "Translate"}
end
},
{ "barreiroleo/ltex-extra.nvim" },
{ "folke/zen-mode.nvim" },
{ 'michaeljsmith/vim-indent-object' },
{ 'tpope/vim-fugitive' },
{ 'mbbill/undotree' },
{ 'gyim/vim-boxdraw' },
{ 'PeterRincker/vim-argumentative' },
{ 'tpope/vim-surround' },
{ 'tpope/vim-repeat' },
{ 'lambdalisue/suda.vim' },
{ 'mattn/gist-vim', requires = { 'mattn/webapi-vim' } },
{ 'Th3Whit3Wolf/one-nvim' },
{ 'dstein64/vim-startuptime' },
{ 'abecodes/tabout.nvim' },
}
-- firenvim must be configured here, not in the `config` field
vim.g.firenvim_config = {
localSettings = {
['.*'] = {
takeover = 'never'
}
}
}
-- +------------------------------------------+
-- | Appeareance |
-- +------------------------------------------+
--- light colorscheme (comment out for dark)
local dark_semanticGUIColors = vim.g.semanticGUIColors
local light_semanticGUIColors = { '#632708', '#0A05E2', '#06839A', '#CA2D80', '#148A29', '#1A2E7F', '#76680A', '#2B625A',
'#8013CA', '#094DDC', '#4B0E3C', '#6648CF', '#0983E4', '#C53941', '#15500E', '#2165B1', '#441578', '#110F92', '#704D8D',
'#155B7E', '#0A7551', '#7F4F64', '#A21799', '#4A5A3A', '#775219', '#B25542', '#122AD7', '#05944D', '#B80D2B', '#0B8079',
'#D12700', '#471FE3', '#3A5ED8', '#8B44B9', '#2C790E', '#682029', '#4E5690', '#99448A', '#6855B6', '#1078B5', '#B7120F',
'#3F51AF', '#765549', '#282E14', '#A1476B', '#A80F53', '#4A50E4', '#485A0F', '#741D76', '#2C7539', '#37119C', '#1263C9',
'#7A45A0', '#62158B', '#7A3AD2', '#BF481A', '#115C3D', '#831649', '#7313A7', '#275993', '#AE3FC4', '#3B319B', '#BA19B7',
'#B23EA1', '#9C5A0C', '#157399', '#2D2BC1', '#1A4317', '#1B4834', '#4F6D0B', '#BB3A73', '#2E1667', '#891B0D', '#1E6C6D',
'#571A5B', '#406029', '#173DA4', '#A70A69', '#945153', '#6B3D6E', '#810E24', '#1729A3', '#5815C7', '#2C751F', '#130BAC',
'#A32747', '#494094', '#411E0E', '#4E2BC1', '#141884', '#7B5A32', '#301085', '#5C3AA8', '#1B44CB', '#134EAE', '#42360D',
'#A14F16', '#1F689B', '#641C37', '#4C5223', '#4D53C9', '#3732B0', '#386850', '#2324D9', '#4357A1', '#1B6A5A', '#0C8247',
'#8F3F4E', '#A51282', '#1B6B7D', '#755E0F', '#4C1211', '#2511CB', '#1429B9', '#135D2D', '#5F5819', '#C1402C', '#3F6740',
'#0E77D1', '#884020', '#804038', '#2B6AE0', '#5A3F2F', '#476D21', '#0734CE', '#8A2F26', '#595F4B', '#15671B', '#0C7419',
'#237C5B' }
function ChangeBackground(mode)
local lazygit_confpath = vim.env.HOME .. "/.config/lazygit/config.yml"
if mode == 'light' then
vim.g.semanticGUIColors = light_semanticGUIColors
vim.g.curword_color = "#e6f2ff"
vim.g.visual_color = "#ffe6e6"
vim.opt.background = "light"
local file = io.open(lazygit_confpath, "w")
if file ~= nil then
io.output(file)
io.write([[
git:
paging:
colorArg: always
pager: delta --light --paging=never
gui:
theme:
lightTheme: true
activeBorderColor:
- black
- bold
inactiveBorderColor:
- black
selectedLineBgColor:
- default
]] )
io.close(file)
else
print("Cannot open lazygit configuration file:" .. lazygit_confpath)
end
elseif mode == 'dark' then
vim.g.semanticGUIColors = dark_semanticGUIColors
vim.g.curword_color = "#404040"
vim.g.visual_color = "#3e4452"
vim.opt.background = 'dark'
local file = io.open(lazygit_confpath, "w")
if file ~= nil then
io.output(file)
io.output(file)
io.write([[
git:
paging:
colorArg: always
pager: delta --dark --paging=never
]] )
io.close(file)
else
print("Cannot open lazygit configuration file:" .. lazygit_confpath)
end
elseif mode == 'transparent' then
vim.g.one_nvim_transparent_bg = true
end
end
vim.cmd("command! -nargs=1 ChangeBackground :lua ChangeBackground(<args>)")
lvim.builtin.which_key.mappings["a"] = {
name = "Appeareance",
l = { "<cmd>ChangeBackground 'light'<CR>", "Light Background" },
d = { "<cmd>ChangeBackground 'dark'<CR>", "Dark Background" },
p = { "<cmd>lua require('telescope.builtin.internal').colorscheme({enable_preview = true})<CR>", "Preview Colorscheme" },
t = { "<cmd>ChangeBackground 'transparent'<CR>", "Use transparent background" },
s = { "<cmd>SemanticHighlightToggle<cr>", "Toggle Semantic Highlight" }
}
lvim.builtin.which_key.mappings['sc'] = nil
lvim.builtin.which_key.mappings['sp'] = nil
ChangeBackground('dark')
-- ChangeBackground('transparent')
-- gui settings
vim.opt.guifont = 'DejaVuSansMono Nerd Font Mono:h11'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment