parent
349ee96a20
commit
9bca3eacae
1
init.lua
1
init.lua
@ -1,5 +1,4 @@
|
||||
require "core"
|
||||
require "core.utils"
|
||||
require "core.options"
|
||||
|
||||
vim.defer_fn(function()
|
||||
|
@ -1,8 +1,10 @@
|
||||
-- commands
|
||||
vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
|
||||
vim.cmd "silent! command! NvChadSnapshotCreate lua require('nvchad').snap_create()"
|
||||
vim.cmd "silent! command! NvChadSnapshotDelete lua require('nvchad').snap_delete()"
|
||||
vim.cmd "silent! command! NvChadSnapshotCheckout lua require('nvchad').snap_checkout()"
|
||||
|
||||
-- autocmds
|
||||
local autocmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- Disable statusline in dashboard
|
||||
|
@ -1,5 +1,7 @@
|
||||
-- https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
|
||||
local lazy_load = function(tb)
|
||||
-- thx to https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
|
||||
local M = {}
|
||||
|
||||
M.lazy_load = function(tb)
|
||||
vim.api.nvim_create_autocmd(tb.events, {
|
||||
pattern = "*",
|
||||
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
|
||||
@ -21,12 +23,8 @@ local lazy_load = function(tb)
|
||||
})
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
M.lazy_load = lazy_load
|
||||
|
||||
M.bufferline = function()
|
||||
lazy_load {
|
||||
M.lazy_load {
|
||||
events = { "BufNewFile", "BufRead", "TabEnter" },
|
||||
augroup_name = "BufferLineLazy",
|
||||
plugins = "bufferline.nvim",
|
||||
@ -38,13 +36,13 @@ M.bufferline = function()
|
||||
end
|
||||
|
||||
M.colorizer = function()
|
||||
lazy_load {
|
||||
M.lazy_load {
|
||||
events = { "BufRead", "BufNewFile" },
|
||||
augroup_name = "ColorizerLazy",
|
||||
plugins = "nvim-colorizer.lua",
|
||||
|
||||
condition = function()
|
||||
local items = { "#", "rgb", "hsl" }
|
||||
local items = { "#", "rgb", "hsl", "rgba", "hsla" }
|
||||
|
||||
for _, val in ipairs(items) do
|
||||
if vim.fn.search(val) ~= 0 then
|
||||
@ -56,28 +54,14 @@ M.colorizer = function()
|
||||
end
|
||||
|
||||
-- load certain plugins only when there's a file opened in the buffer
|
||||
-- if "nvim-file" is executed -> load the plugin after nvim gui loads
|
||||
-- if "nvim filename" is executed -> load the plugin after nvim gui loads
|
||||
-- This gives an instant preview of nvim with the file opened
|
||||
|
||||
M.on_file_open = function()
|
||||
lazy_load {
|
||||
M.on_file_open = function(plugin_name)
|
||||
M.lazy_load {
|
||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
augroup_name = "BeLazyOnFileOpen",
|
||||
plugins = "nvim-lsp-installer indent-blankline.nvim",
|
||||
|
||||
condition = function()
|
||||
local file = vim.fn.expand "%"
|
||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
M.treesitter = function()
|
||||
lazy_load {
|
||||
events = { "BufRead", "BufWinEnter", "BufNewFile" },
|
||||
augroup_name = "Treesitter_lazy",
|
||||
plugins = "nvim-treesitter",
|
||||
|
||||
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
|
||||
plugins = plugin_name,
|
||||
condition = function()
|
||||
local file = vim.fn.expand "%"
|
||||
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- n, v, i are mode names
|
||||
-- n, v, i, tare mode names
|
||||
|
||||
local function termcodes(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
@ -147,7 +147,7 @@ M.lspconfig = {
|
||||
|
||||
["<leader>ra"] = {
|
||||
function()
|
||||
require("ui.renamer").open()
|
||||
require("nvchad.ui.renamer").open()
|
||||
end,
|
||||
" lsp rename",
|
||||
},
|
||||
@ -342,4 +342,24 @@ M.whichkey = {
|
||||
},
|
||||
}
|
||||
|
||||
M.blankline = {
|
||||
n = {
|
||||
["<leader>bc"] = {
|
||||
function()
|
||||
local ok, start = require("indent_blankline.utils").get_current_context(
|
||||
vim.g.indent_blankline_context_patterns,
|
||||
vim.g.indent_blankline_use_treesitter_scope
|
||||
)
|
||||
|
||||
if ok then
|
||||
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
|
||||
vim.cmd [[normal! _]]
|
||||
end
|
||||
end,
|
||||
|
||||
" Jump to current_context",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
||||
|
@ -19,14 +19,12 @@ opt.title = true
|
||||
opt.clipboard = "unnamedplus"
|
||||
opt.cul = true -- cursor line
|
||||
|
||||
-- Indentline
|
||||
-- Indenting
|
||||
opt.expandtab = true
|
||||
opt.shiftwidth = 2
|
||||
opt.smartindent = true
|
||||
|
||||
-- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758
|
||||
opt.fillchars = { eob = " " }
|
||||
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.mouse = "a"
|
||||
@ -53,10 +51,10 @@ opt.updatetime = 250
|
||||
-- go to previous/next line with h,l,left arrow and right arrow
|
||||
-- when cursor reaches end/beginning of line
|
||||
opt.whichwrap:append "<>[]hl"
|
||||
|
||||
g.mapleader = " "
|
||||
|
||||
-- disable some builtin vim plugins
|
||||
|
||||
local default_plugins = {
|
||||
"2html_plugin",
|
||||
"getscript",
|
||||
@ -101,5 +99,5 @@ vim.schedule(function()
|
||||
vim.cmd [[ silent! rsh ]]
|
||||
end)
|
||||
|
||||
-- load user options if the file exists
|
||||
-- load user options
|
||||
config.options.user()
|
||||
|
@ -8,7 +8,6 @@ M.bootstrap = function()
|
||||
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
print "Cloning packer .."
|
||||
|
||||
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
|
||||
|
||||
-- install plugins + compile their configs
|
||||
@ -23,7 +22,7 @@ M.options = {
|
||||
compile_on_sync = true,
|
||||
git = { clone_timeout = 6000 },
|
||||
display = {
|
||||
working_sym = " ﲊ",
|
||||
working_sym = "ﲊ",
|
||||
error_sym = "✗ ",
|
||||
done_sym = " ",
|
||||
removed_sym = " ",
|
||||
|
@ -21,6 +21,7 @@ M.close_buffer = function(force)
|
||||
end
|
||||
|
||||
force = force or not vim.bo.buflisted or vim.bo.buftype == "nofile"
|
||||
|
||||
-- if not force, change to prev buf and then close current
|
||||
local close_cmd = force and ":bd!" or ":bp | bd" .. fn.bufnr()
|
||||
vim.cmd(close_cmd)
|
||||
@ -150,9 +151,7 @@ M.load_override = function(default_table, plugin_name)
|
||||
|
||||
if type(user_table) == "function" then
|
||||
user_table = user_table()
|
||||
end
|
||||
|
||||
if type(user_table) == "table" then
|
||||
elseif type(user_table) == "table" then
|
||||
default_table = merge_tb("force", default_table, user_table)
|
||||
else
|
||||
default_table = default_table
|
||||
|
@ -7,6 +7,7 @@ end
|
||||
require("base46").load_highlight "bufferline"
|
||||
|
||||
vim.cmd [[
|
||||
|
||||
function! Toggle_theme(a,b,c,d)
|
||||
lua require('base46').toggle_theme()
|
||||
endfunction
|
||||
@ -25,18 +26,16 @@ local options = {
|
||||
show_close_icon = false,
|
||||
left_trunc_marker = " ",
|
||||
right_trunc_marker = " ",
|
||||
max_name_length = 14,
|
||||
max_name_length = 20,
|
||||
max_prefix_length = 13,
|
||||
tab_size = 20,
|
||||
show_tab_indicators = true,
|
||||
enforce_regular_tabs = false,
|
||||
view = "multiwindow",
|
||||
show_buffer_close_icons = true,
|
||||
separator_style = "thin",
|
||||
always_show_bufferline = true,
|
||||
diagnostics = false,
|
||||
themable = true,
|
||||
|
||||
-- top right buttons in bufferline
|
||||
custom_areas = {
|
||||
right = function()
|
||||
return {
|
||||
@ -45,24 +44,6 @@ local options = {
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
custom_filter = function(buf_number)
|
||||
-- Func to filter out our managed/persistent split terms
|
||||
local present_type, type = pcall(function()
|
||||
return vim.api.nvim_buf_get_var(buf_number, "term_type")
|
||||
end)
|
||||
|
||||
if present_type then
|
||||
if type == "vert" then
|
||||
return false
|
||||
elseif type == "hori" then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return true
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ local options = {
|
||||
},
|
||||
},
|
||||
|
||||
max_concurrent_installers = 20,
|
||||
max_concurrent_installers = 10,
|
||||
}
|
||||
|
||||
options = require("core.utils").load_override(options, "williamboman/nvim-lsp-installer")
|
||||
|
@ -12,20 +12,14 @@ local utils = require "core.utils"
|
||||
require "ui.lsp"
|
||||
|
||||
M.on_attach = function(client, bufnr)
|
||||
client.server_capabilities.documentFormattingProvider = false
|
||||
client.server_capabilities.documentRangeFormattingProvider = false
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
client.resolved_capabilities.document_range_formatting = false
|
||||
|
||||
local lsp_mappings = utils.load_config().mappings.lspconfig
|
||||
utils.load_mappings({ lsp_mappings }, { buffer = bufnr })
|
||||
|
||||
if client.supports_method "textDocument/signatureHelp" then
|
||||
vim.api.nvim_create_autocmd({ "CursorHoldI" }, {
|
||||
pattern = "*",
|
||||
group = vim.api.nvim_create_augroup("LspSignature", {}),
|
||||
callback = function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end,
|
||||
})
|
||||
if client.server_capabilities.signatureHelpProvider then
|
||||
require("nvchad.ui.signature").setup(client)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -9,12 +9,11 @@ require("base46").load_highlight "nvimtree"
|
||||
local options = {
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
exclude = { "custom" },
|
||||
},
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
ignore_ft_on_setup = { "alpha" },
|
||||
open_on_tab = false,
|
||||
hijack_cursor = true,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
update_cwd = true,
|
||||
@ -43,15 +42,15 @@ local options = {
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
},
|
||||
|
||||
icons = {
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = false,
|
||||
},
|
||||
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
|
@ -48,6 +48,8 @@ M.blankline = function()
|
||||
buftype_exclude = { "terminal" },
|
||||
show_trailing_blankline_indent = false,
|
||||
show_first_indent_level = false,
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
}
|
||||
|
||||
options = load_override(options, "lukas-reineke/indent-blankline.nvim")
|
||||
@ -74,8 +76,6 @@ M.colorizer = function()
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
|
||||
-- Available modes: foreground, background
|
||||
mode = "background", -- Set the display mode.
|
||||
},
|
||||
}
|
||||
@ -146,6 +146,7 @@ M.devicons = function()
|
||||
|
||||
local options = { override = require("ui.icons").devicons }
|
||||
options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons")
|
||||
|
||||
devicons.setup(options)
|
||||
end
|
||||
end
|
||||
|
@ -44,6 +44,9 @@ local plugins = {
|
||||
|
||||
["lukas-reineke/indent-blankline.nvim"] = {
|
||||
opt = true,
|
||||
setup = function()
|
||||
require("core.lazy_load").on_file_open "indent-blankline.nvim"
|
||||
end,
|
||||
config = function()
|
||||
require("plugins.configs.others").blankline()
|
||||
end,
|
||||
@ -61,9 +64,8 @@ local plugins = {
|
||||
|
||||
["nvim-treesitter/nvim-treesitter"] = {
|
||||
module = "nvim-treesitter",
|
||||
cmd = { "TSInstall", "TSUninstall" },
|
||||
setup = function()
|
||||
require("core.lazy_load").treesitter()
|
||||
require("core.lazy_load").on_file_open "nvim-treesitter"
|
||||
end,
|
||||
run = ":TSUpdate",
|
||||
config = function()
|
||||
@ -87,7 +89,7 @@ local plugins = {
|
||||
["williamboman/nvim-lsp-installer"] = {
|
||||
opt = true,
|
||||
setup = function()
|
||||
require("core.lazy_load").on_file_open()
|
||||
require("core.lazy_load").on_file_open "nvim-lsp-installer"
|
||||
end,
|
||||
},
|
||||
|
||||
|
@ -45,13 +45,3 @@ win.default_opts = function(options)
|
||||
opts.border = "single"
|
||||
return opts
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = "single",
|
||||
silent = true,
|
||||
focusable = false,
|
||||
close_events = { "InsertCharPre", "CursorMoved" },
|
||||
anchor = "SW",
|
||||
relative = "cursor",
|
||||
row = -1,
|
||||
})
|
||||
|
@ -1,60 +0,0 @@
|
||||
-- credits to @Malace : https://www.reddit.com/r/neovim/comments/ql4iuj/rename_hover_including_window_title_and/
|
||||
-- This is modified version of the above snippet
|
||||
|
||||
local M = {}
|
||||
|
||||
M.open = function()
|
||||
local currName = vim.fn.expand "<cword>" .. " "
|
||||
|
||||
local win = require("plenary.popup").create(currName, {
|
||||
title = "Renamer",
|
||||
style = "minimal",
|
||||
borderchars = { "─", "│", "─", "│", "╭", "╮", "╯", "╰" },
|
||||
relative = "cursor",
|
||||
borderhighlight = "RenamerBorder",
|
||||
titlehighlight = "RenamerTitle",
|
||||
focusable = true,
|
||||
width = 25,
|
||||
height = 1,
|
||||
line = "cursor+2",
|
||||
col = "cursor-1",
|
||||
})
|
||||
|
||||
local map_opts = { noremap = true, silent = true }
|
||||
|
||||
vim.cmd "normal w"
|
||||
vim.cmd "startinsert"
|
||||
|
||||
vim.api.nvim_buf_set_keymap(0, "i", "<Esc>", "<cmd>stopinsert | q!<CR>", map_opts)
|
||||
vim.api.nvim_buf_set_keymap(0, "n", "<Esc>", "<cmd>stopinsert | q!<CR>", map_opts)
|
||||
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
0,
|
||||
"i",
|
||||
"<CR>",
|
||||
"<cmd>stopinsert | lua require'ui.renamer'.apply(" .. currName .. "," .. win .. ")<CR>",
|
||||
map_opts
|
||||
)
|
||||
|
||||
vim.api.nvim_buf_set_keymap(
|
||||
0,
|
||||
"n",
|
||||
"<CR>",
|
||||
"<cmd>stopinsert | lua require'ui.renamer'.apply(" .. currName .. "," .. win .. ")<CR>",
|
||||
map_opts
|
||||
)
|
||||
end
|
||||
|
||||
M.apply = function(curr, win)
|
||||
local newName = vim.trim(vim.fn.getline ".")
|
||||
vim.api.nvim_win_close(win, true)
|
||||
|
||||
if #newName > 0 and newName ~= curr then
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
params.newName = newName
|
||||
|
||||
vim.lsp.buf_request(0, "textDocument/rename", params)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
@ -149,18 +149,14 @@ end
|
||||
|
||||
M.LSP_status = function()
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
local names = {}
|
||||
local name = false
|
||||
for _, client in ipairs(clients) do
|
||||
if client.attached_buffers[vim.api.nvim_get_current_buf()] then
|
||||
table.insert(names, client.name)
|
||||
name = client.name
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
local name = false
|
||||
if next(names) then
|
||||
name = table.concat(names, '|')
|
||||
end
|
||||
|
||||
local content = name and " LSP ~ " .. name .. " " or false
|
||||
return content and ("%#St_LspStatus#" .. content) or ""
|
||||
end
|
||||
@ -174,19 +170,19 @@ end
|
||||
|
||||
M.cursor_position = function()
|
||||
local left_sep = "%#St_pos_sep#" .. sep_l
|
||||
local icon = "%#St_pos_icon#" .. " "
|
||||
local icon = "%#St_pos_icon#" .. " "
|
||||
|
||||
local current_line = fn.line "."
|
||||
local total_line = fn.line "$"
|
||||
local text = math.modf((current_line / total_line) * 100) .. tostring "%%"
|
||||
|
||||
if current_line == 1 then
|
||||
text = "Top "
|
||||
text = "Top"
|
||||
elseif current_line == total_line then
|
||||
text = "Bot "
|
||||
text = "Bot"
|
||||
end
|
||||
|
||||
return left_sep .. icon .. "%#St_pos_text#" .. " " .. text
|
||||
return left_sep .. icon .. "%#St_pos_text#" .. " " .. text .. " "
|
||||
end
|
||||
|
||||
M.run = function()
|
||||
|
Loading…
Reference in New Issue
Block a user