📦 Initial Commit

This commit is contained in:
UnknownRori 2023-06-12 09:28:01 +07:00
parent 5125fd927a
commit e77acb091e
No known key found for this signature in database
GPG Key ID: 25FB6BA9E0169742
23 changed files with 516 additions and 24 deletions

View File

@ -63,6 +63,7 @@ vim.opt.rtp:prepend(lazypath)
-- You can also configure plugins after the setup call,
-- as they will be available in your neovim runtime.
require('lazy').setup({
-- NOTE: First, some plugins that don't require any configuration
-- Git related plugins
@ -72,6 +73,8 @@ require('lazy').setup({
-- Detect tabstop and shiftwidth automatically
'tpope/vim-sleuth',
require('custom.plugins.inlayhint'),
-- NOTE: This is where your plugins related to LSP can be installed.
-- The configuration is done below. Search for lspconfig to find it below.
{
@ -84,7 +87,7 @@ require('lazy').setup({
-- Useful status updates for LSP
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
{ 'j-hui/fidget.nvim', opts = {} },
{ 'j-hui/fidget.nvim', opts = {} },
-- Additional lua configuration, makes nvim stuff amazing!
'folke/neodev.nvim',
@ -108,7 +111,7 @@ require('lazy').setup({
},
-- Useful plugin to show you pending keybinds.
{ 'folke/which-key.nvim', opts = {} },
{ 'folke/which-key.nvim', opts = {} },
{
-- Adds git releated signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
@ -122,21 +125,14 @@ require('lazy').setup({
changedelete = { text = '~' },
},
on_attach = function(bufnr)
vim.keymap.set('n', '<leader>gp', require('gitsigns').prev_hunk, { buffer = bufnr, desc = '[G]o to [P]revious Hunk' })
vim.keymap.set('n', '<leader>gn', require('gitsigns').next_hunk, { buffer = bufnr, desc = '[G]o to [N]ext Hunk' })
vim.keymap.set('n', '[c', require('gitsigns').prev_hunk, { buffer = bufnr, desc = 'Go to Previous Hunk' })
vim.keymap.set('n', ']c', require('gitsigns').next_hunk, { buffer = bufnr, desc = 'Go to Next Hunk' })
vim.keymap.set('n', '<leader>ph', require('gitsigns').preview_hunk, { buffer = bufnr, desc = '[P]review [H]unk' })
end,
},
},
{
-- Theme inspired by Atom
'navarasu/onedark.nvim',
priority = 1000,
config = function()
vim.cmd.colorscheme 'onedark'
end,
},
require('custom.theme'),
{
-- Set lualine as statusline
@ -144,10 +140,27 @@ require('lazy').setup({
-- See `:help lualine.txt`
opts = {
options = {
icons_enabled = false,
theme = 'onedark',
component_separators = '|',
section_separators = '',
icons_enabled = true,
theme = 'auto',
section_separators = { left = "", right = "" },
component_separators = { left = "", right = "" }
},
-- Custom sections
sections = {
lualine_a = { 'mode' },
lualine_b = { 'branch', 'diff', 'diagnostics' },
lualine_c = { 'filename' },
lualine_x = { 'encoding', 'filetype', require('custom.lualine').me },
lualine_y = { 'progress' },
lualine_z = { 'location' }
},
inactive_sections = {
lualine_a = {},
lualine_b = {},
lualine_c = { 'filename' },
lualine_x = {},
lualine_y = { 'encoding', 'filetype', require('custom.lualine').me },
lualine_z = { 'location' }
},
},
},
@ -164,7 +177,7 @@ require('lazy').setup({
},
-- "gc" to comment visual regions/lines
{ 'numToStr/Comment.nvim', opts = {} },
{ 'numToStr/Comment.nvim', opts = {} },
-- Fuzzy Finder (files, lsp, etc)
{ 'nvim-telescope/telescope.nvim', branch = '0.1.x', dependencies = { 'nvim-lua/plenary.nvim' } },
@ -272,11 +285,15 @@ vim.api.nvim_create_autocmd('TextYankPost', {
-- See `:help telescope` and `:help telescope.setup()`
require('telescope').setup {
defaults = {
winblend = 50,
mappings = {
i = {
['<C-u>'] = false,
['<C-d>'] = false,
["<C-n>"] = require('telescope.actions').cycle_history_next,
["<C-p>"] = require('telescope.actions').cycle_history_prev,
["<C-j>"] = require('telescope.actions').move_selection_next,
["<C-k>"] = require('telescope.actions').move_selection_previous,
},
n = { q = require('telescope.actions').close },
},
},
}
@ -306,10 +323,10 @@ vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { de
-- See `:help nvim-treesitter`
require('nvim-treesitter.configs').setup {
-- Add languages to be installed here that you want installed for treesitter
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim' },
ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'typescript', 'vimdoc', 'vim', 'php' },
-- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!)
auto_install = false,
auto_install = true,
highlight = { enable = true },
indent = { enable = true },
@ -477,8 +494,10 @@ cmp.setup {
end,
},
mapping = cmp.mapping.preset.insert {
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-j>'] = cmp.mapping.select_next_item(),
['<C-k>'] = cmp.mapping.select_prev_item(),
-- ['<C-n>'] = cmp.mapping.select_next_item(),
-- ['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete {},
@ -513,3 +532,8 @@ cmp.setup {
-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
-- Custom stuff
require('custom.core')

23
lua/custom/colors.lua Normal file
View File

@ -0,0 +1,23 @@
local colors = {}
function colors.LineNumberColors()
vim.api.nvim_set_hl(0, 'LineNrAbove', { fg='#999966', bold=true })
vim.api.nvim_set_hl(0, 'LineNr', { fg='white', bold=true })
vim.api.nvim_set_hl(0, 'LineNrBelow', { fg='#999966', bold=true })
end
vim.api.nvim_create_user_command('TransparencyToggle',
function (opts)
vim.cmd('TransparentToggle')
colors.LineNumberColors()
end,
{}
)
vim.g.transparent_groups = vim.list_extend(
vim.g.transparent_groups or {},
vim.tbl_map(function(v)
return v.hl_group
end, vim.tbl_values(require('bufferline.config').highlights))
)
return colors

27
lua/custom/core.lua Normal file
View File

@ -0,0 +1,27 @@
vim.g.transparent_enabled = true
vim.g.transparency = 0.8
vim.wo.number = true
vim.o.relativenumber = true
vim.o.wrap = false
vim.o.smartindent = true
vim.o.ruler = true
vim.o.colorcolumn = "80"
vim.o.shiftround = true
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.tabstop = 4
vim.o.shiftwidth = 4
vim.opt.guicursor = 'n-v-c-sm:block'
vim.opt.guifont = 'FiraCode Nerd Font'
vim.opt.shell = 'bash'
vim.o.shell = 'bash'
vim.opt.shellcmdflag = '-c'
vim.opt.termguicolors = true
require('custom.colors').LineNumberColors()
-- require('custom.colors').CursorLineColors()
require('custom.keymaps')
require('custom.neovide')

88
lua/custom/keymaps.lua Normal file
View File

@ -0,0 +1,88 @@
-- Custom keymap
-- See `:help vim.keymap.set()`
-- Cool keymap
vim.keymap.set("i", "jk", "<Esc>", { desc = "Exit insert mode" })
vim.keymap.set("i", "jj", "<Esc>", { desc = "Exit insert mode" })
vim.keymap.set("v", "p", "pgvy", { desc = "Paste without empty paste register" })
-- File operation
vim.keymap.set("n", "<Leader>w", "<cmd>w<cr>", { desc = "Save the file" })
vim.keymap.set("n", "<Leader>q", "<cmd>bdelete<cr>", { desc = "Quit the current buffer" })
vim.keymap.set("n", "<Leader><leader>q", "<cmd>q<cr>", { desc = "Quit the window" })
-- Lsp stuff
vim.keymap.set("n", "gh", vim.lsp.buf.hover, { desc = "Hover documentation" })
-- Split window
vim.keymap.set("n", "<Leader><leader>=", "<cmd>split<cr>", { desc = "Split the window horizontally" })
vim.keymap.set("n", "<Leader><leader>-", "<cmd>vsplit<cr>", { desc = "Split the window vertically" })
-- Better window operation
vim.keymap.set("n", "<Leader>j", "<C-w>j", { desc = "Focus buffer below" })
vim.keymap.set("n", "<Leader>k", "<C-w>k", { desc = "Focus buffer above" })
vim.keymap.set("n", "<Leader>l", "<C-w>l", { desc = "Focus buffer left" })
vim.keymap.set("n", "<Leader>h", "<C-w>h", { desc = "Focus buffer right" })
vim.keymap.set("n", "<C-Up>", ":resize -2<CR>", { desc = "Resize current view to the top" })
vim.keymap.set("n", "<C-Down>", ":resize +2<CR>", { desc = "Resize current view to the bottom" })
vim.keymap.set("n", "<C-Right>", ":vertical resize -2<CR>", { desc = "Resize current view to the left" })
vim.keymap.set("n", "<C-Left>", ":vertical resize +2<CR>", { desc = "Resize current view to the right" })
-- Buffer
vim.keymap.set("n", "<Leader><Leader>l", "<cmd>bnext<cr>", { desc = "Next buffer" })
vim.keymap.set("n", "<Leader><Leader>h", "<cmd>bnext<cr>", { desc = "Previous buffer" })
-- Formatting
-- vim.keymap.set("n", "<C-/>", "gcc", { desc = "Adding comment to the current line" })
-- vim.keymap.set("v", "<C-/>", "gcc", { desc = "Adding comment to the current line" })
vim.keymap.set("v", "<", "<gv", { desc = "Decrease indent" })
vim.keymap.set("v", ">", ">gv", { desc = "Increase indent" })
-- vim.keymap.set("n", "<Space>j", ":m .+1<CR>==", { desc = "" } )
-- vim.keymap.set("n", "<Space>k", ":m .-2<CR>==", { desc = "" } )
vim.keymap.set("v", "<Space>j", ":m .+1<CR>==", { desc = "" } )
vim.keymap.set("v", "<Space>k", ":m .-2<CR>==", { desc = "" } )
-- Nerdtree
vim.keymap.set('n', '<Leader>n', '<cmd>NERDTreeFocus<cr>', { desc = "Nerd tree focus" })
vim.keymap.set('n', '<C-n>', '<cmd>NERDTree<cr>', { desc = "Nerd tree focus" })
vim.keymap.set('n', '<C-t>', '<cmd>NERDTreeToggle<cr>', { desc = "Nerd tree toggle" })
vim.keymap.set('n', '<C-f>', '<cmd>NERDTreeFind<cr>', { desc = "Nerd tree find" })
-- Term
vim.keymap.set('n', '<Leader>t', '<cmd>terminal<cr>', { desc = "Show terminal" } )
vim.keymap.set('n', '<Leader><Leader>t', '<CMD>lua require("FTerm").toggle()<CR>', { desc = "Toggle Float Terminal" })
vim.keymap.set('t', '<Leader><Leader>t', '<C-\\><C-n><CMD>lua require("FTerm").toggle()<CR>', { desc = "Toggle Float Terminal" })
vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = "Exit terminal mode "} )
vim.keymap.set('t', 'jk', '<C-\\><C-n>', { desc = "Exit terminal mode "} )
vim.keymap.set('t', 'jj', '<C-\\><C-n>', { desc = "Exit terminal mode "} )
vim.keymap.set("t", "<Leader>q", "<cmd>bdelete<cr>", { desc = "Quit the current buffer" })
vim.keymap.set('t', '<A-h>', '<C-\\><C-N><C-w>h', { desc = "" })
vim.keymap.set('t', '<A-j>', '<C-\\><C-N><C-w>j', { desc = "" })
vim.keymap.set('t', '<A-k>', '<C-\\><C-N><C-w>k', { desc = "" })
vim.keymap.set('t', '<A-l>', '<C-\\><C-N><C-w>l', { desc = "" })
vim.keymap.set('i', '<A-h>', '<C-\\><C-N><C-w>h', { desc = "" })
vim.keymap.set('i', '<A-j>', '<C-\\><C-N><C-w>j', { desc = "" })
vim.keymap.set('i', '<A-k>', '<C-\\><C-N><C-w>k', { desc = "" })
vim.keymap.set('i', '<A-l>', '<C-\\><C-N><C-w>l', { desc = "" })
vim.keymap.set('n', '<A-j>', '<C-N><C-w>j', { desc = "" })
vim.keymap.set('n', '<A-k>', '<C-N><C-w>k', { desc = "" })
vim.keymap.set('n', '<A-l>', '<C-N><C-w>l', { desc = "" })
-- Code action
vim.keymap.set('n', '<Leader>,', '<cmd>CodeActionMenu<cr>')
-- Oil
vim.keymap.set('n', '<Leader>-', '<cmd>Oil<cr>', { desc = "Open Oil" })
-- Transparency
vim.keymap.set('n', '<Leader>=', '<cmd>TransparencyToggle<cr>', { desc = "Toggle Transparency" })

7
lua/custom/lualine.lua Normal file
View File

@ -0,0 +1,7 @@
local me_lualine = {}
function me_lualine.me()
return "UnknownRori"
end
return me_lualine

24
lua/custom/neovide.lua Normal file
View File

@ -0,0 +1,24 @@
if vim.g.neovide then
vim.g.neovide_scale_factor = 0.9
vim.api.nvim_create_user_command('FullscreenToggle',
function (opts)
vim.g.neovide_fullscreen = not vim.g.neovide_fullscreen
end,
{}
)
-- Helper function for transparency formatting
local alpha = function()
return string.format("%x", math.floor(255 * vim.g.transparency or 0.8))
end
-- g:neovide_transparency should be 0 if you want to unify transparency of content and title bar.
vim.g.neovide_transparency = 0.8
vim.g.transparency = 0.8
vim.g.neovide_background_color = "#0f1117" .. alpha()
vim.g.neovide_floating_blur_amount_x = 2.0
vim.g.neovide_floating_blur_amount_y = 2.0
vim.g.neovide_scroll_animation_length = 0.3
vim.g.neovide_cursor_vfx_mode = "railgun"
end

View File

@ -0,0 +1,15 @@
return {
"windwp/nvim-autopairs",
-- Optional dependency
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require("nvim-autopairs").setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local cmp = require('cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
end,
}

View File

@ -0,0 +1,19 @@
return {
'akinsho/bufferline.nvim',
version = "*",
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
vim.opt.termguicolors = true
require('bufferline').setup({
options = {
diagnostics = "nvim_lsp",
hover = {
enabled = true,
delay = 200,
reveal = {'close'}
}
}
})
end,
}

View File

@ -0,0 +1,6 @@
return {
'brenoprata10/nvim-highlight-colors',
config = function ()
require('nvim-highlight-colors').setup {}
end,
}

View File

@ -0,0 +1,7 @@
return {
"max397574/colortils.nvim",
cmd = "Colortils",
config = function()
require("colortils").setup()
end,
}

View File

@ -0,0 +1,15 @@
return {
'yamatsum/nvim-cursorline',
opts = {
cursorline = {
enable = true,
timeout = 0,
number = false,
},
cursorword = {
enable = true,
min_length = 3,
hl = { underline = true },
}
}
}

View File

@ -0,0 +1,3 @@
return {
'xiyaowong/nvim-cursorword',
}

View File

@ -0,0 +1,62 @@
return {
"goolord/alpha-nvim",
event = "VimEnter",
dependencies = { {'nvim-tree/nvim-web-devicons'}},
opts = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
]]
dashboard.section.header.val = vim.split(logo, "\n")
dashboard.section.buttons.val = {
dashboard.button("f", "" .. " Find file", ":Telescope find_files <CR>"),
dashboard.button("n", "" .. " New file", ":ene <BAR> startinsert <CR>"),
dashboard.button("r", "" .. " Recent files", ":Telescope oldfiles <CR>"),
dashboard.button("g", "" .. " Find text", ":Telescope live_grep <CR>"),
dashboard.button("c", "" .. " Config", ":e $MYVIMRC <CR>"),
dashboard.button("s", "" .. " Restore Session", [[:lua require("persistence").load() <cr>]]),
dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy<CR>"),
dashboard.button("q", "" .. " Quit", ":qa<CR>"),
}
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 8
return dashboard
end,
config = function(_, dashboard)
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
pattern = "AlphaReady",
callback = function()
require("lazy").show()
end,
})
end
require("alpha").setup(dashboard.opts)
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = "⚡ Rori's Editor loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
}

View File

@ -0,0 +1,12 @@
return {
'andweeb/presence.nvim',
opts = {
editing_text = "🛠️ Editing %s",
file_explorer_text = "📝 Browsing %s",
git_commit_text = "📝 Committing changes",
plugin_manager_text = "📦 Managing plugins",
reading_text = "📝 Reading %s",
workspace_text = "🔨 Working on %s",
line_number_text = "📝 Line %s out of %s",
}
}

View File

@ -0,0 +1,16 @@
return {
'anuvyklack/pretty-fold.nvim',
config = function()
require('pretty-fold').ft_setup('lua', {
matchup_patterns = {
{ '^%s*do$', 'end' }, -- do ... end blocks
{ '^%s*if', 'end' }, -- if ... end
{ '^%s*for', 'end' }, -- for
{ 'function%s*%(', 'end' }, -- 'function( or 'function (''
{ '{', '}' },
{ '%(', ')' }, -- % to escape lua pattern char
{ '%[', ']' }, -- % to escape lua pattern char
},
})
end,
}

View File

@ -2,4 +2,51 @@
-- I promise not to create any merge conflicts in this directory :)
--
-- See the kickstart.nvim README for more information
return {}
function load_plugin (name)
return require('custom.plugins.' .. name)
end
return {
'nvim-tree/nvim-web-devicons',
'preservim/nerdtree',
'hrsh7th/nvim-cmp',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'saadparwaiz1/cmp_luasnip',
'hrsh7th/cmp-nvim-lua',
'jose-elias-alvarez/null-ls.nvim',
'simrat39/rust-tools.nvim',
-- 'jose-elias-alvarez/nvim-lsp-ts-utils',
{
'p00f/clangd_extensions.nvim',
lazy = false,
},
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
'RRethy/vim-illuminate',
'ray-x/lsp_signature.nvim',
'nvim-treesitter/nvim-treesitter-context',
load_plugin('discord_presence'),
load_plugin('oil'),
load_plugin('bufferline'),
load_plugin('terminal'),
load_plugin('autopairs'),
load_plugin('dashboard'),
load_plugin('todocomment'),
load_plugin('notify'),
load_plugin('cursorword'),
load_plugin('cursorline'),
load_plugin('transparent'),
load_plugin('fold'),
load_plugin('colorpicker'),
load_plugin('color_highlight'),
}

View File

@ -0,0 +1,20 @@
return {
'lvimuser/lsp-inlayhints.nvim',
lazy = false,
config = function()
require('lsp-inlayhints.init').setup();
vim.api.nvim_create_augroup("LspAttach_inlayhints", {})
vim.api.nvim_create_autocmd("LspAttach", {
group = "LspAttach_inlayhints",
callback = function(args)
if not (args.data and args.data.client_id) then
return
end
local bufnr = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
require("lsp-inlayhints").on_attach(client, bufnr)
end,
})
end
}

View File

@ -0,0 +1,10 @@
return {
"rcarriga/nvim-notify",
config = function()
local notify = require("notify")
-- this for transparency
notify.setup({ background_colour = "#000000" })
-- this overwrites the vim notify function
vim.notify = notify.notify
end
}

View File

@ -0,0 +1,6 @@
return {
'stevearc/oil.nvim',
opts = {},
-- Optional dependencies
dependencies = { "nvim-tree/nvim-web-devicons" },
}

View File

@ -0,0 +1,27 @@
return {
"numToStr/FTerm.nvim",
opts = {
cmd = "bash",
blend = 50,
width = function()
return vim.opt.columns * 20
end,
}
}
-- return {
-- "akinsho/toggleterm.nvim",
-- -- cmd = { "ToggleTerm", "TermExec" },
-- opts = {
-- size = function()
-- return vim.opt.columns * 20
-- end,
-- hide_numbers = false,
-- shading_factor = 2,
-- direction = "float",
-- float_opts = {
-- border = "curved",
-- highlights = { border = "Normal", background = "Normal" },
-- },
-- },
-- }
--

View File

@ -0,0 +1,15 @@
return {
"folke/todo-comments.nvim",
cmd = { "TodoTrouble", "TodoTelescope" }, event = { "BufReadPost", "BufNewFile" },
config = true,
-- stylua: ignore
keys = {
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
{ "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
{ "<leader>xT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
{ "<leader>st", "<cmd>TodoTelescope<cr>", desc = "Todo" },
{ "<leader>sT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme" },
},
}

View File

@ -0,0 +1,9 @@
return {
'xiyaowong/transparent.nvim',
opts = {
extra_groups = {
"NormalFloat", -- plugins which have float panel such as Lazy, Mason, LspInfo
"NvimTreeNormal", -- NvimTree
},
}
}

10
lua/custom/theme.lua Normal file
View File

@ -0,0 +1,10 @@
return {
'Shatur/neovim-ayu',
-- "folke/tokyonight.nvim",
priority = 1000,
-- opts = { style = "night" },
config = function()
-- vim.cmd.colorscheme 'tokyonight'
vim.cmd.colorscheme 'ayu'
end
}