separated plugins configs and added couple new plugins
This commit is contained in:
parent
8c93e97b86
commit
6b3424c590
25
init.lua
25
init.lua
|
@ -1,11 +1,10 @@
|
|||
-- See `:help mapleader`
|
||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||
-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used)
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- Install package manager
|
||||
-- https://github.com/folke/lazy.nvim
|
||||
-- `:help lazy.nvim.txt` for more info
|
||||
-- https://github.com/folke/lazy.nvim
|
||||
-- Check Lua documentation for more info
|
||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system {
|
||||
|
@ -33,19 +32,13 @@ require('lazy').setup({
|
|||
|
||||
-- Detect tabstop and shiftwidth automatically
|
||||
'tpope/vim-sleuth',
|
||||
{ import = 'custom.plugins' },
|
||||
{
|
||||
import = 'custom.plugins',
|
||||
exclude = 'custom.plugins.mason',
|
||||
},
|
||||
}, opts)
|
||||
|
||||
require('config.options')
|
||||
require('config.mappings')
|
||||
|
||||
-- [[ 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', {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = '*',
|
||||
})
|
||||
require('config.utils')
|
||||
require('config.themes')
|
||||
|
|
|
@ -10,7 +10,9 @@ 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
|
||||
-- Unmap the 'gp' key for previous word
|
||||
expr = true,
|
||||
silent = true
|
||||
})
|
||||
|
||||
-- Move lines
|
||||
|
@ -24,6 +26,8 @@ vim.keymap.set('n', '<C-u>', "<C-u>zz", { desc = "Half Page Jumping Down" })
|
|||
-- Keep search line in the middle
|
||||
vim.keymap.set('n', 'n', 'nzzzv', { silent = true })
|
||||
vim.keymap.set('n', 'N', 'Nzzzv', { silent = true })
|
||||
-- Unmap the 'p' key for previous word
|
||||
vim.api.nvim_set_keymap('n', 'gp', '<Nop>', { noremap = true, silent = true })
|
||||
|
||||
-- Quick fix navigation
|
||||
vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
|
@ -36,8 +40,8 @@ vim.keymap.set({ 'n', 'v' }, '<leader>y', "\"+y", { desc = "Copy to + register"
|
|||
vim.keymap.set('n', '<leader>Y', "\"+Y")
|
||||
|
||||
-- Replace current word
|
||||
vim.keymap.set("n", "<leader>s", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
|
||||
{ desc = "[S]ubstitute Current Word" })
|
||||
vim.keymap.set("n", "<leader>r", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]],
|
||||
{ desc = "[R]eplace Current Word" })
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { desc = "Set Current File to Executable", silent = true })
|
||||
|
||||
-- [ telescope keymaps]
|
||||
|
@ -69,3 +73,14 @@ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous dia
|
|||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' })
|
||||
|
||||
-- [[ 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', {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = '*',
|
||||
})
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
local opt = vim.opt
|
||||
local g = vim.g
|
||||
|
||||
local opts = {
|
||||
-- change cursor in insert mode
|
||||
-- Change cursor in insert mode
|
||||
guicursor = "",
|
||||
|
||||
-- Make line numbers default
|
||||
relativenumber = true,
|
||||
|
||||
-- Enable mouse mode
|
||||
mouse = 'a',
|
||||
|
||||
-- Enable break indent
|
||||
breakindent = true,
|
||||
|
||||
|
@ -18,16 +16,15 @@ local opts = {
|
|||
softtabstop = 4,
|
||||
shiftwidth = 4,
|
||||
expandtab = true,
|
||||
|
||||
smartindent = true,
|
||||
|
||||
-- Disable line wrap
|
||||
wrap = false,
|
||||
|
||||
-- Save undo history_list
|
||||
-- Save undo history
|
||||
swapfile = false,
|
||||
backup = false,
|
||||
undodir = os.getenv("HOME") .. "/.vim/undodir",
|
||||
undodir = vim.fn.stdpath("data") .. "/site/undodir",
|
||||
undofile = true,
|
||||
|
||||
-- Searching Configuration
|
||||
|
@ -48,14 +45,12 @@ local opts = {
|
|||
-- NOTE: You should make sure your terminal supports this
|
||||
termguicolors = true,
|
||||
scrolloff = 10,
|
||||
-- isfname:append("@-@"),
|
||||
colorcolumn = "80",
|
||||
-- part of the neovim imprioving command below
|
||||
pyxversion = 3
|
||||
pyxversion = 3,
|
||||
}
|
||||
|
||||
for k, v in pairs(opts) do
|
||||
vim.opt[k] = v
|
||||
opt[k] = v
|
||||
end
|
||||
|
||||
local win_local = {
|
||||
|
@ -67,7 +62,7 @@ for k, v in pairs(win_local) do
|
|||
vim.wo[k] = v
|
||||
end
|
||||
|
||||
-- disable builtins plugins
|
||||
-- Disable built-in plugins
|
||||
local disabled_built_ins = {
|
||||
"2html_plugin",
|
||||
"getscript",
|
||||
|
@ -75,12 +70,12 @@ local disabled_built_ins = {
|
|||
"gzip",
|
||||
"logipat",
|
||||
"matchit",
|
||||
-- "netrw",
|
||||
-- "netrw",
|
||||
"netrwFileHandlers",
|
||||
"loaded_remote_plugins",
|
||||
"loaded_tutor_mode_plugin",
|
||||
"netrwPlugin",
|
||||
"netrwSettings",
|
||||
-- "netrwPlugin",
|
||||
-- "netrwSettings",
|
||||
"rrhelper",
|
||||
"spellfile_plugin",
|
||||
"tar",
|
||||
|
@ -89,31 +84,27 @@ local disabled_built_ins = {
|
|||
"vimballPlugin",
|
||||
"zip",
|
||||
"zipPlugin",
|
||||
"matchparen", -- matchparen.nvim disables the default
|
||||
"matchparen",
|
||||
}
|
||||
|
||||
for _, plugin in pairs(disabled_built_ins) do
|
||||
vim.g["loaded_" .. plugin] = 1
|
||||
g["loaded_" .. plugin] = 1
|
||||
end
|
||||
|
||||
--
|
||||
-- IMPROVE NEOVIM STARTUP
|
||||
-- https://github.com/editorconfig/editorconfig-vim/issues/50
|
||||
-- Improve Neovim startup
|
||||
local global_let_opts = {
|
||||
loaded_python_provier = 0,
|
||||
loaded_python_provider = 0,
|
||||
loaded_python3_provider = 0,
|
||||
python_host_skip_check = 1,
|
||||
-- python_host_prog = '/bin/python2',
|
||||
python3_host_skip_check = 1,
|
||||
python3_host_prog = '/usr/local/bin/python3',
|
||||
EditorConfig_core_mode = 'external_command',
|
||||
-- https://vi.stackexchange.com/a/5318/7339
|
||||
matchparen_timeout = 20,
|
||||
matchparen_insert_timeout = 20,
|
||||
}
|
||||
|
||||
for k, v in pairs(global_let_opts) do
|
||||
vim.g[k] = v
|
||||
g[k] = v
|
||||
end
|
||||
|
||||
opt.formatoptions = "l"
|
||||
|
@ -126,12 +117,3 @@ opt.formatoptions = opt.formatoptions
|
|||
+ "n" -- Indent past the formatlistpat, not underneath it.
|
||||
+ "j" -- Auto-remove comments if possible.
|
||||
- "2" -- I'm not in gradeschool anymore
|
||||
|
||||
opt.guicursor = {
|
||||
"n-v:block",
|
||||
"i-c-ci-ve:ver25",
|
||||
"r-cr:hor20",
|
||||
"o:hor50",
|
||||
"i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor",
|
||||
"sm:block-blinkwait175-blinkoff150-blinkon175",
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -14,21 +14,48 @@ return {
|
|||
},
|
||||
config = function()
|
||||
-- See `:help cmp`
|
||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||
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 select_opts = { behavior = cmp.SelectBehavior.Select }
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
sources = {
|
||||
{ name = 'path' },
|
||||
{ name = 'nvim_lsp', keyword_length = 1 },
|
||||
{ name = 'buffer', keyword_length = 3 },
|
||||
{ name = 'luasnip', keyword_length = 2 },
|
||||
},
|
||||
window = {
|
||||
documentation = cmp.config.window.bordered()
|
||||
},
|
||||
formatting = {
|
||||
fields = { 'menu', 'abbr', 'kind' },
|
||||
format = function(entry, item)
|
||||
local menu_icon = {
|
||||
nvim_lsp = 'λ',
|
||||
luasnip = '⋗',
|
||||
buffer = 'Ω',
|
||||
path = '🖫',
|
||||
}
|
||||
|
||||
item.menu = menu_icon[entry.source.name]
|
||||
return item
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
|
@ -54,10 +81,38 @@ return {
|
|||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
||||
|
||||
local sign = function(opts)
|
||||
vim.fn.sign_define(opts.name, {
|
||||
texthl = opts.name,
|
||||
text = opts.text,
|
||||
numhl = ''
|
||||
})
|
||||
end
|
||||
|
||||
sign({ name = 'DiagnosticSignError', text = '✘' })
|
||||
sign({ name = 'DiagnosticSignWarn', text = '▲' })
|
||||
sign({ name = 'DiagnosticSignHint', text = '⚑' })
|
||||
sign({ name = 'DiagnosticSignInfo', text = '»' })
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(
|
||||
vim.lsp.handlers.hover,
|
||||
{ border = 'rounded' }
|
||||
)
|
||||
|
||||
vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(
|
||||
vim.lsp.handlers.signature_help,
|
||||
{ border = 'rounded' }
|
||||
)
|
||||
end,
|
||||
}
|
|
@ -60,17 +60,24 @@ return {
|
|||
-- Create a command `:Format` local to the LSP buffer
|
||||
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 and lint' })
|
||||
|
||||
-- Enable auto-formatting on save
|
||||
vim.api.nvim_command([[
|
||||
augroup AutoFormatOnSave
|
||||
autocmd!
|
||||
autocmd BufWritePre * :Format
|
||||
augroup END
|
||||
]])
|
||||
-- vim.api.nvim_command([[
|
||||
-- augroup AutoFormatOnSave
|
||||
-- autocmd!
|
||||
-- autocmd BufWritePre * :Format
|
||||
-- augroup END
|
||||
-- ]])
|
||||
end
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
require('neodev').setup()
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
|
||||
-- Servers configuration
|
||||
local servers = {
|
||||
clangd = {},
|
||||
gopls = {
|
||||
|
@ -82,7 +89,7 @@ return {
|
|||
completeUnimported = true,
|
||||
usePlaceholders = true,
|
||||
analysis = {
|
||||
unusedarams = true,
|
||||
unusedParams = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -91,46 +98,39 @@ return {
|
|||
settings = {
|
||||
pylsp = {
|
||||
plugins = {
|
||||
pycodestyle = {
|
||||
ignore = { 'W391' },
|
||||
maxLineLength = 79
|
||||
black = {
|
||||
blackArgs = {
|
||||
"--line-length", "79",
|
||||
"--exclude", "venv",
|
||||
"--exclude", "env",
|
||||
"--exclude", ".git",
|
||||
"--exclude", ".hg",
|
||||
},
|
||||
lineLength = 79,
|
||||
},
|
||||
flake8 = {},
|
||||
black = {
|
||||
lineLength = 79,
|
||||
-- Configure Black to split lines without specifying a target version
|
||||
blackArgs = {
|
||||
"--line-length",
|
||||
"79",
|
||||
"--exclude",
|
||||
"venv",
|
||||
"--exclude",
|
||||
"env",
|
||||
"--exclude",
|
||||
".git",
|
||||
"--exclude",
|
||||
".hg",
|
||||
},
|
||||
isort = {
|
||||
profile = "black",
|
||||
},
|
||||
mypy = {
|
||||
enabled = true,
|
||||
command = 'mypy',
|
||||
args = {},
|
||||
command = "mypy",
|
||||
diagnostics = true,
|
||||
enabled = true,
|
||||
},
|
||||
isort = {
|
||||
profile = 'black',
|
||||
pycodestyle = {
|
||||
ignore = { "W391" },
|
||||
maxLineLength = 79,
|
||||
},
|
||||
},
|
||||
python = {
|
||||
-- Specify the path to your Python interpreter
|
||||
pythonPath = "/usr/bin/python3",
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
diagnosticMode = "openFilesOnly",
|
||||
typeCheckingMode = "strict",
|
||||
useLibraryCodeForTypes = true,
|
||||
typeCheckingMode = 'on',
|
||||
},
|
||||
pythonPath = "/usr/local/bin/python3",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -138,7 +138,6 @@ return {
|
|||
-- rust_analyzer = {},
|
||||
-- tsserver = {},
|
||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
||||
|
||||
lua_ls = {
|
||||
Lua = {
|
||||
workspace = { checkThirdParty = false },
|
||||
|
@ -147,16 +146,8 @@ return {
|
|||
},
|
||||
}
|
||||
|
||||
-- Setup neovim lua configuration
|
||||
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)
|
||||
|
||||
-- Setup Mason condifuration
|
||||
local mason = require 'mason'
|
||||
|
||||
-- Setup Mason configuration
|
||||
local mason = require('mason')
|
||||
mason.setup {
|
||||
ui = {
|
||||
icons = {
|
||||
|
@ -166,13 +157,14 @@ return {
|
|||
},
|
||||
},
|
||||
}
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require 'mason-lspconfig'
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
local mason_lspconfig = require('mason-lspconfig')
|
||||
mason_lspconfig.setup {
|
||||
ensure_installed = vim.tbl_keys(servers)
|
||||
ensure_installed = vim.tbl_keys(servers),
|
||||
}
|
||||
|
||||
-- Add Mason handlers
|
||||
mason_lspconfig.setup_handlers {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup {
|
||||
|
@ -183,5 +175,8 @@ return {
|
|||
}
|
||||
end
|
||||
}
|
||||
|
||||
-- Load nvim-cmp after Mason to allow Mason to configure it first
|
||||
require('cmp')
|
||||
end
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
return {
|
||||
"debugloop/telescope-undo.nvim",
|
||||
dependencies = { -- note how they're inverted to above example
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
{ -- lazy style key map
|
||||
"<leader>u",
|
||||
"<cmd>Telescope undo<cr>",
|
||||
desc = "undo history",
|
||||
},
|
||||
},
|
||||
opts = {
|
||||
extensions = {
|
||||
undo = {
|
||||
side_by_side = true,
|
||||
layout_strategy = "vertical",
|
||||
layout_config = {
|
||||
preview_height = 0.8,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- Calling telescope's setup from multiple specs does not hurt, it will happily merge the
|
||||
-- configs for us. We won't use data, as everything is in it's own namespace (telescope
|
||||
-- defaults, as well as each extension).
|
||||
require("telescope").setup(opts)
|
||||
require("telescope").load_extension("undo")
|
||||
end,
|
||||
}
|
|
@ -4,6 +4,7 @@ return {
|
|||
branch = '0.1.x',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'debugloop/telescope-undo.nvim',
|
||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||
-- Only load if `make` is available. Make sure you have the system
|
||||
-- requirements installed.
|
||||
|
@ -19,7 +20,7 @@ return {
|
|||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
require('telescope').setup {
|
||||
require('telescope').setup({
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
|
@ -28,7 +29,7 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
-- Enable telescope fzf native, if installed
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
|
||||
|
@ -68,5 +69,7 @@ return {
|
|||
end
|
||||
|
||||
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {})
|
||||
|
||||
-- require("telescope").extensions.undo.undo()
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
return {
|
||||
'mbbill/undotree',
|
||||
config = function()
|
||||
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' })
|
||||
end
|
||||
-- 'mbbill/undotree',
|
||||
-- config = function()
|
||||
-- vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle, { desc = '[U]ndotree' })
|
||||
-- end
|
||||
}
|
||||
|
|
|
@ -43,4 +43,3 @@ return {
|
|||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
return {
|
||||
'folke/which-key.nvim',
|
||||
opts = {}
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
init = function()
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 300
|
||||
end,
|
||||
opts = {
|
||||
-- your configuration comes here
|
||||
-- or leave it empty to use the default settings
|
||||
-- refer to the configuration section below
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue