neovim: move most of files to after/plugin dir
This commit is contained in:
42
neovim/.config/nvim/after/plugin/aus.lua
Normal file
42
neovim/.config/nvim/after/plugin/aus.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
local group = vim.api.nvim_create_augroup("RootGroup", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.highlight.on_yank({ timeout = 200 })
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = "*",
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.cmd(":checktime")
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
pattern = "*",
|
||||
group = group,
|
||||
callback = function()
|
||||
local ft = vim.bo.filetype
|
||||
|
||||
if ft == "fugitive" then
|
||||
vim.wo.colorcolumn = ""
|
||||
end
|
||||
|
||||
if ft == "gitcommit" then
|
||||
vim.wo.colorcolumn = "50"
|
||||
vim.cmd("setlocal spell")
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*.go",
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.cmd(":silent :!goimports -w %")
|
||||
end,
|
||||
})
|
||||
15
neovim/.config/nvim/after/plugin/cmds.lua
Normal file
15
neovim/.config/nvim/after/plugin/cmds.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
local git = require("user.git")
|
||||
|
||||
vim.api.nvim_create_user_command("OrganizeImports", function()
|
||||
require("user.utils").lsp_organize_imports()
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command("GitShowCommit", function()
|
||||
local commit = git.get_commit_hash_for_current_line()
|
||||
|
||||
vim.cmd(":Git show " .. commit)
|
||||
end, {})
|
||||
|
||||
vim.api.nvim_create_user_command("ClearMessages", function()
|
||||
require("notify").dismiss()
|
||||
end, {})
|
||||
24
neovim/.config/nvim/after/plugin/comment.lua
Normal file
24
neovim/.config/nvim/after/plugin/comment.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
require("Comment").setup({
|
||||
pre_hook = function(ctx)
|
||||
-- Only calculate commentstring for tsx filetypes
|
||||
if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then
|
||||
local U = require("Comment.utils")
|
||||
|
||||
-- Detemine whether to use linewise or blockwise commentstring
|
||||
local type = ctx.ctype == U.ctype.line and "__default" or "__multiline"
|
||||
|
||||
-- Determine the location where to calculate commentstring from
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.block then
|
||||
location = require("ts_context_commentstring.utils").get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require("ts_context_commentstring.utils").get_visual_start_location()
|
||||
end
|
||||
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring({
|
||||
key = type,
|
||||
location = location,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
138
neovim/.config/nvim/after/plugin/comp.lua
Normal file
138
neovim/.config/nvim/after/plugin/comp.lua
Normal file
@@ -0,0 +1,138 @@
|
||||
local cmp = require("cmp")
|
||||
local ls = require("luasnip")
|
||||
|
||||
require("cmp_git").setup()
|
||||
|
||||
local kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "ﴯ",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "ﰠ",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
|
||||
local completion_trigger = "<C-space>"
|
||||
if vim.fn.has("win32") == 1 then
|
||||
completion_trigger = "<C-y>"
|
||||
end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = {
|
||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
||||
[completion_trigger] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.close()
|
||||
else
|
||||
cmp.complete()
|
||||
end
|
||||
end),
|
||||
["<TAB>"] = cmp.mapping.confirm({
|
||||
select = true,
|
||||
behavior = cmp.SelectBehavior.Insert,
|
||||
}),
|
||||
["<A-j>"] = cmp.mapping.scroll_docs(4),
|
||||
["<A-k>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-l>"] = cmp.mapping(function(fallback)
|
||||
if ls.expand_or_jumpable() then
|
||||
ls.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<C-h>"] = cmp.mapping(function(fallback)
|
||||
if ls.jumpable(-1) then
|
||||
ls.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
}, {
|
||||
{ name = "path" },
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noselect,noinsert,preview",
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
sorting = {
|
||||
comparators = {
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.kind,
|
||||
},
|
||||
},
|
||||
window = {
|
||||
completion = cmp.config.window.bordered(),
|
||||
documentation = cmp.config.window.bordered(),
|
||||
},
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
vim_item.kind = string.format("%s %s", kind_icons[vim_item.kind], vim_item.kind)
|
||||
vim_item.menu = ({
|
||||
buffer = "[Buffer]",
|
||||
luasnip = "[Snippet]",
|
||||
nvim_lua = "[Lua]",
|
||||
path = "[File]",
|
||||
nvim_lsp = "[LSP]",
|
||||
})[entry.source.name]
|
||||
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline("/", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = "buffer" },
|
||||
},
|
||||
})
|
||||
|
||||
cmp.setup.cmdline(":", {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "cmdline" },
|
||||
}),
|
||||
})
|
||||
|
||||
cmp.setup.filetype("gitcommit", {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "git" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
})
|
||||
102
neovim/.config/nvim/after/plugin/file-tree.lua
Normal file
102
neovim/.config/nvim/after/plugin/file-tree.lua
Normal file
@@ -0,0 +1,102 @@
|
||||
local Job = require("plenary.job")
|
||||
|
||||
local function git_stage(node)
|
||||
local cwd = vim.loop.cwd()
|
||||
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
|
||||
|
||||
Job
|
||||
:new({
|
||||
command = "git",
|
||||
args = { "add", relative_path },
|
||||
})
|
||||
:start()
|
||||
|
||||
require("nvim-tree.actions.reloaders").reload_explorer()
|
||||
end
|
||||
|
||||
local function git_reset(node)
|
||||
local cwd = vim.loop.cwd()
|
||||
local relative_path = string.gsub(node.absolute_path, cwd .. "/", "")
|
||||
|
||||
Job
|
||||
:new({
|
||||
command = "git",
|
||||
args = { "reset", relative_path },
|
||||
})
|
||||
:start()
|
||||
|
||||
require("nvim-tree.actions.reloaders").reload_explorer()
|
||||
end
|
||||
|
||||
-- TODO: add here keymap for git diff window
|
||||
|
||||
require("nvim-tree").setup({
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
open_on_setup = true,
|
||||
hijack_cursor = true,
|
||||
open_on_tab = false,
|
||||
update_cwd = true,
|
||||
auto_reload_on_write = true,
|
||||
reload_on_bufenter = true,
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
side = "left",
|
||||
preserve_window_proportions = true,
|
||||
mappings = {
|
||||
list = {
|
||||
{ key = "tn", action = "tabnew" },
|
||||
{ key = "gs", action = "git_stage", action_cb = git_stage },
|
||||
{ key = "gr", action = "git_reset", action_cb = git_reset },
|
||||
{ key = "l", action = "edit" },
|
||||
{ key = "@", action = "cd" },
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = true,
|
||||
group_empty = true,
|
||||
highlight_git = true,
|
||||
indent_markers = {
|
||||
enable = true,
|
||||
},
|
||||
icons = {
|
||||
show = {
|
||||
git = true,
|
||||
file = true,
|
||||
folder = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
git = {
|
||||
unstaged = "U",
|
||||
staged = "S",
|
||||
unmerged = "M",
|
||||
renamed = "R",
|
||||
untracked = "N",
|
||||
deleted = "D",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
filters = {
|
||||
custom = { "^.git$" },
|
||||
},
|
||||
actions = {
|
||||
open_file = {
|
||||
resize_window = true,
|
||||
},
|
||||
},
|
||||
git = {
|
||||
ignore = true,
|
||||
},
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
show_on_dirs = true,
|
||||
icons = { hint = "", info = "", warning = "", error = "" },
|
||||
},
|
||||
})
|
||||
53
neovim/.config/nvim/after/plugin/gitsigns.lua
Normal file
53
neovim/.config/nvim/after/plugin/gitsigns.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local a = require("gitsigns.actions")
|
||||
local reload_nvimtree = require("nvim-tree.actions.reloaders").reload_explorer
|
||||
|
||||
require("gitsigns").setup({
|
||||
signcolumn = true,
|
||||
attach_to_untracked = false,
|
||||
current_line_blame = true,
|
||||
current_line_blame_opts = {
|
||||
delay = 1000,
|
||||
},
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = true,
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
vim.keymap.set("n", "<leader>gs", function()
|
||||
a.stage_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gu", function()
|
||||
a.undo_stage_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gr", function()
|
||||
a.reset_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gp", function()
|
||||
a.preview_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gn", function()
|
||||
a.next_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gN", function()
|
||||
a.prev_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
|
||||
vim.keymap.set("v", "gs", function()
|
||||
a.stage_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("v", "gu", function()
|
||||
a.undo_stage_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
vim.keymap.set("v", "gr", function()
|
||||
a.reset_hunk()
|
||||
reload_nvimtree()
|
||||
end)
|
||||
end,
|
||||
})
|
||||
163
neovim/.config/nvim/after/plugin/lsp.lua
Normal file
163
neovim/.config/nvim/after/plugin/lsp.lua
Normal file
@@ -0,0 +1,163 @@
|
||||
local lsp_installer = require("nvim-lsp-installer")
|
||||
local lspconfig = require("lspconfig")
|
||||
local null_ls = require("null-ls")
|
||||
local util = require("lspconfig").util
|
||||
local u = require("user.utils")
|
||||
|
||||
local formatting = null_ls.builtins.formatting
|
||||
local diagnostics = null_ls.builtins.diagnostics
|
||||
|
||||
lsp_installer.setup({
|
||||
ensure_installed = {
|
||||
"bashls",
|
||||
"cssmodules_ls",
|
||||
"dockerls",
|
||||
"tailwindcss",
|
||||
"tsserver",
|
||||
"vimls",
|
||||
"cssls",
|
||||
"html",
|
||||
"jsonls",
|
||||
"prismals",
|
||||
"sumneko_lua",
|
||||
"svelte",
|
||||
"emmet_ls",
|
||||
"eslint",
|
||||
"gopls",
|
||||
},
|
||||
automatic_installation = true,
|
||||
})
|
||||
|
||||
null_ls.setup({
|
||||
sources = {
|
||||
formatting.prettierd,
|
||||
formatting.stylua,
|
||||
formatting.black,
|
||||
formatting.gofmt,
|
||||
formatting.goimports,
|
||||
formatting.shfmt,
|
||||
},
|
||||
on_attach = function()
|
||||
local group = vim.api.nvim_create_augroup("NullLsLspFormatting", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = "*",
|
||||
group = group,
|
||||
callback = function()
|
||||
u.lsp_format()
|
||||
end,
|
||||
})
|
||||
end,
|
||||
})
|
||||
|
||||
-- Other formats that work weird with null_ls
|
||||
local group = vim.api.nvim_create_augroup("OtherLspFormatting", { clear = true })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
pattern = { "*.svelte" },
|
||||
group = group,
|
||||
callback = function()
|
||||
vim.lsp.buf.format()
|
||||
end,
|
||||
})
|
||||
|
||||
local capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local lsps_with_disabled_formatting = { "tsserver", "gopls", "jsonls", "html", "sumneko_lua" }
|
||||
|
||||
local on_attach = function(client, bufnr)
|
||||
if vim.tbl_contains(lsps_with_disabled_formatting, client.name) then
|
||||
client.server_capabilities.document_formatting = false
|
||||
client.server_capabilities.document_range_formatting = false
|
||||
end
|
||||
|
||||
if client.name == "tailwindcss" then
|
||||
require("tailwindcss-colors").buf_attach(bufnr)
|
||||
end
|
||||
|
||||
require("lsp_signature").on_attach({
|
||||
bind = true,
|
||||
hint_enable = false,
|
||||
}, bufnr)
|
||||
end
|
||||
|
||||
local servers = lsp_installer.get_installed_servers()
|
||||
|
||||
for _, server in ipairs(servers) do
|
||||
local opts = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
}
|
||||
|
||||
if server.name == "emmet_ls" then
|
||||
opts.filetypes = { "html", "css", "scss", "javascripreact", "typescriptreact" }
|
||||
end
|
||||
|
||||
if server.name == "tailwindcss" then
|
||||
opts.root_dir = util.root_pattern("tailwind.config.js", "tailwind.config.cjs", "tailwind.config.mjs")
|
||||
end
|
||||
|
||||
if server.name == "sumneko_lua" then
|
||||
local luadev = require("lua-dev").setup({
|
||||
lspconfig = {
|
||||
capabilities = capabilities,
|
||||
on_attach = on_attach,
|
||||
},
|
||||
})
|
||||
|
||||
opts = luadev
|
||||
end
|
||||
|
||||
if server.name == "jsonls" then
|
||||
opts.filetypes = { "json", "jsonc" }
|
||||
opts.settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas({
|
||||
select = {
|
||||
".eslintrc",
|
||||
"package.json",
|
||||
"tsconfig.json",
|
||||
"prettierrc.json",
|
||||
"babelrc.json",
|
||||
"Vercel",
|
||||
"cypress.json",
|
||||
"GitHub Action",
|
||||
"GitHub Workflow",
|
||||
"lerna.json",
|
||||
"openapi.json",
|
||||
".postcssrc",
|
||||
"prisma.yml",
|
||||
"Swagger API 2.0",
|
||||
"huskyrc",
|
||||
"jsdoc",
|
||||
".commitlintrc",
|
||||
"docker-compose.yml",
|
||||
".yarnrc.yml",
|
||||
"swcrc",
|
||||
},
|
||||
}),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
if server.name == "tsserver" then
|
||||
opts.root_dir = util.root_pattern(".git", "package.json", "tsconfig.json")
|
||||
end
|
||||
|
||||
if server.name == "eslint" then
|
||||
opts.root_dir = util.root_pattern(".eslintrc", ".eslintrc.json")
|
||||
end
|
||||
|
||||
lspconfig[server.name].setup(opts)
|
||||
end
|
||||
|
||||
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
|
||||
update_in_insert = false,
|
||||
signs = false,
|
||||
})
|
||||
|
||||
vim.cmd([[
|
||||
hi DiagnosticError guifg=#e80f43
|
||||
hi DiagnosticWarn guifg=#ffc914
|
||||
hi DiagnosticInfo guifg=#9fd356
|
||||
hi DiagnosticHint guifg=#1d74f7
|
||||
]])
|
||||
112
neovim/.config/nvim/after/plugin/lualine.lua
Normal file
112
neovim/.config/nvim/after/plugin/lualine.lua
Normal file
@@ -0,0 +1,112 @@
|
||||
local lualine = require("lualine")
|
||||
local devicons = require("nvim-web-devicons")
|
||||
local pkgInfo = require("package-info")
|
||||
|
||||
local mode = {
|
||||
"mode",
|
||||
}
|
||||
|
||||
local branch = {
|
||||
"branch",
|
||||
icons_enabled = true,
|
||||
icon = "",
|
||||
}
|
||||
|
||||
local diagnostics = {
|
||||
"diagnostics",
|
||||
sections = { "error", "warn", "info", "hint" },
|
||||
always_visible = true,
|
||||
}
|
||||
|
||||
local filename = {
|
||||
function()
|
||||
local filetype = vim.bo.filetype
|
||||
local filename = vim.fn.expand("%:t")
|
||||
local fileext = vim.fn.expand("%:e")
|
||||
local icon = devicons.get_icon(filename, fileext)
|
||||
|
||||
if filetype == "fugitive" then
|
||||
icon = devicons.get_icons().git.icon
|
||||
filename = "git"
|
||||
end
|
||||
|
||||
if not icon then
|
||||
return filename
|
||||
end
|
||||
|
||||
return icon .. " " .. filename
|
||||
end,
|
||||
}
|
||||
|
||||
local fileformat = {
|
||||
function()
|
||||
return "[" .. vim.bo.fileformat .. "]"
|
||||
end,
|
||||
}
|
||||
|
||||
local tabstop = {
|
||||
function()
|
||||
local tabstop = vim.bo.tabstop
|
||||
local expandtab = vim.bo.expandtab
|
||||
|
||||
local method = expandtab == true and "spaces" or "tabs"
|
||||
local format = tabstop .. " " .. method
|
||||
|
||||
return format
|
||||
end,
|
||||
}
|
||||
|
||||
local npm = {
|
||||
function()
|
||||
return pkgInfo.get_status()
|
||||
end,
|
||||
}
|
||||
|
||||
local location = {
|
||||
function()
|
||||
local line = vim.fn.line(".")
|
||||
local total_lines = vim.api.nvim_buf_line_count(0)
|
||||
|
||||
local percent = math.floor(line / total_lines * 100)
|
||||
|
||||
return line .. "/" .. total_lines .. " (" .. percent .. "%%)"
|
||||
end,
|
||||
}
|
||||
|
||||
local diff = {
|
||||
"diff",
|
||||
}
|
||||
|
||||
local tabs = {
|
||||
"tabs",
|
||||
mode = 1,
|
||||
}
|
||||
|
||||
local windows = {
|
||||
"windows",
|
||||
disabled_buftypes = { "nofile" },
|
||||
filetype_names = {
|
||||
NvimTree = "File Tree",
|
||||
},
|
||||
}
|
||||
|
||||
lualine.setup({
|
||||
options = {
|
||||
component_separators = "",
|
||||
section_separators = "",
|
||||
globalstatus = true,
|
||||
},
|
||||
tabline = {
|
||||
lualine_a = { tabs },
|
||||
lualine_z = { windows },
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { mode },
|
||||
lualine_b = { branch },
|
||||
lualine_c = { diagnostics },
|
||||
lualine_x = { npm, diff, location, tabstop, fileformat },
|
||||
lualine_y = { filename },
|
||||
lualine_z = {},
|
||||
},
|
||||
extensions = { "nvim-tree", "fugitive", "quickfix" },
|
||||
})
|
||||
43
neovim/.config/nvim/after/plugin/options.lua
Normal file
43
neovim/.config/nvim/after/plugin/options.lua
Normal file
@@ -0,0 +1,43 @@
|
||||
local opt = vim.opt
|
||||
|
||||
-- 2 tabs converted to spaces + autoindentation
|
||||
opt.tabstop = 2
|
||||
opt.shiftwidth = 2
|
||||
opt.expandtab = true
|
||||
opt.autoindent = true
|
||||
|
||||
-- What the **** is this
|
||||
opt.shortmess = "filnxtToOFc"
|
||||
|
||||
-- Create splits like a normal human being
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
|
||||
-- Other settings
|
||||
opt.termguicolors = true
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.wrap = true
|
||||
opt.swapfile = false
|
||||
opt.hidden = true
|
||||
opt.writebackup = false
|
||||
opt.encoding = "utf-8"
|
||||
opt.updatetime = 300
|
||||
opt.mouse = "a"
|
||||
opt.cursorline = true
|
||||
opt.clipboard = "unnamedplus"
|
||||
opt.signcolumn = "yes"
|
||||
opt.fillchars:append({ eob = " " })
|
||||
opt.showtabline = 2
|
||||
opt.showcmd = false
|
||||
opt.guicursor = "a:block,i:ver25"
|
||||
opt.fileformat = "unix"
|
||||
opt.fileformats = { "unix", "dos", "mac" }
|
||||
opt.laststatus = 3
|
||||
opt.smartcase = true
|
||||
opt.ignorecase = true
|
||||
opt.scrolloff = 5
|
||||
opt.colorcolumn = "120"
|
||||
opt.autoread = true
|
||||
opt.showmode = false
|
||||
opt.redrawtime = 4000
|
||||
140
neovim/.config/nvim/after/plugin/remaps.lua
Normal file
140
neovim/.config/nvim/after/plugin/remaps.lua
Normal file
@@ -0,0 +1,140 @@
|
||||
local ts = require("telescope.builtin")
|
||||
local u = require("user.utils")
|
||||
local git = require("user.git")
|
||||
local pkgInfo = require("package-info")
|
||||
|
||||
-- General keymaps
|
||||
vim.keymap.set("n", "<C-c>", ":nohl<CR>")
|
||||
vim.keymap.set("n", "<C-q>", "<C-W>q")
|
||||
|
||||
-- Horizontal moving in insert mode
|
||||
vim.keymap.set("i", "<C-h>", "<Left>")
|
||||
vim.keymap.set("i", "<C-l>", "<Right>")
|
||||
|
||||
-- Disable PageUp and PageDown keys
|
||||
vim.keymap.set({ "n", "i", "v" }, "<PageDown>", "<nop>")
|
||||
vim.keymap.set({ "n", "i", "v" }, "<PageUp>", "<nop>")
|
||||
|
||||
-- Move focus between splits
|
||||
vim.keymap.set("n", "<leader>h", "<C-w>h")
|
||||
vim.keymap.set("n", "<leader>l", "<C-w>l")
|
||||
vim.keymap.set("n", "<leader>j", "<C-w>j")
|
||||
vim.keymap.set("n", "<leader>k", "<C-w>k")
|
||||
|
||||
-- Move lines easily
|
||||
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
|
||||
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
|
||||
|
||||
-- Leave selection when moving code left and right
|
||||
vim.keymap.set("v", "<", "<gv")
|
||||
vim.keymap.set("v", ">", ">gv")
|
||||
|
||||
-- Terminal
|
||||
vim.keymap.set("t", "<ESC>", "<C-\\><C-n>")
|
||||
vim.keymap.set("n", "Th", ":split | :term<CR>")
|
||||
vim.keymap.set("n", "Tv", ":vs | :term<CR>")
|
||||
|
||||
-- Tabs
|
||||
vim.keymap.set("n", "H", ":tabprev<CR>")
|
||||
vim.keymap.set("n", "L", ":tabnext<CR>")
|
||||
vim.keymap.set("n", "tn", ":tabnew<CR>")
|
||||
vim.keymap.set("n", "tN", ":-tabnew<CR>")
|
||||
vim.keymap.set("n", "tc", function()
|
||||
require("user.tabs").close_tab()
|
||||
end)
|
||||
vim.keymap.set("n", "tr", function()
|
||||
require("user.tabs").restore_tab()
|
||||
end)
|
||||
vim.keymap.set("n", "tf", function()
|
||||
require("user.tabs").find_tab()
|
||||
end)
|
||||
vim.keymap.set("n", "<A-h>", ":-tabmove<CR>")
|
||||
vim.keymap.set("n", "<A-l>", ":+tabmove<CR>")
|
||||
|
||||
-- Nvim Tree
|
||||
vim.keymap.set("n", "<leader><leader>", function()
|
||||
require("nvim-tree").toggle(true, false)
|
||||
end)
|
||||
|
||||
-- Telescope
|
||||
vim.keymap.set("n", "<leader>f", function()
|
||||
ts.find_files({ hidden = true })
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>p", function()
|
||||
ts.builtin()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>b", function()
|
||||
ts.buffers()
|
||||
end)
|
||||
|
||||
-- LSP
|
||||
vim.keymap.set("n", "gd", function()
|
||||
ts.lsp_definitions()
|
||||
end)
|
||||
vim.keymap.set("n", "gr", function()
|
||||
ts.lsp_references()
|
||||
end)
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover()
|
||||
-- TODO: find another solution
|
||||
require("notify").dismiss()
|
||||
end)
|
||||
vim.keymap.set("n", "<F2>", function()
|
||||
vim.lsp.buf.rename()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>.", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end)
|
||||
vim.keymap.set("v", "<leader>.", function()
|
||||
vim.lsp.buf.range_code_action()
|
||||
end)
|
||||
|
||||
-- Diagnostics
|
||||
vim.keymap.set("n", "<leader>dd", function()
|
||||
vim.diagnostic.open_float(nil, { focus = false, scope = "line" })
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>dy", function()
|
||||
u.copy_diagnostic_message()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>dn", function()
|
||||
vim.diagnostic.goto_next({ float = false })
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>dp", function()
|
||||
vim.diagnostic.goto_prev({ float = false })
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>do", ":lopen<CR>")
|
||||
|
||||
-- Git
|
||||
vim.keymap.set("n", "<leader>gg", ":G<CR>")
|
||||
vim.keymap.set("n", "<leader>go", function()
|
||||
git.open_commit_on_github()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>gh", ":Octo actions<CR>")
|
||||
|
||||
-- Refactoring
|
||||
vim.keymap.set("n", "<leader>ri", function()
|
||||
u.lsp_organize_imports()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>rf", function()
|
||||
u.lsp_format()
|
||||
end)
|
||||
|
||||
-- package-info
|
||||
vim.keymap.set("n", "<leader>ns", function()
|
||||
pkgInfo.show()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>nh", function()
|
||||
pkgInfo.hide()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>ni", function()
|
||||
pkgInfo.install()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>nd", function()
|
||||
pkgInfo.delete()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>nu", function()
|
||||
pkgInfo.change_version()
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>nr", function()
|
||||
pkgInfo.reinstall()
|
||||
end)
|
||||
69
neovim/.config/nvim/after/plugin/session.lua
Normal file
69
neovim/.config/nvim/after/plugin/session.lua
Normal file
@@ -0,0 +1,69 @@
|
||||
local function get_available_session_names()
|
||||
local sessions = require("possession.query").as_list()
|
||||
|
||||
local available_names = {}
|
||||
for _, session in ipairs(sessions) do
|
||||
table.insert(available_names, session.name)
|
||||
end
|
||||
|
||||
return available_names
|
||||
end
|
||||
|
||||
local function choose_session(available_names, prompt)
|
||||
local name
|
||||
|
||||
vim.ui.select(available_names, {
|
||||
prompt = prompt,
|
||||
}, function(ans)
|
||||
name = ans
|
||||
end)
|
||||
|
||||
return name
|
||||
end
|
||||
|
||||
local function save_session()
|
||||
local default_name = "temp-session-" .. math.random(0, 99)
|
||||
local name
|
||||
|
||||
vim.ui.input({
|
||||
prompt = "Session name: ",
|
||||
}, function(ans)
|
||||
name = ans or default_name
|
||||
end)
|
||||
|
||||
require("possession.commands").save(name)
|
||||
end
|
||||
|
||||
local function list_sessions()
|
||||
require("telescope").extensions.possession.list()
|
||||
end
|
||||
|
||||
local function use_session()
|
||||
local available_names = get_available_session_names()
|
||||
local name = choose_session(available_names, "Choose session to load")
|
||||
|
||||
if name == nil then
|
||||
print("no session? :(")
|
||||
return
|
||||
end
|
||||
|
||||
require("possession.commands").load(name)
|
||||
end
|
||||
|
||||
local function delete_session()
|
||||
local available_names = get_available_session_names()
|
||||
local name = choose_session(available_names, "Choose session to delete")
|
||||
|
||||
if name == nil then
|
||||
print("no session? :(")
|
||||
return
|
||||
end
|
||||
|
||||
require("possession.commands").delete(name)
|
||||
end
|
||||
|
||||
-- remaps
|
||||
vim.keymap.set("n", "<leader>ss", save_session)
|
||||
vim.keymap.set("n", "<leader>sl", list_sessions)
|
||||
vim.keymap.set("n", "<leader>su", use_session)
|
||||
vim.keymap.set("n", "<leader>sd", delete_session)
|
||||
20
neovim/.config/nvim/after/plugin/snippets.lua
Normal file
20
neovim/.config/nvim/after/plugin/snippets.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
local ls = require("luasnip")
|
||||
local s, i = ls.s, ls.insert_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
|
||||
-- NOTE: this is not working right now, i need to RTFM
|
||||
ls.filetype_extend("javascript", { "javascriptreact", "javascript.jsx" })
|
||||
ls.filetype_extend("typescript", { "typescriptreact", "typescript.jsx" })
|
||||
|
||||
local clg = s(
|
||||
"clg",
|
||||
fmt([[console.log({});]], {
|
||||
i(0),
|
||||
})
|
||||
)
|
||||
|
||||
ls.add_snippets("javascript", { clg })
|
||||
ls.add_snippets("typescript", { clg })
|
||||
ls.add_snippets("svelte", { clg })
|
||||
|
||||
require("luasnip.loaders.from_vscode").load()
|
||||
48
neovim/.config/nvim/after/plugin/telescope.lua
Normal file
48
neovim/.config/nvim/after/plugin/telescope.lua
Normal file
@@ -0,0 +1,48 @@
|
||||
local telescope = require("telescope")
|
||||
local actions = require("telescope.actions")
|
||||
local layout_actions = require("telescope.actions.layout")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
sorting_strategy = "ascending",
|
||||
file_ignore_patterns = { ".git/", "node_modules/" },
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-j>"] = actions.move_selection_worse,
|
||||
["<C-k>"] = actions.move_selection_better,
|
||||
["<C-d>"] = function(prompt_bufnr)
|
||||
actions.delete_buffer(prompt_bufnr)
|
||||
end,
|
||||
["<C-p>"] = layout_actions.toggle_preview,
|
||||
},
|
||||
n = {
|
||||
["<C-d>"] = function(prompt_bufnr)
|
||||
actions.delete_buffer(prompt_bufnr)
|
||||
end,
|
||||
["<C-p>"] = layout_actions.toggle_preview,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
lsp_references = {
|
||||
initial_mode = "normal",
|
||||
},
|
||||
lsp_definitions = {
|
||||
initial_mode = "normal",
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = "smart_case",
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
if vim.fn.has("win32") == 0 then
|
||||
require("telescope").load_extension("fzf")
|
||||
end
|
||||
|
||||
telescope.load_extension("possession")
|
||||
21
neovim/.config/nvim/after/plugin/theme.lua
Normal file
21
neovim/.config/nvim/after/plugin/theme.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
vim.g.edge_diagnostic_virtual_text = "colored"
|
||||
vim.g.edge_better_performance = 1
|
||||
vim.g.tokyonight_style = "night"
|
||||
|
||||
vim.api.nvim_set_hl(0, "SpellBad", {
|
||||
fg = "red",
|
||||
})
|
||||
|
||||
vim.api.nvim_set_hl(0, "IndentBlanklineChar", {
|
||||
fg = "#373737",
|
||||
bg = "none",
|
||||
})
|
||||
vim.api.nvim_set_hl(0, "IndentBlanklineContextChar", {
|
||||
fg = "#808080",
|
||||
bg = "none",
|
||||
})
|
||||
|
||||
vim.cmd([[
|
||||
colorscheme gruvbox-material
|
||||
hi clear SignColumn
|
||||
]])
|
||||
41
neovim/.config/nvim/after/plugin/treesitter.lua
Normal file
41
neovim/.config/nvim/after/plugin/treesitter.lua
Normal file
@@ -0,0 +1,41 @@
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"cmake",
|
||||
"comment",
|
||||
"cpp",
|
||||
"css",
|
||||
"dockerfile",
|
||||
"go",
|
||||
"gomod",
|
||||
"graphql",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"make",
|
||||
"markdown",
|
||||
"prisma",
|
||||
"python",
|
||||
"rust",
|
||||
"scss",
|
||||
"svelte",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
context_commentstring = {
|
||||
enable = true,
|
||||
},
|
||||
autotag = {
|
||||
enable = true,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user