mirror of
https://github.com/arkorty/Neolite.git
synced 2026-03-18 00:57:12 +00:00
Refactor plugin configs for safe import
This commit is contained in:
@@ -42,7 +42,7 @@ if colorscheme == "onedark" then
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Load One Dark
|
-- Load One Dark
|
||||||
require("onedark").load()
|
onedark.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
if colorscheme == "catppuccin" then
|
if colorscheme == "catppuccin" then
|
||||||
@@ -96,7 +96,7 @@ if colorscheme == "catppuccin" then
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Load Catppuccin
|
-- Load Catppuccin
|
||||||
require("catppuccin").load()
|
catppuccin.load()
|
||||||
end
|
end
|
||||||
|
|
||||||
if colorscheme == "gruvbox" then
|
if colorscheme == "gruvbox" then
|
||||||
@@ -126,5 +126,5 @@ if colorscheme == "gruvbox" then
|
|||||||
})
|
})
|
||||||
|
|
||||||
-- Load Gruvbox
|
-- Load Gruvbox
|
||||||
require("gruvbox").load()
|
gruvbox.load()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,82 +1,86 @@
|
|||||||
local ok, cmp = pcall(require, "cmp")
|
local ok, cmp = pcall(require, "cmp")
|
||||||
if not ok then
|
if not ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local luasnip_ok, luasnip = pcall(require, "luasnip")
|
local luasnip_ok, luasnip = pcall(require, "luasnip")
|
||||||
if not luasnip_ok then
|
if not luasnip_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode")
|
local luasnip_vscode_ok, luasnip_vscode = pcall(require, "luasnip/loaders/from_vscode")
|
||||||
if not luasnip_vscode_ok then
|
if not luasnip_vscode_ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
unpack = unpack or table.unpack
|
unpack = unpack or table.unpack
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
luasnip_vscode.lazy_load()
|
luasnip_vscode.lazy_load()
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
view = {
|
view = {
|
||||||
--entries = { name = "custom", selection_order = "near_cursor" },
|
--entries = { name = "custom", selection_order = "near_cursor" },
|
||||||
},
|
},
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
luasnip.lsp_expand(args.body) -- For `luasnip` users.
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||||
-- they way you will only jump inside the snippet region
|
-- they way you will only jump inside the snippet region
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
luasnip.expand_or_jump()
|
luasnip.expand_or_jump()
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
cmp.complete()
|
cmp.complete()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif luasnip.jumpable(-1) then
|
elseif luasnip.jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end, { "i", "s" }),
|
end, { "i", "s" }),
|
||||||
},
|
},
|
||||||
formatting = {
|
sources = {
|
||||||
fields = { "kind", "abbr", "menu" },
|
{ name = "nvim_lsp" },
|
||||||
format = function(entry, vim_item)
|
{ name = "luasnip" },
|
||||||
local kind = require("lspkind").cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
{ name = "buffer" },
|
||||||
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
{ name = "path" },
|
||||||
kind.kind = " " .. (strings[1] or "") .. " "
|
},
|
||||||
kind.menu = " (" .. (strings[2] or "") .. ")"
|
confirm_opts = {
|
||||||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||||||
|
select = false,
|
||||||
|
},
|
||||||
|
experimental = {
|
||||||
|
ghost_text = false,
|
||||||
|
},
|
||||||
|
formatting = {
|
||||||
|
fields = { "kind", "abbr", "menu" },
|
||||||
|
format = function(entry, vim_item)
|
||||||
|
local lk_ok, lspkind = pcall(require, "lspkind")
|
||||||
|
if not lk_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
local kind = lspkind.cmp_format({ mode = "symbol_text", maxwidth = 50 })(entry, vim_item)
|
||||||
|
local strings = vim.split(kind.kind, "%s", { trimempty = true })
|
||||||
|
kind.kind = " " .. (strings[1] or "") .. " "
|
||||||
|
kind.menu = " (" .. (strings[2] or "") .. ")"
|
||||||
|
|
||||||
return kind
|
return kind
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
sources = {
|
|
||||||
{ name = "nvim_lsp" },
|
|
||||||
{ name = "luasnip" },
|
|
||||||
{ name = "buffer" },
|
|
||||||
{ name = "path" },
|
|
||||||
},
|
|
||||||
confirm_opts = {
|
|
||||||
behavior = cmp.ConfirmBehavior.Replace,
|
|
||||||
select = false,
|
|
||||||
},
|
|
||||||
experimental = {
|
|
||||||
ghost_text = false,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
-- disable netrw
|
-- disable netrw
|
||||||
vim.g.loaded_netrw = 1
|
vim.g.loaded_netrw = 1
|
||||||
vim.g.loaded_netrwPlugin = 1
|
vim.g.loaded_netrwPlugin = 1
|
||||||
|
|
||||||
-- set termguicolors to enable highlight groups
|
-- set termguicolors to enable highlight groups
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ mason_lspconfig.setup({
|
|||||||
ensure_installed = { "lua_ls", "rust_analyzer", "clangd" },
|
ensure_installed = { "lua_ls", "rust_analyzer", "clangd" },
|
||||||
})
|
})
|
||||||
|
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
local cnl_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
|
||||||
|
if not cnl_ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers({
|
mason_lspconfig.setup_handlers({
|
||||||
function(server)
|
function(server)
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
local ok, null_ls = pcall(require, "null-ls")
|
local ok, null_ls = pcall(require, "null-ls")
|
||||||
if not ok then
|
if not ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local formatting = null_ls.builtins.formatting
|
local formatting = null_ls.builtins.formatting
|
||||||
|
|
||||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||||
null_ls.setup({
|
null_ls.setup({
|
||||||
sources = {
|
sources = {
|
||||||
formatting.rustfmt,
|
formatting.rustfmt,
|
||||||
formatting.stylua,
|
formatting.stylua,
|
||||||
formatting.black,
|
formatting.black,
|
||||||
formatting.prettier,
|
formatting.prettier,
|
||||||
}, -- you can reuse a shared lspconfig on_attach callback here
|
}, -- you can reuse a shared lspconfig on_attach callback here
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
group = augroup,
|
group = augroup,
|
||||||
buffer = bufnr,
|
buffer = bufnr,
|
||||||
callback = function()
|
callback = function()
|
||||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||||
vim.lsp.buf.format({ bufnr = bufnr })
|
vim.lsp.buf.format({ bufnr = bufnr })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -68,8 +68,11 @@ packer.startup(function(use)
|
|||||||
use({
|
use({
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
run = function()
|
run = function()
|
||||||
local ts_update = require("nvim-treesitter.install").update({ with_sync = true })
|
local ntsi_ok, nvim_treesitter_install = pcall(require, "nvim-treesitter.install")
|
||||||
ts_update()
|
if ntsi_ok then
|
||||||
|
local ts_update = nvim_treesitter_install.install.update({ with_sync = true })
|
||||||
|
ts_update()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,45 +1,45 @@
|
|||||||
local ok, lualine = pcall(require, "lualine")
|
local ok, lualine = pcall(require, "lualine")
|
||||||
if not ok then
|
if not ok then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
lualine.setup({
|
lualine.setup({
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
component_separators = { left = "", right = "" },
|
component_separators = { left = "", right = "" },
|
||||||
section_separators = { left = "", right = "" },
|
section_separators = { left = "", right = "" },
|
||||||
disabled_filetypes = {
|
disabled_filetypes = {
|
||||||
statusline = {},
|
statusline = {},
|
||||||
winbar = {},
|
winbar = {},
|
||||||
},
|
},
|
||||||
ignore_focus = {},
|
ignore_focus = {},
|
||||||
always_divide_middle = true,
|
always_divide_middle = true,
|
||||||
globalstatus = false,
|
globalstatus = false,
|
||||||
refresh = {
|
refresh = {
|
||||||
statusline = 1000,
|
statusline = 1000,
|
||||||
tabline = 1000,
|
tabline = 1000,
|
||||||
winbar = 1000,
|
winbar = 1000,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
sections = {
|
sections = {
|
||||||
lualine_a = { "mode" },
|
lualine_a = { "mode" },
|
||||||
lualine_b = { "branch", "diff", "diagnostics" },
|
lualine_b = { "branch", "diff", "diagnostics" },
|
||||||
lualine_c = { "filename" },
|
lualine_c = { "filename" },
|
||||||
lualine_x = { "encoding", "fileformat", "filetype" },
|
lualine_x = { "encoding", "fileformat", "filetype" },
|
||||||
lualine_y = { "progress" },
|
lualine_y = { "progress" },
|
||||||
lualine_z = { "location" },
|
lualine_z = { "location" },
|
||||||
},
|
},
|
||||||
inactive_sections = {
|
inactive_sections = {
|
||||||
lualine_a = {},
|
lualine_a = {},
|
||||||
lualine_b = {},
|
lualine_b = {},
|
||||||
lualine_c = { "filename" },
|
lualine_c = { "filename" },
|
||||||
lualine_x = { "location" },
|
lualine_x = { "location" },
|
||||||
lualine_y = {},
|
lualine_y = {},
|
||||||
lualine_z = {},
|
lualine_z = {},
|
||||||
},
|
},
|
||||||
tabline = {},
|
tabline = {},
|
||||||
winbar = {},
|
winbar = {},
|
||||||
inactive_winbar = {},
|
inactive_winbar = {},
|
||||||
extensions = {},
|
extensions = {},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user