diff --git a/init.lua b/init.lua index 306a93a..0284025 100644 --- a/init.lua +++ b/init.lua @@ -2,7 +2,7 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " -- If possible use 24 Bit Colors -if vim.fn.has('termguicolors') == 1 then +if vim.fn.has("termguicolors") == 1 then vim.o.termguicolors = true end @@ -187,7 +187,7 @@ require("lazy").setup({ keymap("n", "hu", "Gitsigns undo_stage_hunk", "[h]unk [u]ndo stage") keymap("n", "hR", "Gitsigns reset_buffer", "[h]unk [R]eset buffer") keymap("n", "hp", "Gitsigns preview_hunk", "[h]unk [p]review") - keymap("n", 'ht', 'Gitsigns toggle_deleted', "[h]unk [t]oggle deleted") + keymap("n", "ht", "Gitsigns toggle_deleted", "[h]unk [t]oggle deleted") end }, }, @@ -402,12 +402,12 @@ require("lazy").setup({ -- TODO: Setup DAP -- use { "mfussenegger/nvim-dap", config_name="dap" } - -- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require('dapui').setup()]] } - -- use 'simrat39/rust-tools.nvim' + -- use { "rcarriga/nvim-dap-ui", requires = "mfussenegger/nvim-dap", config=[[require("dapui").setup()]] } + -- use "simrat39/rust-tools.nvim" -- use { - -- 'theHamsta/nvim-dap-virtual-text', + -- "theHamsta/nvim-dap-virtual-text", -- requires = {"mfussenegger/nvim-dap", "nvim-treesitter/nvim-treesitter"}, - -- config=[[require('nvim-dap-virtual-text')]] + -- config=[[require("nvim-dap-virtual-text")]] -- } { @@ -464,7 +464,7 @@ do -- pattern = {"*"}, -- callback = function() -- -- TODO: Port this to lua - -- vim.cmd [[if mode() != 'c' | checktime | endif]] + -- vim.cmd [[if mode() != "c" | checktime | endif]] -- end -- }) -- vim.api.nvim_create_autocmd({"FileChangedShellPost"}, { @@ -476,7 +476,7 @@ do -- end -- }) -- autocmd("auto-reload", { - -- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif]], + -- [[FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != "c" | checktime | endif]], -- [[FileChangedShellPost * echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None]] -- }, true) end @@ -489,7 +489,7 @@ do vim.g.zig_fmt_autosave = 0 -- Folding options - vim.o.foldmethod = 'indent' + vim.o.foldmethod = "indent" vim.o.foldlevelstart = 99 -- Identation/Tab settings @@ -540,13 +540,13 @@ do vim.wo.relativenumber = true -- Enable mouse mode - vim.o.mouse = 'a' + vim.o.mouse = "a" -- Skip redrawing window while executing macro vim.o.lazyredraw = true -- Sync clipboard between OS and Neovim. - vim.o.clipboard = 'unnamedplus' + vim.o.clipboard = "unnamedplus" -- Enable break indent vim.o.breakindent = true @@ -555,7 +555,7 @@ do vim.o.undofile = true -- Keep signcolumn on by default - vim.wo.signcolumn = 'yes' + vim.wo.signcolumn = "yes" -- Decrease update time vim.o.updatetime = 250 @@ -565,14 +565,14 @@ do vim.o.splitbelow = true vim.o.splitright = true - -- By default don't wrap text + -- By default don"t wrap text vim.o.wrap = false -- Remove cmdline when not used vim.o.cmdheight = 0 -- Set completeopt to have a better completion experience - vim.o.completeopt = 'menuone,noselect' + vim.o.completeopt = "menuone,noselect" -- Scale neovide a bit if vim.g.neovide then @@ -586,31 +586,31 @@ end do -- Keymaps for better default experience -- See `:help vim.keymap.set()` - vim.keymap.set({ 'n', 'v' }, '', '', { silent = true }) + vim.keymap.set({ "n", "v" }, "", "", { silent = true }) -- Remap for dealing with word wrap - vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) - vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + vim.keymap.set("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) + vim.keymap.set("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) -- Better movement between tabs - vim.keymap.set('n', '', ':tabprevious', { silent = true }) - vim.keymap.set('n', '', ':tabnext', { silent = true }) + vim.keymap.set("n", "", ":tabprevious", { silent = true }) + vim.keymap.set("n", "", ":tabnext", { silent = true }) -- Better indenting - vim.keymap.set('v', '<', '', '>gv') + vim.keymap.set("v", "<", "", ">gv") -- Save file - vim.keymap.set('n', '', ':w', { silent = true }) + vim.keymap.set("n", "", ":w", { silent = true }) -- Disable Ex mode - vim.keymap.set('n', 'Q', '') + vim.keymap.set("n", "Q", "") -- Window movement - vim.keymap.set('n', '', 'h') - vim.keymap.set('n', '', 'j') - vim.keymap.set('n', '', 'k') - vim.keymap.set('n', '', 'l') + vim.keymap.set("n", "", "h") + vim.keymap.set("n", "", "j") + vim.keymap.set("n", "", "k") + vim.keymap.set("n", "", "l") end -- Change c file comment string @@ -642,23 +642,23 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { -- Move between windows easier in terminal windows function _G.set_terminal_keymaps() local opts = {buffer = 0} - vim.keymap.set('t', '', [[]], opts) - vim.keymap.set('t', '', [[wincmd h]], opts) - vim.keymap.set('t', '', [[wincmd j]], opts) - vim.keymap.set('t', '', [[wincmd k]], opts) - vim.keymap.set('t', '', [[wincmd l]], opts) + vim.keymap.set("t", "", [[]], opts) + vim.keymap.set("t", "", [[wincmd h]], opts) + vim.keymap.set("t", "", [[wincmd j]], opts) + vim.keymap.set("t", "", [[wincmd k]], opts) + vim.keymap.set("t", "", [[wincmd l]], opts) end -vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') +vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()") -- [[ Highlight on yank ]] -- See `:help vim.highlight.on_yank()` -local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) -vim.api.nvim_create_autocmd('TextYankPost', { +local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) +vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank() end, group = highlight_group, - pattern = '*', + pattern = "*", }) -- Add abbreviation for != => ~= in lua files @@ -672,7 +672,7 @@ vim.api.nvim_create_autocmd("BufEnter", { -- [[ Configure Treesitter ]] -- See `:help nvim-treesitter` --- Defer Treesitter setup after first render to improve startup time of 'nvim {filename}' +-- Defer Treesitter setup after first render to improve startup time of "nvim {filename}" vim.defer_fn(function() require("nvim-treesitter.configs").setup { -- Add languages to be installed here that you want installed for treesitter @@ -740,65 +740,65 @@ vim.defer_fn(function() end, 0) -- Diagnostic keymaps -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) ---vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous diagnostic message" }) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next diagnostic message" }) +vim.keymap.set("n", "dm", vim.diagnostic.open_float, { desc = "Open floating diagnostic message" }) +vim.keymap.set("n", "q", vim.diagnostic.setloclist, { desc = "Open diagnostics list" }) -- [[ Configure LSP ]] -- This function gets run when an LSP connects to a particular buffer. local on_attach = function(_, bufnr) -- NOTE: Remember that lua is a real programming language, and as such it is possible - -- to define small helper and utility functions so you don't have to repeat yourself + -- to define small helper and utility functions so you don"t have to repeat yourself -- many times. -- -- In this case, we create a function that lets us more easily define mappings specific -- for LSP related items. It sets the mode, buffer and description for us each time. local nmap = function(keys, func, desc) if desc then - desc = 'LSP: ' .. desc + desc = "LSP: " .. desc end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") + nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') - nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') - nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') - nmap('ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") + nmap("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") + nmap("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") + nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") + nmap("ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") + nmap("ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - --nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + --nmap("", vim.lsp.buf.signature_help, "Signature Documentation") -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + nmap("wl", function() print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') + end, "[W]orkspace [L]ist Folders") -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) + end, { desc = "Format current buffer with LSP" }) end -- document existing key chains -require('which-key').register({ - ['c'] = { name = '[C]ode', _ = 'which_key_ignore' }, - ['d'] = { name = '[D]ocument', _ = 'which_key_ignore' }, - ['g'] = { name = '[G]it', _ = 'which_key_ignore' }, - ['h'] = { name = 'More git', _ = 'which_key_ignore' }, - ['r'] = { name = '[R]ename', _ = 'which_key_ignore' }, - ['s'] = { name = '[S]earch', _ = 'which_key_ignore' }, - ['w'] = { name = '[W]orkspace', _ = 'which_key_ignore' }, +require("which-key").register({ + ["c"] = { name = "[C]ode", _ = "which_key_ignore" }, + ["d"] = { name = "[D]ocument", _ = "which_key_ignore" }, + ["g"] = { name = "[G]it", _ = "which_key_ignore" }, + ["h"] = { name = "More git", _ = "which_key_ignore" }, + ["r"] = { name = "[R]ename", _ = "which_key_ignore" }, + ["s"] = { name = "[S]earch", _ = "which_key_ignore" }, + ["w"] = { name = "[W]orkspace", _ = "which_key_ignore" }, }) -- Enable the following language servers @@ -808,14 +808,14 @@ require('which-key').register({ -- the `settings` field of the server config. You must look up that documentation yourself. -- -- If you want to override the default filetypes that your language server will attach to you can --- define the property 'filetypes' to the map in question. +-- define the property "filetypes" to the map in question. local servers = { -- clangd = {}, -- gopls = {}, -- pyright = {}, -- rust_analyzer = {}, -- tsserver = {}, - -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + -- html = { filetypes = { "html", "twig", "hbs"} }, lua_ls = { Lua = { @@ -826,14 +826,14 @@ local servers = { } -- Setup neovim lua configuration -require('neodev').setup() +require("neodev").setup() -- nvim-cmp supports additional completion capabilities, so broadcast that to servers local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) +capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) -- Ensure the servers above are installed -local mason_lspconfig = require 'mason-lspconfig' +local mason_lspconfig = require "mason-lspconfig" mason_lspconfig.setup { ensure_installed = vim.tbl_keys(servers), @@ -841,7 +841,7 @@ mason_lspconfig.setup { mason_lspconfig.setup_handlers { function(server_name) - require('lspconfig')[server_name].setup { + require("lspconfig")[server_name].setup { capabilities = capabilities, on_attach = on_attach, settings = servers[server_name], @@ -852,12 +852,12 @@ mason_lspconfig.setup_handlers { -- [[ Configure nvim-cmp ]] -- See `:help cmp` -local cmp = require 'cmp' -local luasnip = require 'luasnip' -require('luasnip.loaders.from_vscode').lazy_load() +local cmp = require "cmp" +local luasnip = require "luasnip" +require("luasnip.loaders.from_vscode").lazy_load() luasnip.config.setup {} -local lspkind = require('lspkind') +local lspkind = require("lspkind") lspkind.init() cmp.setup { @@ -867,16 +867,16 @@ cmp.setup { end, }, mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete {}, + [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = true, }, - [''] = cmp.mapping(function(fallback) + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then @@ -884,8 +884,8 @@ cmp.setup { else fallback() end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.locally_jumpable(-1) then @@ -893,13 +893,13 @@ cmp.setup { else fallback() end - end, { 'i', 's' }), + end, { "i", "s" }), }, sources = { - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, - { name = 'buffer', max_item_count = 10, keyword_length = 5 }, + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer", max_item_count = 10, keyword_length = 5 }, }, formatting = { format = lspkind.cmp_format{ with_text = true } @@ -911,9 +911,9 @@ cmp.setup { } -- Use buffer source for `/`. -cmp.setup.cmdline('/', { +cmp.setup.cmdline("/", { sources = { - { name = 'buffer' } + { name = "buffer" } } }) diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index 1c9faf3..7a07661 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -32,57 +32,57 @@ return { return stdout end - ls.config.set_config { - history = true, - updateevents = "TextChanged,TextChangedI", - enable_autosnippets = true - } + -- ls.config.set_config { + -- history = true, + -- updateevents = "TextChanged,TextChangedI", + -- enable_autosnippets = true + -- } - vim.keymap.set({"i", "s"}, "", function() - if ls.expand_or_jumpable() then - ls.expand_or_jump() - end - end, { silent = true }) + -- vim.keymap.set({"i", "s"}, "", function() + -- if ls.expand_or_jumpable() then + -- ls.expand_or_jump() + -- end + -- end, { silent = true }) - vim.keymap.set({ "i", "s" }, "", function() - if ls.jumpable(-1) then ls.jump(-1) end - end, { silent = -1 }) + -- vim.keymap.set({ "i", "s" }, "", function() + -- if ls.jumpable(-1) then ls.jump(-1) end + -- end, { silent = -1 }) - vim.keymap.set({"i"}, "", function() - if ls.choice_active() then ls.change_choice(1) end - end) + -- vim.keymap.set({"i"}, "", function() + -- if ls.choice_active() then ls.change_choice(1) end + -- end) ls.add_snippets("all", { s("MIT", { - t({"The MIT License (MIT)", "Copyright © "}), - f(getCurrentYear, {}), - t(" "), - d(1, function() - return sn(nil, { - i(1, getGitUsername() or "") - }) - end, {}), - t{ - "", - "", - "Permission is hereby granted, free of charge, to any person obtaining a copy of", - "this software and associated documentation files (the “Software”), to deal in", - "the Software without restriction, including without limitation the rights to", - "use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies", - "of the Software, and to permit persons to whom the Software is furnished to do", - "so, subject to the following conditions:", - "", - "The above copyright notice and this permission notice shall be included in all", - "copies or substantial portions of the Software.", - "", - "THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", - "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", - "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", - "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", - "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", - "SOFTWARE.", - } + t({"The MIT License (MIT)", "Copyright © "}), + f(getCurrentYear, {}), + t(" "), + d(1, function() + return sn(nil, { + i(1, getGitUsername() or "") + }) + end, {}), + t{ + "", + "", + "Permission is hereby granted, free of charge, to any person obtaining a copy of", + "this software and associated documentation files (the “Software”), to deal in", + "the Software without restriction, including without limitation the rights to", + "use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies", + "of the Software, and to permit persons to whom the Software is furnished to do", + "so, subject to the following conditions:", + "", + "The above copyright notice and this permission notice shall be included in all", + "copies or substantial portions of the Software.", + "", + "THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE", + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", + "SOFTWARE.", + } }) }) end