Move nvim config
This commit is contained in:
182
modules/nvim/lua/base.lua
Normal file
182
modules/nvim/lua/base.lua
Normal file
@@ -0,0 +1,182 @@
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
-------------------------
|
||||
-------- OPTIONS --------
|
||||
-------------------------
|
||||
vim.opt.mouse = 'a'
|
||||
vim.opt.history = 1000
|
||||
vim.opt.ruler = true
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
vim.opt.showcmd = true
|
||||
vim.opt.ttimeoutlen = 100
|
||||
vim.opt.backspace = 'indent,eol,start'
|
||||
vim.opt.tabstop = 2
|
||||
vim.opt.expandtab = true
|
||||
vim.opt.shiftwidth = 2
|
||||
vim.opt.softtabstop = 2
|
||||
vim.opt.autoindent = true
|
||||
vim.opt.showmatch = true
|
||||
vim.opt.incsearch = true
|
||||
vim.opt.hlsearch = true
|
||||
vim.opt.wrapscan = true
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
vim.opt.hidden = true
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.swapfile = true
|
||||
vim.opt.directory= '~/.cache/nvim/swap//,$TEMP//,/tmp//'
|
||||
vim.opt.wildmode = 'longest,list'
|
||||
vim.opt.wildignore = vim.opt.wildignore + 'main,*.o,*.d,*.aux,*.bbl,*.lof,*.loa,*.blg,*.fdb_latexmk,*.fls,*.tdo,*.pdf,*.pyc'
|
||||
vim.opt.spell = false
|
||||
vim.opt.foldmethod = 'syntax'
|
||||
vim.opt.foldopen = vim.opt.foldopen - 'block'
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.lazyredraw = true
|
||||
vim.opt.listchars = 'eol:¬,tab:▸ ,trail:·'
|
||||
vim.opt.fillchars = 'vert:|,fold: '
|
||||
vim.opt.list = true
|
||||
vim.opt.laststatus = 3
|
||||
vim.opt.scrolloff = 8
|
||||
vim.opt.background = 'light'
|
||||
vim.opt.wrap = true
|
||||
vim.opt.showbreak = '..'
|
||||
vim.opt.errorbells = false
|
||||
vim.opt.visualbell = false
|
||||
vim.opt.title = true
|
||||
vim.opt.autoread = true
|
||||
vim.opt.syntax = 'on'
|
||||
vim.opt.encoding = 'utf-8'
|
||||
vim.opt.completeopt = 'menu,menuone,noselect'
|
||||
vim.opt.termguicolors = true
|
||||
vim.opt.conceallevel = 1
|
||||
|
||||
|
||||
----------------------------
|
||||
-------- CLIPBOARD ---------
|
||||
----------------------------
|
||||
if vim.fn.has("wsl") == 1 then
|
||||
vim.opt.clipboard = vim.opt.clipboard + 'unnamedplus'
|
||||
end
|
||||
|
||||
|
||||
----------------------------
|
||||
-------- COMMANDS ----------
|
||||
----------------------------
|
||||
|
||||
vim.cmd('filetype plugin indent on')
|
||||
|
||||
-- vim.cmd('colorscheme lucius')
|
||||
-- vim.cmd('LuciusWhite')
|
||||
|
||||
|
||||
----------------------------
|
||||
-------- AUTOGROUPS --------
|
||||
----------------------------
|
||||
|
||||
vim.api.nvim_create_augroup('VimIntern', { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({'FocusGained', 'BufEnter', 'CursorMoved', 'CursorMovedI', 'CursorHold', 'CursorHoldI'}, {
|
||||
group = 'VimIntern',
|
||||
pattern = '*',
|
||||
command = 'silent! checktime'
|
||||
})
|
||||
|
||||
-- vim.api.nvim_create_autocmd('BufEnter', {
|
||||
-- group = 'VimIntern',
|
||||
-- pattern = '*',
|
||||
-- command = 'silent! lcd %:p:h'
|
||||
-- })
|
||||
|
||||
-- Open nvim-tree when starting Neovim in a specific directory or any of its subdirectories
|
||||
vim.api.nvim_create_autocmd("VimEnter", {
|
||||
callback = function()
|
||||
local args = vim.fn.argv()
|
||||
|
||||
if #args > 0 then
|
||||
local current_dir = vim.fn.fnamemodify(args[1], ":p:h")
|
||||
local dir_name = vim.fn.fnamemodify(current_dir, ":t")
|
||||
|
||||
-- Check if in a "notes" directory or its subdirectory
|
||||
local in_notes = dir_name == "notes"
|
||||
if not in_notes then
|
||||
-- Check if any parent directory is named "notes"
|
||||
local path_parts = vim.split(current_dir, "/", {plain = true})
|
||||
for i, part in ipairs(path_parts) do
|
||||
if part == "notes" then
|
||||
in_notes = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- If in a notes directory or subdirectory, open the tree
|
||||
if in_notes then
|
||||
require("nvim-tree.api").tree.open()
|
||||
vim.defer_fn(function()
|
||||
require("nvim-tree.api").tree.expand_all()
|
||||
-- After expanding, return focus to the main window/buffer
|
||||
vim.cmd("wincmd p")
|
||||
end, 100) -- Small delay to ensure tree is fully loaded before expanding
|
||||
end
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
---------------------------
|
||||
-------- FUNCTIONS --------
|
||||
---------------------------
|
||||
|
||||
vim.api.nvim_create_user_command('TrimWhiteSpace', function()
|
||||
vim.cmd('%s/\\s\\+$//e')
|
||||
end, {})
|
||||
|
||||
function ToggleDiagnostics()
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
if vim.diagnostic.is_enabled() then
|
||||
print("Diagnostics enabled")
|
||||
else
|
||||
print("Diagnostics disabled")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
---------------------------
|
||||
------- DIAGNOSTICS -------
|
||||
---------------------------
|
||||
|
||||
vim.diagnostic.config({
|
||||
update_in_insert = true,
|
||||
signs = true,
|
||||
virtual_text = {
|
||||
prefix = '● ',
|
||||
current_line = false,
|
||||
severity = {
|
||||
-- min = vim.diagnostic.severity.INFO,
|
||||
max = vim.diagnostic.severity.INFO,
|
||||
},
|
||||
},
|
||||
virtual_lines = {
|
||||
current_line = false,
|
||||
severity = {
|
||||
min = vim.diagnostic.severity.WARN,
|
||||
-- max = vim.diagnostic.severity.WARN,
|
||||
},
|
||||
},
|
||||
float = {
|
||||
prefix = '',
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
},
|
||||
})
|
||||
|
||||
vim.cmd([[highlight DiagnosticUnderlineError gui=undercurl guifg=Red]])
|
||||
vim.cmd([[highlight DiagnosticUnderlineWarn gui=undercurl guifg=Yellow]])
|
||||
vim.cmd([[highlight DiagnosticUnderlineInfo gui=undercurl guifg=Blue]])
|
||||
vim.cmd([[highlight DiagnosticUnderlineHint gui=undercurl guifg=Cyan]])
|
||||
|
||||
Reference in New Issue
Block a user