formatted code

pull/945/head
Neeraj 2 years ago
parent da382b5d61
commit 4316ac84df

@ -25,7 +25,6 @@ vim.keymap.set('n', '<leader>u', '20k')
vim.keymap.set('v', '<leader>n', '20j') vim.keymap.set('v', '<leader>n', '20j')
vim.keymap.set('v', '<leader>u', '20k') vim.keymap.set('v', '<leader>u', '20k')
-- Alternate way to save -- Alternate way to save
vim.cmd('nnoremap <C-s> :w!<CR>') vim.cmd('nnoremap <C-s> :w!<CR>')
vim.cmd('inoremap <C-s> <ESC> :w!<CR>') vim.cmd('inoremap <C-s> <ESC> :w!<CR>')
@ -33,7 +32,6 @@ vim.cmd('inoremap <C-s> <ESC> :w!<CR>')
-- Alternate way to quit -- Alternate way to quit
vim.cmd('nnoremap <S-c> :q!<CR>') vim.cmd('nnoremap <S-c> :q!<CR>')
-- ================= File management ================= -- -- ================= File management ================= --
-- swapfile has global & local config, eventhough help says otherwise -- swapfile has global & local config, eventhough help says otherwise
@ -103,8 +101,8 @@ vim.o.hidden = true
vim.o.clipboard = "unnamedplus" vim.o.clipboard = "unnamedplus"
-- diagnostic symbols -- diagnostic symbols
local signs = { Error = "", Warn = "", Hint = "", Info = "" } local signs = {Error = "", Warn = "", Hint = "", Info = ""}
for type, icon in pairs(signs) do for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl})
end end

@ -2,5 +2,5 @@ return {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
config = function() config = function()
require("nvim-autopairs").setup {} require("nvim-autopairs").setup {}
end, end
} }

@ -1,10 +1,9 @@
return { return {
'romgrk/barbar.nvim', 'romgrk/barbar.nvim',
dependencies = 'nvim-tree/nvim-web-devicons', dependencies = 'nvim-tree/nvim-web-devicons',
config = function () config = function()
vim.keymap.set('', 'J', '<Cmd>BufferPrevious<CR>') vim.keymap.set('', 'J', '<Cmd>BufferPrevious<CR>')
vim.keymap.set('', 'K', '<Cmd>BufferNext<CR>') vim.keymap.set('', 'K', '<Cmd>BufferNext<CR>')
vim.keymap.set('', 'X', '<Cmd>BufferClose<CR>') vim.keymap.set('', 'X', '<Cmd>BufferClose<CR>')
end end
} }

@ -1,6 +1,6 @@
return { return {
"rmehri01/onenord.nvim", "rmehri01/onenord.nvim",
config = function () config = function()
vim.cmd.colorscheme 'onenord' vim.cmd.colorscheme 'onenord'
end end
} }

@ -1,26 +1,24 @@
return { return {
'onsails/lspkind.nvim', '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 -- The function below will be called before any actual modifications from lspkind
local cmp = require 'cmp' -- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
cmp.setup { before = function(entry, vim_item)
formatting = { return vim_item
format = lspkind.cmp_format({ end
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
})
}
}
end end
} }

@ -1,19 +1,19 @@
return { return {
"glepnir/lspsaga.nvim", "glepnir/lspsaga.nvim",
event = "BufRead", event = "BufRead",
config = function() config = function()
vim.keymap.set('n', '<leader>k', ':Lspsaga hover_doc<CR>') vim.keymap.set('n', '<leader>k', ':Lspsaga hover_doc<CR>')
vim.keymap.set('n', '<leader>gs', ':Lspsaga signature_help<CR>') vim.keymap.set('n', '<leader>gs', ':Lspsaga signature_help<CR>')
vim.keymap.set('n', '<leader>rn', ':Lspsaga rename<CR>') vim.keymap.set('n', '<leader>rn', ':Lspsaga rename<CR>')
vim.keymap.set('n', '<leader>ca', ':Lspsaga code_action<CR>') vim.keymap.set('n', '<leader>ca', ':Lspsaga code_action<CR>')
vim.keymap.set('n', '<leader>gl', ':Lspsaga show_line_diagnostics<CR>') vim.keymap.set('n', '<leader>gl', ':Lspsaga show_line_diagnostics<CR>')
vim.keymap.set('n', '<leader>gn', ':Lspsaga diagnostic_jump_next<CR>') vim.keymap.set('n', '<leader>gn', ':Lspsaga diagnostic_jump_next<CR>')
vim.keymap.set('n', '<leader>gp', ':Lspsaga diagnostic_jump_prev<CR>') vim.keymap.set('n', '<leader>gp', ':Lspsaga diagnostic_jump_prev<CR>')
require("lspsaga").setup({}) require("lspsaga").setup({})
end, end,
dependencies = { dependencies = {
{"nvim-tree/nvim-web-devicons"}, {"nvim-tree/nvim-web-devicons"},
--Please make sure you install markdown and markdown_inline parser -- Please make sure you install markdown and markdown_inline parser
{"nvim-treesitter/nvim-treesitter"} {"nvim-treesitter/nvim-treesitter"}
} }
} }

