diff options
Diffstat (limited to 'store/config/nvim/lua/setup/plugins')
-rw-r--r-- | store/config/nvim/lua/setup/plugins/cmp.lua | 30 | ||||
-rw-r--r-- | store/config/nvim/lua/setup/plugins/gitsigns.lua | 40 | ||||
-rw-r--r-- | store/config/nvim/lua/setup/plugins/init.lua | 24 | ||||
-rw-r--r-- | store/config/nvim/lua/setup/plugins/lint.lua | 94 | ||||
-rw-r--r-- | store/config/nvim/lua/setup/plugins/telescope.lua | 28 | ||||
-rw-r--r-- | store/config/nvim/lua/setup/plugins/tree-sitter.lua | 11 |
6 files changed, 227 insertions, 0 deletions
diff --git a/store/config/nvim/lua/setup/plugins/cmp.lua b/store/config/nvim/lua/setup/plugins/cmp.lua new file mode 100644 index 0000000..be9f8ea --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/cmp.lua @@ -0,0 +1,30 @@ +local function setup() + local cmp = require("cmp") + + cmp.setup { + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + ['<C-b>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-j>'] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), + ['<C-k>'] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + ['<C-e>'] = cmp.mapping.abort(), + ['<C-y>'] = cmp.mapping.confirm({ select = true }), + ['<CR>'] = cmp.mapping.confirm({ select = true }), + }), + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, + { name = 'path' }, + }, { + { name = 'buffer' }, + }) + } +end + +return { + setup = setup +} diff --git a/store/config/nvim/lua/setup/plugins/gitsigns.lua b/store/config/nvim/lua/setup/plugins/gitsigns.lua new file mode 100644 index 0000000..957c661 --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/gitsigns.lua @@ -0,0 +1,40 @@ +local function setup() + local gitsigns = require('gitsigns') + + gitsigns.setup { + on_attach = function(bufnr) + 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 + vim.cmd.normal({ ']c', bang = true }) + else + gitsigns.nav_hunk('next') + end + end) + + map('n', '[c', function() + if vim.wo.diff then + vim.cmd.normal({ '[c', bang = true }) + else + gitsigns.nav_hunk('prev') + end + end) + + -- Actions + map('n', '<leader>gc', gitsigns.preview_hunk) + map('n', '<leader>gt', gitsigns.toggle_deleted) + map('n', '<leader>gd', gitsigns.diffthis) + map('n', '<leader>gb', function() gitsigns.blame_line { full = true } end) + end + } +end + +return { + setup = setup +} diff --git a/store/config/nvim/lua/setup/plugins/init.lua b/store/config/nvim/lua/setup/plugins/init.lua new file mode 100644 index 0000000..8f1346b --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/init.lua @@ -0,0 +1,24 @@ +local function setup() + require('lualine').setup {} + require("neo-tree").setup { + filesystem = { + filtered_items = { + hide_dotfiles = false, + hide_gitignored = false, + hide_hidden = false, + } + } + } + + require("setup.plugins.telescope").setup() + require("setup.plugins.gitsigns").setup() + + require("setup.plugins.tree-sitter").setup() + require("setup.plugins.lint").setup() + require("setup.plugins.cmp").setup() + require("nvim-autopairs").setup {} +end + +return { + setup = setup +} diff --git a/store/config/nvim/lua/setup/plugins/lint.lua b/store/config/nvim/lua/setup/plugins/lint.lua new file mode 100644 index 0000000..d03f539 --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/lint.lua @@ -0,0 +1,94 @@ +--- spellchecker: ignore markdownlintrc + +---@alias CruLinter { name: string, config_patterns: string[], filetypes: string[] | nil, fast: boolean } + +local cspell = { + name = "cspell", + config_patterns = { + ".cspell.json", + "cspell.json", + ".cSpell.json", + "cSpell.json", + "cspell.config.js", + "cspell.config.cjs", + "cspell.config.json", + "cspell.config.yaml", + "cspell.config.yml", + "cspell.yaml", + "cspell.yml", + }, + fast = true, +} + +local markdownlint = { + name = "markdownlint", + config_patterns = { + ".markdownlint.jsonc", + ".markdownlint.json", + ".markdownlint.yaml", + ".markdownlint.yml", + ".markdownlintrc", + }, + filetypes = { "markdown" }, + fast = true, +} + +local linters = { cspell = cspell, markdownlint = markdownlint } + +---@param linter CruLinter +---@param buf integer +---@return string | nil +local function find_config(linter, buf) + local files = vim.fs.find(linter.config_patterns, { + path = vim.api.nvim_buf_get_name(buf), upward = true }) + if #files ~= 0 then + return files[1]; + end + return nil +end + +vim.list_extend(require("lint.linters.markdownlint").args, { + "--config", + function() + return find_config(markdownlint, 0); + end +}) + +---@param linter CruLinter +---@param buf integer +function vim.crupest.lint(linter, buf) + if linter.filetypes then + local filetype = vim.api.nvim_get_option_value("filetype", { buf = buf }) + if not vim.list_contains(linter.filetypes, filetype) then + return + end + end + + if find_config(linter, buf) then + require("lint").try_lint(linter.name) + end +end + +function vim.crupest.lint_all(buf, fast) + for _, linter in pairs(linters) do + if not fast or linter.fast then + vim.crupest.lint(linter, buf) + end + end +end + +local function setup() + vim.api.nvim_create_autocmd( + { "BufReadPost", "InsertLeave", "TextChanged" }, + { + callback = function(opt) + if vim.api.nvim_get_option_value("buftype", { buf = opt.buf }) == "" then + vim.crupest.lint_all(opt.buf, true) + end + end + }) +end + +return { + setup = setup, +} diff --git a/store/config/nvim/lua/setup/plugins/telescope.lua b/store/config/nvim/lua/setup/plugins/telescope.lua new file mode 100644 index 0000000..69a69c0 --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/telescope.lua @@ -0,0 +1,28 @@ +local function setup() + local builtin = require('telescope.builtin') + vim.keymap.set('n', '<leader>/', builtin.live_grep, {}) + vim.keymap.set('n', '<leader>fg', builtin.live_grep, {}) + vim.keymap.set('n', '<leader>ff', builtin.find_files, {}) + vim.keymap.set('n', '<leader>fb', builtin.buffers, {}) + vim.keymap.set('n', '<leader>fh', builtin.help_tags, {}) + vim.keymap.set('n', '<leader>fr', builtin.registers, {}) + vim.keymap.set('n', '<leader>fq', builtin.quickfixhistory, {}) + vim.keymap.set('n', '<leader>fm', builtin.marks, {}) + vim.keymap.set('n', '<leader>fd', builtin.diagnostics, {}) + vim.keymap.set('n', '<leader>fs', builtin.lsp_workspace_symbols, {}) + + local function all_files(opts) + opts = vim.tbl_extend('force', { + hidden = true, + no_ignore = true, + no_ignore_parent = true, + }, opts or {}) + builtin.find_files(opts) + end + + vim.keymap.set('n', '<leader>fa', all_files, {}) +end + +return { + setup = setup +} diff --git a/store/config/nvim/lua/setup/plugins/tree-sitter.lua b/store/config/nvim/lua/setup/plugins/tree-sitter.lua new file mode 100644 index 0000000..043f425 --- /dev/null +++ b/store/config/nvim/lua/setup/plugins/tree-sitter.lua @@ -0,0 +1,11 @@ +local function setup() + require'nvim-treesitter.configs'.setup { + highlight = { enable = true }, + incremental_selection = { enable = true }, + textobjects = { enable = true }, + } +end + +return { + setup = setup +} |