diff --git a/init.lua b/init.lua index dd3a308..6d6590a 100644 --- a/init.lua +++ b/init.lua @@ -1,18 +1,18 @@ local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) -require('options') -require('lazy').setup('plugins') -require('mappings') -require('lsp_settings') -require('autocmds') +require("options") +require("lazy").setup("plugins") +require("mappings") +require("lsp_settings") +require("autocmds") diff --git a/lua/autocmds.lua b/lua/autocmds.lua index caa25a8..b99a084 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -3,143 +3,148 @@ local autocmd = vim.api.nvim_create_autocmd -- Create autocommand local _group = vim.api.nvim_create_augroup("LineNumber", { clear = true }) local function relativeln(target) - if vim.b.lnstatus == nil then - vim.b.lnstatus = "number" - end + if vim.b.lnstatus == nil then + vim.b.lnstatus = "number" + end - if vim.b.lnstatus ~= "nonumber" then - if target == "number" then - vim.o.number = true - vim.o.relativenumber = false - else - vim.o.number = true - vim.o.relativenumber = true - end - else - vim.o.number = false - end + if vim.b.lnstatus ~= "nonumber" then + if target == "number" then + vim.o.number = true + vim.o.relativenumber = false + else + vim.o.number = true + vim.o.relativenumber = true + end + else + vim.o.number = false + end end autocmd("InsertEnter", { - pattern = "*", - callback = function() - relativeln("number") - end, - once = false, - group = _group, + pattern = "*", + callback = function() + relativeln("number") + end, + once = false, + group = _group, }) autocmd("InsertLeave", { - pattern = "*", - callback = function() - relativeln("relativenumber") - end, - once = false, - group = _group, + pattern = "*", + callback = function() + relativeln("relativenumber") + end, + once = false, + group = _group, }) autocmd("FocusLost", { - pattern = "*", - callback = function() - relativeln("number") - end, - once = false, - group = _group, + pattern = "*", + callback = function() + relativeln("number") + end, + once = false, + group = _group, }) autocmd("CursorMoved", { - pattern = "*", - callback = function() - relativeln("relativenumber") - end, - once = false, - group = _group, + pattern = "*", + callback = function() + relativeln("relativenumber") + end, + once = false, + group = _group, }) -local nvim_tree_events = require('nvim-tree.events') -local bufferline_api = require('bufferline.api') +vim.cmd([[ +:augroup fmt +: autocmd! +: autocmd BufWritePre * silent! undojoin | silent! Neoformat +:augroup END +]]) + +local nvim_tree_events = require("nvim-tree.events") +local bufferline_api = require("bufferline.api") local function get_tree_size() - return require 'nvim-tree.view'.View.width + return require("nvim-tree.view").View.width end -nvim_tree_events.subscribe('TreeOpen', function() - bufferline_api.set_offset(get_tree_size()) +nvim_tree_events.subscribe("TreeOpen", function() + bufferline_api.set_offset(get_tree_size()) end) -nvim_tree_events.subscribe('Resize', function() - bufferline_api.set_offset(get_tree_size()) +nvim_tree_events.subscribe("Resize", function() + bufferline_api.set_offset(get_tree_size()) end) -nvim_tree_events.subscribe('TreeClose', function() - bufferline_api.set_offset(0) +nvim_tree_events.subscribe("TreeClose", function() + bufferline_api.set_offset(0) end) -- change tmux title autocmd("BufReadPost", { - pattern = "*", - callback = function() - vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) - end, - once = false, - group = _group, + pattern = "*", + callback = function() + vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) + end, + once = false, + group = _group, }) autocmd("FileReadPost", { - pattern = "*", - callback = function() - vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) - end, - once = false, - group = _group, + pattern = "*", + callback = function() + vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) + end, + once = false, + group = _group, }) autocmd("BufNewFile", { - pattern = "*", - callback = function() - vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) - end, - once = false, - group = _group, + pattern = "*", + callback = function() + vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) + end, + once = false, + group = _group, }) autocmd("BufEnter", { - pattern = "*", - callback = function() - vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) - end, - once = false, - group = _group, + pattern = "*", + callback = function() + vim.cmd([[call system("tmux rename-window '" . expand("%:t") . "'")]]) + end, + once = false, + group = _group, }) -- auto close nvimtree -autocmd('BufEnter', { - command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif", - nested = true, +autocmd("BufEnter", { + command = "if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif", + nested = true, }) - -- dont show line numbers for nvimtree buffers -autocmd("BufEnter", - { - pattern = { "NvimTree*" }, - callback = function() - vim.b.lnstatus = "nonumber" - end - }) +autocmd("BufEnter", { + pattern = { "NvimTree*" }, + callback = function() + vim.b.lnstatus = "nonumber" + end, +}) -- Disable the statusline, tabline and cmdline while the alpha dashboard is open -autocmd('User', { - pattern = 'AlphaReady', - desc = 'disable status, tabline and cmdline for alpha', - callback = function() - vim.go.laststatus = 1 - vim.opt.showtabline = 1 - vim.opt.cmdheight = 1 - end, +autocmd("User", { + pattern = "AlphaReady", + desc = "disable status, tabline and cmdline for alpha", + callback = function() + vim.go.laststatus = 1 + vim.opt.showtabline = 1 + vim.opt.cmdheight = 1 + end, }) -autocmd('BufUnload', { - buffer = 0, - desc = 'enable status, tabline and cmdline after alpha', - callback = function() - vim.go.laststatus = 2 - vim.opt.showtabline = 2 - vim.opt.cmdheight = 1 - end, +autocmd("BufUnload", { + buffer = 0, + desc = "enable status, tabline and cmdline after alpha", + callback = function() + vim.go.laststatus = 2 + vim.opt.showtabline = 2 + vim.opt.cmdheight = 1 + end, }) diff --git a/lua/lsp_settings.lua b/lua/lsp_settings.lua index df19941..4319572 100644 --- a/lua/lsp_settings.lua +++ b/lua/lsp_settings.lua @@ -1,116 +1,116 @@ -require("mason").setup { - automatic_installation = true -} +require("mason").setup({ + automatic_installation = true, +}) -- Setup lspconfig. -local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities()) +local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) local navic = require("nvim-navic") -- LSP hotkey config local opts = { noremap = true, silent = true } -vim.keymap.set('n', 'e', vim.diagnostic.open_float, opts) -vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts) -vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts) -vim.keymap.set('n', 'q', vim.diagnostic.setloclist, opts) +vim.keymap.set("n", "e", vim.diagnostic.open_float, opts) +vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) +vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) +vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) -- 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) - if client.server_capabilities.documentSymbolProvider then - navic.attach(client, bufnr) - end - vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + if client.server_capabilities.documentSymbolProvider then + navic.attach(client, bufnr) + end + -- vim.cmd [[autocmd BufWritePre * lua vim.lsp.buf.format()]] + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) - vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) - vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) - vim.keymap.set('n', '', vim.lsp.buf.signature_help, bufopts) - vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set('n', 'wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'f', vim.lsp.buf.formatting, bufopts) + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts) + vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts) + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) + vim.keymap.set("n", "f", vim.lsp.buf.formatting, bufopts) end local lsp_flags = { - -- This is the default in Nvim 0.7+ - debounce_text_changes = 150, + -- This is the default in Nvim 0.7+ + debounce_text_changes = 150, } --- initialize language servers -require('mason-lspconfig').setup() -require('mason-lspconfig').setup_handlers { - function(server_name) - require("lspconfig")[server_name].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - settings = { - Lua = { - completion = { - callSnippet = 'Replace', - }, - diagnostics = { - globals = { 'vim' } - } - }, - } - } - require("lspconfig")['tsserver'].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - settings = { - typescript = { - format = { - insertSpaceAfterOpeningAndBeforeClosingEmptyBraces = false, - insertSpaceAfterFunctionKeywordForAnonymousFunctions = true, - semicolons = 'remove', - }, - }, - }, - } - require("lspconfig")['pylsp'].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - settings = { - pylsp = { - plugins = { - pycodestyle = { - maxLineLength = 120 - } - } - } - } - } - require("lspconfig")['gopls'].setup { - on_attach = on_attach, - flags = lsp_flags, - capabilities = capabilities, - settings = { - gopls = { - experimentalPostfixCompletions = true, - gofumpt = true, - analyses = { - nilness = true, - unusedwrite = true, - unusedvariable = true, - }, - staticcheck = true, - } - }, - } - end -} +require("mason-lspconfig").setup() +require("mason-lspconfig").setup_handlers({ + function(server_name) + require("lspconfig")[server_name].setup({ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, + settings = { + Lua = { + completion = { + callSnippet = "Replace", + }, + diagnostics = { + globals = { "vim" }, + }, + }, + }, + }) + require("lspconfig")["tsserver"].setup({ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, + settings = { + typescript = { + format = { + insertSpaceAfterOpeningAndBeforeClosingEmptyBraces = false, + insertSpaceAfterFunctionKeywordForAnonymousFunctions = true, + semicolons = "remove", + }, + }, + }, + }) + require("lspconfig")["pylsp"].setup({ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, + settings = { + pylsp = { + plugins = { + pycodestyle = { + maxLineLength = 120, + }, + }, + }, + }, + }) + require("lspconfig")["gopls"].setup({ + on_attach = on_attach, + flags = lsp_flags, + capabilities = capabilities, + settings = { + gopls = { + experimentalPostfixCompletions = true, + gofumpt = true, + analyses = { + nilness = true, + unusedwrite = true, + unusedvariable = true, + }, + staticcheck = true, + }, + }, + }) + end, +}) diff --git a/lua/mappings.lua b/lua/mappings.lua index d7fe768..915839e 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,4 +1,4 @@ -local vimp = require('vimp') +local vimp = require("vimp") -- tabs and stuff vimp.vnoremap("", [[]]) @@ -13,34 +13,34 @@ vimp.xnoremap("<", [[", [[>gv]]) -- Toggle Lines -vimp.nnoremap({ 'silent' }, 'l', function() - if vim.b.lnstatus == nil then - vim.b.lnstatus = "number" - end - if vim.b.lnstatus == "number" then - vim.o.number = false - vim.o.relativenumber = false - vim.b.lnstatus = "nonumber" - else - vim.o.number = true - vim.o.relativenumber = true - vim.b.lnstatus = "number" - end +vimp.nnoremap({ "silent" }, "l", function() + if vim.b.lnstatus == nil then + vim.b.lnstatus = "number" + end + if vim.b.lnstatus == "number" then + vim.o.number = false + vim.o.relativenumber = false + vim.b.lnstatus = "nonumber" + else + vim.o.number = true + vim.o.relativenumber = true + vim.b.lnstatus = "number" + end end) -- plugins -vimp.noremap('md', [[:MarkdownPreviewToggle]]) +vimp.noremap("md", [[:MarkdownPreviewToggle]]) -vimp.nnoremap({ 'silent' }, '', [[:BufferNext]]) -vimp.nnoremap({ 'silent' }, '', [[:BufferPrevious]]) +vimp.nnoremap({ "silent" }, "", [[:BufferNext]]) +vimp.nnoremap({ "silent" }, "", [[:BufferPrevious]]) +vimp.nnoremap({ "silent" }, "a", [[:ArgWrap]]) -vimp.nnoremap({ 'silent' }, 'a', [[:ArgWrap]]) +vimp.noremap({ "silent" }, "n", [[:NvimTreeToggle]]) - -vimp.noremap({ 'silent' }, 'n', [[:NvimTreeToggle]]) - -vimp.noremap({ 'silent' }, 'ff', [[:Telescope find_files]]) -vimp.noremap({ 'silent' }, 'fg', [[:Telescope live_grep]]) -vimp.noremap({ 'silent' }, 'fb', [[:Telescope buffers]]) -vimp.noremap({ 'silent' }, 'fp', function() require 'telescope'.extensions.projects.projects {} end) +vimp.noremap({ "silent" }, "ff", [[:Telescope find_files]]) +vimp.noremap({ "silent" }, "fg", [[:Telescope live_grep]]) +vimp.noremap({ "silent" }, "fb", [[:Telescope buffers]]) +vimp.noremap({ "silent" }, "fp", function() + require("telescope").extensions.projects.projects({}) +end) diff --git a/lua/options.lua b/lua/options.lua index 775d312..74e3771 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -13,11 +13,11 @@ vim.o.mmp = 5000 -- don't give |ins-completion-menu| messages. vim.o.hidden = true -vim.o.signcolumn = 'yes' -vim.o.encoding = 'utf-8' -vim.o.shortmess = 'c' +vim.o.signcolumn = "yes" +vim.o.encoding = "utf-8" +vim.o.shortmess = "c" vim.o.autoread = true -vim.o.backspace = 'indent,eol,start' +vim.o.backspace = "indent,eol,start" vim.o.ruler = true vim.o.showmode = true vim.o.history = 1000 @@ -35,24 +35,24 @@ vim.o.softtabstop = 2 vim.o.tabstop = 2 vim.o.expandtab = true vim.o.scrolloff = 5 -vim.o.foldmethod = 'indent' +vim.o.foldmethod = "indent" vim.o.foldlevel = 99 vim.wo.wrap = false vim.o.showcmd = true vim.o.number = true vim.o.relativenumber = true -vim.o.mouse = 'a' +vim.o.mouse = "a" vim.o.redrawtime = 10000 -vim.o.inccommand = 'split' +vim.o.inccommand = "split" ---- Sync " and + registers -vim.o.clipboard = 'unnamedplus' +vim.o.clipboard = "unnamedplus" -- show completion options on vim.o.wildmenu = true -- complete only up to the point of ambiguity -vim.o.wildmode = 'list:longest' +vim.o.wildmode = "list:longest" -vim.opt.backupdir = os.getenv("XDG_CACHE_HOME") .. '/nvim/backup//' -vim.o.directory = os.getenv("XDG_CACHE_HOME") .. '/nvim/swap//' -vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. '/nvim/undo//' +vim.opt.backupdir = os.getenv("XDG_CACHE_HOME") .. "/nvim/backup//" +vim.o.directory = os.getenv("XDG_CACHE_HOME") .. "/nvim/swap//" +vim.o.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo//" vim.o.undofile = true diff --git a/lua/plugins.lua b/lua/plugins.lua index 64dc85d..7865af7 100644 --- a/lua/plugins.lua +++ b/lua/plugins.lua @@ -1,534 +1,515 @@ return { - -- https://github.com/tpope/vim-obsession - 'tpope/vim-obsession', + -- https://github.com/tpope/vim-obsession + "tpope/vim-obsession", - -- https://github.com/svermeulen/vimpeccable - 'svermeulen/vimpeccable', + -- https://github.com/svermeulen/vimpeccable + "svermeulen/vimpeccable", - -- https://github.com/kien/ctrlp.vim - 'ctrlpvim/ctrlp.vim', + -- https://github.com/kien/ctrlp.vim + "ctrlpvim/ctrlp.vim", - -- https://github.com/lervag/vimtex#installation - 'lervag/vimtex', + -- https://github.com/lervag/vimtex#installation + "lervag/vimtex", - -- https://github.com/iamcco/markdown-preview.nvim - { - "iamcco/markdown-preview.nvim", - run = function() - vim.fn["mkdp#util#install"]() - end, - config = function() - vim.g.mkdp_filetypes = { "markdown" } - vim.g.mkdp_markdown_css = os.getenv("XDG_CONFIG_HOME") .. '/nvim/static/custom.css' - vim.g.mkdp_highlight_css = os.getenv("XDG_CACHE_HOME") .. '/wal/colors.css' - vim.g.mkdp_browser = 'rose' - vim.g.mkdp_echo_preview_url = 1 - end, - ft = { "markdown" } - }, + -- https://github.com/iamcco/markdown-preview.nvim + { + "iamcco/markdown-preview.nvim", + run = function() + vim.fn["mkdp#util#install"]() + end, + config = function() + vim.g.mkdp_filetypes = { "markdown" } + vim.g.mkdp_markdown_css = os.getenv("XDG_CONFIG_HOME") .. "/nvim/static/custom.css" + vim.g.mkdp_highlight_css = os.getenv("XDG_CACHE_HOME") .. "/wal/colors.css" + vim.g.mkdp_browser = "rose" + vim.g.mkdp_echo_preview_url = 1 + end, + ft = { "markdown" }, + }, - { - 'windwp/nvim-spectre', - dependencies = { 'nvim-lua/plenary.nvim' }, - }, + { + "windwp/nvim-spectre", + dependencies = { "nvim-lua/plenary.nvim" }, + }, - { - 'MunifTanjim/prettier.nvim', - config = function() - local prettier = require("prettier") + { + "sbdchd/neoformat", + }, - prettier.setup({ - bin = 'prettierd', -- or `'prettierd'` (v0.23.3+) - filetypes = { - "css", - "graphql", - "html", - "javascript", - "javascriptreact", - "json", - "less", - "markdown", - "scss", - "typescript", - "typescriptreact", - "yaml", - }, - }) - end - }, + { + "simrat39/rust-tools.nvim", + config = function() + local rt = require("rust-tools") + rt.setup({ + server = { + on_attach = function(_, bufnr) + -- Hover actions + vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) + -- Code action groups + vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + end, + }, + }) + end, + }, - { - 'simrat39/rust-tools.nvim', - config = function() - local rt = require("rust-tools") - rt.setup({ - server = { - on_attach = function(_, bufnr) - -- Hover actions - vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - -- Code action groups - vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) - end, - }, - }) - end - }, + { + "ray-x/web-tools.nvim", + config = function() + require("web-tools").setup({ + keymaps = { + rename = nil, -- by default use same setup of lspconfig + repeat_rename = ".", -- . to repeat + }, + hurl = { + -- hurl default + show_headers = false, -- do not show http headers + floating = false, -- use floating windows (need guihua.lua) + formatters = { + -- format the result by filetype + json = { "jq" }, + html = { "prettier", "--parser", "html" }, + }, + }, + }) + end, + }, - { - 'ray-x/web-tools.nvim', - config = function() - require 'web-tools'.setup({ - keymaps = { - rename = nil, -- by default use same setup of lspconfig - repeat_rename = '.', -- . to repeat - }, - hurl = { - -- hurl default - show_headers = false, -- do not show http headers - floating = false, -- use floating windows (need guihua.lua) - formatters = { - -- format the result by filetype - json = { 'jq' }, - html = { 'prettier', '--parser', 'html' }, - }, - }, - }) - end - }, + -- https://github.com/fatih/vim-go + { + "fatih/vim-go", + config = function() + vim.g.go_fmt_command = "gofumpt" + vim.g.go_fmt_fail_silently = 1 + vim.g.go_highlight_types = 1 + vim.g.go_highlight_fields = 1 + vim.g.go_highlight_functions = 1 + vim.g.go_highlight_function_calls = 1 + vim.g.go_highlight_operators = 1 + vim.g.go_highlight_extra_types = 1 + vim.g.go_highlight_build_constraints = 1 + vim.g.go_metalinter_command = "golangci-lint" + end, + }, - -- https://github.com/fatih/vim-go - { - 'fatih/vim-go', - config = function() - vim.g.go_fmt_command = "gofumpt" - vim.g.go_fmt_fail_silently = 1 - vim.g.go_highlight_types = 1 - vim.g.go_highlight_fields = 1 - vim.g.go_highlight_functions = 1 - vim.g.go_highlight_function_calls = 1 - vim.g.go_highlight_operators = 1 - vim.g.go_highlight_extra_types = 1 - vim.g.go_highlight_build_constraints = 1 - vim.g.go_metalinter_command = 'golangci-lint' - end - }, + -- https://github.com/norcalli/nvim-colorizer.lua + { + "norcalli/nvim-colorizer.lua", + config = function() + require("colorizer").setup() + end, + }, - -- https://github.com/norcalli/nvim-colorizer.lua - { - 'norcalli/nvim-colorizer.lua', - config = function() - require('colorizer').setup() - end, - }, + -- https://github.com/numToStr/Comment.nvim + { + "numToStr/Comment.nvim", + config = function() + require("Comment").setup() + end, + }, - -- https://github.com/numToStr/Comment.nvim - { - 'numToStr/Comment.nvim', - config = function() - require('Comment').setup() - end - }, + { + "ahmedkhalf/project.nvim", + config = function() + require("project_nvim").setup({}) + end, + }, - { - "ahmedkhalf/project.nvim", - config = function() - require("project_nvim").setup {} - end - }, + -- https://github.com/ellisonleao/glow.nvim + { + "ellisonleao/glow.nvim", + cmd = "Glow", + config = function() + require("glow").setup({}) + end, + ft = { "markdown" }, + }, + -- https://github.com/windwp/nvim-autopairs + { + "windwp/nvim-autopairs", + config = function() + require("nvim-autopairs").setup({}) + end, + }, - -- https://github.com/ellisonleao/glow.nvim - { - "ellisonleao/glow.nvim", - cmd = "Glow", - config = function() - require('glow').setup({}) - end, - ft = { "markdown" } - }, + -- https://github.com/lewis6991/gitsigns.nvim + { + "lewis6991/gitsigns.nvim", + config = function() + require("gitsigns").setup({ + current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 100, + ignore_whitespace = false, + }, + yadm = { + enable = true, + }, + }) + end, + }, - -- https://github.com/windwp/nvim-autopairs - { - 'windwp/nvim-autopairs', - config = function() - require('nvim-autopairs').setup {} - end, - }, + -- https://github.com/nvim-telescope/telescope.nvim + { + "nvim-telescope/telescope.nvim", + cmd = "Telescope", + branch = "0.1.x", + dependencies = { + { + "nvim-lua/plenary.nvim", + lazy = true, + }, + }, + config = function() + require("telescope").load_extension("projects") + end, + }, - -- https://github.com/lewis6991/gitsigns.nvim - { - 'lewis6991/gitsigns.nvim', - config = function() - require('gitsigns').setup({ - current_line_blame = true, -- Toggle with `:Gitsigns toggle_current_line_blame` - current_line_blame_opts = { - virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' - delay = 100, - ignore_whitespace = false, - }, - yadm = { - enable = true - }, - }) - end - }, + -- https://github.com/SmiteshP/nvim-navic + { + "SmiteshP/nvim-navic", + dependencies = "neovim/nvim-lspconfig", + config = function() + require("nvim-navic").setup({ + icons = { + File = " ", + Module = " ", + Namespace = " ", + Package = " ", + Class = " ", + Method = " ", + Property = " ", + Field = " ", + Constructor = " ", + Enum = "練", + Interface = "練", + Function = " ", + Variable = " ", + Constant = " ", + String = " ", + Number = " ", + Boolean = "◩ ", + Array = " ", + Object = " ", + Key = " ", + Null = "ﳠ ", + EnumMember = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + }, + highlight = false, + separator = " > ", + depth_limit = 0, + depth_limit_indicator = "..", + safe_output = true, + }) + end, + }, - -- https://github.com/nvim-telescope/telescope.nvim - { - 'nvim-telescope/telescope.nvim', - cmd = "Telescope", - branch = '0.1.x', - dependencies = { - { - 'nvim-lua/plenary.nvim', - lazy = true - }, - }, - config = function() - require('telescope').load_extension('projects') - end - }, + -- https://github.com/nvim-tree/nvim-tree.lua + { + "nvim-tree/nvim-tree.lua", + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + config = function() + require("nvim-tree").setup({ + sync_root_with_cwd = true, + respect_buf_cwd = true, + update_focused_file = { + enable = true, + update_root = true, + }, + sort_by = "case_sensitive", + view = { + adaptive_size = true, + }, + renderer = { + group_empty = true, + }, + filters = { + dotfiles = true, + }, + live_filter = { + always_show_folders = false, + }, + }) + end, + }, - -- https://github.com/SmiteshP/nvim-navic - { - "SmiteshP/nvim-navic", - dependencies = "neovim/nvim-lspconfig", - config = function() - require('nvim-navic').setup({ - icons = { - File = " ", - Module = " ", - Namespace = " ", - Package = " ", - Class = " ", - Method = " ", - Property = " ", - Field = " ", - Constructor = " ", - Enum = "練", - Interface = "練", - Function = " ", - Variable = " ", - Constant = " ", - String = " ", - Number = " ", - Boolean = "◩ ", - Array = " ", - Object = " ", - Key = " ", - Null = "ﳠ ", - EnumMember = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - }, - highlight = false, - separator = " > ", - depth_limit = 0, - depth_limit_indicator = "..", - safe_output = true - }) - end - }, + -- https://github.com/kylechui/nvim-surround + { + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end, + }, - -- https://github.com/nvim-tree/nvim-tree.lua - { - 'nvim-tree/nvim-tree.lua', - dependencies = { - 'nvim-tree/nvim-web-devicons' - }, - config = function() - require('nvim-tree').setup { - sync_root_with_cwd = true, - respect_buf_cwd = true, - update_focused_file = { - enable = true, - update_root = true - }, - sort_by = "case_sensitive", - view = { - adaptive_size = true, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = true, - }, - live_filter = { - always_show_folders = false, - }, - } - end - }, + -- https://github.com/ethanholz/nvim-lastplace + { + "ethanholz/nvim-lastplace", + config = function() + require("nvim-lastplace").setup({ + lastplace_open_folds = true, + }) + end, + }, - -- https://github.com/kylechui/nvim-surround - { - "kylechui/nvim-surround", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end - }, + -- https://github.com/mg979/vim-visual-multi + "mg979/vim-visual-multi", - -- https://github.com/ethanholz/nvim-lastplace - { - 'ethanholz/nvim-lastplace', - config = function() - require('nvim-lastplace').setup { - lastplace_open_folds = true - } - end - }, + -- https://github.com/FooSoft/vim-argwrap + { + "FooSoft/vim-argwrap", + }, - -- https://github.com/mg979/vim-visual-multi - 'mg979/vim-visual-multi', + -- https://github.com/kylechui/nvim-surround + { + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup() + end, + }, - -- https://github.com/FooSoft/vim-argwrap - { - 'FooSoft/vim-argwrap', - }, + -- https://github.com/neovim/nvim-lspconfig + "neovim/nvim-lspconfig", - -- https://github.com/kylechui/nvim-surround - { - "kylechui/nvim-surround", - config = function() - require("nvim-surround").setup() - end - }, + -- https://github.com/williamboman/mason-lspconfig.nvim + "williamboman/mason-lspconfig", - -- https://github.com/neovim/nvim-lspconfig - 'neovim/nvim-lspconfig', + -- https://github.com/williamboman/mason.nvim + "williamboman/mason.nvim", - -- https://github.com/williamboman/mason-lspconfig.nvim - 'williamboman/mason-lspconfig', + -- https://github.com/hrsh7th/nvim-cmp + { + "hrsh7th/nvim-cmp", + dependencies = { + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-nvim-lua" }, + { "hrsh7th/cmp-buffer" }, + { "hrsh7th/cmp-path" }, + { "hrsh7th/cmp-cmdline" }, + { "L3MON4D3/LuaSnip" }, + { "saadparwaiz1/cmp_luasnip" }, + { "rafamadriz/friendly-snippets" }, + { "onsails/lspkind.nvim" }, + }, + config = function() + local lspkind = require("lspkind") + local has_words_before = function() + unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 + and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + end + local cmp = require("cmp") + local luasnip = require("luasnip") + cmp.setup({ + experimental = { + ghost_text = true, + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + formatting = { + format = lspkind.cmp_format({ + mode = "symbol", + maxwidth = 50, + ellipsis_char = "...", + before = function(entry, vim_item) + return vim_item + 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 = false }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "path" }, + { name = "luasnip" }, + { name = "neorg" }, + }, { + { name = "buffer" }, + }), + }) - -- https://github.com/williamboman/mason.nvim - 'williamboman/mason.nvim', + cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "cmp_git" }, + }, { + { name = "buffer" }, + }), + }) - -- https://github.com/hrsh7th/nvim-cmp - { - "hrsh7th/nvim-cmp", - dependencies = { - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-nvim-lua" }, - { "hrsh7th/cmp-buffer" }, - { "hrsh7th/cmp-path" }, - { "hrsh7th/cmp-cmdline" }, - { "L3MON4D3/LuaSnip" }, - { "saadparwaiz1/cmp_luasnip" }, - { "rafamadriz/friendly-snippets" }, - { "onsails/lspkind.nvim" }, - }, - config = function() - local lspkind = require('lspkind') - local has_words_before = function() - unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - local cmp = require 'cmp' - local luasnip = require("luasnip") - cmp.setup({ - experimental = { - ghost_text = true - }, - snippet = { - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - formatting = { - format = lspkind.cmp_format({ - mode = 'symbol', - maxwidth = 50, - ellipsis_char = '...', - before = function(entry, vim_item) - return vim_item - 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 = false }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, - { name = 'nvim_lua' }, - { name = 'path' }, - { name = 'luasnip' }, - { name = 'neorg' }, - }, { - { name = 'buffer' }, - }) - }) + cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + }) - cmp.setup.filetype('gitcommit', { - sources = cmp.config.sources({ - { name = 'cmp_git' }, - }, { - { name = 'buffer' }, - }) - }) + cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), + }) + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, - cmp.setup.cmdline('/', { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = 'buffer' } - } - }) + -- https://github.com/AlphaTechnolog/pywal.nvim + { + "AlphaTechnolog/pywal.nvim", + priority = 1000, + name = "pywal", + config = function() + local pywal = require("pywal") + pywal.setup() + end, + }, - cmp.setup.cmdline(':', { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = 'path' } - }, { - { name = 'cmdline' } - }) - }) - require('luasnip.loaders.from_vscode').lazy_load() - end, - }, + -- https://github.com/nvim-lualine/lualine.nvim + { + "hoob3rt/lualine.nvim", + dependencies = { { "nvim-tree/nvim-web-devicons" } }, + config = function() + local navic = require("nvim-navic") + require("lualine").setup({ + sections = { + lualine_c = { + { navic.get_location, cond = navic.is_available }, + }, + }, + options = { + theme = "pywal-nvim", + }, + }) + end, + }, - -- https://github.com/AlphaTechnolog/pywal.nvim - { - 'AlphaTechnolog/pywal.nvim', - priority = 1000, - name = 'pywal', - config = function() - local pywal = require('pywal') - pywal.setup() - end - }, + -- https://github.com/romgrk/barbar.nvim + { + "romgrk/barbar.nvim", + dependencies = "nvim-tree/nvim-web-devicons", + config = function() + require("bufferline").setup({ + animation = true, + closable = true, + clickable = true, + icons = { + seperator = { + left = " ", + }, + incactive = { + seperator = { + left = " ", + }, + }, + }, + }) + end, + }, - -- https://github.com/nvim-lualine/lualine.nvim - { - 'hoob3rt/lualine.nvim', - dependencies = { { 'nvim-tree/nvim-web-devicons' } }, - config = function() - local navic = require("nvim-navic") - require('lualine').setup({ - sections = { - lualine_c = { - { navic.get_location, cond = navic.is_available }, - } - }, - options = { - theme = 'pywal-nvim' - } - }) - end, - }, + -- https://github.com/rktjmp/fwatch.nvim + { + "rktjmp/fwatch.nvim", + config = function() + require("fwatch").watch(os.getenv("XDG_CACHE_HOME") .. "/wal/colors", { + on_event = function() + vim.defer_fn(function() + vim.cmd("colorscheme pywal") + end, 100) + end, + }) + end, + }, - -- https://github.com/romgrk/barbar.nvim - { - 'romgrk/barbar.nvim', - dependencies = 'nvim-tree/nvim-web-devicons', - config = function() - require 'bufferline'.setup { - animation = true, - closable = true, - clickable = true, - icons = { - seperator = { - left = ' ', - }, - incactive = { - seperator = { - left = ' ', - }, - }, - } - } - end - }, - - -- https://github.com/rktjmp/fwatch.nvim - { - 'rktjmp/fwatch.nvim', - config = function() - require('fwatch').watch(os.getenv("XDG_CACHE_HOME") .. "/wal/colors", - { - on_event = function() - vim.defer_fn(function() - vim.cmd('colorscheme pywal') - end, 100) - end - }) - end, - }, - - -- https://github.com/goolord/alpha-nvim - { - 'goolord/alpha-nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, - config = function() - local alpha = require('alpha') - local dashboard = require('alpha.themes.dashboard') - dashboard.section.header.val = { - [[ ▄▄▄ ▄▄▄▄ ██████ ███▄ █ ▄▄▄█████▓]], - [[▒████▄ ▓█████▄ ▒██ ▒ ██ ▀█ █ ▓ ██▒ ▓▒]], - [[▒██ ▀█▄ ▒██▒ ▄██░ ▓██▄ ▓██ ▀█ ██▒▒ ▓██░ ▒░]], - [[░██▄▄▄▄██ ▒██░█▀ ▒ ██▒▓██▒ ▐▌██▒░ ▓██▓ ░ ]], - [[ ▓█ ▓██▒░▓█ ▀█▓▒██████▒▒▒██░ ▓██░ ▒██▒ ░ ]], - [[ ▒▒ ▓▒█░░▒▓███▀▒▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ▒ ░░ ]], - [[ ▒ ▒▒ ░▒░▒ ░ ░ ░▒ ░ ░░ ░░ ░ ▒░ ░ ]], - [[ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ]], - [[ ░ ░ ░ ░ ░ ]], - [[ ░ ]] - } - dashboard.section.buttons.val = { - dashboard.button("e", " New file", ":ene startinsert "), - dashboard.button("r", " Recently used files", ":Telescope oldfiles"), - dashboard.button("p", " Find project", ":Telescope projects"), - dashboard.button("f", " Find file", ":Telescope find_files"), - dashboard.button("t", " Find text", ":Telescope live_grep "), - dashboard.button("s", " Settings", - ":e $HOME/.config/nvim/init.lua | :cd %:p:h | split . | wincmd k | pwd"), - dashboard.button("q", " Quit NVIM", ":qa"), - } - dashboard.section.footer.val = require 'alpha.fortune' - dashboard.section.header.opts.hl = "Title" - dashboard.section.buttons.opts.hl = "Debug" - dashboard.section.footer.opts.hl = "Conceal" - dashboard.config.opts.noautocmd = true - dashboard.config.opts.setup = function() - vim.b.lnstatus = "nonumber" - end - alpha.setup(dashboard.opts) - end - }, + -- https://github.com/goolord/alpha-nvim + { + "goolord/alpha-nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + dashboard.section.header.val = { + [[ ▄▄▄ ▄▄▄▄ ██████ ███▄ █ ▄▄▄█████▓]], + [[▒████▄ ▓█████▄ ▒██ ▒ ██ ▀█ █ ▓ ██▒ ▓▒]], + [[▒██ ▀█▄ ▒██▒ ▄██░ ▓██▄ ▓██ ▀█ ██▒▒ ▓██░ ▒░]], + [[░██▄▄▄▄██ ▒██░█▀ ▒ ██▒▓██▒ ▐▌██▒░ ▓██▓ ░ ]], + [[ ▓█ ▓██▒░▓█ ▀█▓▒██████▒▒▒██░ ▓██░ ▒██▒ ░ ]], + [[ ▒▒ ▓▒█░░▒▓███▀▒▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ▒ ░░ ]], + [[ ▒ ▒▒ ░▒░▒ ░ ░ ░▒ ░ ░░ ░░ ░ ▒░ ░ ]], + [[ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ]], + [[ ░ ░ ░ ░ ░ ]], + [[ ░ ]], + } + dashboard.section.buttons.val = { + dashboard.button("e", " New file", ":ene startinsert "), + dashboard.button("r", " Recently used files", ":Telescope oldfiles"), + dashboard.button("p", " Find project", ":Telescope projects"), + dashboard.button("f", " Find file", ":Telescope find_files"), + dashboard.button("t", " Find text", ":Telescope live_grep "), + dashboard.button( + "s", + " Settings", + ":e $HOME/.config/nvim/init.lua | :cd %:p:h | split . | wincmd k | pwd" + ), + dashboard.button("q", " Quit NVIM", ":qa"), + } + dashboard.section.footer.val = require("alpha.fortune") + dashboard.section.header.opts.hl = "Title" + dashboard.section.buttons.opts.hl = "Debug" + dashboard.section.footer.opts.hl = "Conceal" + dashboard.config.opts.noautocmd = true + dashboard.config.opts.setup = function() + vim.b.lnstatus = "nonumber" + end + alpha.setup(dashboard.opts) + end, + }, }