Compare commits

...

7 Commits

18 changed files with 639 additions and 65 deletions

2
.gitignore vendored
View File

@ -1,5 +1,3 @@
plugin
custom
spell spell
ftplugin ftplugin
syntax syntax

11
after/syntax/diff.vim Normal file
View File

@ -0,0 +1,11 @@
" hi DiffAdd gui=none guifg=NONE guibg=#bada9f
" hi DiffChange gui=none guifg=NONE guibg=#e5d5ac
" hi DiffDelete gui=bold guifg=#ff8080 guibg=#ffb0b0
" hi DiffText gui=none guifg=NONE guibg=#8cbee2
hi DiffAdd gui=none guifg=NONE guibg=#003200
hi DiffChange gui=none guifg=NONE guibg=#000032
hi DiffDelete gui=bold guifg=#ff8080 guibg=#602020
hi DiffText gui=bold guifg=NONE guibg=#102040
hi link @text.diff.add DiffAdd
hi link @text.diff.delete DiffDelete
hi link @text.diff.change DiffChange

View File

@ -10,9 +10,9 @@ M.ui = {
hl_add = {}, hl_add = {},
hl_override = {}, hl_override = {},
changed_themes = {}, changed_themes = {},
theme_toggle = { "onedark", "one_light" }, theme_toggle = { "gatekeeper", "one_light" },
theme = "onedark", -- default theme theme = "gatekeeper", -- default theme
transparency = false, transparency = true,
lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens
-- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations
@ -36,6 +36,9 @@ M.ui = {
-- round and block will work for minimal theme only -- round and block will work for minimal theme only
separator_style = "default", separator_style = "default",
overriden_modules = nil, overriden_modules = nil,
fileInfo = function()
return require("nvchad_ui.statusline.default.fileInfo").run()
end
}, },
-- lazyload it when there are 1+ buffers -- lazyload it when there are 1+ buffers
@ -65,7 +68,7 @@ M.ui = {
buttons = { buttons = {
{ " Find File", "Spc f f", "Telescope find_files" }, { " Find File", "Spc f f", "Telescope find_files" },
{ "󰈚 Recent Files", "Spc f o", "Telescope oldfiles" }, { "󰈚 Recent Files", "Spc f o", "Telescope oldfiles" },
{ "󰈭 Find Word", "Spc f w", "Telescope live_grep" }, { "󰈭 Find Word", "Spc f w", "Telescope find_grep" },
{ " Bookmarks", "Spc m a", "Telescope marks" }, { " Bookmarks", "Spc m a", "Telescope marks" },
{ " Themes", "Spc t h", "Telescope themes" }, { " Themes", "Spc t h", "Telescope themes" },
{ " Mappings", "Spc c h", "NvCheatsheet" }, { " Mappings", "Spc c h", "NvCheatsheet" },

View File

@ -6,7 +6,7 @@ local config = require("core.utils").load_config()
g.nvchad_theme = config.ui.theme g.nvchad_theme = config.ui.theme
g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/"
g.toggle_theme_icon = "" g.toggle_theme_icon = ""
g.transparency = config.ui.transparency g.transparency = true
-------------------------------------- options ------------------------------------------ -------------------------------------- options ------------------------------------------
opt.laststatus = 3 -- global statusline opt.laststatus = 3 -- global statusline
@ -17,10 +17,10 @@ opt.cursorline = true
-- Indenting -- Indenting
opt.expandtab = true opt.expandtab = true
opt.shiftwidth = 2 opt.shiftwidth = 4
opt.smartindent = true opt.smartindent = true
opt.tabstop = 2 opt.tabstop = 4
opt.softtabstop = 2 opt.softtabstop = 4
opt.fillchars = { eob = " " } opt.fillchars = { eob = " " }
opt.ignorecase = true opt.ignorecase = true
@ -31,6 +31,7 @@ opt.mouse = "a"
opt.number = true opt.number = true
opt.numberwidth = 2 opt.numberwidth = 2
opt.ruler = false opt.ruler = false
opt.relativenumber = true
-- disable nvim intro -- disable nvim intro
opt.shortmess:append "sI" opt.shortmess:append "sI"
@ -41,6 +42,7 @@ opt.splitright = true
opt.termguicolors = true opt.termguicolors = true
opt.timeoutlen = 400 opt.timeoutlen = 400
opt.undofile = true opt.undofile = true
opt.scrolloff = 15
-- interval for writing swap file to disk, also used by gitsigns -- interval for writing swap file to disk, also used by gitsigns
opt.updatetime = 250 opt.updatetime = 250
@ -91,6 +93,7 @@ autocmd("BufWritePost", {
vim.g.nvchad_theme = config.ui.theme vim.g.nvchad_theme = config.ui.theme
vim.g.transparency = config.ui.transparency vim.g.transparency = config.ui.transparency
vim.g.transparency = true
-- statusline -- statusline
require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme) require("plenary.reload").reload_module("nvchad.statusline." .. config.ui.statusline.theme)

View File

@ -16,42 +16,51 @@ M.general = {
}, },
n = { n = {
["<Esc>"] = { "<cmd> noh <CR>", "Clear highlights" }, ["<leader>n"] = { ":noh <CR>", "Clear highlights" },
["<leader>rr"] = { ":source $MYVIMRC<CR>", "Reload config file" },
-- switch between windows -- switch between windows
["<C-h>"] = { "<C-w>h", "Window left" }, ["<C-h>"] = { "<C-w>h", "Window left" },
["<C-l>"] = { "<C-w>l", "Window right" }, ["<C-l>"] = { "<C-w>l", "Window right" },
["<C-j>"] = { "<C-w>j", "Window down" }, ["<C-j>"] = { "<C-w>j", "Window down" },
["<C-k>"] = { "<C-w>k", "Window up" }, ["<C-k>"] = { "<C-w>k", "Window up" },
-- ["<C-d>"] = { "<cmd> tab Git diff %<CR>", "Git diff this file" },
["<C-d>"] = { "<cmd> DiffviewOpen -- %<CR>", "Git diff this file" },
["<C-o>"] = { "<cmd> DiffviewFileHistory %<CR>", "Git history diff this file" },
["<C-a-d>"] = { "<cmd> DiffviewClose<CR>", "Close git diff" },
-- ["<C-p>"] = { "<cmd> tab Git diff<CR>", "Git diff global" },
["<C-p>"] = { "<cmd> DiffviewOpen<CR>", "Git diff global" },
["<a-p>"] = { ":DiffviewOpen HEAD~", "Show last N commits" },
["<leader>gd"] = { "<cmd> DiffviewClose<CR>", "Git diff close" },
-- save -- save
["<C-s>"] = { "<cmd> w <CR>", "Save file" }, ["<C-s>"] = { "<cmd> w <CR>", "Save file" },
-- Copy all -- Copy all
["<C-c>"] = { "<cmd> %y+ <CR>", "Copy whole file" }, -- ["<C-c>"] = { "<cmd> %y+ <CR>", "Copy whole file" },
-- Quit
["<C-q>"] = { "<cmd> q! <CR>", "Force quit window" },
-- line numbers -- line numbers
["<leader>n"] = { "<cmd> set nu! <CR>", "Toggle line number" }, -- ["<leader>n"] = { "<cmd> set nu! <CR>", "Toggle line number" },
["<leader>rn"] = { "<cmd> set rnu! <CR>", "Toggle relative number" }, -- ["<leader>rn"] = { "<cmd> set rnu! <CR>", "Toggle relative number" },
-- Allow moving the cursor through wrapped lines with j, k, <Up> and <Down> -- allow moving the cursor through wrapped lines with j, k, <Up> and <Down>
-- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/
-- empty mode is same as using <cmd> :map -- empty mode is same as using <cmd> :map
-- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["<leader>y"] = {"<cmd> :w! /tmp/vimtmp<CR>", "Save into a global tmp file"},
["<leader>p"] = {"<cmd> :r! cat /tmp/vimtmp<CR>", "Restore from the global tmp file"},
-- new buffer -- new buffer
["<leader>b"] = { "<cmd> enew <CR>", "New buffer" }, -- ["<leader>b"] = { "<cmd> enew <CR>", "New buffer" },
["<leader>ch"] = { "<cmd> NvCheatsheet <CR>", "Mapping cheatsheet" }, -- ["<leader>ch"] = { "<cmd> NvCheatsheet <CR>", "Mapping cheatsheet" },
["<leader>fm"] = {
function()
vim.lsp.buf.format { async = true }
end,
"LSP formatting",
},
}, },
t = { t = {
@ -59,21 +68,66 @@ M.general = {
}, },
v = { v = {
["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["<Up>"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["<Down>"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["<"] = { "<gv", "Indent line" }, -- ["<"] = { "<gv", "Indent line" },
[">"] = { ">gv", "Indent line" }, -- [">"] = { ">gv", "Indent line" },
}, },
x = { x = {
["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } },
["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } },
-- Don't copy the replaced text after pasting in visual mode -- Don't copy the replaced text after pasting in visual mode
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#alternative_mapping_for_paste
["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', "Dont copy replaced text", opts = { silent = true } }, ["p"] = { 'p:let @+=@0<CR>:let @"=@0<CR>', "Dont copy replaced text", opts = { silent = true } },
}, },
} }
M.customstuffs = {
n = {
["<Return>"] = { "o<ESC>", "Insert new line below" },
["<BS>"] = { "O<ESC>", "Insert new line above" },
["<C-c>"] = { "<cmd> vertical topleft Git <bar> vertical resize 50<CR>", "Show Git status on a left pane" },
["<F1>"] = { "<cmd> tabprevious<CR>", "Previous tab" },
["<F2>"] = { "<cmd> tabnext<CR>", "Next tab" },
["<F3>"] = { "<cmd> Flog -all<CR>", "Show git tree" },
["<F4>"] = { "<cmd> tab Git show -", "Git show N last commits" },
["<C-t>"] = { "<cmd> TagbarToggle<CR>", "Show tagbar" },
["<leader>ra"] = { "<cmd> call VrcQuery()<CR>", "Call REST endpoint" },
["<leader>dl"] = { "0d$", "Delete line from start" },
["<leader>gp"] = { "<cmd> Git pull<CR>", "Git pull" },
["<leader>gnb"] = { ":Git checkout -b ", "Checkout to a new branch" },
["<leader>gri"] = { ":Git rebase -i HEAD~", "Git rebase interactive from HEAD" },
["<leader>mkd"] = { "<cmd>lua vim.api.nvim_create_user_command('PeekOpen', require('peek').open, {})<CR>", "Open markdown preview" },
["<leader>mkc"] = { "<cmd>lua vim.api.nvim_create_user_command('PeekClose', require('peek').close, {})<CR>", "Open markdown preview" },
["n"] = { "nzz", "Next + auto center" },
["N"] = { "Nzz", "Previous + auto center" },
["("] = { "(zz", "Previous + auto center" },
[")"] = { ")zz", "Previous + auto center" },
["{"] = { "{zz", "Previous + auto center" },
["}"] = { "}zz", "Previous + auto center" },
["[["] = { "[[zz", "Previous + auto center" },
["]]"] = { "]]zz", "Previous + auto center" },
-- Mappings: TODO
-- "trim(system('git branch --show-current 2>/dev/null'))"
["<leader>tt"] = { ":call append(line('.') - 1, repeat(' ', indent('.')) . '# TODO-' . trim(system('git branch --show-current 2>/dev/null')) . ': ' . input('Comment >'))<CR>", "Add TODO comment + add to quickfix list" },
},
v = {
["n"] = { "nzz", "Next + auto center" },
["N"] = { "Nzz", "Previous + auto center" },
["("] = { "(zz", "Previous + auto center" },
[")"] = { ")zz", "Previous + auto center" },
["{"] = { "{zz", "Previous + auto center" },
["}"] = { "}zz", "Previous + auto center" },
["[["] = { "[[zz", "Previous + auto center" },
["]]"] = { "]]zz", "Previous + auto center" },
},
}
M.tabufline = { M.tabufline = {
plugin = true, plugin = true,
@ -108,7 +162,7 @@ M.comment = {
-- toggle comment in both modes -- toggle comment in both modes
n = { n = {
["<leader>/"] = { ["<leader>ci"] = {
function() function()
require("Comment.api").toggle.linewise.current() require("Comment.api").toggle.linewise.current()
end, end,
@ -117,7 +171,7 @@ M.comment = {
}, },
v = { v = {
["<leader>/"] = { ["<leader>ci"] = {
"<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>", "<ESC><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<CR>",
"Toggle comment", "Toggle comment",
}, },
@ -214,18 +268,18 @@ M.lspconfig = {
"Goto next", "Goto next",
}, },
["<leader>q"] = { -- ["<leader>q"] = {
function() -- function()
vim.diagnostic.setloclist() -- vim.diagnostic.setloclist()
end, -- end,
"Diagnostic setloclist", -- "Diagnostic setloclist",
}, -- },
["<leader>wa"] = { ["<leader>wa"] = {
function() function()
vim.lsp.buf.add_workspace_folder() vim.lsp.buf.add_workspace_folder()
end, end,
"Add workspace folder", "add workspace folder",
}, },
["<leader>wr"] = { ["<leader>wr"] = {
@ -269,18 +323,37 @@ M.telescope = {
plugin = true, plugin = true,
n = { n = {
-- Resume
["<a-f>"] = { "<cmd> Telescope resume <CR>", "Resume" },
-- find -- find
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", "Find files" }, ["<C-g>"] = { "<cmd> Telescope find_files <CR>", "Find files" },
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find all" }, ["<C-x>"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", "Find all" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "Live grep" }, ["<C-f>"] = { "<cmd> Telescope live_grep <CR>", "Live grep" },
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", "Find buffers" }, ["<C-b>"] = { "<cmd> Telescope buffers <CR>", "Find buffers" },
["<leader>fg"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text=vim.fn.getreg('/')}) <CR>", "Live grep with actual search value as prefix" },
["<leader>ac"] = { ":execute 'vimgrep' input('Pattern >', getreg('/')) '**/*' <CR>", "add search term files in quickfix list" },
["<leader>qc"] = { "<cmd> Telescope quickfix <CR>", "Show quickfix list" },
["<leader>qr"] = { ":execute 'cdo' '%s/' . input('Search term >', getreg('/')) . '/' . input('Replace by >', getreg('')) . '/g | update' <CR>", "Replace pattern in all quickfix list" },
["<leader>ll"] = { "<cmd> Telescope loclist <CR>", "Show loclist list" },
["<leader>ln"] = { ":lnext<CR>", "Jump to next in loclist" },
["<leader>lp"] = { ":lprevious<CR>", "Jump to previous in loclist" },
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "Help page" }, ["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", "Help page" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "Find oldfiles" }, ["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "Find oldfiles" },
["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" }, ["<leader>fz"] = { "<cmd> Telescope current_buffer_fuzzy_find <CR>", "Find in current buffer" },
-- git -- git
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", "Git commits" }, --- Commits
["<leader>gt"] = { "<cmd> Telescope git_status <CR>", "Git status" }, ["<leader>gc"] = { "<cmd> lua require('custom.telescope').my_git_commits()<CR>", "Custom Git commits" },
--- Status
["<leader>gss"] = { "<cmd> lua require('custom.telescope').my_git_status()<CR>", "Custom Git status" },
--- Stash
["<leader>gsh"] = { "<cmd> Telescope git_stash<CR>", "Git stash" },
--- Branches
["<leader>gbb"] = { "<cmd> Telescope git_branches<CR>", "Git branches" },
["<leader>gbc"] = { "<cmd> lua require('custom.telescope').my_git_bcommits()<CR>", "Custom Git branchs commits" },
-- pick a hidden term -- pick a hidden term
["<leader>pt"] = { "<cmd> Telescope terms <CR>", "Pick hidden term" }, ["<leader>pt"] = { "<cmd> Telescope terms <CR>", "Pick hidden term" },
@ -289,6 +362,10 @@ M.telescope = {
["<leader>th"] = { "<cmd> Telescope themes <CR>", "Nvchad themes" }, ["<leader>th"] = { "<cmd> Telescope themes <CR>", "Nvchad themes" },
["<leader>ma"] = { "<cmd> Telescope marks <CR>", "telescope bookmarks" }, ["<leader>ma"] = { "<cmd> Telescope marks <CR>", "telescope bookmarks" },
-- History
["<leader>ch"] = { "<cmd> Telescope command_history <CR>", "telescope commands history" },
["<leader>/"] = { "<cmd> Telescope search_history <CR>", "telescope search history" },
}, },
} }
@ -297,21 +374,21 @@ M.nvterm = {
t = { t = {
-- toggle in terminal mode -- toggle in terminal mode
["<A-i>"] = { ["<a-i>"] = {
function() function()
require("nvterm.terminal").toggle "float" require("nvterm.terminal").toggle "float"
end, end,
"Toggle floating term", "Toggle floating term",
}, },
["<A-h>"] = { ["<a-h>"] = {
function() function()
require("nvterm.terminal").toggle "horizontal" require("nvterm.terminal").toggle "horizontal"
end, end,
"Toggle horizontal term", "Toggle horizontal term",
}, },
["<A-v>"] = { ["<a-v>"] = {
function() function()
require("nvterm.terminal").toggle "vertical" require("nvterm.terminal").toggle "vertical"
end, end,
@ -321,21 +398,21 @@ M.nvterm = {
n = { n = {
-- toggle in normal mode -- toggle in normal mode
["<A-i>"] = { ["<a-i>"] = {
function() function()
require("nvterm.terminal").toggle "float" require("nvterm.terminal").toggle "float"
end, end,
"Toggle floating term", "Toggle floating term",
}, },
["<A-h>"] = { ["<a-h>"] = {
function() function()
require("nvterm.terminal").toggle "horizontal" require("nvterm.terminal").toggle "horizontal"
end, end,
"Toggle horizontal term", "Toggle horizontal term",
}, },
["<A-v>"] = { ["<a-v>"] = {
function() function()
require("nvterm.terminal").toggle "vertical" require("nvterm.terminal").toggle "vertical"
end, end,
@ -434,7 +511,7 @@ M.gitsigns = {
opts = { expr = true }, opts = { expr = true },
}, },
-- Actions -- actions
["<leader>rh"] = { ["<leader>rh"] = {
function() function()
require("gitsigns").reset_hunk() require("gitsigns").reset_hunk()
@ -449,7 +526,7 @@ M.gitsigns = {
"Preview hunk", "Preview hunk",
}, },
["<leader>gb"] = { ["<leader>bb"] = {
function() function()
package.loaded.gitsigns.blame_line() package.loaded.gitsigns.blame_line()
end, end,

20
lua/custom/chadrc.lua Normal file
View File

@ -0,0 +1,20 @@
---@type ChadrcConfig
local M = {}
-- Path to overriding theme and highlights files
local highlights = require "custom.highlights"
M.ui = {
theme = "gatekeeper",
theme_toggle = { "gatekeeper", "monekai" },
hl_override = highlights.override,
hl_add = highlights.add,
}
M.plugins = "custom.plugins"
-- check core.mappings for table structure
M.mappings = require "custom.mappings"
return M

View File

@ -0,0 +1,17 @@
local on_attach = require("plugins.configs.lspconfig").on_attach
local capabilities = require("plugins.configs.lspconfig").capabilities
local lspconfig = require "lspconfig"
-- if you just want default config for the servers then put them in a table
local servers = { "html", "cssls", "tsserver", "clangd" }
for _, lsp in ipairs(servers) do
lspconfig[lsp].setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
--
-- lspconfig.pyright.setup { blabla}

View File

@ -0,0 +1,25 @@
local present, null_ls = pcall(require, "null-ls")
if not present then
return
end
local b = null_ls.builtins
local sources = {
-- webdev stuff
b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast!
b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes
-- Lua
b.formatting.stylua,
-- cpp
b.formatting.clang_format,
}
null_ls.setup {
debug = true,
sources = sources,
}

View File

@ -0,0 +1,59 @@
local M = {}
M.treesitter = {
ensure_installed = {
"vim",
"lua",
"html",
"css",
"javascript",
"typescript",
"tsx",
"c",
"markdown",
"markdown_inline",
},
indent = {
enable = true,
-- disable = {
-- "python"
-- },
},
}
M.mason = {
ensure_installed = {
-- lua stuff
"lua-language-server",
"stylua",
-- web dev stuff
"css-lsp",
"html-lsp",
"typescript-language-server",
"deno",
"prettier",
-- c/cpp stuff
"clangd",
"clang-format",
},
}
-- git support in nvimtree
M.nvimtree = {
git = {
enable = true,
},
renderer = {
highlight_git = true,
icons = {
show = {
git = true,
},
},
},
}
return M

19
lua/custom/highlights.lua Normal file
View File

@ -0,0 +1,19 @@
-- To find any highlight groups: "<cmd> Telescope highlights"
-- Each highlight group can take a table with variables fg, bg, bold, italic, etc
-- base30 variable names can also be used as colors
local M = {}
---@type Base46HLGroupsList
M.override = {
Comment = {
italic = true,
},
}
---@type HLTable
M.add = {
NvimTreeOpenedFolderName = { fg = "green", bold = true },
}
return M

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

@ -0,0 +1,7 @@
-- local autocmd = vim.api.nvim_create_autocmd
-- Auto resize panes when resizing nvim window
-- autocmd("VimResized", {
-- pattern = "*",
-- command = "tabdo wincmd =",
-- })

12
lua/custom/mappings.lua Normal file
View File

@ -0,0 +1,12 @@
---@type MappingsTable
local M = {}
M.general = {
n = {
[";"] = { ":", "enter command mode", opts = { nowait = true } },
},
}
-- more keybinds!
--
return M

65
lua/custom/plugins.lua Normal file
View File

@ -0,0 +1,65 @@
local overrides = require("custom.configs.overrides")
---@type NvPluginSpec[]
local plugins = {
-- Override plugin definition options
{
"neovim/nvim-lspconfig",
dependencies = {
-- format & linting
{
"jose-elias-alvarez/null-ls.nvim",
config = function()
require "custom.configs.null-ls"
end,
},
},
config = function()
require "plugins.configs.lspconfig"
require "custom.configs.lspconfig"
end, -- Override to setup mason-lspconfig
},
-- override plugin configs
{
"williamboman/mason.nvim",
opts = overrides.mason
},
{
"nvim-treesitter/nvim-treesitter",
opts = overrides.treesitter,
},
{
"nvim-tree/nvim-tree.lua",
opts = overrides.nvimtree,
},
-- Install a plugin
{
"max397574/better-escape.nvim",
event = "InsertEnter",
config = function()
require("better_escape").setup()
end,
},
-- To make a plugin not be loaded
-- {
-- "NvChad/nvim-colorizer.lua",
-- enabled = false
-- },
-- All NvChad plugins are lazy-loaded by default
-- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false`
-- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example
-- {
-- "mg979/vim-visual-multi",
-- lazy = false,
-- }
}
return plugins

61
lua/custom/telescope.lua Normal file
View File

@ -0,0 +1,61 @@
-- Implement delta as previewer for diffs
local previewers = require('telescope.previewers')
local builtin = require('telescope.builtin')
local E = {}
local delta = previewers.new_termopen_previewer {
get_command = function(entry)
-- this is for status
-- You can get the AM things in entry.status. So we are displaying file if entry.status == '??' or 'A '
-- just do an if and return a different command
if entry.status == '??' or 'A ' then
return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value }
end
-- note we can't use pipes
-- this command is for git_commits and git_bcommits
return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value .. '^!' }
end
}
E.my_git_commits = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_commits(opts)
end
E.my_git_bcommits = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_bcommits(opts)
end
E.my_git_status = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_status(opts)
end
E.my_git_branches = function(opts)
opts = opts or {}
opts.previewer = delta
builtin.git_branches(opts)
end
E.project_files = function()
local opts = {} -- define here if you want to define something
vim.fn.system('git rev-parse --is-inside-work-tree')
if vim.v.shell_error == 0 then
require"telescope.builtin".git_files(opts)
else
require"telescope.builtin".find_files(opts)
end
end
return E

View File

@ -0,0 +1,5 @@
local actions = require("diffview.actions")
local options = {}
return options

View File

@ -0,0 +1,46 @@
-- See: https://github.com/neovim/nvim-lspconfig/tree/54eb2a070a4f389b1be0f98070f81d23e2b1a715#suggested-configuration
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>k', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap=true, silent=true, buffer=bufnr }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>f', function() vim.lsp.buf.format { async = true } end, bufopts)
end
-- Configure `ruff-lsp`.
-- See: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#ruff_lsp
-- For the default config, along with instructions on how to customize the settings
require('lspconfig').ruff_lsp.setup {
on_attach = on_attach,
init_options = {
settings = {
-- Any extra CLI arguments for `ruff` go here.
args = {},
}
}
}

View File

@ -1,3 +1,96 @@
local custom_actions = {}
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local from_entry = require("telescope.from_entry")
local entry_to_qf = function(entry)
local text = entry.text
if not text then
if type(entry.value) == "table" then
text = entry.value.text
else
text = entry.value
end
end
return {
bufnr = entry.bufnr,
filename = from_entry.path(entry, false, false),
lnum = vim.F.if_nil(entry.lnum, 1),
col = vim.F.if_nil(entry.col, 1),
text = text,
}
end
local send_selected_to_list_without_closing_prompt = function(prompt_bufnr, mode, target)
local picker = action_state.get_current_picker(prompt_bufnr)
local qf_entries = {}
for _, entry in ipairs(picker:get_multi_selection()) do
table.insert(qf_entries, entry_to_qf(entry))
end
local prompt = picker:_get_prompt()
-- actions.close(prompt_bufnr)
vim.api.nvim_exec_autocmds("QuickFixCmdPre", {})
if target == "loclist" then
vim.fn.setloclist(picker.original_win_id, qf_entries, mode)
else
local qf_title = string.format([[%s (%s)]], picker.prompt_title, prompt)
vim.fn.setqflist(qf_entries, mode)
vim.fn.setqflist({}, "a", { title = qf_title })
end
vim.api.nvim_exec_autocmds("QuickFixCmdPost", {})
end
function custom_actions._multiopen(prompt_bufnr, cmd, cmd2, mode, list)
-- actions.send_selected_to_loclist(prompt_bufnr)
local picker = action_state.get_current_picker(prompt_bufnr)
local multi = picker:get_multi_selection()
local single = picker:get_selection()
local str = ""
if #multi > 0 then
send_selected_to_list_without_closing_prompt(prompt_bufnr, mode, list)
for i, j in ipairs(multi) do
if i % 2 == 1 then
str = str..cmd.." "..j[1].." | "
else
str = str..cmd2.." "..j[1].." | "
end
end
else
str = cmd.." "..single[1]
end
-- To avoid populating qf or doing ":edit! file", close the prompt first
actions.close(prompt_bufnr)
vim.api.nvim_command(str)
end
function custom_actions.multi_selection_open(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "edit", "edit", "a", "loclist")
end
function custom_actions.multi_selection_vsplit(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "vsplit", "split", "a", "loclist")
end
function custom_actions.multi_selection_split(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "split", "vsplit", "a", "loclist")
end
function custom_actions.multi_selection_vtab(prompt_bufnr)
return custom_actions._multiopen(prompt_bufnr, "tabe", "tabe", "a", "loclist")
end
local options = { local options = {
defaults = { defaults = {
vimgrep_arguments = { vimgrep_arguments = {
@ -20,15 +113,15 @@ local options = {
layout_config = { layout_config = {
horizontal = { horizontal = {
prompt_position = "top", prompt_position = "top",
preview_width = 0.55, preview_width = 0.60,
results_width = 0.8, results_width = 0.8,
}, },
vertical = { vertical = {
mirror = false, mirror = false,
}, },
width = 0.87, width = 0.90,
height = 0.80, height = 0.92,
preview_cutoff = 120, preview_cutoff = 200,
}, },
file_sorter = require("telescope.sorters").get_fuzzy_file, file_sorter = require("telescope.sorters").get_fuzzy_file,
file_ignore_patterns = { "node_modules" }, file_ignore_patterns = { "node_modules" },
@ -45,9 +138,35 @@ local options = {
-- Developer configurations: Not meant for general override -- Developer configurations: Not meant for general override
buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker, buffer_previewer_maker = require("telescope.previewers").buffer_previewer_maker,
mappings = { mappings = {
n = { ["q"] = require("telescope.actions").close }, n = { ["q"] = actions.close },
}, },
}, },
pickers = {
buffers = {
show_all_buffers = true,
sort_lastused = true,
mappings = {
n = {
["d"] = "delete_buffer",
},
i = {
["<C-d>"] = "delete_buffer",
}
}
},
find_files = {
mappings = {
i = {
["<CR>"] = custom_actions.multi_selection_open,
["<C-V>"] = custom_actions.multi_selection_vsplit,
["<C-X>"] = custom_actions.multi_selection_split,
["<C-T>"] = custom_actions.multi_selection_tab,
["<C-SPACE>"] = actions.send_selected_to_qflist,
},
n = i,
}
}
},
extensions_list = { "themes", "terms", "fzf" }, extensions_list = { "themes", "terms", "fzf" },
extensions = { extensions = {
@ -56,8 +175,8 @@ local options = {
override_generic_sorter = true, override_generic_sorter = true,
override_file_sorter = true, override_file_sorter = true,
case_mode = "smart_case", case_mode = "smart_case",
}, }
}, }
} }
return options return options

View File

@ -3,6 +3,32 @@
local default_plugins = { local default_plugins = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
"rebelot/kanagawa.nvim",
{
"iamcco/markdown-preview.nvim",
run = "cd app && npm install",
lazy = false,
setup = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
{"tpope/vim-fugitive", lazy=false},
{"rbong/vim-flog", lazy=false},
{"tpope/vim-surround", lazy=false},
{"tpope/vim-obsession", lazy=false},
{"preservim/tagbar", lazy=false},
{"ludovicchabant/vim-gutentags", lazy=false},
{"emaniacs/vim-rest-console", lazy=false},
{
"sindrets/diffview.nvim",
lazy=false,
opts = function()
return require "plugins.configs.diffview"
end,
},
{"nvim-telescope/telescope-fzf-native.nvim", build="make"},
{ {
"NvChad/base46", "NvChad/base46",
@ -271,3 +297,4 @@ if #config.plugins > 0 then
end end
require("lazy").setup(default_plugins, config.lazy_nvim) require("lazy").setup(default_plugins, config.lazy_nvim)
require "plugins.configs.ruff_lsp"