diff --git a/dotfiles/.config/nvim/init.lua b/dotfiles/.config/nvim/init.lua index fa8c8f7..c9c0977 100644 --- a/dotfiles/.config/nvim/init.lua +++ b/dotfiles/.config/nvim/init.lua @@ -1,8 +1,9 @@ -require "custom.plugins" -require "custom.options" -require "custom.lsp" -require "custom.utils" -require "custom.treesitter" -require "custom.keymaps" -require "custom.whichkey" -require "custom.nvim-tree" +-- Make sure to setup `mapleader` and `maplocalleader` before +-- loading lazy.nvim so that mappings are correct. +-- This is also a good place to setup other settings (vim.opt) +require("config.opts") +-- Plugins are loaded from ~/.config/nvim/lua/config/plugins.lua by lazy.nvim +require("config.lazy") +require("config.theme") +-- This is where the keybindings are setup using which-key.nvim +require("config.keybindings") diff --git a/dotfiles/.config/nvim/lazy-lock.json b/dotfiles/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..f06de14 --- /dev/null +++ b/dotfiles/.config/nvim/lazy-lock.json @@ -0,0 +1,37 @@ +{ + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, + "cmp-git": { "branch": "main", "commit": "ec049036e354ed8ed0215f2427112882e1ea7051" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "99290b3ec1322070bcfb9e846450a46f6efa50f0" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, + "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, + "lsp_lines.nvim": { "branch": "main", "commit": "f7f18b85360b8e85cd6a5418c9fbccb6a2ff4b1b" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.icons": { "branch": "main", "commit": "44c0160526f7ae17ca8e8eab9ab235d047fcf7a6" }, + "mini.nvim": { "branch": "main", "commit": "7ebfab26d77a4b9b05aaae565907e7fa4b2ee154" }, + "none-ls-autoload.nvim": { "branch": "main", "commit": "7b6358f1f03d95297d737c6ff141895845bc847c" }, + "none-ls.nvim": { "branch": "main", "commit": "c279e541f73a2deea9deb5231b9c037678dd6353" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-cmp": { "branch": "main", "commit": "3403e2e9391ed0a28c3afddd8612701b647c8e26" }, + "nvim-lspconfig": { "branch": "master", "commit": "ae8a01bb40848490548e5d07b97ed972ed43c2f9" }, + "nvim-treesitter": { "branch": "master", "commit": "54a29bf99d5ccb2de512906279686457d699f8e5" }, + "oil.nvim": { "branch": "master", "commit": "dba037598843973b8c54bc5ce0318db4a0da439d" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "sentiment.nvim": { "branch": "main", "commit": "54a6db15b630eccfa98c32a76baf90f21c6f1e40" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "toggleterm.nvim": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, + "tokyonight.nvim": { "branch": "main", "commit": "45d22cf0e1b93476d3b6d362d720412b3d34465c" }, + "vim-dadbod": { "branch": "master", "commit": "f740950d0703099e0f172016f10e0e39f50fd0ba" }, + "vim-dadbod-completion": { "branch": "master", "commit": "04485bfb53a629423233a4178d71cd4f8abf7406" }, + "vim-dadbod-ui": { "branch": "master", "commit": "0fec59e3e1e619e302198cd491b7d27f8d398b7c" }, + "vim-fugitive": { "branch": "master", "commit": "fcb4db52e7f65b95705aa58f0f2df1312c1f2df2" }, + "vim-lastplace": { "branch": "master", "commit": "e58cb0df716d3c88605ae49db5c4741db8b48aa9" }, + "vim-puppet": { "branch": "master", "commit": "10bf0b27c5be81ee26c3a0d32e39b270f95329ce" }, + "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, + "vim-tabby": { "branch": "main", "commit": "b29c0681569fcc9857ff13835afec2dda9b8d90f" }, + "vim-vsnip": { "branch": "master", "commit": "02a8e79295c9733434aab4e0e2b8c4b7cea9f3a9" }, + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" } +} diff --git a/dotfiles/.config/nvim/lua/config/keybindings.lua b/dotfiles/.config/nvim/lua/config/keybindings.lua new file mode 100644 index 0000000..1201f3f --- /dev/null +++ b/dotfiles/.config/nvim/lua/config/keybindings.lua @@ -0,0 +1,61 @@ +local wk = require("which-key") +wk.add({ + -- Git mappings + { "g", group = "git" }, + { "ga", "Git add", desc = "Add" }, + { "gb", "Git blame", desc = "Blame" }, + { "gc", "Git commit", desc = "Commit" }, + { "gC", desc = "git confict" }, + { "gCo", "GitConflictChooseOurs", desc = "Choose ours" }, + { "gCt", "GitConflictChooseTheirs", desc = "Choose theirs" }, + { "gCb", "GitConflictChooseBoth", desc = "Choose both" }, + { "gCn", "GitConflictChooseNone", desc = "Choose none" }, + { "gCN", "GitConflictNextConflict", desc = "Next conflict" }, + { "gCp", "GitConflictPrevConflict", desc = "Prev conflict" }, + { "gCl", "GitConflictListQf", desc = "List quickfix" }, + { "gd", "Git diff", desc = "Diff" }, + -- LSP mappings + { "l", group = "lsp" }, + { "lc", "lua vim.cmd.norm('gcc')", desc = "Toggle Comment", mode = "n" }, + { "lc", "lua vim.cmd.norm('gc')", desc = "Toggle Comment", mode = "v" }, + { "lC", "lua vim.lsp.buf.code_action()", desc = "Code Action" }, + { "lD", "lua vim.lsp.buf.declaration()", desc = "Declaration" }, + { "ld", "lua vim.lsp.buf.definition()", desc = "Definition" }, + { "lf", "lua vim.lsp.buf.format()", desc = "Format" }, + { "lh", "lua vim.lsp.buf.hover()", desc = "Hover" }, + { "li", "lua vim.lsp.buf.implementation()", desc = "Implementation" }, + { "lR", "lua vim.lsp.buf.references()", desc = "References" }, + { "lr", "lua vim.lsp.buf.rename()", desc = "Rename" }, + { "ls", "lua vim.lsp.buf.signatur_help()", desc = "Signature Help" }, + { "lt", "lua vim.lsp.buf.type_definition()", desc = "Type Definition" }, + -- Mason mappings + { "M", group = "mason" }, + { "m", "Mason", desc = "Mason" }, + { "Ml", "MasonLog", desc = "Mason log" }, + { "Mu", "MasonUpdate", desc = "Mason update" }, + -- oil mappings + { "o", group = "oil" }, + { "of", "Oil --float", desc = "Open floating parent" }, + { "op", "lua require('oil.actions').preview.callback()", desc = "Show preview" }, + { + "oc", + "lua require('oil.actions').close.callback()", + desc = "Close", + mode = "n", + }, + { "oo", "Oil", desc = "Open parent" }, + -- telescope mappings + { "f", group = "find" }, + { "ff", "Telescope find_files", desc = "Find files" }, + { "fg", "Telescope live_grep", desc = "Grep" }, + { "fb", "Telescope buffers", desc = "Buffers" }, + { "fh", "Telescope help_tags", desc = "Help tags" }, + -- terminal mappings + { "t", group = "term" }, + { "tt", "ToggleTerm", mode = "n", desc = "Toggle terminal" }, + { "ts", "ToggleTermSendCurrentLine", desc = "Send current line to terminal" }, + { "tl", "ToggleTermSendVisualLines", desc = "Send visualy selected lines to terminal" }, + { "tv", "ToggleTermSendVisualSelection", desc = "Send visual selection to terminal" }, + { "", "ToggleTerm", mode = "t", desc = "Toggle terminal" }, + { "", "bd!", mode = "t", desc = "Quit terminal" }, +}) diff --git a/dotfiles/.config/nvim/lua/config/lazy.lua b/dotfiles/.config/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..e410339 --- /dev/null +++ b/dotfiles/.config/nvim/lua/config/lazy.lua @@ -0,0 +1,36 @@ +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "config.plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "habamax" } }, + -- automatically check for plugin updates + checker = { enabled = true }, +}) +vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + require("lazy").update({ + show = false, + }) + end, +}) diff --git a/dotfiles/.config/nvim/lua/config/opts.lua b/dotfiles/.config/nvim/lua/config/opts.lua new file mode 100644 index 0000000..3b6297e --- /dev/null +++ b/dotfiles/.config/nvim/lua/config/opts.lua @@ -0,0 +1,10 @@ + +vim.g.mapleader = "\\" +vim.g.maplocalleader = "\\" +local set = vim.opt +set.shiftwidth = 2 +set.tabstop = 2 +set.clipboard = "unnamedplus" +set.relativenumber = true +set.number = true +set.expandtab = true diff --git a/dotfiles/.config/nvim/lua/config/plugins.lua b/dotfiles/.config/nvim/lua/config/plugins.lua new file mode 100644 index 0000000..62da8dd --- /dev/null +++ b/dotfiles/.config/nvim/lua/config/plugins.lua @@ -0,0 +1,284 @@ +return { + "farmergreg/vim-lastplace", + "folke/which-key.nvim", + "nvim-lua/plenary.nvim", + "nvimtools/none-ls.nvim", + "rodjek/vim-puppet", + "tpope/vim-dadbod", + "tpope/vim-fugitive", + "tpope/vim-surround", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-vsnip", + "hrsh7th/vim-vsnip", + "petertriho/cmp-git", + { "akinsho/git-conflict.nvim", version = "*", config = true }, + { 'akinsho/toggleterm.nvim', version = "*", config = true }, + { + "echasnovski/mini.nvim", + config = function() + local statusline = require("mini.statusline") + statusline.setup({ use_icons = true }) + end, + }, + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = {}, + }, + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + cmp.setup({ + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, + }, { + { name = "buffer" }, + }), + }) + + -- Set configuration for specific filetype. + cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "git" }, + }, { + { name = "buffer" }, + }), + }) + require("cmp_git").setup() + + -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) + + -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + matching = { + disallow_symbol_nonprefix_matching = false, + disallow_fuzzy_matching = false, + disallow_fullfuzzy_matching = false, + disallow_partial_matching = false, + disallow_prefix_unmatching = false, + disallow_partial_fuzzy_matching = false, + }, + }) + + -- Set up lspconfig. + local capabilities = require("cmp_nvim_lsp").default_capabilities() + -- Replace with each lsp server you've enabled. + local lsps = { "lua_ls", "pylsp", "bashls", "puppet", "tabby_ml", "intelephense", "puppet" } + local configs = require("lspconfig.configs") + if not configs.intelephense then + configs.intelephense = { + default_config = { + cmd = { "intelephense", "--stdio" }, + filetypes = { "php" }, + root_dir = function(fname) + return vim.loop.cwd() + end, + settings = { + intelephense = { + files = { + maxSize = 1000000, + }, + environment = { + includePaths = { + "/home/micke/sources/nextcloud/server", + }, + }, + }, + }, + }, + } + end + for _, server in ipairs(lsps) do + require("lspconfig")[server].setup({ + capabilities = capabilities, + }) + end + end, + }, + { + 'kristijanhusak/vim-dadbod-ui', + dependencies = { + { 'tpope/vim-dadbod', lazy = true }, + { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional + }, + cmd = { + 'DBUI', + 'DBUIToggle', + 'DBUIAddConnection', + 'DBUIFindBuffer', + }, + init = function() + -- Your DBUI configuration + vim.g.db_ui_use_nerd_fonts = 1 + end, + }, + { + "neovim/nvim-lspconfig", + dependencies = { + { + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, + }, + config = function() + require("lspconfig").lua_ls.setup({}) + end, + }, + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.8', + dependencies = { 'nvim-lua/plenary.nvim' } + }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + auto_install = false, + ignore_install = {}, + modules = {}, + ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "python", "php", "javascript", "html" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end, + }, + { + "stevearc/oil.nvim", + opts = {}, + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + config = function() + require("oil").setup({ + set_default_keymaps = false, + view_options = { + -- Show files and directories that start with "." + show_hidden = true, + -- This function defines what is considered a "hidden" file + is_hidden_file = function(name, bufnr) + local m = name:match("^%.") + return m ~= nil + end, + -- This function defines what will never be shown, even when `show_hidden` is set + is_always_hidden = function(name, bufnr) + return false + end, + -- Sort file names with numbers in a more intuitive order for humans. + -- Can be "fast", true, or false. "fast" will turn it off for large directories. + natural_order = "fast", + -- Sort file and directory names case insensitive + case_insensitive = false, + sort = { + -- sort order can be "asc" or "desc" + -- see :help oil-columns to see which columns are sortable + { "type", "asc" }, + { "name", "asc" }, + }, + -- Customize the highlight group for the file name + highlight_filename = function(entry, is_hidden, is_link_target, is_link_orphan) + return nil + end, + }, + }) + end, + }, + { + "TabbyML/vim-tabby", + lazy = false, + dependencies = { + "neovim/nvim-lspconfig", + }, + init = function() + vim.g.tabby_agent_start_command = { "npx", "tabby-agent", "--lsp", "--stdio" } + vim.g.tabby_inline_completion_trigger = "auto" + end, + config = function() + vim.g.tabby_inline_completion_keybinding_accept = "" + vim.g.tabby_inline_completion_keybinding_trigger_or_dismiss = "" + end, + }, + { + "https://git.sr.ht/~whynothugo/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + vim.diagnostic.config({ + virtual_text = false, + }) + end, + }, + { + "utilyre/sentiment.nvim", + version = "*", + event = "VeryLazy", -- keep for lazy loading + opts = { + -- config + }, + init = function() + -- `matchparen.vim` needs to be disabled manually in case of lazy loading + vim.g.loaded_matchparen = 1 + end, + }, + + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end, + }, + { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = true, + -- use opts = {} for passing setup options + -- this is equivalent to setup({}) function + }, + { + "zeioth/none-ls-autoload.nvim", + event = "BufEnter", + dependencies = { "williamboman/mason.nvim", "nvimtools/none-ls.nvim" }, + opts = {}, + }, +} diff --git a/dotfiles/.config/nvim/lua/config/theme.lua b/dotfiles/.config/nvim/lua/config/theme.lua new file mode 100644 index 0000000..b5f375a --- /dev/null +++ b/dotfiles/.config/nvim/lua/config/theme.lua @@ -0,0 +1,12 @@ + +vim.cmd([[colorscheme tokyonight]]) +-- Highlight when yanking (copying) text +-- Try it with `yap` in normal mode +-- See `:help vim.highlight.on_yank()` +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("kickstart-highlight-yank", { clear = true }), + callback = function() + vim.highlight.on_yank() + end, +}) diff --git a/dotfiles/.config/nvim/lua/custom/keymaps.lua b/dotfiles/.config/nvim/lua/custom/keymaps.lua deleted file mode 100644 index 7bf365b..0000000 --- a/dotfiles/.config/nvim/lua/custom/keymaps.lua +++ /dev/null @@ -1,70 +0,0 @@ -local opts = { noremap = true, silent = true } - -local term_opts = { silent = true } - --- Shorten function name -local keymap = vim.api.nvim_set_keymap - ---Map \ as leader key --- keymap("", "", "", opts) -vim.g.mapleader = '\\' -vim.g.maplocalleader = '\\' - --- Modes --- normal_mode = "n", --- insert_mode = "i", --- visual_mode = "v", --- visual_block_mode = "x", --- term_mode = "t", --- command_mode = "c", - --- Normal -- --- Better window navigation -keymap("n", "", "h", opts) -keymap("n", "", "j", opts) -keymap("n", "", "k", opts) -keymap("n", "", "l", opts) - --- Resize with arrows -keymap("n", "", ":resize -2", opts) -keymap("n", "", ":resize +2", opts) -keymap("n", "", ":vertical resize -2", opts) -keymap("n", "", ":vertical resize +2", opts) - --- Navigate buffers -keymap("n", "", ":bnext", opts) -keymap("n", "", ":bprevious", opts) - --- Move text up and down -keymap("n", "", ":m .+1==gi", opts) -keymap("n", "", ":m .-2==gi", opts) - --- Insert -- --- Press jk fast to exit insert mode -keymap("i", "jk", "", opts) - --- Visual -- --- Stay in indent mode -keymap("v", "<", "", ">gv", opts) - --- Move text up and down -keymap("v", "", ":m .+1==", opts) -keymap("v", "", ":m .-2==", opts) -keymap("v", "p", '"_dP', opts) - --- Visual Block -- --- Move text up and down -keymap("x", "J", ":move '>+1gv-gv", opts) -keymap("x", "K", ":move '<-2gv-gv", opts) -keymap("x", "", ":move '>+1gv-gv", opts) -keymap("x", "", ":move '<-2gv-gv", opts) - --- Terminal -- --- Better terminal navigation --- keymap("t", "", "h", term_opts) --- keymap("t", "", "j", term_opts) --- keymap("t", "", "k", term_opts) --- keymap("t", "", "l", term_opts) - - diff --git a/dotfiles/.config/nvim/lua/custom/lsp.lua b/dotfiles/.config/nvim/lua/custom/lsp.lua deleted file mode 100644 index 06b4151..0000000 --- a/dotfiles/.config/nvim/lua/custom/lsp.lua +++ /dev/null @@ -1,153 +0,0 @@ --- Diagnostics -local notify = vim.notify -vim.notify = function(msg, ...) - if msg:match("warning: multiple different client offset_encodings") then - return - end - - notify(msg, ...) -end -require'toggle_lsp_diagnostics'.init({ start_on = true }) - -local nvim_lsp = require('lspconfig') -vim.lsp.handlers["textDocument/hover"] = vim.lsp.with( - vim.lsp.handlers.hover, { focusable = false } -) - --- Use an on_attach function to only map the following keys --- after the language server attaches to the current buffer -local on_attach = function(client, bufnr) - local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - - -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - local opts = { noremap=true, silent=true } - - -- See `:help vim.lsp.*` for documentation on any of the below functions - buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts) - buf_set_keymap('n', 'd', 'lua vim.lsp.buf.definition()', opts) - buf_set_keymap('n', 'h', 'lua vim.lsp.buf.hover()', opts) - buf_set_keymap('n', 'i', 'lua vim.lsp.buf.implementation()', opts) - buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts) - buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts) - buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts) - buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts) - buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts) - buf_set_keymap('n', 'r', 'lua vim.lsp.buf.rename()', opts) - buf_set_keymap('n', 'a', 'lua vim.lsp.buf.code_action()', opts) - buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts) - buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts) - buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts) - buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts) - buf_set_keymap('n', 'q', 'lua vim.diagnostic.setloclist()', opts) - buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts) - - vim.diagnostic.config({ - virtual_text = true, - signs = true, - underline = true, - update_in_insert = true, - severity_sort = false, - }) - - local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " } - for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) - end -end - --- set up completion -local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities()) - -local cmp = require'cmp' - - cmp.setup({ - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - -- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. - -- require('snippy').expand_snippet(args.body) -- For `snippy` users. - -- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. - end, - }, - mapping = { - [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), - [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), - [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. - [''] = cmp.mapping({ - i = cmp.mapping.abort(), - c = cmp.mapping.close(), - }), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'vsnip' }, -- For vsnip users. - -- { name = 'luasnip' }, -- For luasnip users. - -- { name = 'ultisnips' }, -- For ultisnips users. - -- { name = 'snippy' }, -- For snippy users. - }, { - { name = 'buffer' }, - }) - }) - - -- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline('/', { - sources = { - { name = 'buffer' } - } - }) - - -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). - cmp.setup.cmdline(':', { - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - - --- Use a loop to conveniently call 'setup' on multiple servers and --- map buffer local keybindings when the language server attaches -local servers = { 'pylsp', 'clangd', 'puppet', 'bashls'} -for _, lsp in ipairs(servers) do - nvim_lsp[lsp].setup { - capabilities = capabilities, - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - } - } -end - -nvim_lsp["efm"].setup { - capabilities = capabilities, - on_attach = on_attach, - flags = { - debounce_text_changes = 150, - }, - init_options = {documentFormatting = true}, - filetypes = { 'sh', 'puppet'}, - settings = { - rootMarkers = {".git/"}, - languages = { - puppet = { - { - formatCommand = 'puppet-fix', formatStdin = true, lintCommand = 'puppet-lint --log-format "%{filename}:%{line}:%{column}: %{kind}: %{message}. [%{check}]"', lintSource = 'puppet-lint', lintFormats= {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} - } - }, - sh = { - { - formatCommand = "shfmt -i 2", formatStdin = true, lintCommand = 'shellcheck -f gcc -x', lintSource = 'shellcheck', lintFormats= {'%f:%l:%c: %trror: %m', '%f:%l:%c: %tarning: %m', '%f:%l:%c: %tote: %m'} - } - } - } - } -} diff --git a/dotfiles/.config/nvim/lua/custom/nvim-tree.lua b/dotfiles/.config/nvim/lua/custom/nvim-tree.lua deleted file mode 100644 index 6b8a932..0000000 --- a/dotfiles/.config/nvim/lua/custom/nvim-tree.lua +++ /dev/null @@ -1,69 +0,0 @@ -local status_ok, nvim_tree = pcall(require, "nvim-tree") -if not status_ok then - return -end - -local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") -if not config_status_ok then - return -end - -local tree_cb = nvim_tree_config.nvim_tree_callback - -nvim_tree.setup { - update_focused_file = { - enable = true, - update_cwd = true, - }, - renderer = { - root_folder_modifier = ":t", - icons = { - glyphs = { - default = "", - symlink = "", - folder = { - arrow_open = "", - arrow_closed = "", - default = "", - open = "", - empty = "", - empty_open = "", - symlink = "", - symlink_open = "", - }, - git = { - unstaged = "", - staged = "S", - unmerged = "", - renamed = "➜", - untracked = "U", - deleted = "", - ignored = "◌", - }, - }, - }, - }, - diagnostics = { - enable = true, - show_on_dirs = true, - icons = { - hint = "", - info = "", - warning = "", - error = "", - }, - }, - view = { - width = 30, - height = 30, - side = "left", - mappings = { - list = { - { key = { "l", "", "o" }, cb = tree_cb "edit" }, - { key = "h", cb = tree_cb "close_node" }, - { key = "v", cb = tree_cb "vsplit" }, - }, - }, - }, -} - diff --git a/dotfiles/.config/nvim/lua/custom/options.lua b/dotfiles/.config/nvim/lua/custom/options.lua deleted file mode 100644 index b271819..0000000 --- a/dotfiles/.config/nvim/lua/custom/options.lua +++ /dev/null @@ -1,45 +0,0 @@ -local options = { - backup = false, -- creates a backup file - clipboard = "unnamedplus", -- allows neovim to access the system clipboard - cmdheight = 2, -- more space in the neovim command line for displaying messages - completeopt = { "menu", "menuone", "noselect" }, -- mostly just for cmp - conceallevel = 0, -- so that `` is visible in markdown files - fileencoding = "utf-8", -- the encoding written to a file - hlsearch = true, -- highlight all matches on previous search pattern - ignorecase = true, -- ignore case in search patterns - mouse = "", -- allow the mouse to be used in neovim - pumheight = 10, -- pop up menu height - showmode = true, -- we don't need to see things like -- INSERT -- anymore - showtabline = 2, -- always show tabs - smartcase = true, -- smart case - smartindent = true, -- make indenting smarter again - splitbelow = true, -- force all horizontal splits to go below current window - splitright = true, -- force all vertical splits to go to the right of current window - swapfile = false, -- creates a swapfile - -- termguicolors = true, -- set term gui colors (most terminals support this) - timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds) - undofile = true, -- enable persistent undo - updatetime = 300, -- faster completion (4000ms default) - writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited - expandtab = true, -- convert tabs to spaces - shiftwidth = 4, -- the number of spaces inserted for each indentation - tabstop = 4, -- insert 2 spaces for a tab - cursorline = true, -- highlight the current line - number = true, -- set numbered lines - relativenumber = false, -- set relative numbered lines - numberwidth = 4, -- set number column width to 2 {default 4} - signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time - wrap = false, -- display lines as one long line - scrolloff = 8, -- is one of my fav - sidescrolloff = 8, - guifont = "monospace:h17", -- the font used in graphical neovim applications -} - -vim.opt.shortmess:append "c" - -for k, v in pairs(options) do - vim.opt[k] = v -end - -vim.cmd "set whichwrap+=<,>,[,],h,l" -vim.cmd [[set iskeyword+=-]] diff --git a/dotfiles/.config/nvim/lua/custom/plugins.lua b/dotfiles/.config/nvim/lua/custom/plugins.lua deleted file mode 100644 index 1993205..0000000 --- a/dotfiles/.config/nvim/lua/custom/plugins.lua +++ /dev/null @@ -1,27 +0,0 @@ -local Plug = vim.fn['plug#'] -vim.call('plug#begin', '~/.local/share/nvim/plugged/') -Plug 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim' -Plug 'hrsh7th/cmp-buffer' -Plug 'hrsh7th/cmp-cmdline' -Plug 'hrsh7th/cmp-nvim-lsp' -Plug 'folke/which-key.nvim' -Plug 'hrsh7th/cmp-nvim-lua' -Plug 'hrsh7th/cmp-path' -Plug 'hrsh7th/cmp-vsnip' -Plug 'hrsh7th/nvim-cmp' -Plug 'hrsh7th/vim-vsnip' -Plug 'mrk21/yaml-vim' -- For hieradata -Plug 'neovim/nvim-lspconfig' -Plug 'nvim-lua/completion-nvim' -Plug 'nvim-lua/diagnostic-nvim' -Plug 'windwp/nvim-autopairs' -Plug 'kyazdani42/nvim-tree.lua' -Plug 'nvim-lua/plenary.nvim' -- Dependecy for telescope -Plug('nvim-treesitter/nvim-treesitter', {['do'] = ':TSUpdate'}) -- Dependecy for telescope -Plug 'nvim-lua/telescope.nvim' -Plug 'rodjek/vim-puppet' -Plug 'tpope/vim-surround' -Plug 'vim-ruby/vim-ruby' -- For Facts, Ruby functions, and custom providers -Plug 'williamboman/nvim-lsp-installer' -Plug('preservim/nerdtree', { on = {'NERDTreeToggle', 'NERDTree' }}) -vim.call('plug#end') diff --git a/dotfiles/.config/nvim/lua/custom/treesitter.lua b/dotfiles/.config/nvim/lua/custom/treesitter.lua deleted file mode 100644 index 5505950..0000000 --- a/dotfiles/.config/nvim/lua/custom/treesitter.lua +++ /dev/null @@ -1,24 +0,0 @@ -require'nvim-treesitter.configs'.setup { - -- One of "all", "maintained" (parsers with maintainers), or a list of languages - ensure_installed = "maintained", - - -- Install languages synchronously (only applied to `ensure_installed`) - sync_install = false, - - -- List of parsers to ignore installing - ignore_install = { "javascript" }, - - highlight = { - -- `false` will disable the whole extension - enable = true, - - -- list of language that will be disabled - disable = { "c", "rust" }, - - -- 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, - }, -} diff --git a/dotfiles/.config/nvim/lua/custom/utils.lua b/dotfiles/.config/nvim/lua/custom/utils.lua deleted file mode 100644 index f1908eb..0000000 --- a/dotfiles/.config/nvim/lua/custom/utils.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.cmd([[if has("autocmd") - au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif -endif]]) diff --git a/dotfiles/.config/nvim/lua/custom/whichkey.lua b/dotfiles/.config/nvim/lua/custom/whichkey.lua deleted file mode 100644 index 13b9ca8..0000000 --- a/dotfiles/.config/nvim/lua/custom/whichkey.lua +++ /dev/null @@ -1,188 +0,0 @@ -local status_ok, which_key = pcall(require, "which-key") -if not status_ok then - return -end - -local setup = { - plugins = { - marks = true, -- shows a list of your marks on ' and ` - registers = true, -- shows your registers on " in NORMAL or in INSERT mode - spelling = { - enabled = true, -- enabling this will show WhichKey when pressing z= to select spelling suggestions - suggestions = 20, -- how many suggestions should be shown in the list? - }, - -- the presets plugin, adds help for a bunch of default keybindings in Neovim - -- No actual key bindings are created - presets = { - operators = false, -- adds help for operators like d, y, ... and registers them for motion / text object completion - motions = true, -- adds help for motions - text_objects = true, -- help for text objects triggered after entering an operator - windows = true, -- default bindings on - nav = true, -- misc bindings to work with windows - z = true, -- bindings for folds, spelling and others prefixed with z - g = true, -- bindings for prefixed with g - }, - }, - -- add operators that will trigger motion and text object completion - -- to enable all native operators, set the preset / operators plugin above - -- operators = { gc = "Comments" }, - key_labels = { - -- override the label used to display some keys. It doesn't effect WK in any other way. - -- For example: - -- [""] = "SPC", - -- [""] = "RET", - -- [""] = "TAB", - }, - icons = { - breadcrumb = "»", -- symbol used in the command line area that shows your active key combo - separator = "➜", -- symbol used between a key and it's label - group = "+", -- symbol prepended to a group - }, - popup_mappings = { - scroll_down = "", -- binding to scroll down inside the popup - scroll_up = "", -- binding to scroll up inside the popup - }, - window = { - border = "rounded", -- none, single, double, shadow - position = "bottom", -- bottom, top - margin = { 1, 0, 1, 0 }, -- extra window margin [top, right, bottom, left] - padding = { 2, 2, 2, 2 }, -- extra window padding [top, right, bottom, left] - winblend = 0, - }, - layout = { - height = { min = 4, max = 25 }, -- min and max height of the columns - width = { min = 20, max = 50 }, -- min and max width of the columns - spacing = 3, -- spacing between columns - align = "left", -- align columns left, center or right - }, - ignore_missing = true, -- enable this to hide mappings for which you didn't specify a label - hidden = { "", "", "", "", "call", "lua", "^:", "^ " }, -- hide mapping boilerplate - show_help = true, -- show help message on the command line when the popup is visible - triggers = "auto", -- automatically setup triggers - -- triggers = {""} -- or specify a list manually - triggers_blacklist = { - -- list of mode / prefixes that should never be hooked by WhichKey - -- this is mostly relevant for key maps that start with a native binding - -- most people should not need to change this - i = { "j", "k" }, - v = { "j", "k" }, - }, -} - -local opts = { - mode = "n", -- NORMAL mode - prefix = "", - buffer = nil, -- Global mappings. Specify a buffer number for buffer local mappings - silent = true, -- use `silent` when creating keymaps - noremap = true, -- use `noremap` when creating keymaps - nowait = true, -- use `nowait` when creating keymaps -} - -local mappings = { - ["a"] = { "Alpha", "Alpha" }, - ["b"] = { - "lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})", - "Buffers", - }, - ["e"] = { "NvimTreeToggle", "Explorer" }, - ["w"] = { "w!", "Save" }, - ["q"] = { "q!", "Quit" }, - ["c"] = { "Bdelete!", "Close Buffer" }, - ["h"] = { "nohlsearch", "No Highlight" }, - ["f"] = { - "lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})", - "Find files", - }, - ["F"] = { "Telescope live_grep theme=ivy", "Find Text" }, - ["P"] = { "lua require('telescope').extensions.projects.projects()", "Projects" }, - - p = { - name = "Packer", - c = { "PackerCompile", "Compile" }, - i = { "PackerInstall", "Install" }, - s = { "PackerSync", "Sync" }, - S = { "PackerStatus", "Status" }, - u = { "PackerUpdate", "Update" }, - }, - - g = { - name = "Git", - g = { "lua _LAZYGIT_TOGGLE()", "Lazygit" }, - j = { "lua require 'gitsigns'.next_hunk()", "Next Hunk" }, - k = { "lua require 'gitsigns'.prev_hunk()", "Prev Hunk" }, - l = { "lua require 'gitsigns'.blame_line()", "Blame" }, - p = { "lua require 'gitsigns'.preview_hunk()", "Preview Hunk" }, - r = { "lua require 'gitsigns'.reset_hunk()", "Reset Hunk" }, - R = { "lua require 'gitsigns'.reset_buffer()", "Reset Buffer" }, - s = { "lua require 'gitsigns'.stage_hunk()", "Stage Hunk" }, - u = { - "lua require 'gitsigns'.undo_stage_hunk()", - "Undo Stage Hunk", - }, - o = { "Telescope git_status", "Open changed file" }, - b = { "Telescope git_branches", "Checkout branch" }, - c = { "Telescope git_commits", "Checkout commit" }, - d = { - "Gitsigns diffthis HEAD", - "Diff", - }, - }, - - l = { - name = "LSP", - a = { "lua vim.lsp.buf.code_action()", "Code Action" }, - d = { - "Telescope lsp_document_diagnostics", - "Document Diagnostics", - }, - w = { - "Telescope lsp_workspace_diagnostics", - "Workspace Diagnostics", - }, - f = { "lua vim.lsp.buf.format{async=true}", "Format" }, - i = { "LspInfo", "Info" }, - I = { "LspInstallInfo", "Installer Info" }, - j = { - "lua vim.lsp.diagnostic.goto_next()", - "Next Diagnostic", - }, - k = { - "lua vim.lsp.diagnostic.goto_prev()", - "Prev Diagnostic", - }, - l = { "lua vim.lsp.codelens.run()", "CodeLens Action" }, - q = { "lua vim.lsp.diagnostic.set_loclist()", "Quickfix" }, - r = { "lua vim.lsp.buf.rename()", "Rename" }, - s = { "Telescope lsp_document_symbols", "Document Symbols" }, - S = { - "Telescope lsp_dynamic_workspace_symbols", - "Workspace Symbols", - }, - }, - s = { - name = "Search", - b = { "Telescope git_branches", "Checkout branch" }, - c = { "Telescope colorscheme", "Colorscheme" }, - h = { "Telescope help_tags", "Find Help" }, - M = { "Telescope man_pages", "Man Pages" }, - r = { "Telescope oldfiles", "Open Recent File" }, - R = { "Telescope registers", "Registers" }, - k = { "Telescope keymaps", "Keymaps" }, - C = { "Telescope commands", "Commands" }, - }, - - t = { - name = "Terminal", - n = { "lua _NODE_TOGGLE()", "Node" }, - u = { "lua _NCDU_TOGGLE()", "NCDU" }, - t = { "lua _HTOP_TOGGLE()", "Htop" }, - p = { "lua _PYTHON_TOGGLE()", "Python" }, - f = { "ToggleTerm direction=float", "Float" }, - h = { "ToggleTerm size=10 direction=horizontal", "Horizontal" }, - v = { "ToggleTerm size=80 direction=vertical", "Vertical" }, - }, -} - -which_key.setup(setup) -which_key.register(mappings, opts) -