@ -1,41 +1,41 @@
return { return {
'nvim-lualine/lualine.nvim', 'nvim-lualine/lualine.nvim',
opts = { opts = {
options = { options = {
theme = 'onenord', theme = 'onenord',
icons_enabled = true, icons_enabled = true,
component_separators = {left = '', right = ''}, component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''}, section_separators = {left = '', right = ''},
disabled_filetypes = {}, disabled_filetypes = {},
always_divide_middle = true 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?)
}
}, },
lualine_x = {'encoding', 'fileformat', 'filetype'}, sections = {
lualine_y = {'progress'}, lualine_a = {'mode'},
lualine_z = {'location'} lualine_b = {'branch', 'diff', 'diagnostics'},
}, -- lualine_c = {'filename'},
inactive_sections = { lualine_c = {
lualine_a = {}, {
lualine_b = {}, 'filename',
lualine_c = {'filename'}, file_status = true, -- Displays file status (readonly status, modified status)
lualine_x = {'location'}, path = 1, -- 0: Just the filename
lualine_y = {}, -- 1: Relative path
lualine_z = {} -- 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 = {}
}
} }
}

@ -1,54 +1,56 @@
return { return {
"jose-elias-alvarez/null-ls.nvim", "jose-elias-alvarez/null-ls.nvim",
dependencies = {"nvim-lua/plenary.nvim"}, dependencies = {"nvim-lua/plenary.nvim"},
config = function () config = function()
local null_ls = require("null-ls") local null_ls = require("null-ls")
local formatting = null_ls.builtins.formatting local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics local diagnostics = null_ls.builtins.diagnostics
local codeActions = null_ls.builtins.code_actions local codeActions = null_ls.builtins.code_actions
local sources = { local sources = {
formatting.eslint_d, formatting.prettierd.with({ formatting.eslint_d, formatting.prettierd.with({
env = { env = {
PRETTIERD_DEFAULT_CONFIG = vim.fn.expand "~/.config/nvim/utils/linter-config/.prettierrc.js" 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.prettier
formatting.lua_format.with({ -- .with({extra_args = {'--single-quote', '--tab-width 2', '--arrow-parens avoid'}}),
extra_args = { formatting.lua_format.with({
'--no-keep-simple-function-one-line', '--no-break-after-operator', '--column-limit=100', extra_args = {
'--break-after-table-lb', '--indent-width=2' '--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 }
} }), diagnostics.eslint_d.with({diagnostics_format = "[#{c}] #{m} (#{s})"}),
codeActions.eslint_d
}
local lsp_formatting = function(bufnr) local lsp_formatting = function(bufnr)
vim.lsp.buf.format({ vim.lsp.buf.format({
filter = function(client) filter = function(client)
-- apply whatever logic you want (in this example, we'll only use null-ls) -- apply whatever logic you want (in this example, we'll only use null-ls)
return client.name == "null-ls" return client.name == "null-ls"
end, end,
bufnr = bufnr bufnr = bufnr
}) })
end end
-- if you want to set up formatting on save, you can use this as a callback -- 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 augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local on_attach = function(client, bufnr) local on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr}) vim.api.nvim_clear_autocmds({group = augroup, buffer = bufnr})
vim.api.nvim_create_autocmd("BufWritePre", { vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup, group = augroup,
buffer = bufnr, buffer = bufnr,
callback = function() callback = function()
lsp_formatting(bufnr) lsp_formatting(bufnr)
end end
}) })
end 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 end
} }

@ -1,6 +1,6 @@
return { return {
"rafamadriz/friendly-snippets", "rafamadriz/friendly-snippets",
config = function () config = function()
require("luasnip/loaders/from_vscode").lazy_load() require("luasnip/loaders/from_vscode").lazy_load()
end end
} }

@ -1,9 +1,9 @@
return { return {
'norcalli/nvim-colorizer.lua', 'norcalli/nvim-colorizer.lua',
config = function () config = function()
require'colorizer'.setup { require'colorizer'.setup {
'*', -- Highlight all files, but customize some others. '*', -- Highlight all files, but customize some others.
css = {css = true} -- Enable parsing rgb(...) functions in css. css = {css = true} -- Enable parsing rgb(...) functions in css.
} }
end end
} }

@ -1,16 +1,16 @@
return { return {
'petertriho/nvim-scrollbar', 'petertriho/nvim-scrollbar',
config = function () config = function()
require("scrollbar").setup({ require("scrollbar").setup({
handle = {text = " "}, handle = {text = " "},
marks = { marks = {
Search = {text = {"-- ", "== "}}, Search = {text = {"-- ", "== "}},
Error = {text = {"", ""}}, Error = {text = {"", ""}},
Warn = {text = {"", ""}}, Warn = {text = {"", ""}},
Info = {text = {"", ""}}, Info = {text = {"", ""}},
Hint = {text = {"", ""}}, Hint = {text = {"", ""}},
Misc = {text = {"-- ", "== "}} Misc = {text = {"-- ", "== "}}
} }
}) })
end end
} }

@ -1,6 +1,6 @@
return { return {
"kylechui/nvim-surround", "kylechui/nvim-surround",
config = function() config = function()
require("nvim-surround").setup({}) require("nvim-surround").setup({})
end end
} }

@ -1,7 +1,7 @@
return { return {
'nvim-tree/nvim-tree.lua', 'nvim-tree/nvim-tree.lua',
requires = { requires = {
'nvim-tree/nvim-web-devicons', -- optional, for file icons 'nvim-tree/nvim-web-devicons' -- optional, for file icons
}, },
config = function() config = function()
local nvim_tree_events = require('nvim-tree.events') local nvim_tree_events = require('nvim-tree.events')
@ -29,10 +29,7 @@ return {
require("nvim-tree").setup({ require("nvim-tree").setup({
sync_root_with_cwd = true, sync_root_with_cwd = true,
respect_buf_cwd = true, respect_buf_cwd = true,
update_focused_file = { update_focused_file = { enable = true, update_root = true }
enable = true,
update_root = true
},
}) })
end end
} }

@ -1,3 +1 @@
return { return {'mhinz/vim-startify'}
'mhinz/vim-startify'
}

@ -1,73 +1,78 @@
return { return {
'nvim-telescope/telescope.nvim', 'nvim-telescope/telescope.nvim',
version = '*', version = '*',
dependencies = { 'nvim-lua/plenary.nvim' }, dependencies = {'nvim-lua/plenary.nvim'},
config = function () config = function()
-- Find files using lua fuctions -- Find files using lua fuctions
local opts = { silent = true, noremap = true } local opts = {silent = true, noremap = true}
vim.api.nvim_set_keymap('n', '<Leader>ff', "<Cmd>lua require'telescope.builtin'.find_files()<CR>", {silent=false, noremap=true}) vim.api.nvim_set_keymap('n', '<Leader>ff',
vim.api.nvim_set_keymap('n', '<Leader>fg', "<Cmd>lua require'telescope.builtin'.live_grep()<CR>", opts) "<Cmd>lua require'telescope.builtin'.find_files()<CR>",
vim.api.nvim_set_keymap('n', '<Leader>fs', "<Cmd>lua require'telescope.builtin'.grep_string()<CR>", opts) {silent = false, noremap = true})
vim.api.nvim_set_keymap('n', '<Leader>ft', "<Cmd>lua require'telescope.builtin'.file_browser()<CR>", opts) vim.api.nvim_set_keymap('n', '<Leader>fg',
vim.api.nvim_set_keymap('n', '<Leader>fo', "<Cmd>lua require'telescope.builtin'.oldfiles()<CR>", opts) "<Cmd>lua require'telescope.builtin'.live_grep()<CR>", opts)
vim.api.nvim_set_keymap('n', '<Leader>gc', "<Cmd>lua require'telescope.builtin'.git_commits()<CR>", opts) vim.api.nvim_set_keymap('n', '<Leader>fs',
vim.api.nvim_set_keymap('n', '<Leader>gb', "<Cmd>lua require'telescope.builtin'.git_branches()<CR>", opts) "<Cmd>lua require'telescope.builtin'.grep_string()<CR>", opts)
vim.api.nvim_set_keymap('n', '<Leader>fb', "<Cmd>lua require'telescope.builtin'.buffers()<CR>", opts) vim.api.nvim_set_keymap('n', '<Leader>ft',
vim.api.nvim_set_keymap('n', '<Leader>fh', "<Cmd>lua require'telescope.builtin'.help_tags()<CR>", opts) "<Cmd>lua require'telescope.builtin'.file_browser()<CR>", opts)
vim.api.nvim_set_keymap('n', '<Leader>fo', "<Cmd>lua require'telescope.builtin'.oldfiles()<CR>",
opts)
vim.api.nvim_set_keymap('n', '<Leader>gc',
"<Cmd>lua require'telescope.builtin'.git_commits()<CR>", opts)
vim.api.nvim_set_keymap('n', '<Leader>gb',
"<Cmd>lua require'telescope.builtin'.git_branches()<CR>", opts)
vim.api.nvim_set_keymap('n', '<Leader>fb', "<Cmd>lua require'telescope.builtin'.buffers()<CR>",
opts)
vim.api.nvim_set_keymap('n', '<Leader>fh',
"<Cmd>lua require'telescope.builtin'.help_tags()<CR>", opts)
local actions = require('telescope.actions') local actions = require('telescope.actions')
require('telescope').setup { require('telescope').setup {
defaults = { defaults = {
-- program to use for searching with its arguments -- program to use for searching with its arguments
find_command = {'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}, find_command = {
-- prompt_position = 'top', -- have prompt at the top (has no effect on vertical configuration) 'rg', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'
prompt_prefix = '', -- symbol on prompt window },
selection_caret = '', -- symbol on selected row in results window -- prompt_position = 'top', -- have prompt at the top (has no effect on vertical configuration)
entry_prefix = ' ', -- symbol on non-selected rows in results window prompt_prefix = '', -- symbol on prompt window
initial_mode = 'insert', -- start in insert mode selection_caret = '', -- symbol on selected row in results window
selection_strategy = 'reset', -- what happens to selection when list changes entry_prefix = ' ', -- symbol on non-selected rows in results window
sorting_strategy = 'ascending', -- start with most important search on top initial_mode = 'insert', -- start in insert mode
layout_strategy = 'horizontal', -- vertical layout selection_strategy = 'reset', -- what happens to selection when list changes
layout_config = { sorting_strategy = 'ascending', -- start with most important search on top
prompt_position = 'top' layout_strategy = 'horizontal', -- vertical layout
}, layout_config = {prompt_position = 'top'},
file_sorter = require'telescope.sorters'.get_fuzzy_file, file_sorter = require'telescope.sorters'.get_fuzzy_file,
file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir file_ignore_patterns = {'node_modules/.*'}, -- never search in node_modules/ dir
generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter, generic_sorter = require'telescope.sorters'.get_generic_fuzzy_sorter,
display_path = true, display_path = true,
winblend = 0, -- window should not be transparent winblend = 0, -- window should not be transparent
border = {}, -- no border? border = {}, -- no border?
borderchars = {'', '', '', '', '', '', '', ''}, -- border chars borderchars = {'', '', '', '', '', '', '', ''}, -- border chars
color_devicons = true, -- colorize used icons color_devicons = true, -- colorize used icons
use_less = true, -- less is bash program for preview file contents use_less = true, -- less is bash program for preview file contents
set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors set_env = {['COLORTERM'] = 'truecolor'}, -- use all the colors
file_previewer = require'telescope.previewers'.vim_buffer_cat.new, file_previewer = require'telescope.previewers'.vim_buffer_cat.new,
grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new, grep_previewer = require'telescope.previewers'.vim_buffer_vimgrep.new,
qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new, qflist_previewer = require'telescope.previewers'.vim_buffer_qflist.new,
buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker, buffer_previewer_maker = require'telescope.previewers'.buffer_previewer_maker,
-- preview_cutoff = 120, -- preview_cutoff = 120,
mappings = { mappings = {
i = { i = {
['<C-j>'] = actions.move_selection_next, ['<C-j>'] = actions.move_selection_next,
['<C-k>'] = actions.move_selection_previous, ['<C-k>'] = actions.move_selection_previous,
['<C-q>'] = actions.smart_send_to_qflist + actions.open_qflist, ['<C-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
-- ['ć'] = actions.close, -- ['ć'] = actions.close,
['<CR>'] = actions.select_default + actions.center, ['<CR>'] = actions.select_default + actions.center
}, },
n = { n = {
['<C-j>'] = actions.move_selection_next, ['<C-j>'] = actions.move_selection_next,
['<C-k>'] = actions.move_selection_previous, ['<C-k>'] = actions.move_selection_previous,
['<C-q>'] = actions.smart_send_to_qflist + actions.open_qflist, ['<C-q>'] = actions.smart_send_to_qflist + actions.open_qflist,
['ć'] = actions.close, ['ć'] = actions.close
} }
} }
}, },
extensions = { extensions = {fzy_native = {override_generic_sorter = false, override_file_sorter = true}}
fzy_native = { }
override_generic_sorter = false, end
override_file_sorter = true,
}
}
}
end
} }

Loading…
Cancel
Save