diff --git a/after/plugin/defaults.lua b/after/plugin/defaults.lua index 7ad9e12c..2e4bc0e4 100644 --- a/after/plugin/defaults.lua +++ b/after/plugin/defaults.lua @@ -25,7 +25,6 @@ vim.keymap.set('n', 'u', '20k') vim.keymap.set('v', 'n', '20j') vim.keymap.set('v', 'u', '20k') - -- Alternate way to save vim.cmd('nnoremap :w!') vim.cmd('inoremap :w!') @@ -33,7 +32,6 @@ vim.cmd('inoremap :w!') -- Alternate way to quit vim.cmd('nnoremap :q!') - -- ================= File management ================= -- -- swapfile has global & local config, eventhough help says otherwise @@ -103,8 +101,8 @@ vim.o.hidden = true vim.o.clipboard = "unnamedplus" -- diagnostic symbols -local signs = { Error = "", Warn = "", Hint = "", Info = "" } +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 }) + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl}) end diff --git a/lua/custom/plugins/autopairs.lua b/lua/custom/plugins/autopairs.lua index 4082bd88..49fa14f4 100644 --- a/lua/custom/plugins/autopairs.lua +++ b/lua/custom/plugins/autopairs.lua @@ -2,5 +2,5 @@ return { "windwp/nvim-autopairs", config = function() require("nvim-autopairs").setup {} - end, + end } diff --git a/lua/custom/plugins/barbar.lua b/lua/custom/plugins/barbar.lua index 10235d17..50a71a3d 100644 --- a/lua/custom/plugins/barbar.lua +++ b/lua/custom/plugins/barbar.lua @@ -1,10 +1,9 @@ return { 'romgrk/barbar.nvim', dependencies = 'nvim-tree/nvim-web-devicons', - config = function () + config = function() vim.keymap.set('', 'J', 'BufferPrevious') vim.keymap.set('', 'K', 'BufferNext') vim.keymap.set('', 'X', 'BufferClose') end } - diff --git a/lua/custom/plugins/colorscheme.lua b/lua/custom/plugins/colorscheme.lua index 948f117c..5e7f59a7 100644 --- a/lua/custom/plugins/colorscheme.lua +++ b/lua/custom/plugins/colorscheme.lua @@ -1,6 +1,6 @@ return { - "rmehri01/onenord.nvim", - config = function () - vim.cmd.colorscheme 'onenord' - end + "rmehri01/onenord.nvim", + config = function() + vim.cmd.colorscheme 'onenord' + end } diff --git a/lua/custom/plugins/lspkind.lua b/lua/custom/plugins/lspkind.lua index 49f80738..84f5470b 100644 --- a/lua/custom/plugins/lspkind.lua +++ b/lua/custom/plugins/lspkind.lua @@ -1,26 +1,24 @@ return { 'onsails/lspkind.nvim', - config = function () + config = function() + local lspkind = require 'lspkind' - local lspkind = require'lspkind' + -- nvim-cmp setup + local cmp = require 'cmp' + cmp.setup { + formatting = { + format = lspkind.cmp_format({ + mode = 'symbol_text', -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) + ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - -- nvim-cmp setup - local cmp = require 'cmp' - cmp.setup { - formatting = { - format = lspkind.cmp_format({ - mode = 'symbol_text', -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) - ellipsis_char = '...', -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first) - - -- The function below will be called before any actual modifications from lspkind - -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) - before = function (entry, vim_item) - return vim_item - end - }) - } - } + -- The function below will be called before any actual modifications from lspkind + -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30)) + before = function(entry, vim_item) + return vim_item + end + }) + } + } end } - diff --git a/lua/custom/plugins/lspsaga.lua b/lua/custom/plugins/lspsaga.lua index 2b68b955..8d4554b3 100644 --- a/lua/custom/plugins/lspsaga.lua +++ b/lua/custom/plugins/lspsaga.lua @@ -1,19 +1,19 @@ return { - "glepnir/lspsaga.nvim", - event = "BufRead", - config = function() - vim.keymap.set('n', 'k', ':Lspsaga hover_doc') - vim.keymap.set('n', 'gs', ':Lspsaga signature_help') - vim.keymap.set('n', 'rn', ':Lspsaga rename') - vim.keymap.set('n', 'ca', ':Lspsaga code_action') - vim.keymap.set('n', 'gl', ':Lspsaga show_line_diagnostics') - vim.keymap.set('n', 'gn', ':Lspsaga diagnostic_jump_next') - vim.keymap.set('n', 'gp', ':Lspsaga diagnostic_jump_prev') - require("lspsaga").setup({}) - end, - dependencies = { - {"nvim-tree/nvim-web-devicons"}, - --Please make sure you install markdown and markdown_inline parser - {"nvim-treesitter/nvim-treesitter"} - } + "glepnir/lspsaga.nvim", + event = "BufRead", + config = function() + vim.keymap.set('n', 'k', ':Lspsaga hover_doc') + vim.keymap.set('n', 'gs', ':Lspsaga signature_help') + vim.keymap.set('n', 'rn', ':Lspsaga rename') + vim.keymap.set('n', 'ca', ':Lspsaga code_action') + vim.keymap.set('n', 'gl', ':Lspsaga show_line_diagnostics') + vim.keymap.set('n', 'gn', ':Lspsaga diagnostic_jump_next') + vim.keymap.set('n', 'gp', ':Lspsaga diagnostic_jump_prev') + require("lspsaga").setup({}) + end, + dependencies = { + {"nvim-tree/nvim-web-devicons"}, + -- Please make sure you install markdown and markdown_inline parser + {"nvim-treesitter/nvim-treesitter"} + } } diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua index c942e05d..74c5877b 100644 --- a/lua/custom/plugins/lualine.lua +++ b/lua/custom/plugins/lualine.lua @@ -1,41 +1,41 @@ return { - 'nvim-lualine/lualine.nvim', - opts = { -options = { - theme = 'onenord', - icons_enabled = true, - component_separators = {left = '', right = ''}, - section_separators = {left = '', right = ''}, - disabled_filetypes = {}, - always_divide_middle = true - }, - sections = { - lualine_a = {'mode'}, - lualine_b = {'branch', 'diff', 'diagnostics'}, - -- lualine_c = {'filename'}, - lualine_c = { - { - 'filename', - file_status = true, -- Displays file status (readonly status, modified status) - path = 1, -- 0: Just the filename - -- 1: Relative path - -- 2: Absolute path - - shorting_target = 40 -- Shortens path to leave 40 spaces in the window - -- for other components. (terrible name, any suggestions?) - } + 'nvim-lualine/lualine.nvim', + opts = { + options = { + theme = 'onenord', + icons_enabled = true, + component_separators = {left = '', right = ''}, + section_separators = {left = '', right = ''}, + disabled_filetypes = {}, + always_divide_middle = true }, - lualine_x = {'encoding', 'fileformat', 'filetype'}, - lualine_y = {'progress'}, - lualine_z = {'location'} - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = {'filename'}, - lualine_x = {'location'}, - lualine_y = {}, - lualine_z = {} - }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + -- lualine_c = {'filename'}, + lualine_c = { + { + 'filename', + file_status = true, -- Displays file status (readonly status, modified status) + path = 1, -- 0: Just the filename + -- 1: Relative path + -- 2: Absolute path + + shorting_target = 40 -- Shortens path to leave 40 spaces in the window + -- for other components. (terrible name, any suggestions?) + } + }, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + } } +} diff --git a/lua/custom/plugins/null-ls.lua b/lua/custom/plugins/null-ls.lua index 474410c4..323e9c6e 100644 --- a/lua/custom/plugins/null-ls.lua +++ b/lua/custom/plugins/null-ls.lua @@ -1,54 +1,56 @@ return { "jose-elias-alvarez/null-ls.nvim", - dependencies = {"nvim-lua/plenary.nvim"}, - config = function () - local null_ls = require("null-ls") + dependencies = {"nvim-lua/plenary.nvim"}, + config = function() + local null_ls = require("null-ls") - local formatting = null_ls.builtins.formatting - local diagnostics = null_ls.builtins.diagnostics - local codeActions = null_ls.builtins.code_actions + local formatting = null_ls.builtins.formatting + local diagnostics = null_ls.builtins.diagnostics + local codeActions = null_ls.builtins.code_actions - local sources = { - formatting.eslint_d, formatting.prettierd.with({ - env = { - PRETTIERD_DEFAULT_CONFIG = vim.fn.expand "~/.config/nvim/utils/linter-config/.prettierrc.js" - } - }), -- formatting.prettier - -- .with({extra_args = {'--single-quote', '--tab-width 2', '--arrow-parens avoid'}}), - formatting.lua_format.with({ - extra_args = { - '--no-keep-simple-function-one-line', '--no-break-after-operator', '--column-limit=100', - '--break-after-table-lb', '--indent-width=2' - } - }), diagnostics.eslint_d.with({diagnostics_format = "[#{c}] #{m} (#{s})"}), codeActions.eslint_d - } + local sources = { + formatting.eslint_d, formatting.prettierd.with({ + env = { + PRETTIERD_DEFAULT_CONFIG = vim.fn + .expand "~/.config/nvim/utils/linter-config/.prettierrc.js" + } + }), -- formatting.prettier + -- .with({extra_args = {'--single-quote', '--tab-width 2', '--arrow-parens avoid'}}), + formatting.lua_format.with({ + extra_args = { + '--no-keep-simple-function-one-line', '--no-break-after-operator', '--column-limit=100', + '--break-after-table-lb', '--indent-width=2' + } + }), diagnostics.eslint_d.with({diagnostics_format = "[#{c}] #{m} (#{s})"}), + codeActions.eslint_d + } - local lsp_formatting = function(bufnr) - vim.lsp.buf.format({ - filter = function(client) - -- apply whatever logic you want (in this example, we'll only use null-ls) - return client.name == "null-ls" - end, - bufnr = bufnr - }) - end + local lsp_formatting = function(bufnr) + vim.lsp.buf.format({ + filter = function(client) + -- apply whatever logic you want (in this example, we'll only use null-ls) + return client.name == "null-ls" + end, + bufnr = bufnr + }) + end - -- if you want to set up formatting on save, you can use this as a callback - local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + -- if you want to set up formatting on save, you can use this as a callback + local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) - local on_attach = function(client, bufnr) - if client.supports_method("textDocument/formatting") then - vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr}) - vim.api.nvim_create_autocmd("BufWritePre", { - group = augroup, - buffer = bufnr, - callback = function() - lsp_formatting(bufnr) - end - }) - end - end + local on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr}) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + lsp_formatting(bufnr) + end + }) + end + end - null_ls.setup({sources = sources, debug = true, on_attach = on_attach}) + null_ls.setup({sources = sources, debug = true, on_attach = on_attach}) end } diff --git a/lua/custom/plugins/nvim-cmp.lua b/lua/custom/plugins/nvim-cmp.lua index 78f1843a..4b3932f1 100644 --- a/lua/custom/plugins/nvim-cmp.lua +++ b/lua/custom/plugins/nvim-cmp.lua @@ -1,6 +1,6 @@ return { "rafamadriz/friendly-snippets", - config = function () - require("luasnip/loaders/from_vscode").lazy_load() + config = function() + require("luasnip/loaders/from_vscode").lazy_load() end } diff --git a/lua/custom/plugins/nvim-colorizer.lua b/lua/custom/plugins/nvim-colorizer.lua index 113b18b3..cdb475af 100644 --- a/lua/custom/plugins/nvim-colorizer.lua +++ b/lua/custom/plugins/nvim-colorizer.lua @@ -1,9 +1,9 @@ return { 'norcalli/nvim-colorizer.lua', - config = function () - require'colorizer'.setup { - '*', -- Highlight all files, but customize some others. - css = {css = true} -- Enable parsing rgb(...) functions in css. - } + config = function() + require'colorizer'.setup { + '*', -- Highlight all files, but customize some others. + css = {css = true} -- Enable parsing rgb(...) functions in css. + } end } diff --git a/lua/custom/plugins/nvim-scrollbar.lua b/lua/custom/plugins/nvim-scrollbar.lua index c723ddfb..05d15357 100644 --- a/lua/custom/plugins/nvim-scrollbar.lua +++ b/lua/custom/plugins/nvim-scrollbar.lua @@ -1,16 +1,16 @@ return { 'petertriho/nvim-scrollbar', - config = function () - require("scrollbar").setup({ - handle = {text = " "}, - marks = { - Search = {text = {"-- ", "== "}}, - Error = {text = {" ", " "}}, - Warn = {text = {" ", " "}}, - Info = {text = {" ", " "}}, - Hint = {text = {" ", " "}}, - Misc = {text = {"-- ", "== "}} - } - }) + config = function() + require("scrollbar").setup({ + handle = {text = " "}, + marks = { + Search = {text = {"-- ", "== "}}, + Error = {text = {" ", " "}}, + Warn = {text = {" ", " "}}, + Info = {text = {" ", " "}}, + Hint = {text = {" ", " "}}, + Misc = {text = {"-- ", "== "}} + } + }) end } diff --git a/lua/custom/plugins/nvim-surround.lua b/lua/custom/plugins/nvim-surround.lua index bdac1d41..c763c8a4 100644 --- a/lua/custom/plugins/nvim-surround.lua +++ b/lua/custom/plugins/nvim-surround.lua @@ -1,6 +1,6 @@ return { - "kylechui/nvim-surround", - config = function() - require("nvim-surround").setup({}) - end + "kylechui/nvim-surround", + config = function() + require("nvim-surround").setup({}) + end } diff --git a/lua/custom/plugins/nvimtree.lua b/lua/custom/plugins/nvimtree.lua index 1c6ca463..905eba88 100644 --- a/lua/custom/plugins/nvimtree.lua +++ b/lua/custom/plugins/nvimtree.lua @@ -1,7 +1,7 @@ return { 'nvim-tree/nvim-tree.lua', requires = { - 'nvim-tree/nvim-web-devicons', -- optional, for file icons + 'nvim-tree/nvim-web-devicons' -- optional, for file icons }, config = function() local nvim_tree_events = require('nvim-tree.events') @@ -29,10 +29,7 @@ return { require("nvim-tree").setup({ sync_root_with_cwd = true, respect_buf_cwd = true, - update_focused_file = { - enable = true, - update_root = true - }, + update_focused_file = { enable = true, update_root = true } }) end } diff --git a/lua/custom/plugins/startify.lua b/lua/custom/plugins/startify.lua index 40dd380c..445bffd8 100644 --- a/lua/custom/plugins/startify.lua +++ b/lua/custom/plugins/startify.lua @@ -1,3 +1 @@ -return { - 'mhinz/vim-startify' -} +return {'mhinz/vim-startify'} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index 8a63e6a2..09a4e40a 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -1,73 +1,78 @@ return { - 'nvim-telescope/telescope.nvim', + 'nvim-telescope/telescope.nvim', version = '*', - dependencies = { 'nvim-lua/plenary.nvim' }, - config = function () - -- Find files using lua fuctions - local opts = { silent = true, noremap = true } - vim.api.nvim_set_keymap('n', 'ff', "lua require'telescope.builtin'.find_files()", {silent=false, noremap=true}) - vim.api.nvim_set_keymap('n', 'fg', "lua require'telescope.builtin'.live_grep()", opts) - vim.api.nvim_set_keymap('n', 'fs', "lua require'telescope.builtin'.grep_string()", opts) - vim.api.nvim_set_keymap('n', 'ft', "lua require'telescope.builtin'.file_browser()", opts) - vim.api.nvim_set_keymap('n', 'fo', "lua require'telescope.builtin'.oldfiles()", opts) - vim.api.nvim_set_keymap('n', 'gc', "lua require'telescope.builtin'.git_commits()", opts) - vim.api.nvim_set_keymap('n', 'gb', "lua require'telescope.builtin'.git_branches()", opts) - vim.api.nvim_set_keymap('n', 'fb', "lua require'telescope.builtin'.buffers()", opts) - vim.api.nvim_set_keymap('n', 'fh', "lua require'telescope.builtin'.help_tags()", opts) + dependencies = {'nvim-lua/plenary.nvim'}, + config = function() + -- Find files using lua fuctions + local opts = {silent = true, noremap = true} + vim.api.nvim_set_keymap('n', 'ff', + "lua require'telescope.builtin'.find_files()", + {silent = false, noremap = true}) + vim.api.nvim_set_keymap('n', 'fg', + "lua require'telescope.builtin'.live_grep()", opts) + vim.api.nvim_set_keymap('n', 'fs', + "lua require'telescope.builtin'.grep_string()", opts) + vim.api.nvim_set_keymap('n', 'ft', + "lua require'telescope.builtin'.file_browser()", opts) + vim.api.nvim_set_keymap('n', 'fo', "lua require'telescope.builtin'.oldfiles()", + opts) + vim.api.nvim_set_keymap('n', 'gc', + "lua require'telescope.builtin'.git_commits()", opts) + vim.api.nvim_set_keymap('n', 'gb', + "lua require'telescope.builtin'.git_branches()", opts) + vim.api.nvim_set_keymap('n', 'fb', "lua require'telescope.builtin'.buffers()", + opts) + vim.api.nvim_set_keymap('n', 'fh', + "lua require'telescope.builtin'.help_tags()", opts) - local actions = require('telescope.actions') - require('telescope').setup { - defaults = { - -- program to use for searching with its arguments - find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, - -- prompt_position = 'top', -- have prompt at the top (has no effect on vertical configuration) - prompt_prefix = ' ', -- symbol on prompt window - selection_caret = ' ', -- symbol on selected row in results window - entry_prefix = ' ', -- symbol on non-selected rows in results window - initial_mode = 'insert', -- start in insert mode - selection_strategy = 'reset', -- what happens to selection when list changes - sorting_strategy = 'ascending', -- start with most important search on top - layout_strategy = 'horizontal', -- vertical layout - layout_config = { - prompt_position = 'top' - }, - file_sorter = require'telescope.sorters'.get_fuzzy_file, - file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir - generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, - display_path = true, - winblend = 0, -- window should not be transparent - border = {}, -- no border? - borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, -- border chars - color_devicons = true, -- colorize used icons - use_less = true, -- less is bash program for preview file contents - set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors - file_previewer = require'telescope.previewers'.vim_buffer_cat.new, - grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, - qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, - buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker, - -- preview_cutoff = 120, - mappings = { - i = { - [''] = actions.move_selection_next, - [''] = actions.move_selection_previous, - [''] = actions.smart_send_to_qflist + actions.open_qflist, - -- ['ć'] = actions.close, - [''] = actions.select_default + actions.center, - }, - n = { - [''] = actions.move_selection_next, - [''] = actions.move_selection_previous, - [''] = actions.smart_send_to_qflist + actions.open_qflist, - ['ć'] = actions.close, - } - } - }, - extensions = { - fzy_native = { - override_generic_sorter = false, - override_file_sorter = true, - } - } - } - end + local actions = require('telescope.actions') + require('telescope').setup { + defaults = { + -- program to use for searching with its arguments + find_command = { + 'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case' + }, + -- prompt_position = 'top', -- have prompt at the top (has no effect on vertical configuration) + prompt_prefix = ' ', -- symbol on prompt window + selection_caret = ' ', -- symbol on selected row in results window + entry_prefix = ' ', -- symbol on non-selected rows in results window + initial_mode = 'insert', -- start in insert mode + selection_strategy = 'reset', -- what happens to selection when list changes + sorting_strategy = 'ascending', -- start with most important search on top + layout_strategy = 'horizontal', -- vertical layout + layout_config = {prompt_position = 'top'}, + file_sorter = require'telescope.sorters'.get_fuzzy_file, + file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir + generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, + display_path = true, + winblend = 0, -- window should not be transparent + border = {}, -- no border? + borderchars = {'─', '│', '─', '│', '╭', '╮', '╯', '╰'}, -- border chars + color_devicons = true, -- colorize used icons + use_less = true, -- less is bash program for preview file contents + set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors + file_previewer = require'telescope.previewers'.vim_buffer_cat.new, + grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, + qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, + buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker, + -- preview_cutoff = 120, + mappings = { + i = { + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.smart_send_to_qflist + actions.open_qflist, + -- ['ć'] = actions.close, + [''] = actions.select_default + actions.center + }, + n = { + [''] = actions.move_selection_next, + [''] = actions.move_selection_previous, + [''] = actions.smart_send_to_qflist + actions.open_qflist, + ['ć'] = actions.close + } + } + }, + extensions = {fzy_native = {override_generic_sorter = false, override_file_sorter = true}} + } + end }