dotfiles/data/nvim/init.lua

296 lines
6.5 KiB
Lua
Raw Normal View History

2023-03-12 03:28:32 +00:00
-- https://neovim.io/doc/user/lua-guide.html
vim.opt.completeopt = { "menuone", "noinsert", "noselect" }
2022-09-21 03:37:23 +00:00
vim.opt.swapfile = false
vim.opt.title = true
vim.opt.virtualedit = "block"
vim.opt.whichwrap = "<,>,[,]"
2023-05-19 09:43:12 +00:00
-- Case character
vim.opt.ignorecase = true
vim.opt.smartcase = true
2022-09-21 03:37:23 +00:00
-- Line number
vim.opt.number = true
vim.opt.relativenumber = true
vim.opt.scrolloff = 4
-- Tab
vim.opt.tabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
-- Wrap
vim.opt.breakindent = true
2023-03-20 06:22:29 +00:00
-- Clipboard support
vim.opt.clipboard = "unnamedplus"
2023-03-20 06:22:29 +00:00
2022-09-21 03:37:23 +00:00
-- Truecolor
if vim.env.COLORTERM == "truecolor" then
vim.opt.termguicolors = true
end
-- Mouse support
vim.opt.mouse = "a"
-- Workaround
-- https://github.com/neovim/neovim/issues/16416
vim.keymap.set("i", "<C-c>", "<Esc>")
-- Keymap
vim.keymap.set("n", ";", "<leader>", { remap = true })
2023-05-14 14:05:33 +00:00
vim.keymap.set("n", "q", ":q<CR>")
2023-04-18 03:52:55 +00:00
-- Keymap for plugin
2023-06-12 07:30:44 +00:00
vim.keymap.set("n", "<leader>f", ":FZF<CR>")
2023-06-12 07:04:24 +00:00
vim.keymap.set("n", "<leader>rg", ":FZFRg<CR>")
2022-09-21 03:37:23 +00:00
vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
vim.keymap.set("n", "<leader>n", ":NvimTreeFindFile<CR>")
vim.keymap.set("n", "<leader>tr", ":lua MiniTrailspace.trim()<CR>")
2023-02-28 03:34:59 +00:00
vim.keymap.set("n", "<F2>", ":GoRename<CR>")
2023-03-06 04:25:25 +00:00
vim.keymap.set("n", "<leader>gf", ":GoFillStruct<CR>:w<CR>")
2023-05-05 15:58:26 +00:00
vim.keymap.set("n", "<leader>gat", ":GoAlternate<CR>")
vim.keymap.set("n", "<leader>gt", ":GoTest<CR>")
2023-03-25 03:31:37 +00:00
vim.keymap.set("n", "<leader>gr", ":GoReferrers<CR>")
2023-04-04 17:57:15 +00:00
vim.keymap.set("n", "<leader>gcv", ":GoCoverage<CR>")
2023-04-11 10:47:00 +00:00
vim.keymap.set("n", "<leader>gdd", ":GoDeclsDir<CR>")
2022-09-21 03:37:23 +00:00
2023-06-12 07:04:24 +00:00
-- Use plugin fzf.vim
vim.g.fzf_command_prefix = "FZF"
2023-04-12 07:09:54 +00:00
-- Use plugin nvim-tree.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
2023-03-11 14:16:39 +00:00
-- Use plugin neoformat
vim.g.neoformat_basic_format_trim = 1
2023-03-11 14:16:39 +00:00
vim.g.neoformat_enabled_go = { "gofumpt" }
vim.g.shfmt_opt = "-ci"
-- Use plugin vim-go
2022-09-21 03:37:23 +00:00
vim.g.go_gopls_gofumpt = 1
vim.g.go_doc_popup_window = 1
-- Use plugin copilot
2022-09-21 03:37:23 +00:00
vim.g.copilot_filetypes = {
["*"] = false,
2023-06-02 16:43:22 +00:00
c = true,
cpp = true,
2022-09-21 03:37:23 +00:00
go = true,
2023-06-02 16:43:22 +00:00
java = true,
2023-02-25 14:35:42 +00:00
json = true,
2023-02-28 09:00:43 +00:00
lua = true,
2023-02-28 03:34:59 +00:00
make = true,
2023-06-02 16:43:22 +00:00
markdown = true,
2022-09-21 03:37:23 +00:00
proto = true,
2023-02-25 14:35:42 +00:00
python = true,
2023-02-28 09:00:43 +00:00
toml = true,
2023-03-06 04:25:25 +00:00
yaml = true,
2022-09-21 03:37:23 +00:00
}
2023-06-17 04:20:37 +00:00
-- https://github.com/folke/lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
2023-06-17 04:53:00 +00:00
"--branch=stable",
2023-06-17 04:20:37 +00:00
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
2022-09-21 03:37:23 +00:00
2023-06-17 04:20:37 +00:00
require("lazy").setup({
2023-04-18 03:52:55 +00:00
-- https://github.com/junegunn/fzf.vim
2023-06-19 03:33:50 +00:00
"junegunn/fzf",
2023-06-17 04:20:37 +00:00
"junegunn/fzf.vim",
2022-09-21 03:37:23 +00:00
-- https://github.com/nvim-lualine/lualine.nvim
2023-06-17 04:20:37 +00:00
{
2022-09-21 03:37:23 +00:00
"nvim-lualine/lualine.nvim",
config = function()
require("lualine").setup({
options = {
icons_enabled = false,
2023-03-26 16:39:01 +00:00
theme = "auto",
2023-03-17 09:28:40 +00:00
-- theme = "iceberg",
2023-03-26 16:39:01 +00:00
-- theme = "catppuccin",
2022-09-21 03:37:23 +00:00
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
},
extensions = { "fzf", "nvim-tree" },
})
2022-10-31 16:01:33 +00:00
-- Disable showmode when use lualine
vim.opt.showmode = false
2022-09-21 03:37:23 +00:00
end,
2023-06-17 04:20:37 +00:00
},
2022-09-21 03:37:23 +00:00
2023-04-12 07:09:54 +00:00
-- https://github.com/nvim-tree/nvim-tree.lua
2023-06-17 04:20:37 +00:00
{
2023-04-12 07:09:54 +00:00
"nvim-tree/nvim-tree.lua",
2022-09-21 03:37:23 +00:00
config = function()
require("nvim-tree").setup({
renderer = {
2023-04-12 07:09:54 +00:00
group_empty = true,
2023-02-07 10:10:22 +00:00
icons = {
show = {
file = false,
folder = false,
folder_arrow = false,
git = false,
modified = false,
},
},
2022-09-21 03:37:23 +00:00
},
2023-05-24 07:10:08 +00:00
filters = {
2023-06-02 08:13:33 +00:00
custom = { "^\\.git$", "^\\.DS_Store", "\\.out", "\\.class" },
2023-05-24 07:10:08 +00:00
},
2022-09-21 03:37:23 +00:00
})
end,
2023-06-17 04:20:37 +00:00
},
2022-09-21 03:37:23 +00:00
-- https://github.com/lukas-reineke/indent-blankline.nvim
2023-06-17 04:20:37 +00:00
{
2022-09-21 03:37:23 +00:00
"lukas-reineke/indent-blankline.nvim",
config = function()
require("indent_blankline").setup({
-- For oxocarbon
char_highlight_list = {
"Whitespace",
},
})
2022-09-21 03:37:23 +00:00
end,
2023-06-17 04:20:37 +00:00
},
2022-09-21 03:37:23 +00:00
-- https://github.com/lewis6991/gitsigns.nvim
{
"lewis6991/gitsigns.nvim",
config = function()
require("gitsigns").setup({
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map("n", "]c", function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gs.next_hunk()
end)
return "<Ignore>"
end, { expr = true })
map("n", "[c", function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gs.prev_hunk()
end)
return "<Ignore>"
end, { expr = true })
end,
})
end,
},
2023-04-26 05:57:22 +00:00
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim
2023-06-17 04:20:37 +00:00
{
2023-06-21 09:35:14 +00:00
"echasnovski/mini.nvim",
2023-02-28 09:00:43 +00:00
config = function()
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-bracketed.md
2023-06-17 04:33:05 +00:00
require("mini.bracketed").setup({
comment = { suffix = "", options = {} },
})
2023-02-28 09:00:43 +00:00
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-comment.md
2023-06-17 04:33:05 +00:00
require("mini.comment").setup()
2023-03-01 09:19:40 +00:00
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-cursorword.md
2023-04-02 18:10:10 +00:00
require("mini.cursorword").setup()
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-surround.md
2023-04-02 18:17:38 +00:00
require("mini.surround").setup()
2023-06-21 09:35:14 +00:00
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-trailspace.md
2023-05-03 17:12:34 +00:00
require("mini.trailspace").setup()
end,
2023-06-17 04:20:37 +00:00
},
2023-05-03 17:12:34 +00:00
2022-09-21 03:37:23 +00:00
-- Colorschemes
-- https://github.com/cocopon/iceberg.vim
2023-06-17 04:20:37 +00:00
"cocopon/iceberg.vim",
2022-09-21 03:37:23 +00:00
-- https://github.com/projekt0n/github-nvim-theme
2023-06-17 04:20:37 +00:00
"projekt0n/github-nvim-theme",
2023-03-17 09:28:40 +00:00
-- https://github.com/nyoom-engineering/oxocarbon.nvim
2023-06-17 04:20:37 +00:00
"nyoom-engineering/oxocarbon.nvim",
2023-03-17 09:28:40 +00:00
2022-10-31 16:01:33 +00:00
-- https://github.com/catppuccin/nvim
2023-06-17 04:20:37 +00:00
{
2022-10-31 16:01:33 +00:00
"catppuccin/nvim",
2023-06-17 04:20:37 +00:00
name = "catppuccin",
2022-10-31 16:01:33 +00:00
config = function()
require("catppuccin").setup({
flavour = "mocha",
})
end,
2023-06-17 04:20:37 +00:00
},
2022-09-26 02:30:19 +00:00
2022-09-21 03:37:23 +00:00
-- Programming languages
-- https://github.com/sbdchd/neoformat
2023-06-17 04:20:37 +00:00
"sbdchd/neoformat",
2022-09-21 03:37:23 +00:00
-- https://github.com/nvim-treesitter/nvim-treesitter
2023-06-17 04:20:37 +00:00
{
"nvim-treesitter/nvim-treesitter",
2023-06-17 16:07:41 +00:00
build = {
":TSUpdate",
},
config = function()
require("nvim-treesitter.configs").setup({
ensure_installed = {
"go",
"json",
"yaml",
"toml",
"lua",
},
})
end,
2023-06-17 04:20:37 +00:00
},
-- https://github.com/nvim-treesitter/nvim-treesitter-context
2023-06-17 04:20:37 +00:00
{
"nvim-treesitter/nvim-treesitter-context",
config = function()
require("treesitter-context").setup({
enable = true,
max_lines = 2,
})
end,
2023-06-17 04:20:37 +00:00
},
2022-09-21 03:37:23 +00:00
-- https://github.com/fatih/vim-go
2023-06-17 04:20:37 +00:00
"fatih/vim-go",
2022-09-21 03:37:23 +00:00
-- https://github.com/github/copilot.vim
2023-06-17 04:20:37 +00:00
"github/copilot.vim",
})
2022-09-21 03:37:23 +00:00
2022-10-31 16:01:33 +00:00
-- vim.api.nvim_command("colorscheme iceberg")
2023-04-02 18:10:10 +00:00
vim.api.nvim_command("colorscheme oxocarbon")
2023-05-30 14:34:20 +00:00
-- vim.api.nvim_command("colorscheme github_dark")
2023-04-02 18:10:10 +00:00
-- vim.api.nvim_command("colorscheme catppuccin")