aboutsummaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/plugins
diff options
context:
space:
mode:
authordavidpkj <davidpenkow1@gmail.com>2022-12-03 22:26:26 +0100
committerdavidpkj <davidpenkow1@gmail.com>2022-12-03 22:26:26 +0100
commit5d4a749b7c51649bcd3953cd1686856408d08121 (patch)
treed0ddab7d5ee206e9b4403d4f177d942ec1608aa0 /neovim/.config/nvim/lua/plugins
parent4f7ccffecdfa36c5e531654b8eec44199935d497 (diff)
Merge in dotfiles
Diffstat (limited to 'neovim/.config/nvim/lua/plugins')
-rw-r--r--neovim/.config/nvim/lua/plugins/catppuccin.lua22
-rw-r--r--neovim/.config/nvim/lua/plugins/cmp.lua29
-rw-r--r--neovim/.config/nvim/lua/plugins/fidget.lua9
-rw-r--r--neovim/.config/nvim/lua/plugins/github-theme.lua4
-rw-r--r--neovim/.config/nvim/lua/plugins/gitsigns.lua27
-rw-r--r--neovim/.config/nvim/lua/plugins/lsp.lua79
-rw-r--r--neovim/.config/nvim/lua/plugins/lualine.lua34
-rw-r--r--neovim/.config/nvim/lua/plugins/mason.lua10
-rw-r--r--neovim/.config/nvim/lua/plugins/pairs.lua2
-rw-r--r--neovim/.config/nvim/lua/plugins/rust-tools.lua24
-rw-r--r--neovim/.config/nvim/lua/plugins/telescope.lua64
-rw-r--r--neovim/.config/nvim/lua/plugins/treesitter.lua126
12 files changed, 430 insertions, 0 deletions
diff --git a/neovim/.config/nvim/lua/plugins/catppuccin.lua b/neovim/.config/nvim/lua/plugins/catppuccin.lua
new file mode 100644
index 0000000..e1780e3
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/catppuccin.lua
@@ -0,0 +1,22 @@
+vim.g.catppuccin_flavour = "macchiato" -- latte, frappe, macchiato, mocha
+local colors = require("catppuccin.palettes").get_palette() -- return vim.g.catppuccin_flavour palette
+
+require("catppuccin").setup({
+ transparent_background = true,
+ styles = {
+ comments = {},
+ conditionals = {},
+ },
+ integration = {
+ telescope = true,
+ },
+ highlight_overrides = {
+ all = {
+ CursorLine = { bg = colors.base },
+ CursorLineNr = { bg = colors.base },
+ },
+ },
+})
+
+vim.cmd([[ colorscheme catppuccin ]])
+
diff --git a/neovim/.config/nvim/lua/plugins/cmp.lua b/neovim/.config/nvim/lua/plugins/cmp.lua
new file mode 100644
index 0000000..18d8fe6
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/cmp.lua
@@ -0,0 +1,29 @@
+-- https://github.com/hrsh7th/nvim-cmp#basic-configuration
+local cmp = require('cmp')
+
+cmp.setup({
+ snippet = {
+ expand = function(args)
+ vim.fn["vsnip#anonymous"](args.body)
+ end,
+ },
+ mapping = {
+ ['<S-Tab>'] = cmp.mapping.select_prev_item(),
+ ['<Tab>'] = cmp.mapping.select_next_item(),
+ ['<C-k>'] = cmp.mapping.scroll_docs(-4),
+ ['<C-j>'] = cmp.mapping.scroll_docs(4),
+ ['<C-Space>'] = cmp.mapping.complete(),
+ ['<C-e>'] = cmp.mapping.close(),
+ ['<Return>'] = cmp.mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Insert,
+ select = false,
+ })
+ },
+ sources = {
+ { name = 'nvim_lsp' },
+ { name = 'vsnip' },
+ { name = 'path' },
+ { name = 'buffer' },
+ },
+})
+
diff --git a/neovim/.config/nvim/lua/plugins/fidget.lua b/neovim/.config/nvim/lua/plugins/fidget.lua
new file mode 100644
index 0000000..f6564d5
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/fidget.lua
@@ -0,0 +1,9 @@
+require("fidget").setup({
+ text = {
+ spinner = "dots", -- animation shown when tasks are ongoing
+ done = "✓", -- character shown when all tasks are complete
+ },
+ window = {
+ blend = 0, -- &winblend for the window
+ },
+})
diff --git a/neovim/.config/nvim/lua/plugins/github-theme.lua b/neovim/.config/nvim/lua/plugins/github-theme.lua
new file mode 100644
index 0000000..b000fbb
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/github-theme.lua
@@ -0,0 +1,4 @@
+require('github-theme').setup({
+ transparent = true,
+ theme_style = "dark_default",
+})
diff --git a/neovim/.config/nvim/lua/plugins/gitsigns.lua b/neovim/.config/nvim/lua/plugins/gitsigns.lua
new file mode 100644
index 0000000..61f6238
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/gitsigns.lua
@@ -0,0 +1,27 @@
+local map = vim.keymap.set
+
+require("gitsigns").setup({
+ signs = {
+ add = { text = "+" },
+ delete = { text = "-" },
+ change = { text = "~" },
+ changedelete = { text = "⋍" },
+ },
+ on_attach = function(buf)
+ local gs = package.loaded.gitsigns
+ local opts = { buffer = buf, expr = true, replace_keycodes = false }
+
+ -- Navigation
+ map("n", "]c", "&diff ? ']c' : '<CMD>Gitsigns next_hunk<CR>'", opts)
+ map("n", "[c", "&diff ? '[c' : '<CMD>Gitsigns prev_hunk<CR>'", opts)
+
+ -- Actions
+ map({ "n", "v" }, "<leader>hr", gs.reset_hunk, { buffer = buf })
+ map({ "n", "v" }, "<leader>hs", gs.stage_hunk)
+ map("n", "<leader>hS", gs.stage_buffer, { buffer = buf })
+ map("n", "<leader>hp", gs.preview_hunk, { buffer = buf })
+
+ -- Text object
+ map({ "o", "x" }, "ih", ":<C-U>Gitsigns select_hunk<CR>", { buffer = buf })
+ end,
+})
diff --git a/neovim/.config/nvim/lua/plugins/lsp.lua b/neovim/.config/nvim/lua/plugins/lsp.lua
new file mode 100644
index 0000000..db73c10
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/lsp.lua
@@ -0,0 +1,79 @@
+require("lspconfig")
+
+local sign = function(opts)
+ vim.fn.sign_define(opts.name, {
+ texthl = opts.name,
+ text = opts.text,
+ numhl = ''
+ })
+end
+
+sign({name = 'DiagnosticSignError', text = ''})
+sign({name = 'DiagnosticSignWarn', text = ''})
+sign({name = 'DiagnosticSignHint', text = ''})
+sign({name = 'DiagnosticSignInfo', text = ''})
+
+vim.diagnostic.config({
+ signs = true,
+ virtual_text = false,
+ update_in_insert = true,
+ underline = false,
+ severity_sort = true,
+ float = {
+ source = 'always',
+ header = '',
+ prefix = '',
+ },
+})
+
+require("keybinds")
+
+map("n", "<F2>", "<cmd>lua vim.lsp.buf.rename()<cr>")
+map("n", "<C-h>", "<cmd>lua vim.diagnostic.open_float()<cr>")
+
+--[[
+nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
+nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
+nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
+nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
+nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
+nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
+nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
+nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
+nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
+
+-- Jump to the definition
+bufmap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>')
+
+-- Jump to declaration
+bufmap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>')
+
+-- Lists all the implementations for the symbol under the cursor
+bufmap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>')
+
+-- Jumps to the definition of the type symbol
+bufmap('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>')
+
+-- Lists all the references
+bufmap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>')
+
+-- Displays a function's signature information
+bufmap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<cr>')
+
+-- Renames all references to the symbol under the cursor
+bufmap('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>')
+
+-- Selects a code action available at the current cursor position
+bufmap('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>')
+bufmap('x', '<F4>', '<cmd>lua vim.lsp.buf.range_code_action()<cr>')
+
+-- Show diagnostics in a floating window
+bufmap('n', 'gl', '<cmd>lua vim.diagnostic.open_float()<cr>')
+
+-- Move to the previous diagnostic
+bufmap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<cr>')
+
+-- Move to the next diagnostic
+bufmap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<cr>')
+]]
+
diff --git a/neovim/.config/nvim/lua/plugins/lualine.lua b/neovim/.config/nvim/lua/plugins/lualine.lua
new file mode 100644
index 0000000..353e691
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/lualine.lua
@@ -0,0 +1,34 @@
+require("lualine").setup({
+ options = {
+ theme = "catppuccin",
+ component_separators = { left = "»", right = "«" },
+ section_separators = "",
+ icons_enabled = true,
+ globalstatus = true,
+ },
+ sections = {
+ lualine_a = {
+ { "mode", color = { gui = "bold" } },
+ },
+ lualine_b = {
+ { "branch" },
+ { "diff", colored = false },
+ },
+ lualine_c = {
+ { "filename", file_status = true },
+ { "diagnostics" },
+ },
+ lualine_x = {
+ { "filetype" },
+ { "fileformat", icons_enabled = false },
+ { "encoding" },
+ },
+ lualine_y = {
+ { "progress" },
+ },
+ lualine_z = {
+ { "location", color = { gui = "bold" } },
+ },
+ },
+ extensions = { "quickfix", "nvim-tree" },
+})
diff --git a/neovim/.config/nvim/lua/plugins/mason.lua b/neovim/.config/nvim/lua/plugins/mason.lua
new file mode 100644
index 0000000..3e97958
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/mason.lua
@@ -0,0 +1,10 @@
+require("mason").setup({
+ ui = {
+ icons = {
+ package_installed = "✓",
+ package_pending = "➜",
+ package_uninstalled = "✗"
+ }
+ }
+})
+require("mason-lspconfig").setup()
diff --git a/neovim/.config/nvim/lua/plugins/pairs.lua b/neovim/.config/nvim/lua/plugins/pairs.lua
new file mode 100644
index 0000000..ed0e692
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/pairs.lua
@@ -0,0 +1,2 @@
+require("nvim-autopairs").setup()
+require("cmp").event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done())
diff --git a/neovim/.config/nvim/lua/plugins/rust-tools.lua b/neovim/.config/nvim/lua/plugins/rust-tools.lua
new file mode 100644
index 0000000..c8442aa
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/rust-tools.lua
@@ -0,0 +1,24 @@
+require("rust-tools").setup({
+ tools = {
+ autoSetHints = true,
+ inlay_hints = {
+ auto = false,
+ show_parameter_hints = false,
+ parameter_hints_prefix = "",
+ other_hints_prefix = "",
+ },
+ },
+
+ -- https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
+ server = {
+ settings = {
+ -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
+ ["rust-analyzer"] = {
+ checkOnSave = {
+ command = "clippy"
+ },
+ }
+ }
+ },
+})
+
diff --git a/neovim/.config/nvim/lua/plugins/telescope.lua b/neovim/.config/nvim/lua/plugins/telescope.lua
new file mode 100644
index 0000000..01dcb2f
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/telescope.lua
@@ -0,0 +1,64 @@
+local actions = require("telescope.actions")
+local finders = require("telescope.builtin")
+
+local action_mt = require "telescope.actions.mt"
+local action_state = require "telescope.actions.state"
+-- global for later inspection
+custom_actions = action_mt.transform_mod({
+ print_entry = function()
+ print(vim.inspect(action_state.get_selected_entry()))
+ end,
+})
+
+require("telescope").setup({
+ defaults = {
+ prompt_prefix = " ",
+ initial_mode = "insert",
+ sorting_strategy = "ascending",
+ layout_config = {
+ prompt_position = "top",
+ },
+ mappings = {
+ i = {
+ ["<C-M>"] = custom_actions['print_entry'],
+ ["<ESC>"] = actions.close,
+ ["<C-j>"] = actions.move_selection_next,
+ ["<C-k>"] = actions.move_selection_previous,
+ ["<TAB>"] = actions.toggle_selection + actions.move_selection_next,
+ ["<C-s>"] = actions.send_selected_to_qflist,
+ ["<C-q>"] = actions.send_to_qflist,
+ },
+ },
+ },
+ extensions = {
+ fzf = {
+ fuzzy = true,
+ override_generic_sorter = true,
+ override_file_sorter = true,
+ case_mode = "smart_case",
+ },
+ },
+})
+
+local Telescope = setmetatable({}, {
+ __index = function(_, k)
+ if vim.bo.filetype == "NvimTree" then
+ vim.cmd.wincmd("l")
+ end
+ return finders[k]
+ end,
+})
+
+vim.keymap.set("n", "<C-space>", function()
+ local ok = pcall(Telescope.git_files, { show_untracked = true })
+ if not ok then
+ Telescope.find_files()
+ end
+end)
+
+-- Get :help at the speed of light
+vim.keymap.set("n", "<leader>H", Telescope.help_tags)
+-- Search for string
+vim.keymap.set("n", "<leaders>s", Telescope.live_grep)
+-- Fuzzy find changed files in git
+vim.keymap.set("n", "<leader>c", Telescope.git_status)
diff --git a/neovim/.config/nvim/lua/plugins/treesitter.lua b/neovim/.config/nvim/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..e3d8fbb
--- /dev/null
+++ b/neovim/.config/nvim/lua/plugins/treesitter.lua
@@ -0,0 +1,126 @@
+-- Treesitter folds
+-- vim.o.foldmethod = "expr"
+-- vim.o.foldexpr = "nvim_treesitter#foldexpr()"
+-- vim.o.foldlevelstart = 99
+
+require("nvim-treesitter.configs").setup({
+ -- nvim-treesitter/nvim-treesitter (self config)
+ auto_install = true,
+ ensure_installed = {
+ "c",
+ "lua",
+ "rust",
+ "go",
+ "javascript",
+ "typescript",
+ "tsx",
+ "markdown",
+ "markdown_inline",
+ "html",
+ "css",
+ "json",
+ "bash",
+ },
+ highlight = {
+ enable = true,
+ -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
+ -- Set this to `true` if you depend on "syntax" being enabled (like for indentation).
+ -- Using this option may slow down your editor, and you may see some duplicate highlights.
+ -- Instead of true it can also be a list of languages
+ additional_vim_regex_highlighting = false,
+ },
+ indent = {
+ enable = true,
+ },
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = "gs",
+ -- NOTE: These are visual mode mappings
+ node_incremental = "gs",
+ node_decremental = "gS",
+ scope_incremental = "<leader>gc",
+ },
+ },
+ -- nvim-treesitter/nvim-treesitter-textobjects
+ textobjects = {
+ select = {
+ enable = true,
+ -- Automatically jump forward to textobj, similar to targets.vim
+ lookahead = true,
+ keymaps = {
+ -- You can use the capture groups defined in textobjects.scm
+ ["af"] = "@function.outer",
+ ["if"] = "@function.inner",
+ ["ac"] = "@class.outer",
+ ["ic"] = "@class.inner",
+ ["al"] = "@loop.outer",
+ ["il"] = "@loop.inner",
+ ["aa"] = "@parameter.outer",
+ ["ia"] = "@parameter.inner",
+ ["uc"] = "@comment.outer",
+
+ -- Or you can define your own textobjects like this
+ -- ["iF"] = {
+ -- python = "(function_definition) @function",
+ -- cpp = "(function_definition) @function",
+ -- c = "(function_definition) @function",
+ -- java = "(method_declaration) @function",
+ -- },
+ },
+ },
+ swap = {
+ enable = true,
+ swap_next = {
+ ["<leader>a"] = "@parameter.inner",
+ ["<leader>f"] = "@function.outer",
+ ["<leader>e"] = "@element",
+ },
+ swap_previous = {
+ ["<leader>A"] = "@parameter.inner",
+ ["<leader>F"] = "@function.outer",
+ ["<leader>E"] = "@element",
+ },
+ },
+ move = {
+ enable = true,
+ set_jumps = true, -- whether to set jumps in the jumplist
+ goto_next_start = {
+ ["]f"] = "@function.outer",
+ ["]]"] = "@class.outer",
+ },
+ goto_next_end = {
+ ["]F"] = "@function.outer",
+ ["]["] = "@class.outer",
+ },
+ goto_previous_start = {
+ ["[f"] = "@function.outer",
+ ["[["] = "@class.outer",
+ },
+ goto_previous_end = {
+ ["[F"] = "@function.outer",
+ ["[]"] = "@class.outer",
+ },
+ },
+ },
+ -- windwp/nvim-ts-autotag
+ autotag = {
+ enable = true,
+ },
+ -- nvim-treesitter/playground
+ playground = {
+ enable = true,
+ disable = {},
+ updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
+ persist_queries = false, -- Whether the query persists across vim sessions
+ },
+ -- nvim-treesitter/nvim-treesitter-refactor
+ refactor = {
+ highlight_definitions = { enable = true },
+ -- highlight_current_scope = { enable = false },
+ },
+ context_commentstring = {
+ enable = true,
+ enable_autocmd = false,
+ },
+})