rationalise plugin structure

This commit is contained in:
Andrzej Stepien 2024-03-12 16:13:19 +01:00
parent f84576f525
commit a2ee74b73a
17 changed files with 342 additions and 0 deletions

View File

@ -0,0 +1,8 @@
return {
"akinsho/bufferline.nvim",
version = "*",
dependencies = "nvim-tree/nvim-web-devicons",
config = function()
require("bufferline").setup({})
end,
}

6
lua/plugins/comment.lua Normal file
View File

@ -0,0 +1,6 @@
return {'numToStr/Comment.nvim',
opts = {
-- add any options here
},
lazy = false,
}

106
lua/plugins/completion.lua Normal file
View File

@ -0,0 +1,106 @@
return {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
{
"L3MON4D3/LuaSnip",
-- follow latest release.
version = "v2.*", -- Replace <CurrentMajor> by the latest released major (first number of latest release)
-- install jsregexp (optional!).
build = "make install_jsregexp",
dependencies = { "rafamadriz/friendly-snippets" },
},
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
{
"hrsh7th/nvim-cmp",
config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect" }
local cmp = require("cmp")
local luasnip = require("luasnip")
local select_opts = { behavior = cmp.SelectBehavior.Select }
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
sources = {
{ name = "path" },
{ name = "nvim_lsp", keyword_length = 1 },
{ name = "buffer", keyword_length = 3 },
{ name = "luasnip", keyword_length = 2 },
},
window = {
documentation = cmp.config.window.bordered(),
},
formatting = {
fields = { "menu", "abbr", "kind" },
format = function(entry, item)
local menu_icon = {
nvim_lsp = "λ",
luasnip = "",
buffer = "Ω",
path = "🖫",
}
item.menu = menu_icon[entry.source.name]
return item
end,
},
mapping = {
["<Up>"] = cmp.mapping.select_prev_item(select_opts),
["<Down>"] = cmp.mapping.select_next_item(select_opts),
["<C-p>"] = cmp.mapping.select_prev_item(select_opts),
["<C-n>"] = cmp.mapping.select_next_item(select_opts),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping.confirm({ select = true }),
["<CR>"] = cmp.mapping.confirm({ select = false }),
["<C-f>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<C-b>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<Tab>"] = cmp.mapping(function(fallback)
local col = vim.fn.col(".") - 1
if cmp.visible() then
cmp.select_next_item(select_opts)
elseif col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then
fallback()
else
cmp.complete()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item(select_opts)
else
fallback()
end
end, { "i", "s" }),
},
})
end,
},
}

View File

@ -0,0 +1,38 @@
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conform = require("conform")
conform.setup({
formatters_by_ft = {
javascript = { "prettier" },
typescript = { "prettier" },
javascriptreact = { "prettier" },
typescriptreact = { "prettier" },
svelte = { "prettier" },
css = { "prettier" },
html = { "prettier" },
json = { "prettier" },
yaml = { "prettier" },
markdown = { "prettier" },
graphql = { "prettier" },
lua = { "stylua" },
python = { "isort", "black" },
},
format_on_save = {
lsp_fallback = true,
async = false,
timeout_ms = 500,
},
})
vim.keymap.set({ "n", "v" }, "<leader>mp", function()
conform.format({
lsp_fallback = true,
async = false,
timeout_ms = 500,
})
end, { desc = "Format file or range (in visual mode)" })
end,
}

16
lua/plugins/lazygit.lua Normal file
View File

@ -0,0 +1,16 @@
return {
{
"kdheepak/lazygit.nvim",
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
},
}

43
lua/plugins/linting.lua Normal file
View File

@ -0,0 +1,43 @@
return {
{
"mfussenegger/nvim-lint",
event = {
"BufReadPre",
"BufNewFile",
},
config = function()
local lint = require("lint")
lint.linters_by_ft = {
javascript = { "eslint_d" },
typescript = { "eslint_d" },
javascriptreact = { "eslint_d" },
typescriptreact = { "eslint_d" },
svelte = { "eslint_d" },
python = { "pylint" },
markdown = { "proselint" },
}
local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true })
vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, {
group = lint_augroup,
callback = function()
lint.try_lint()
end,
})
vim.keymap.set("n", "<leader>l", function()
lint.try_lint()
end, { desc = "Trigger linting for current file" })
end,
},
{
"WhoIsSethDaniel/toggle-lsp-diagnostics.nvim",
config = function()
require("toggle_lsp_diagnostics").init({
start_on = false,
})
end,
},
}

View File

@ -0,0 +1,35 @@
return {"neovim/nvim-lspconfig",
config = function()
local lsp_capabilities = require("cmp_nvim_lsp").default_capabilities()
local lspconfig = require('lspconfig')
lspconfig.lua_ls.setup {
capabilities = lsp_capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
},
},
}
-- lspconfig.ltex.setup {
-- capabilities = lsp_capabilities,
-- }
-- lspconfig.grammarly.setup {
-- capabilities = lsp_capabilities,
-- filetypes = { "markdown", "tex", "text", },
-- init_options = {
-- clientId = "client_"
-- },
-- root_dir = function(fname)
-- return require'lspconfig'.util.find_git_ancestor(fname) or vim.loop.os_homedir()
-- end,
-- }
-- lspconfig.marksman.setup {
-- capabilities = lsp_capabilities,
-- }
end
}

41
lua/plugins/lsp/mason.lua Normal file
View File

@ -0,0 +1,41 @@
return {
{
"williamboman/mason.nvim",
dependencies = { "WhoIsSethDaniel/mason-tool-installer.nvim" },
config = function()
-- import mason
local mason = require("mason")
local mason_tool_installer = require("mason-tool-installer")
-- enable mason and configure icons
mason.setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
mason_tool_installer.setup({
ensure_installed = {
"prettier", -- prettier formatter
"stylua", -- lua formatter
"isort", -- python formatter
"black", -- python formatter
"pylint", -- python linter
"eslint_d", -- js linter
},
})
end,
},
-- {"williamboman/mason-lspconfig.nvim",
-- config = function()
-- local mason_lspconfig = require("mason-lspconfig")
-- mason_lspconfig.setup {
-- ensure_installed = { "grammarly", "ltex" },
-- }
-- end
-- }
}

16
lua/plugins/lualine.lua Normal file
View File

@ -0,0 +1,16 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
config = function()
local function getWords()
return tostring(vim.fn.wordcount().words)
end
require("lualine").setup({
sections = {
lualine_z = { getWords },
},
})
end,
}

9
lua/plugins/neotree.lua Normal file
View File

@ -0,0 +1,9 @@
return {"nvim-neo-tree/neo-tree.nvim",
branch = "v3.x",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
"MunifTanjim/nui.nvim",
-- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information
}
}

View File

@ -0,0 +1 @@
return { "ellisonleao/gruvbox.nvim", priority = 1000 , config = true, opts = ...}

View File

@ -0,0 +1,2 @@
return {"rose-pine/neovim", name = "rose-pine"}

View File

@ -0,0 +1,3 @@
return {
"nvim-treesitter/nvim-treesitter"
}

1
lua/plugins/twilight.lua Normal file
View File

@ -0,0 +1 @@
return {"folke/twilight.nvim", opts = {context = 1}}

View File

@ -0,0 +1 @@
return {"preservim/vim-pencil"}

12
lua/plugins/which-key.lua Normal file
View File

@ -0,0 +1,12 @@
return {"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 300
end,
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}

4
lua/plugins/zen-mode.lua Normal file
View File

@ -0,0 +1,4 @@
return {"folke/zen-mode.nvim",
opts = {
window = {width = 60}}
}