feat manage script
This commit is contained in:
40
config/linux-dev/nvim/lua/plugins/autoformat.lua
Normal file
40
config/linux-dev/nvim/lua/plugins/autoformat.lua
Normal file
@@ -0,0 +1,40 @@
|
||||
return { -- Autoformat
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
keys = {
|
||||
{
|
||||
"<leader>f",
|
||||
function()
|
||||
require("conform").format({ async = true, lsp_format = "fallback" })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "[F]ormat buffer",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
notify_on_error = false,
|
||||
format_on_save = function(bufnr)
|
||||
local disable_filetypes = { c = true, cpp = true }
|
||||
local lsp_format_opt
|
||||
if disable_filetypes[vim.bo[bufnr].filetype] then
|
||||
lsp_format_opt = "never"
|
||||
else
|
||||
lsp_format_opt = "fallback"
|
||||
end
|
||||
return {
|
||||
timeout_ms = 500,
|
||||
lsp_format = lsp_format_opt,
|
||||
}
|
||||
end,
|
||||
formatters_by_ft = {
|
||||
lua = { "stylua" },
|
||||
swift = { "swift_format" },
|
||||
python = { "isort", "black", stop_after_first = true },
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
},
|
||||
},
|
||||
}
|
||||
13
config/linux-dev/nvim/lua/plugins/autopairs.lua
Normal file
13
config/linux-dev/nvim/lua/plugins/autopairs.lua
Normal file
@@ -0,0 +1,13 @@
|
||||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
event = 'InsertEnter',
|
||||
-- Optional dependency
|
||||
dependencies = { 'hrsh7th/nvim-cmp' },
|
||||
config = function()
|
||||
require('nvim-autopairs').setup {}
|
||||
-- If you want to automatically add `(` after selecting a function or method
|
||||
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
|
||||
local cmp = require 'cmp'
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
end,
|
||||
}
|
||||
11
config/linux-dev/nvim/lua/plugins/autotag.lua
Normal file
11
config/linux-dev/nvim/lua/plugins/autotag.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
"windwp/nvim-ts-autotag",
|
||||
config = {
|
||||
autotag = {
|
||||
enable = true,
|
||||
enable_close = true,
|
||||
enable_rename = true,
|
||||
enable_close_on_slash = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
11
config/linux-dev/nvim/lua/plugins/colorscheme.lua
Normal file
11
config/linux-dev/nvim/lua/plugins/colorscheme.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
"rose-pine/neovim",
|
||||
name = "rose-pine",
|
||||
config = function()
|
||||
require("rose-pine").setup({
|
||||
disable_background = true,
|
||||
disable_float_background = true,
|
||||
})
|
||||
vim.cmd("colorscheme rose-pine")
|
||||
end,
|
||||
}
|
||||
60
config/linux-dev/nvim/lua/plugins/completion.lua
Normal file
60
config/linux-dev/nvim/lua/plugins/completion.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
return {
|
||||
"hrsh7th/nvim-cmp",
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
config = function()
|
||||
local cmp = require("cmp")
|
||||
cmp.setup({
|
||||
window = {
|
||||
completion = {
|
||||
border = "single",
|
||||
-- or border = true for default border
|
||||
},
|
||||
documentation = {
|
||||
border = "single",
|
||||
},
|
||||
},
|
||||
completion = { completeopt = "menu,menuone,noselect" }, -- This ensures nothing is auto-selected
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" }, -- from language server
|
||||
{ name = "buffer" }, -- from current buffer
|
||||
{ name = "path" }, -- for file paths
|
||||
}),
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<C-e>"] = cmp.mapping.abort(), -- This closes the completion menu
|
||||
|
||||
["<C-u>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() and cmp.get_selected_entry() then
|
||||
cmp.scroll_docs(-4)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<C-d>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() and cmp.get_selected_entry() then
|
||||
cmp.scroll_docs(4)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
}),
|
||||
})
|
||||
end,
|
||||
}
|
||||
42
config/linux-dev/nvim/lua/plugins/harpoon2.lua
Normal file
42
config/linux-dev/nvim/lua/plugins/harpoon2.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
return {
|
||||
"ThePrimeagen/harpoon",
|
||||
branch = "harpoon2",
|
||||
opts = {
|
||||
menu = {
|
||||
width = vim.api.nvim_win_get_width(0) - 4,
|
||||
},
|
||||
settings = {
|
||||
save_on_toggle = true,
|
||||
},
|
||||
},
|
||||
keys = function()
|
||||
local keys = {
|
||||
{
|
||||
"<leader>H",
|
||||
function()
|
||||
require("harpoon"):list():add()
|
||||
end,
|
||||
desc = "Harpoon File",
|
||||
},
|
||||
{
|
||||
"<leader>h",
|
||||
function()
|
||||
local harpoon = require("harpoon")
|
||||
harpoon.ui:toggle_quick_menu(harpoon:list())
|
||||
end,
|
||||
desc = "Harpoon Quick Menu",
|
||||
},
|
||||
}
|
||||
|
||||
for i = 1, 5 do
|
||||
table.insert(keys, {
|
||||
"<C-" .. i .. ">",
|
||||
function()
|
||||
require("harpoon"):list():select(i)
|
||||
end,
|
||||
desc = "Harpoon to File " .. i,
|
||||
})
|
||||
end
|
||||
return keys
|
||||
end,
|
||||
}
|
||||
9
config/linux-dev/nvim/lua/plugins/indent_line.lua
Normal file
9
config/linux-dev/nvim/lua/plugins/indent_line.lua
Normal file
@@ -0,0 +1,9 @@
|
||||
return {
|
||||
{ -- Add indentation guides even on blank lines
|
||||
'lukas-reineke/indent-blankline.nvim',
|
||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||
-- See `:help ibl`
|
||||
main = 'ibl',
|
||||
opts = {},
|
||||
},
|
||||
}
|
||||
98
config/linux-dev/nvim/lua/plugins/lsp.lua
Normal file
98
config/linux-dev/nvim/lua/plugins/lsp.lua
Normal file
@@ -0,0 +1,98 @@
|
||||
local remap = require("utils.remap")
|
||||
|
||||
vim.diagnostic.config({
|
||||
update_in_insert = false,
|
||||
virtual_text = {
|
||||
source = true,
|
||||
},
|
||||
float = {
|
||||
border = "rounded",
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = "rounded",
|
||||
})
|
||||
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
|
||||
border = "rounded",
|
||||
})
|
||||
|
||||
return {
|
||||
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
{ "williamboman/mason.nvim", config = true },
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
{ "j-hui/fidget.nvim", opts = {} }, -- side fidget showing status
|
||||
"hrsh7th/cmp-nvim-lsp", -- completion
|
||||
"b0o/schemastore.nvim",
|
||||
},
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
require("mason-lspconfig").setup()
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
||||
|
||||
require("lspconfig.ui.windows").default_options = {
|
||||
border = "rounded",
|
||||
}
|
||||
|
||||
lspconfig.ts_ls.setup({
|
||||
capabilities = capabilities,
|
||||
init_options = {
|
||||
preferences = {
|
||||
includeCompletionsWithSnippetText = true,
|
||||
jsxAttributeCompletionStyle = "auto",
|
||||
},
|
||||
},
|
||||
on_attach = function(client, bufnr)
|
||||
-- Mappings
|
||||
local opts = { buffer = bufnr }
|
||||
remap.nmap("gd", vim.lsp.buf.definition, opts)
|
||||
remap.nmap("gr", vim.lsp.buf.references, opts)
|
||||
|
||||
remap.nmap("K", vim.lsp.buf.hover, opts)
|
||||
|
||||
remap.nmap("<leader>rn", vim.lsp.buf.rename, opts)
|
||||
remap.nmap("<leader>ca", vim.lsp.buf.code_action, opts)
|
||||
remap.nmap("<leader>ri", function()
|
||||
local diagnostics = vim.diagnostic.get(0)
|
||||
|
||||
-- Filter for TypeScript's unused import diagnostics (code 6133)
|
||||
local unused_imports_diagnostics = {}
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
if diagnostic.code == 6133 and diagnostic.source == "typescript" then
|
||||
table.insert(unused_imports_diagnostics, diagnostic)
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.buf.code_action({
|
||||
context = {
|
||||
diagnostics = unused_imports_diagnostics,
|
||||
only = { "source.removeUnusedImports" },
|
||||
},
|
||||
})
|
||||
end, { desc = "Remove unused imports" })
|
||||
|
||||
remap.nmap("[d", vim.diagnostic.goto_prev, opts)
|
||||
remap.nmap("]d", vim.diagnostic.goto_next, opts)
|
||||
remap.nmap("<leader>d", vim.diagnostic.open_float, opts)
|
||||
end,
|
||||
})
|
||||
|
||||
lspconfig.eslint.setup({})
|
||||
lspconfig.html.setup({})
|
||||
lspconfig.cssls.setup({})
|
||||
lspconfig.jsonls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
json = {
|
||||
schemas = require("schemastore").json.schemas(),
|
||||
validate = { enable = true },
|
||||
allowComments = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
}
|
||||
33
config/linux-dev/nvim/lua/plugins/neo-tree.lua
Normal file
33
config/linux-dev/nvim/lua/plugins/neo-tree.lua
Normal file
@@ -0,0 +1,33 @@
|
||||
return {
|
||||
"nvim-neo-tree/neo-tree.nvim",
|
||||
version = "*",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"nvim-tree/nvim-web-devicons",
|
||||
"MunifTanjim/nui.nvim",
|
||||
},
|
||||
cmd = "Neotree",
|
||||
keys = {
|
||||
{ "<Leader>et", ":Neotree position=left toggle<CR>", desc = "Explorer Toggle", silent = true },
|
||||
{ "<Leader>E", ":Neotree focus<CR>", desc = "Explorer Focus", silent = true },
|
||||
{ "<Leader>ef", ":Neotree float<CR>", desc = "Explorer Float", silent = true },
|
||||
{ "<Leader>eb", ":Neotree buffers<CR>", desc = "Explorer Buffers", silent = true },
|
||||
{ "<Leader>eg", ":Neotree git_status<CR>", desc = "Explorer Git", silent = true },
|
||||
},
|
||||
opts = {
|
||||
filesystem = {
|
||||
follow_current_file = {
|
||||
enabled = true, -- Enable this feature
|
||||
leave_dirs_open = true, -- Leave directories open when following
|
||||
},
|
||||
filtered_items = {
|
||||
visible = true,
|
||||
},
|
||||
window = {
|
||||
mappings = {
|
||||
["<Leader>e"] = "close_window",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
91
config/linux-dev/nvim/lua/plugins/telescope.lua
Normal file
91
config/linux-dev/nvim/lua/plugins/telescope.lua
Normal file
@@ -0,0 +1,91 @@
|
||||
local remap = require("utils.remap")
|
||||
|
||||
return { -- Fuzzy Finder (files, lsp, etc)
|
||||
"nvim-telescope/telescope.nvim",
|
||||
event = "VimEnter",
|
||||
branch = "0.1.x",
|
||||
dependencies = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
{ -- If encountering errors, see telescope-fzf-native README for installation instructions
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
|
||||
-- `build` is used to run some command when the plugin is installed/updated.
|
||||
-- This is only run then, not every time Neovim starts up.
|
||||
build = "make",
|
||||
|
||||
-- `cond` is a condition used to determine whether this plugin should be
|
||||
-- installed and loaded.
|
||||
cond = function()
|
||||
return vim.fn.executable("make") == 1
|
||||
end,
|
||||
},
|
||||
{ "nvim-telescope/telescope-ui-select.nvim" },
|
||||
|
||||
-- Useful for getting pretty icons, but requires a Nerd Font.
|
||||
{ "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font },
|
||||
},
|
||||
config = function()
|
||||
-- Telescope is a fuzzy finder that comes with a lot of different things that
|
||||
-- it can fuzzy find! It's more than just a "file finder", it can search
|
||||
-- many different aspects of Neovim, your workspace, LSP, and more!
|
||||
--
|
||||
-- The easiest way to use Telescope, is to start by doing something like:
|
||||
-- :Telescope help_tags
|
||||
--
|
||||
-- After running this command, a window will open up and you're able to
|
||||
-- type in the prompt window. You'll see a list of `help_tags` options and
|
||||
-- a corresponding preview of the help.
|
||||
--
|
||||
-- Two important keymaps to use while in Telescope are:
|
||||
-- - Insert mode: <c-/>
|
||||
-- - Normal mode: ?
|
||||
--
|
||||
-- This opens a window that shows you all of the keymaps for the current
|
||||
-- Telescope picker. This is really useful to discover what Telescope can
|
||||
-- do as well as how to actually do it!
|
||||
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
require("telescope").setup({
|
||||
-- You can put your default mappings / updates / etc. in here
|
||||
-- All the info you're looking for is in `:help telescope.setup()`
|
||||
--
|
||||
-- defaults = {
|
||||
-- mappings = {
|
||||
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
|
||||
-- },
|
||||
-- },
|
||||
-- pickers = {}
|
||||
defaults = {
|
||||
layout_strategy = "vertical",
|
||||
layout_config = {
|
||||
-- vertical = { width = 0.5 }
|
||||
-- horizontal = {
|
||||
-- width = 0.9,
|
||||
-- preview_width = 0.5,
|
||||
-- },
|
||||
},
|
||||
mappings = {
|
||||
n = {
|
||||
["d"] = "delete_buffer",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Enable Telescope extensions if they are installed
|
||||
pcall(require("telescope").load_extension, "fzf")
|
||||
pcall(require("telescope").load_extension, "ui-select")
|
||||
|
||||
local builtin = require("telescope.builtin")
|
||||
remap.nmap("<leader>sk", builtin.keymaps, { desc = "[S]earch [K]eymaps" })
|
||||
remap.nmap("<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
|
||||
remap.nmap("<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
|
||||
remap.nmap("<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
|
||||
remap.nmap("<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
|
||||
remap.nmap("<leader>sr", builtin.lsp_references, { desc = "[S]earch [R]references" })
|
||||
remap.nmap("<leader>s.", builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
remap.nmap("<leader>ss", builtin.git_status, { desc = "[S]earch Git [S]tatus" })
|
||||
remap.nmap("<leader><leader>", builtin.buffers, { desc = "Find existing [B]uffers" })
|
||||
end,
|
||||
}
|
||||
21
config/linux-dev/nvim/lua/plugins/treesitter.lua
Normal file
21
config/linux-dev/nvim/lua/plugins/treesitter.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
build = 'TSUpdate',
|
||||
main = 'nvim-treesitter.configs',
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
'diff',
|
||||
'lua',
|
||||
'html',
|
||||
'css',
|
||||
'javascript',
|
||||
'typescript'
|
||||
},
|
||||
auto_install = true,
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
indent = { enable = true }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user