feat(nvim): re-write config for 0.8.0
This commit is contained in:
parent
5156a67767
commit
ea40a78563
11 changed files with 246 additions and 330 deletions
|
@ -7,12 +7,11 @@ pcall(require, "lsp")
|
|||
vim.o.termguicolors = true
|
||||
-- map leader to space
|
||||
vim.g.mapleader = " "
|
||||
-- allow mouse in normal/visual mode
|
||||
vim.o.mouse = "nv"
|
||||
vim.o.cmdheight = 0
|
||||
-- line numbers
|
||||
vim.o.mouse = ""
|
||||
vim.o.number = true
|
||||
vim.o.relativenumber = true
|
||||
vim.o.numberwidth = 5
|
||||
-- scroll offsets
|
||||
vim.o.scrolloff = 5
|
||||
vim.o.sidescrolloff = 15
|
||||
|
@ -29,64 +28,50 @@ vim.o.splitright = true
|
|||
-- redefine word boundaries - '_' is a word seperator, this helps with snake_case
|
||||
vim.opt.iskeyword:remove("_")
|
||||
|
||||
function Map(mode, shortcut, command, opt)
|
||||
opt = opt or { noremap = true, silent = true }
|
||||
vim.keymap.set(mode, shortcut, command, opt)
|
||||
end
|
||||
|
||||
-- easier split navigation
|
||||
Nmap("<C-J>", "<C-W>j")
|
||||
Nmap("<C-K>", "<C-W>k")
|
||||
Nmap("<C-L>", "<C-W>l")
|
||||
Nmap("<C-H>", "<C-W>h")
|
||||
|
||||
Map("n", "<C-J>", "<C-W>j")
|
||||
Map("n", "<C-K>", "<C-W>k")
|
||||
Map("n", "<C-L>", "<C-W>l")
|
||||
Map("n", "<C-H>", "<C-W>h")
|
||||
Map("n", "<C-W>\\", ":vsplit<CR>")
|
||||
Map("n", "<C-W>-", ":split<CR>")
|
||||
Map("n", "<C-W>x", ":q<CR>")
|
||||
-- merge conflicts
|
||||
Nmap("<leader>gd", ":Gvdiff!<CR>")
|
||||
Nmap("gdh", ":diffget //2<CR>")
|
||||
Nmap("gdl", ":diffget //3<CR>")
|
||||
|
||||
Map("n", "<leader>gd", ":Gvdiff!<CR>")
|
||||
Map("n", "gdh", ":diffget //2<CR>")
|
||||
Map("n", "gdl", ":diffget //3<CR>")
|
||||
-- clipboard
|
||||
Map("n", "<leader>p", '"+p')
|
||||
Map("n", "<leader>y", '"+y')
|
||||
-- escape :terminal easier
|
||||
vim.cmd([[tnoremap <Esc> <C-\><C-n>]])
|
||||
|
||||
-- indentations settings
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.tabstop = 2
|
||||
vim.o.softtabstop = 2
|
||||
vim.o.softtabstop = 0
|
||||
vim.o.expandtab = true
|
||||
-- indentation autocmds for some filetypes
|
||||
vim.cmd([[
|
||||
" smol spaces for soydev
|
||||
autocmd FileType html,lua,css,js,jsreact,ts,tsreact,json,yaml setlocal ts=2 sw=2 sts=0 et
|
||||
" Tabs, yikes
|
||||
autocmd FileType go setlocal ts=4 sw=4 sts=4 noet
|
||||
" Spaces, based languages
|
||||
autocmd FileType python,rust setlocal ts=4 sw=4 sts=4 et
|
||||
autocmd FileType markdown let g:table_mode_corner='|'
|
||||
]])
|
||||
|
||||
-- auto-compile when lua files in `~/.config/nvim/*` change
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "*.lua",
|
||||
callback = function()
|
||||
local cfg_path = vim.fn.resolve(vim.fn.stdpath("config"))
|
||||
vim.defer_fn(function()
|
||||
if vim.fn.expand("%:p"):match(cfg_path) then
|
||||
vim.cmd("silent! PackerCompile")
|
||||
end
|
||||
end, 0)
|
||||
end,
|
||||
})
|
||||
|
||||
local wr_group = vim.api.nvim_create_augroup("WinResize", { clear = true })
|
||||
|
||||
-- resize splits when vim window is resized
|
||||
vim.api.nvim_create_autocmd("VimResized", {
|
||||
group = wr_group,
|
||||
pattern = "*",
|
||||
command = "wincmd =",
|
||||
desc = "Automatically resize windows when the host window size changes.",
|
||||
})
|
||||
|
||||
-- neovide settings {{{
|
||||
if vim.g.neovide then
|
||||
vim.cmd("cd $HOME")
|
||||
vim.g.neovide_cursor_vfx_mode = "ripple"
|
||||
vim.g.neovide_input_macos_alt_is_meta = true
|
||||
vim.o.guifont = "VictorMono Nerd Font:h18"
|
||||
end
|
||||
-- }}}
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ higroup = "IncSearch", timeout = 200 })
|
||||
end,
|
||||
desc = "Highlight yanked text",
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ require("bufferline").setup({
|
|||
options = {
|
||||
show_close_icon = false,
|
||||
separator_style = "slant",
|
||||
close_icon = "",
|
||||
show_buffer_close_icons = false,
|
||||
offsets = { { filetype = "NvimTree" } },
|
||||
left_mouse_command = "buffer %d",
|
||||
middle_mouse_command = "bdelete! %d",
|
||||
|
@ -10,31 +10,31 @@ require("bufferline").setup({
|
|||
},
|
||||
})
|
||||
-- hop between buffers in order of the bar
|
||||
Nmap("<A-,>", "<Cmd>BufferLineCyclePrev<CR>")
|
||||
Nmap("<A-.>", "<Cmd>BufferLineCycleNext<CR>")
|
||||
Map("n", "<A-,>", "<Cmd>BufferLineCyclePrev<CR>")
|
||||
Map("n", "<A-.>", "<Cmd>BufferLineCycleNext<CR>")
|
||||
-- Re-order to previous/next
|
||||
Nmap("<A-<>", "<Cmd>BufferLineMovePrev<CR>")
|
||||
Nmap("<A->>", "<Cmd>BufferLineMoveNext<CR>")
|
||||
Map("n", "<A-<>", "<Cmd>BufferLineMovePrev<CR>")
|
||||
Map("n", "<A->>", "<Cmd>BufferLineMoveNext<CR>")
|
||||
-- Goto buffer in position...
|
||||
Nmap("<A-1>", "<Cmd>BufferLineGoToBuffer 1<CR>")
|
||||
Nmap("<A-2>", "<Cmd>BufferLineGoToBuffer 2<CR>")
|
||||
Nmap("<A-3>", "<Cmd>BufferLineGoToBuffer 3<CR>")
|
||||
Nmap("<A-4>", "<Cmd>BufferLineGoToBuffer 4<CR>")
|
||||
Nmap("<A-5>", "<Cmd>BufferLineGoToBuffer 5<CR>")
|
||||
Nmap("<A-6>", "<Cmd>BufferLineGoToBuffer 6<CR>")
|
||||
Nmap("<A-7>", "<Cmd>BufferLineGoToBuffer 7<CR>")
|
||||
Nmap("<A-8>", "<Cmd>BufferLineGoToBuffer 8<CR>")
|
||||
Nmap("<A-9>", "<Cmd>BufferLineGoToBuffer 9<CR>")
|
||||
Nmap("<A-0>", "<Cmd>BufferLineGoToBuffer -1<CR>")
|
||||
Map("n", "<A-1>", "<Cmd>BufferLineGoToBuffer 1<CR>")
|
||||
Map("n", "<A-2>", "<Cmd>BufferLineGoToBuffer 2<CR>")
|
||||
Map("n", "<A-3>", "<Cmd>BufferLineGoToBuffer 3<CR>")
|
||||
Map("n", "<A-4>", "<Cmd>BufferLineGoToBuffer 4<CR>")
|
||||
Map("n", "<A-5>", "<Cmd>BufferLineGoToBuffer 5<CR>")
|
||||
Map("n", "<A-6>", "<Cmd>BufferLineGoToBuffer 6<CR>")
|
||||
Map("n", "<A-7>", "<Cmd>BufferLineGoToBuffer 7<CR>")
|
||||
Map("n", "<A-8>", "<Cmd>BufferLineGoToBuffer 8<CR>")
|
||||
Map("n", "<A-9>", "<Cmd>BufferLineGoToBuffer 9<CR>")
|
||||
Map("n", "<A-0>", "<Cmd>BufferLineGoToBuffer -1<CR>")
|
||||
-- Pin/unpin buffer
|
||||
Nmap("<A-p>", "<Cmd>BufferLineTogglePin<CR>")
|
||||
Map("n", "<A-p>", "<Cmd>BufferLineTogglePin<CR>")
|
||||
-- Close buffer
|
||||
Nmap("<A-x>", "<Cmd>bdelete<CR>")
|
||||
Nmap("<A-X>", "<Cmd>bdelete!<CR>")
|
||||
Map("n", "<A-x>", "<Cmd>bdelete<CR>")
|
||||
Map("n", "<A-X>", "<Cmd>bdelete!<CR>")
|
||||
-- create new buffer
|
||||
Nmap("<A-c>", "<Cmd>enew<CR>")
|
||||
Map("n", "<A-c>", "<Cmd>enew<CR>")
|
||||
-- pick buffer
|
||||
Nmap("<A-space>", "<Cmd>BufferLinePick<CR>")
|
||||
Map("n", "<A-space>", "<Cmd>BufferLinePick<CR>")
|
||||
-- Sort automatically by...
|
||||
Nmap("<Space>bd", "<Cmd>BufferLineSortByDirectory<CR>")
|
||||
Nmap("<Space>bl", "<Cmd>BufferLineSortByExtension<CR>")
|
||||
Map("n", "<Space>bd", "<Cmd>BufferLineSortByDirectory<CR>")
|
||||
Map("n", "<Space>bl", "<Cmd>BufferLineSortByExtension<CR>")
|
||||
|
|
|
@ -47,7 +47,7 @@ require("catppuccin").setup({
|
|||
},
|
||||
barbar = false,
|
||||
bufferline = true,
|
||||
dashboard = false,
|
||||
dashboard = true, -- manually set
|
||||
fern = false,
|
||||
gitgutter = false,
|
||||
gitsigns = true,
|
||||
|
@ -64,20 +64,20 @@ require("catppuccin").setup({
|
|||
vim_sneak = false,
|
||||
},
|
||||
custom_highlights = {
|
||||
DashboardShortCut = { fg = colors.yellow },
|
||||
DashboardHeader = { fg = colors.red },
|
||||
DashboardHeader = { fg = colors.pink },
|
||||
DashboardCenter = { fg = colors.peach },
|
||||
DashboardShortCut = { fg = colors.yellow },
|
||||
DashboardFooter = { fg = colors.maroon },
|
||||
},
|
||||
})
|
||||
|
||||
vim.api.nvim_command("colorscheme catppuccin")
|
||||
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
package.loaded["feline"] = nil
|
||||
package.loaded["catppuccin.groups.integrations.feline"] = nil
|
||||
require("config.feline")
|
||||
end,
|
||||
})
|
||||
-- vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
-- pattern = "*",
|
||||
-- callback = function()
|
||||
-- package.loaded["feline"] = nil
|
||||
-- package.loaded["catppuccin.groups.integrations.feline"] = nil
|
||||
-- require("config.feline")
|
||||
-- end,
|
||||
-- })
|
||||
|
|
|
@ -1,42 +1,40 @@
|
|||
local cp = require("catppuccin.palettes.init").get_palette()
|
||||
|
||||
local home = os.getenv("HOME")
|
||||
local db = require("dashboard")
|
||||
|
||||
db.custom_header = function()
|
||||
local quotes = {
|
||||
"Demonic presence at unsafe levels.",
|
||||
"Rip and tear, until it is done.",
|
||||
"So you walk eternally through the shadow realms.",
|
||||
"The only thing they fear... is you.",
|
||||
"There he lies still, and ever more, in silent suffering.",
|
||||
"We will send unto them...only you.",
|
||||
"What you see now in this facility is the cost. Of progress.",
|
||||
"You can't just shoot a hole in the surface of mars!",
|
||||
"WARNING: The Slayer has entered the facility.",
|
||||
"DANGER: THE SLAYER HAS CONTROL OF THE BFG.",
|
||||
local cringe = {
|
||||
"Have fun coding!",
|
||||
"Sisyphus wasn't forbidden to smile.",
|
||||
"Pro tip: Run :q! to exit. Now!",
|
||||
}
|
||||
local random_quote = quotes[math.random(#quotes)]
|
||||
local random_cringe = cringe[math.random(#cringe)]
|
||||
return {
|
||||
[[]],
|
||||
[[ _ _ _____ _ _ _____ _____ _____ _ _ _ _ ________ ___]],
|
||||
[[| | | |_ _| \ | |/ ___|_ _| _ | \ | | | | | |_ _| \/ |]],
|
||||
[[| | | | | | | \| |\ `--. | | | | | | \| | | | | | | | | . . |]],
|
||||
[[| |/\| | | | | . ` | `--. \ | | | | | | . ` | | | | | | | | |\/| |]],
|
||||
[[\ /\ /_| |_| |\ |/\__/ / | | \ \_/ / |\ | _ \ \_/ /_| |_| | | |]],
|
||||
[[ \/ \/ \___/\_| \_/\____/ \_/ \___/\_| \_/ (_) \___/ \___/\_| |_/]],
|
||||
[[]],
|
||||
random_quote,
|
||||
[[]],
|
||||
[[╭──────────────────────────────────────────────────╮]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⡏⠀⠀⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣄⢧⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⢰⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠘⣄⠀⠀⠀⠀⢹⣦⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠘⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⡄⠀⠀⠀⠈⠙⣧⡀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⠀⠀⠀⠀⢸⡼⣇⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⢿⡆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠖⠀⠀⡸⠀⠀⠀⡟⠈⠃⣿⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⢺⡇⠀⠀⠀⠀⠀⠀⣀⣶⣶⠀⠀⠀⠀⠀⣠⣶⣶⣶⣶⣦⣤⣀⣀⣤⡶⠶⠶⠶⡇⠀⠀⣼⣿⣶⠀⣿⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠈⣷⠀⠀⠀⣠⣾⣿⣿⣿⣿⢿⠀⠀⠀⠘⢻⠙⠛⠒⠛⠛⢉⣩⠁⠀⠀⢀⡄⠀⡇⠀⢀⣿⡿⠛⠀⣿⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠘⣆⠀⠈⠉⠁⣉⣉⣃⠞⣠⠀⠀⠀⠀⠀⠀⠀⠈⠙⠛⠉⠁⠀⠀⠀⡾⠀⡀⠁⠀⠈⣿⠁⠀⣸⠇⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠹⣷⠐⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⢤⣀⡀⠀⠀⠀⠀⠀⠀⠀⣦⢱⠀⠀⠀⢿⣀⣠⠏⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⠀⠀⠀⠀⠀⣰⡾⠃⠀⠀⠀⠀⠀⣀⣠⡿⠀⠀⣤⣄⡀⠀⠀⠀⠸⣄⠀⠀⠀⢳⡝⢯⡀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⠀⣰⡟⠑⠦⠴⣤⣤⣤⣾⡛⠁⠀⠀⠀⠀⠈⢷⠀⠀⠀⠀⢿⡄⠀⠀⠀⣿⡆⠙⣆⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⣿⠀⠀⢠⣤⣤⣄⢉⣨⣥⣶⠶⢶⣾⠶⠂⠘⠦⢤⣤⣠⡾⠃⠀⠀⠀⣿⠀⠀⠘⣦⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣇⠀⣀⠀⠈⠀⠐⢿⣏⠉⠉⠉⢉⣁⣠⡶⠟⠁⠀⠀⠀⠀⠀⠈⠁⠀⠀⠀⣠⣾⡟⠀⠀⠀⠘⢧⣀⡀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢻⡄⠈⠀⠂⠀⠀⠀⠈⠉⢉⣉⣩⡭⠓⠂⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⡿⠀⠀⠀⠀⠀⠀⠉⠉⠑⠒│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣨⠟⠀⡁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡴⠋⠀⠀⡠⠇⢠⣀⠀⠀⠀⠀⠀⠀⠠⠐⠂⠀⠀⢀⣠⣼⣿⣿⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⠀⠀⠀⣀⣀⡠⠤⠶⠛⠁⠀⠀⠀⠈⠀⠀⠀⠛⢷⣤⣀⣀⠀⠀⠀⠀⢀⣠⣴⣿⣿⣿⣿⣿⡟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[│⣤⠞⠋⠉⠀⡀⠀⠀⣀⡀⠀⠀⠀⠀⠀⠀⣤⣄⠘⣿⣿⣟⠛⠿⣷⣿⣿⣿⣿⣿⣿⣿⣿⣯⣿⣦⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│]],
|
||||
[[╰──────────────────────────────────────────────────╯]],
|
||||
random_cringe,
|
||||
}
|
||||
end
|
||||
|
||||
db.custom_center = {
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Restore latest session ",
|
||||
action = "SessionLoad",
|
||||
},
|
||||
{
|
||||
icon = " ",
|
||||
desc = "Open Projects ",
|
||||
|
@ -72,7 +70,7 @@ db.custom_footer = function()
|
|||
local vStr = string.format("%d.%d.%d", v.major, v.minor, v.patch)
|
||||
local plugCount = #vim.tbl_keys(packer_plugins)
|
||||
return {
|
||||
"neovim " .. vStr,
|
||||
"masochism " .. vStr,
|
||||
plugCount .. " regrets",
|
||||
}
|
||||
end
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
local saga = require("lspsaga")
|
||||
saga.init_lsp_saga({
|
||||
symbol_in_winbar = {
|
||||
in_custom = true,
|
||||
},
|
||||
code_action_lightbulb = {
|
||||
enable = false,
|
||||
},
|
||||
})
|
||||
|
||||
Nmap("gr", "<cmd>Lspsaga rename<cr>")
|
||||
Nmap("gx", "<cmd>Lspsaga code_action<cr>")
|
||||
Xmap("gx", ":<c-u>Lspsaga range_code_action<cr>")
|
||||
Nmap("K", "<cmd>Lspsaga hover_doc<cr>")
|
||||
Nmap("go", "<cmd>Lspsaga show_line_diagnostics<cr>")
|
||||
Nmap("gj", "<cmd>Lspsaga diagnostic_jump_next<cr>")
|
||||
Nmap("gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>")
|
||||
Map("n", "gr", "<cmd>Lspsaga rename<cr>")
|
||||
Map("n", "gx", "<cmd>Lspsaga code_action<cr>")
|
||||
Map("n", "gx", ":<c-u>Lspsaga range_code_action<cr>")
|
||||
Map("n", "K", "<cmd>Lspsaga hover_doc<cr>")
|
||||
Map("n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>")
|
||||
Map("n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>")
|
||||
Map("n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>")
|
||||
|
||||
vim.cmd([[
|
||||
nnoremap <silent> <A-d> <cmd>lua require('lspsaga.floaterm').open_float_terminal()<CR>
|
||||
|
|
|
@ -7,6 +7,7 @@ local conceal = function()
|
|||
local blacklist = {
|
||||
[home .. "/git/work"] = "Using nvim at work.",
|
||||
[home .. "/git/freelance"] = "Using nvim to freelance.",
|
||||
[vim.fn.resolve(vim.fn.stdpath("config"))] = "Stuck in the hell of nvim config.",
|
||||
}
|
||||
|
||||
local cur_file = vim.fn.expand("%:p")
|
||||
|
|
|
@ -7,6 +7,11 @@ require("nvim-treesitter.configs").setup({
|
|||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = 8192,
|
||||
},
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"css",
|
||||
|
|
|
@ -12,12 +12,9 @@ require("mason-lspconfig").setup({ automatic_installation = true })
|
|||
|
||||
vim.opt.completeopt = "menu,menuone,noselect"
|
||||
|
||||
-- debug mode enabled
|
||||
-- vim.lsp.set_log_level("debug")
|
||||
|
||||
-- Setup nvim-cmp.
|
||||
local present, cmp = pcall(require, "cmp")
|
||||
if not present then
|
||||
if not present or not cmp then
|
||||
vim.pretty_print("cmp not found")
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -27,65 +24,66 @@ cmp.setup({
|
|||
vim.fn["vsnip#anonymous"](args.body)
|
||||
end,
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<Tab>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
-- This little snippet will confirm with tab, and if no entry is selected, will confirm the first item
|
||||
if cmp.visible() then
|
||||
local entry = cmp.get_selected_entry()
|
||||
if not entry then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
|
||||
else
|
||||
cmp.confirm()
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s", "c" }),
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "vsnip" },
|
||||
}, { { name = "buffer" } }),
|
||||
{ name = "vim-dadbod-completion" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype("gitcommit", {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "cmp_git" },
|
||||
}, { { name = "buffer" } }),
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
-- search
|
||||
cmp.setup.cmdline("/", {
|
||||
|
||||
cmp.setup.cmdline({ "/", "?" }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = { { name = "buffer" } },
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
-- Use cmdline & path source for ':'
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources(
|
||||
{ {
|
||||
name = "path",
|
||||
option = { trailing_slash = true },
|
||||
} },
|
||||
{ { name = "cmdline" } }
|
||||
),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
|
||||
-- Setup lspconfig.
|
||||
local capabilities = require("cmp_nvim_lsp").update_capabilities(
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(
|
||||
vim.lsp.protocol.make_client_capabilities()
|
||||
)
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set("n", "<space>e", 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
|
||||
---@diagnostic disable-next-line: unused-local
|
||||
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")
|
||||
|
||||
-- disable diagnostics on Helm files
|
||||
if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then
|
||||
vim.diagnostic.disable()
|
||||
end
|
||||
|
||||
-- Mappings.
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
|
@ -103,22 +101,17 @@ local on_attach = function(client, bufnr)
|
|||
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>nf", function() end, bufopts)
|
||||
end
|
||||
local lspconfig = require("lspconfig")
|
||||
|
||||
local common_config = {
|
||||
on_attach = on_attach,
|
||||
lspconfig.gopls.setup({
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
local present, lsp = pcall(require, "lspconfig")
|
||||
if not present then
|
||||
return
|
||||
end
|
||||
|
||||
lsp.sumneko_lua.setup({
|
||||
on_attach = on_attach,
|
||||
})
|
||||
|
||||
lspconfig.sumneko_lua.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
settings = {
|
||||
Lua = {
|
||||
workspace = {
|
||||
|
@ -129,8 +122,7 @@ lsp.sumneko_lua.setup({
|
|||
preloadFileSize = 10000,
|
||||
},
|
||||
diagnostics = {
|
||||
-- Get the language server to recognize the `vim` global
|
||||
globals = { "vim" },
|
||||
globals = { "vim" }, -- Get the server to recognize the `vim` global
|
||||
},
|
||||
telemetry = {
|
||||
enable = false,
|
||||
|
@ -138,22 +130,9 @@ lsp.sumneko_lua.setup({
|
|||
},
|
||||
},
|
||||
})
|
||||
|
||||
--- the cool kids
|
||||
lsp.bashls.setup(common_config)
|
||||
lsp.gopls.setup(common_config)
|
||||
lsp.pyright.setup(common_config)
|
||||
lsp.rust_analyzer.setup(common_config)
|
||||
|
||||
--- Web Development
|
||||
lsp.cssls.setup(common_config)
|
||||
local emmet_cap = require("cmp_nvim_lsp").update_capabilities(
|
||||
vim.lsp.protocol.make_client_capabilities()
|
||||
)
|
||||
emmet_cap.textDocument.completion.completionItem.snippetSupport = true
|
||||
lsp.emmet_ls.setup({
|
||||
lspconfig["emmet_ls"].setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
capabilities = emmet_cap,
|
||||
filetypes = {
|
||||
"javascriptreact",
|
||||
"typescriptreact",
|
||||
|
@ -165,67 +144,49 @@ lsp.emmet_ls.setup({
|
|||
"scss",
|
||||
},
|
||||
})
|
||||
-- lsp.html.setup(common_config)
|
||||
lsp.tailwindcss.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
emmetCompletions = true,
|
||||
},
|
||||
})
|
||||
|
||||
-- soydev
|
||||
lsp.prismals.setup(common_config)
|
||||
lsp.svelte.setup(common_config)
|
||||
-- attach tsserver only when there's a 'package.json' file in the CWD
|
||||
lsp.tsserver.setup({
|
||||
on_attach = on_attach,
|
||||
lspconfig.tsserver.setup({
|
||||
capabilities = capabilities,
|
||||
root_dir = lsp.util.root_pattern("package.json"),
|
||||
on_attach = on_attach,
|
||||
root_dir = lspconfig.util.root_pattern("package.json"),
|
||||
})
|
||||
-- attach deno only when there's a 'deps.ts' file in the CWD
|
||||
lsp.denols.setup({
|
||||
on_attach = on_attach,
|
||||
lspconfig.denols.setup({
|
||||
capabilities = capabilities,
|
||||
root_dir = lsp.util.root_pattern("deps.ts"),
|
||||
on_attach = on_attach,
|
||||
root_dir = lspconfig.util.root_pattern("deps.ts"),
|
||||
single_file_support = false,
|
||||
})
|
||||
|
||||
-- data formats
|
||||
lsp.dockerls.setup(common_config)
|
||||
lsp.graphql.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
root_dir = lsp.util.root_pattern(
|
||||
".graphqlrc*",
|
||||
".graphql.config.*",
|
||||
"graphql.config.*"
|
||||
),
|
||||
settings = {
|
||||
graphql = {
|
||||
schemaPath = "schema.graphql",
|
||||
},
|
||||
},
|
||||
})
|
||||
lsp.jsonls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
validate = { enable = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
lsp.yamlls.setup({
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
yaml = {
|
||||
["https://raw.githubusercontent.com/instrumenta/kubernetes-json-schema/master/v1.18.0-standalone-strict/all.json"] = "/*.k8s.yaml",
|
||||
},
|
||||
local null = require("null-ls")
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
null.setup({
|
||||
sources = {
|
||||
null.builtins.formatting.gofmt,
|
||||
null.builtins.formatting.stylua,
|
||||
null.builtins.formatting.stylua,
|
||||
null.builtins.formatting.deno_fmt,
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = bufnr })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--- Documentation
|
||||
lsp.ltex.setup(common_config)
|
||||
local toggle_formatters = function()
|
||||
null.toggle({ methods = null.methods.FORMATTING })
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command("ToggleFormatters", toggle_formatters, {})
|
||||
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
|
|
|
@ -1,20 +1,38 @@
|
|||
require("utils")
|
||||
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
local packer = require("packer")
|
||||
if not packer then
|
||||
return
|
||||
local ensure_packer = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data")
|
||||
.. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
install_path,
|
||||
})
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- slow internet...
|
||||
packer.init({
|
||||
git = { clone_timeout = 180 },
|
||||
profile = {
|
||||
enable = true,
|
||||
},
|
||||
local packer_bootstrap = ensure_packer()
|
||||
|
||||
-- auto-compile when lua files in `~/.config/nvim/*` change
|
||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||
pattern = "*.lua",
|
||||
callback = function()
|
||||
local cfg_path = vim.fn.resolve(vim.fn.stdpath("config"))
|
||||
vim.defer_fn(function()
|
||||
if vim.fn.expand("%:p"):match(cfg_path) then
|
||||
vim.cmd("silent! PackerCompile")
|
||||
end
|
||||
end, 0)
|
||||
end,
|
||||
})
|
||||
|
||||
return packer.startup(function(use)
|
||||
return require("packer").startup(function(use)
|
||||
-- Packer managing itself
|
||||
use("wbthomason/packer.nvim")
|
||||
-- startup time or some shit
|
||||
|
@ -37,7 +55,6 @@ return packer.startup(function(use)
|
|||
require("config/gitsigns")
|
||||
end,
|
||||
})
|
||||
|
||||
-- rainbow indents
|
||||
use({
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
|
@ -102,7 +119,10 @@ return packer.startup(function(use)
|
|||
require("config/treesitter")
|
||||
end,
|
||||
})
|
||||
use({ "p00f/nvim-ts-rainbow", requires = "nvim-treesitter/nvim-treesitter" })
|
||||
use({
|
||||
"p00f/nvim-ts-rainbow",
|
||||
requires = "nvim-treesitter/nvim-treesitter",
|
||||
})
|
||||
|
||||
-- show possible key combos
|
||||
use({
|
||||
|
@ -114,7 +134,6 @@ return packer.startup(function(use)
|
|||
|
||||
-- syntax
|
||||
use("alker0/chezmoi.vim")
|
||||
use("digitaltoad/vim-pug")
|
||||
use("ron-rs/ron.vim")
|
||||
use("elkowar/yuck.vim")
|
||||
|
||||
|
@ -137,16 +156,8 @@ return packer.startup(function(use)
|
|||
end,
|
||||
})
|
||||
use("ggandor/lightspeed.nvim")
|
||||
-- make those above work in repeat commands
|
||||
|
||||
use({
|
||||
"windwp/nvim-autopairs",
|
||||
config = function()
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
local cmp = require("cmp")
|
||||
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
})
|
||||
use("windwp/nvim-autopairs")
|
||||
use({
|
||||
"windwp/nvim-ts-autotag",
|
||||
config = function()
|
||||
|
@ -161,7 +172,7 @@ return packer.startup(function(use)
|
|||
"TimUntersberger/neogit",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
Nmap("<leader>ng", "<Cmd>Neogit<CR>")
|
||||
Map("n", "<leader>ng", "<Cmd>Neogit<CR>")
|
||||
end,
|
||||
})
|
||||
use("dhruvasagar/vim-table-mode")
|
||||
|
@ -169,8 +180,7 @@ return packer.startup(function(use)
|
|||
"kyazdani42/nvim-tree.lua",
|
||||
config = function()
|
||||
require("nvim-tree").setup({ update_cwd = true })
|
||||
Nmap("<C-n>", ":NvimTreeToggle<CR>")
|
||||
Nmap("<leader>r", ":NvimTreeRefresh<CR>")
|
||||
Map("n", "<C-n>", ":NvimTreeToggle<CR>")
|
||||
end,
|
||||
})
|
||||
use({
|
||||
|
@ -183,42 +193,32 @@ return packer.startup(function(use)
|
|||
"simrat39/symbols-outline.nvim",
|
||||
config = function()
|
||||
require("symbols-outline").setup()
|
||||
Nmap("<leader>so", ":SymbolsOutline<CR>")
|
||||
Map("n", "<leader>so", ":SymbolsOutline<CR>")
|
||||
end,
|
||||
})
|
||||
|
||||
-- databases
|
||||
use("tpope/vim-dadbod")
|
||||
use("kristijanhusak/vim-dadbod-completion")
|
||||
use({
|
||||
"kristijanhusak/vim-dadbod-ui",
|
||||
requires = "tpope/vim-dadbod",
|
||||
config = function()
|
||||
Nmap("<leader>db", ":DBUIToggle<CR>")
|
||||
Map("n", "<leader>db", ":DBUIToggle<CR>")
|
||||
vim.g.db_ui_use_nerd_fonts = true
|
||||
vim.g.db_ui_win_position = "right"
|
||||
end,
|
||||
})
|
||||
use({
|
||||
"kristijanhusak/vim-dadbod-completion",
|
||||
requires = { { "tpope/vim-dadbod" }, { "hrsh7th/nvim-cmp" } },
|
||||
config = function()
|
||||
require("cmp").setup.buffer({
|
||||
sources = { { name = "vim-dadbod-completion" } },
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- telescope
|
||||
use({
|
||||
"nvim-telescope/telescope.nvim",
|
||||
requires = "nvim-lua/plenary.nvim",
|
||||
config = function()
|
||||
-- Find files using Telescope command-line sugar.
|
||||
Nmap("<leader>fc", "<cmd>Telescope conventional_commits<CR>")
|
||||
Nmap("<leader>fr", "<cmd>Telescope asynctasks all<CR>")
|
||||
Nmap("<leader>ff", "<cmd>Telescope find_files<CR>")
|
||||
Nmap("<leader>fg", "<cmd>Telescope live_grep<CR>")
|
||||
Nmap("<leader>fb", "<cmd>Telescope buffers<CR>")
|
||||
Nmap("<leader>fh", "<cmd>Telescope help_tags<CR>")
|
||||
Map("n", "<leader>fr", "<cmd>Telescope asynctasks all<CR>")
|
||||
Map("n", "<leader>fb", "<cmd>Telescope buffers<CR>")
|
||||
Map("n", "<leader>ff", "<cmd>Telescope find_files<CR>")
|
||||
Map("n", "<leader>fg", "<cmd>Telescope live_grep<CR>")
|
||||
Map("n", "<leader>fh", "<cmd>Telescope help_tags<CR>")
|
||||
end,
|
||||
})
|
||||
use({
|
||||
|
@ -258,16 +258,6 @@ return packer.startup(function(use)
|
|||
require("telescope").load_extension("packer")
|
||||
end,
|
||||
})
|
||||
use({
|
||||
"olacin/telescope-cc.nvim",
|
||||
requires = {
|
||||
{ "nvim-telescope/telescope.nvim" },
|
||||
{ "nvim-lua/popup.nvim" },
|
||||
},
|
||||
config = function()
|
||||
require("telescope").load_extension("conventional_commits")
|
||||
end,
|
||||
})
|
||||
|
||||
use({
|
||||
"andweeb/presence.nvim",
|
||||
|
@ -291,36 +281,22 @@ return packer.startup(function(use)
|
|||
use("hrsh7th/cmp-vsnip")
|
||||
use("hrsh7th/vim-vsnip")
|
||||
use("petertriho/cmp-git")
|
||||
|
||||
use({
|
||||
"simrat39/rust-tools.nvim",
|
||||
config = function()
|
||||
require("rust-tools").setup({})
|
||||
end,
|
||||
})
|
||||
use("b0o/schemastore.nvim")
|
||||
--
|
||||
use({
|
||||
"folke/trouble.nvim",
|
||||
config = function()
|
||||
require("trouble").setup({})
|
||||
end,
|
||||
})
|
||||
use("rafamadriz/friendly-snippets")
|
||||
use("jose-elias-alvarez/null-ls.nvim")
|
||||
use({
|
||||
"glepnir/lspsaga.nvim",
|
||||
branch = "main",
|
||||
config = function()
|
||||
require("config/lspsaga")
|
||||
end,
|
||||
})
|
||||
--
|
||||
|
||||
use("b0o/schemastore.nvim")
|
||||
use({
|
||||
"github/copilot.vim",
|
||||
config = function()
|
||||
Imap(
|
||||
"<C-J>",
|
||||
"copilot#Accept(<Tab>)",
|
||||
{ noremap = true, silent = true, expr = true }
|
||||
)
|
||||
local opt = { noremap = true, silent = true, expr = true }
|
||||
Map("i", "<C-J>", "copilot#Accept(<Tab>)", opt)
|
||||
vim.g.copilot_no_tab_map = true
|
||||
end,
|
||||
})
|
||||
|
@ -348,6 +324,7 @@ return packer.startup(function(use)
|
|||
end,
|
||||
})
|
||||
use("tools-life/taskwiki")
|
||||
|
||||
use({
|
||||
"skywind3000/asyncrun.vim",
|
||||
config = function()
|
||||
|
@ -390,4 +367,8 @@ return packer.startup(function(use)
|
|||
end,
|
||||
})
|
||||
end
|
||||
|
||||
if packer_bootstrap then
|
||||
require("packer").sync()
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
local function map(mode, shortcut, command, opt)
|
||||
vim.keymap.set(mode, shortcut, command, opt)
|
||||
end
|
||||
|
||||
function Nmap(shortcut, command, opt)
|
||||
opt = opt or { noremap = true, silent = true }
|
||||
map("n", shortcut, command, opt)
|
||||
end
|
||||
|
||||
function Imap(shortcut, command, opt)
|
||||
opt = opt or { noremap = true, silent = true }
|
||||
map("i", shortcut, command, opt)
|
||||
end
|
||||
|
||||
function Xmap(shortcut, command, opt)
|
||||
opt = opt or { noremap = true, silent = true }
|
||||
map("x", shortcut, command, opt)
|
||||
end
|
Loading…
Reference in a new issue