refactor config
This commit is contained in:
commit
4f0e213f4a
155 changed files with 13983 additions and 0 deletions
17
config/nvim.old/lua/autocommands.lua
Normal file
17
config/nvim.old/lua/autocommands.lua
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
local cmd = vim.api.nvim_create_autocmd
|
||||
|
||||
-- cmd({"BufNewFile", "BufFilePre", "BufRead"}, {
|
||||
-- pattern = {"*.md"},
|
||||
-- callback = function() vim.opt.filetype = "markdown" end
|
||||
-- })
|
||||
|
||||
cmd("InsertEnter",
|
||||
{pattern = "*", command = "norm zz", desc = "Center line on insert mode"})
|
||||
|
||||
-- highlight yank selection
|
||||
cmd("TextYankPost", {
|
||||
pattern = "*",
|
||||
callback = function() vim.highlight.on_yank() end,
|
||||
desc = "Highligth line on yank"
|
||||
})
|
||||
|
||||
51
config/nvim.old/lua/keys.lua
Normal file
51
config/nvim.old/lua/keys.lua
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
--[[
|
||||
|
||||
Modes:
|
||||
|
||||
| String value | Help page | Affected modes | Vimscript equivalent |
|
||||
| -------------|------------------|-----------------------------------------------|-----------------------|
|
||||
| '' | mapmode-nvo | Normal, Visual, Select, Operator-pending | :map |
|
||||
| 'n' | mapmode-n | Normal | :nmap |
|
||||
| 'v' | mapmode-v | Visual and Select | :vmap |
|
||||
| 's' | mapmode-s | Select | :smap |
|
||||
| 'x' | mapmode-x | Visual | :xmap |
|
||||
| 'o' | mapmode-o | Operator-pending | :omap |
|
||||
| '!' | mapmode-ic | Insert and Command-line | :map! |
|
||||
| 'i' | mapmode-i | Insert | :imap |
|
||||
| 'l' | mapmode-l | Insert, Command-line, Lang-Arg | :lmap |
|
||||
| 'c' | mapmode-c | Command-line | :cmap |
|
||||
| 't' | mapmode-t | Terminal | :tmap |
|
||||
|
||||
Define Mapping with:
|
||||
vim.keymap.set(mode, keys, action[, options])
|
||||
|
||||
--]]
|
||||
|
||||
-- Leader Key
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
vim.keymap.set('n', "<CR>", ":noh<CR>", { desc = "Remove search Highlight", silent = true })
|
||||
|
||||
-- local function changeComment()
|
||||
-- local table = vim.opt.fo:get()
|
||||
-- local enabled = tagle.c == true && tagle.r == true && tagle.o == true
|
||||
-- end
|
||||
|
||||
vim.keymap.set('', "<Leader>tc", [[if &fo =~ 'cro' | set fo-=cro | else | set fo+=cro | endif]], { desc = "Toggle autocomments", silent = true })
|
||||
|
||||
vim.keymap.set('', "<Leader>ti", ":setlocal autoindent!<CR>", { desc = "toggle auto indent"})
|
||||
|
||||
vim.keymap.set('', "<Leader>ts", ":setlocal spell!<CR>", { desc = "Toggle spell checker", silent = true })
|
||||
|
||||
vim.keymap.set('t', '<ESC>', [[<C-\><C-n>]], { desc = "Exit terminal with Esc", silent = true })
|
||||
|
||||
vim.keymap.set('n', '<C-s>', ':w<CR>', { desc = "Save file", silent = true })
|
||||
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<A-j>', ':m .+1<CR>==', { desc = "Move current line down", silent = true })
|
||||
|
||||
vim.keymap.set({ 'n', 'v', 'i' }, '<A-k>', ':m .-2<CR>==', { desc = "Move current line up", silent = true })
|
||||
|
||||
|
||||
vim.keymap.set('v', '<', '<gv', { desc = "Better indentation in visual mode", silent = true })
|
||||
|
||||
vim.keymap.set('v', '>', '>gv', { desc = "Better indentation in visual mode", silent = true })
|
||||
63
config/nvim.old/lua/options.lua
Normal file
63
config/nvim.old/lua/options.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
--------------------------------------------------------------------------------
|
||||
-- Native Neovim Config --
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
--[[
|
||||
|
||||
vim.opt.{option} -> :set
|
||||
vim.opt_global.{option} -> :setglobal
|
||||
vim.opt_local.{option} -> :setlocal
|
||||
|
||||
--]]
|
||||
|
||||
|
||||
-- Set Shell
|
||||
vim.opt.shell = "/usr/bin/env bash"
|
||||
|
||||
vim.g.python3_host_prog = "/usr/bin/python3"
|
||||
|
||||
-- Keep the cursor centered by X rows from top / bottom
|
||||
vim.opt.scrolloff = 15
|
||||
|
||||
-- Use System clipboard
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
-- Enable Mouse
|
||||
vim.opt.mouse = "a"
|
||||
|
||||
-- Set Numbers
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- Identation
|
||||
local indent = 2
|
||||
vim.opt.tabstop = indent
|
||||
vim.opt.shiftwidth = indent
|
||||
vim.opt.softtabstop = indent
|
||||
|
||||
-- Ignore case when searching
|
||||
vim.opt.ignorecase = true
|
||||
|
||||
-- Override the 'ignorecase' option if the search pattern contains case characters.
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Wrap Search
|
||||
vim.opt.wrapscan = true
|
||||
|
||||
-- Autocompletion with 'wildchar'
|
||||
vim.opt.wildmode = "longest,list,full"
|
||||
|
||||
-- Fix Sppliting
|
||||
vim.opt.splitbelow = true
|
||||
vim.opt.splitright = true
|
||||
|
||||
-- Set undofile
|
||||
vim.opt.undofile = true
|
||||
vim.opt.undodir = os.getenv("HOME") .. "/.nvim/undo"
|
||||
vim.opt.undolevels = 1000
|
||||
|
||||
-- Open already open windows
|
||||
vim.opt.switchbuf = 'usetab'
|
||||
|
||||
-- Auto add comments on new line if prev was a comment
|
||||
vim.opt.fo:append({ cro = true })
|
||||
50
config/nvim.old/lua/plugins/autocompletion.lua
Normal file
50
config/nvim.old/lua/plugins/autocompletion.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
-- luasnip setup
|
||||
local luasnip = require 'luasnip'
|
||||
local cmp = require 'cmp'
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args) require('luasnip').lsp_expand(args.body) end
|
||||
},
|
||||
mapping = {
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<C-e>'] = cmp.mapping.close(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true
|
||||
},
|
||||
['<Tab>'] = function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-n>', true,
|
||||
true, true), 'n')
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes(
|
||||
'<Plug>luasnip-expand-or-jump', true, true,
|
||||
true), '')
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
['<S-Tab>'] = function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes('<C-p>', true,
|
||||
true, true), 'n')
|
||||
elseif luasnip.jumpable(-1) then
|
||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes(
|
||||
'<Plug>luasnip-jump-prev', true, true, true),
|
||||
'')
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
},
|
||||
sources = {
|
||||
{name = 'nvim_lsp'}, {name = 'luasnip'}, {name = "nvim_lua"},
|
||||
{name = 'path'}, {name = 'buffer'}, {name = 'calc'},
|
||||
{name = 'treesitter'}
|
||||
}
|
||||
}
|
||||
2
config/nvim.old/lua/plugins/autopairs.lua
Normal file
2
config/nvim.old/lua/plugins/autopairs.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
require('nvim-autopairs').setup()
|
||||
|
||||
22
config/nvim.old/lua/plugins/bufferline.lua
Normal file
22
config/nvim.old/lua/plugins/bufferline.lua
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local function config()
|
||||
require("bufferline").setup({
|
||||
options = {
|
||||
diagnostics = "nvim_lsp",
|
||||
diagnostics_update_in_insert = true,
|
||||
color_icons = true,
|
||||
show_close_icon = false
|
||||
}
|
||||
})
|
||||
|
||||
vim.keymap.set('n', 'H', ':BufferLineCyclePrev<CR>', { desc = "Go to prev buffer", silent = true })
|
||||
vim.keymap.set('n', 'L', ':BufferLineCycleNext<CR>', { desc = "Go to next buffer", silent = true })
|
||||
vim.keymap.set('n', '<Leader>c', ':bdelete<CR>', { desc = "Close current buffer", silent = true })
|
||||
vim.keymap.set('n', '<Leader>C', ':bdelete!<CR>', { desc = "Close current buffer whitout saving", silent = true })
|
||||
end
|
||||
|
||||
return {
|
||||
'akinsho/bufferline.nvim',
|
||||
tag = "v2.*",
|
||||
requires = 'kyazdani42/nvim-web-devicons',
|
||||
config = config
|
||||
}
|
||||
81
config/nvim.old/lua/plugins/colorscheme.lua
Normal file
81
config/nvim.old/lua/plugins/colorscheme.lua
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
local function config()
|
||||
|
||||
local catppuccin = require("catppuccin")
|
||||
|
||||
vim.g.catppuccin_flavour = "mocha"
|
||||
|
||||
vim.cmd [[colorscheme catppuccin]]
|
||||
|
||||
-- configure it
|
||||
catppuccin.setup({
|
||||
transparent_background = true,
|
||||
term_colors = false,
|
||||
styles = {
|
||||
comments = {"italic"},
|
||||
conditionals = {"italic"},
|
||||
loops = {"italic"},
|
||||
functions = {"italic"},
|
||||
keywords = {"italic"},
|
||||
strings = {"italic"},
|
||||
variables = {"italic"},
|
||||
numbers = {},
|
||||
booleans = {},
|
||||
properties = {},
|
||||
types = {},
|
||||
operators = {}
|
||||
},
|
||||
integrations = {
|
||||
treesitter = true,
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
virtual_text = {
|
||||
errors = {"italic"},
|
||||
hints = {"italic"},
|
||||
warnings = {"italic"},
|
||||
information = {"italic"}
|
||||
},
|
||||
underlines = {
|
||||
errors = {"underline"},
|
||||
hints = {"underline"},
|
||||
warnings = {"underline"},
|
||||
information = {"underline"}
|
||||
}
|
||||
},
|
||||
lsp_trouble = true,
|
||||
cmp = true,
|
||||
lsp_saga = true,
|
||||
gitgutter = false,
|
||||
gitsigns = true,
|
||||
telescope = true,
|
||||
nvimtree = {
|
||||
enabled = true,
|
||||
show_root = true,
|
||||
transparent_panel = true
|
||||
},
|
||||
indent_blankline = {enabled = true, colored_indent_levels = true},
|
||||
neotree = {
|
||||
enabled = false,
|
||||
show_root = true,
|
||||
transparent_panel = false
|
||||
},
|
||||
dap = {enabled = false, enable_ui = false},
|
||||
which_key = true,
|
||||
dashboard = true,
|
||||
neogit = false,
|
||||
vim_sneak = false,
|
||||
fern = false,
|
||||
barbar = true,
|
||||
bufferline = true,
|
||||
markdown = true,
|
||||
lightspeed = false,
|
||||
ts_rainbow = true,
|
||||
hop = false,
|
||||
notify = true,
|
||||
telekasten = true,
|
||||
symbols_outline = true,
|
||||
mini = false
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
return {"catppuccin/nvim", as = "catppuccin", config = config}
|
||||
33
config/nvim.old/lua/plugins/dashboard.lua
Normal file
33
config/nvim.old/lua/plugins/dashboard.lua
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
-- Default FZF
|
||||
vim.g.dashboard_default_executive = "telescope"
|
||||
|
||||
-- Custom Shortcuts
|
||||
-- TODO: Change this for telescope equivalents
|
||||
vim.api.nvim_set_keymap('n', '<Leader>db', ":DashboardJumpMark<CR>",
|
||||
{silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>dh', ":DashboardFindHistory<CR>",
|
||||
{silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>df', ":DashboardFindFile<CR>",
|
||||
{silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>dn', ":DashboardNewFile<CR>",
|
||||
{silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>da', ":DashboardFindWord<CR>",
|
||||
{silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>dc', ":DashboardChangeColorscheme<CR>",
|
||||
{silent = true})
|
||||
|
||||
-- Show mappings
|
||||
vim.g.dashboard_custom_shortcut = {
|
||||
last_session = 'SPC s l',
|
||||
book_marks = 'SPC d b',
|
||||
find_history = 'SPC d h',
|
||||
find_file = 'SPC d f',
|
||||
new_file = 'SPC d n',
|
||||
find_word = 'SPC d a',
|
||||
change_colorscheme = 'SPC d c'
|
||||
}
|
||||
|
||||
-- Hide tabline on dashboard
|
||||
vim.cmd([[
|
||||
autocmd FileType dashboard set showtabline=0 | autocmd WinLeave <buffer> set showtabline=2
|
||||
]])
|
||||
72
config/nvim.old/lua/plugins/focus.lua
Normal file
72
config/nvim.old/lua/plugins/focus.lua
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
local focus = require("focus")
|
||||
|
||||
local options = {
|
||||
-- Completely disable this plugin
|
||||
-- Default: true
|
||||
enable = true,
|
||||
|
||||
-- Force width for the d window
|
||||
-- Default: Calculated based on golden ratio
|
||||
-- width = 120
|
||||
|
||||
-- Force height for the d window
|
||||
-- Default: Calculated based on golden ratio
|
||||
-- height = 40
|
||||
|
||||
-- Sets the width of directory tree buffers such as NerdTree, NvimTree and CHADTree
|
||||
-- Default: vim.g.nvim_tree_width or 30
|
||||
-- treewidth = 20
|
||||
|
||||
-- Displays a cursorline in the ed window only
|
||||
-- Not displayed in uned windows
|
||||
-- Default: true
|
||||
-- cursorline = false
|
||||
|
||||
-- Displays a sign column in the ed window only
|
||||
-- Not displayed in uned windows
|
||||
-- Default: true
|
||||
-- signcolumn = false
|
||||
|
||||
-- Displays line numbers in the ed window only
|
||||
-- Not displayed in uned windows
|
||||
-- Default: true
|
||||
number = true,
|
||||
|
||||
-- Displays relative line numbers in the ed window only
|
||||
-- Not displayed in uned windows
|
||||
-- See :h relativenumber
|
||||
-- Default: false
|
||||
relativenumber = true,
|
||||
|
||||
-- Displays hybrid line numbers in the ed window only
|
||||
-- Not displayed in uned windows
|
||||
-- Combination of :h relativenumber, but also displays the line number of the current line only
|
||||
-- Default: false
|
||||
-- hybridnumber = true
|
||||
|
||||
-- Enable auto highlighting for ed/unfocussed windows
|
||||
-- Default: false
|
||||
winhighlight = true,
|
||||
}
|
||||
|
||||
----------------------------------------------------------------------
|
||||
-- Mappings --
|
||||
----------------------------------------------------------------------
|
||||
|
||||
local function focusmap(direction)
|
||||
vim.keymap.set("n", "<C-" .. direction .. ">", function()
|
||||
focus.split_command(direction)
|
||||
end, { desc = "Change or create focused window" })
|
||||
end
|
||||
|
||||
focusmap("h")
|
||||
focusmap("j")
|
||||
focusmap("k")
|
||||
focusmap("l")
|
||||
|
||||
return {
|
||||
"beauwilliams/focus.nvim",
|
||||
config = function()
|
||||
require("focus").setup(options)
|
||||
end,
|
||||
}
|
||||
91
config/nvim.old/lua/plugins/gitsigns.lua
Normal file
91
config/nvim.old/lua/plugins/gitsigns.lua
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
local mapper = require("nvim-mapper")
|
||||
|
||||
require('gitsigns').setup {
|
||||
signs = {
|
||||
add = {
|
||||
hl = 'GitSignsAdd',
|
||||
text = '│',
|
||||
numhl = 'GitSignsAddNr',
|
||||
linehl = 'GitSignsAddLn'
|
||||
},
|
||||
change = {
|
||||
hl = 'GitSignsChange',
|
||||
text = '│',
|
||||
numhl = 'GitSignsChangeNr',
|
||||
linehl = 'GitSignsChangeLn'
|
||||
},
|
||||
delete = {
|
||||
hl = 'GitSignsDelete',
|
||||
text = '_',
|
||||
numhl = 'GitSignsDeleteNr',
|
||||
linehl = 'GitSignsDeleteLn'
|
||||
},
|
||||
topdelete = {
|
||||
hl = 'GitSignsDelete',
|
||||
text = '‾',
|
||||
numhl = 'GitSignsDeleteNr',
|
||||
linehl = 'GitSignsDeleteLn'
|
||||
},
|
||||
changedelete = {
|
||||
hl = 'GitSignsChange',
|
||||
text = '~',
|
||||
numhl = 'GitSignsChangeNr',
|
||||
linehl = 'GitSignsChangeLn'
|
||||
}
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
keymaps = {
|
||||
-- Default keymap options
|
||||
noremap = true,
|
||||
|
||||
['n ]h'] = {
|
||||
expr = true,
|
||||
"&diff ? ']c' : '<cmd>lua require\"gitsigns.actions\".next_hunk()<CR>'"
|
||||
},
|
||||
['n [h'] = {
|
||||
expr = true,
|
||||
"&diff ? '[c' : '<cmd>lua require\"gitsigns.actions\".prev_hunk()<CR>'"
|
||||
},
|
||||
|
||||
['n <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
|
||||
['v <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
||||
['n <leader>gu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
|
||||
['n <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
|
||||
['v <leader>gr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
|
||||
['n <leader>gR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
|
||||
['n <leader>gp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
|
||||
['n <leader>gb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>',
|
||||
['n <leader>gS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>',
|
||||
['n <leader>gU'] = '<cmd>lua require"gitsigns".reset_buffer_index()<CR>',
|
||||
|
||||
-- Text objects
|
||||
['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>',
|
||||
['x ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>'
|
||||
},
|
||||
watch_index = {interval = 1000, follow_files = true},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000
|
||||
},
|
||||
current_line_blame_formatter_opts = {relative_time = false},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = 'single',
|
||||
style = 'minimal',
|
||||
relative = 'cursor',
|
||||
row = 0,
|
||||
col = 1
|
||||
},
|
||||
diff_opts = {internal = true}, -- If vim.diff or luajit is present
|
||||
yadm = {enable = false}
|
||||
}
|
||||
27
config/nvim.old/lua/plugins/harpoon.lua
Normal file
27
config/nvim.old/lua/plugins/harpoon.lua
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
local mapper = require("nvim-mapper")
|
||||
|
||||
require("harpoon").setup({
|
||||
global_settings = {save_on_toggle = false, save_on_change = true}
|
||||
})
|
||||
|
||||
-- Mark list
|
||||
mapper.map('n', '<Leader>mq',
|
||||
[[:lua require("harpoon.ui").toggle_quick_menu()<CR>]],
|
||||
{silent = true, noremap = true}, "harpoon", "quick_menu",
|
||||
"Open list of marked files")
|
||||
|
||||
-- Mark File
|
||||
mapper.map('n', '<Leader>ma', [[:lua require("harpoon.mark").add_file()<CR>]],
|
||||
{silent = true, noremap = true}, "harpoon", "add_file",
|
||||
"Add current file to mark list")
|
||||
|
||||
-- Open marked file
|
||||
mapper.map('n', '<Leader>mj', [[:lua require("harpoon.ui").nav_file(1)<CR>]],
|
||||
{silent = true, noremap = true}, "harpoon", "file_navigation_1",
|
||||
"Go to marked file 1")
|
||||
mapper.map('n', '<Leader>mk', [[:lua require("harpoon.ui").nav_file(2)<CR>]],
|
||||
{silent = true, noremap = true}, "harpoon", "file_navigation_2",
|
||||
"Go to marked file 2")
|
||||
mapper.map('n', '<Leader>ml', [[:lua require("harpoon.ui").nav_file(3)<CR>]],
|
||||
{silent = true, noremap = true}, "harpoon", "file_navigation_3",
|
||||
"Go to marked file 3")
|
||||
25
config/nvim.old/lua/plugins/indent-lines.lua
Normal file
25
config/nvim.old/lua/plugins/indent-lines.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
local function config()
|
||||
|
||||
-- vim.opt.list = true
|
||||
-- vim.opt.listchars:append "space:⋅"
|
||||
-- vim.opt.listchars:append "eol:↴"
|
||||
|
||||
require("indent_blankline").setup {
|
||||
space_char_blankline = " ",
|
||||
show_current_context = true,
|
||||
show_current_context_start = false
|
||||
}
|
||||
|
||||
-- vim.g.indent_blankline_char_list = {"│"}
|
||||
-- vim.g.indentLine_enabled = 1
|
||||
vim.g.indent_blankline_show_trailing_blankline_indent = false
|
||||
vim.g.indent_blankline_filetype_exclude = {
|
||||
"help", "terminal", "dashboard", "nvim-tree"
|
||||
}
|
||||
vim.g.indent_blankline_buftype_exclude = {"terminal"}
|
||||
vim.g.indent_blankline_show_first_indent_level = false
|
||||
vim.g.indent_blankline_use_treesitter = true
|
||||
|
||||
end
|
||||
|
||||
return {"lukas-reineke/indent-blankline.nvim", config = config}
|
||||
62
config/nvim.old/lua/plugins/init.lua
Normal file
62
config/nvim.old/lua/plugins/init.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
local active_plugins = {
|
||||
"focus",
|
||||
"colorscheme",
|
||||
"nvim-tree",
|
||||
"bufferline",
|
||||
"treesitter",
|
||||
"prettyfolds",
|
||||
"indent-lines",
|
||||
"lsp",
|
||||
"telescope",
|
||||
}
|
||||
|
||||
--[[
|
||||
Auto update plugins from outside neomvim
|
||||
nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync'
|
||||
--]]
|
||||
--
|
||||
local ensure_packer = function()
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--depth",
|
||||
"1",
|
||||
"https://github.com/wbthomason/packer.nvim",
|
||||
install_path,
|
||||
})
|
||||
vim.cmd([[packadd packer.nvim]])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local packer_bootstrap = ensure_packer()
|
||||
|
||||
require("packer").startup({
|
||||
function(use)
|
||||
use("wbthomason/packer.nvim")
|
||||
|
||||
for _, name in ipairs(active_plugins) do
|
||||
local ok, plugin = pcall(require, "plugins." .. name)
|
||||
if ok then
|
||||
use(plugin)
|
||||
else
|
||||
print("Error loading " .. name .. "In: " .. plugin)
|
||||
end
|
||||
end
|
||||
|
||||
if packer_bootstrap then
|
||||
require("packer").sync()
|
||||
end
|
||||
end,
|
||||
config = {
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require("packer.util").float({ border = "single" })
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
160
config/nvim.old/lua/plugins/lsp.lua
Normal file
160
config/nvim.old/lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
--[[
|
||||
|
||||
LSP Server: code completition, references for variables and other stuff.
|
||||
Linter: Code rules for consistency.
|
||||
Formatter: Code style for eye candy.
|
||||
Debugger: well... a debugger...
|
||||
|
||||
--]]
|
||||
|
||||
-- FIXME: Refactor this code so it's more readable
|
||||
|
||||
local function setup()
|
||||
local lsp = require("lsp-zero")
|
||||
local cmp = require("cmp")
|
||||
local null_ls = require("null-ls")
|
||||
-- local mason_null_ls = require("mason-null-ls")
|
||||
|
||||
lsp.preset("recommended")
|
||||
|
||||
lsp.nvim_workspace({
|
||||
library = vim.api.nvim_get_runtime_file("", true),
|
||||
})
|
||||
|
||||
local cmp_select = { behavior = cmp.SelectBehavior.Select }
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
mapping = lsp.defaults.cmp_mappings({
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
|
||||
}),
|
||||
|
||||
sources = {
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lsp", keyword_length = 3 },
|
||||
{ name = "luasnip", keyword_length = 2 },
|
||||
},
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
set_lsp_keymaps = false,
|
||||
})
|
||||
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover()
|
||||
end, { desc = "Show lsp info of the symbol under the cursor", silent = true })
|
||||
vim.keymap.set("n", "gd", function()
|
||||
vim.lsp.buf.definition()
|
||||
end, { desc = "Go to definition", silent = true })
|
||||
vim.keymap.set("n", "gD", function()
|
||||
vim.lsp.buf.declaration()
|
||||
end, { desc = "Go to declaration", silent = true })
|
||||
vim.keymap.set("n", "gi", function()
|
||||
vim.lsp.buf.implementation()
|
||||
end, { desc = "Go to implementation", silent = true })
|
||||
vim.keymap.set("n", "go", function()
|
||||
vim.lsp.buf.type_definition()
|
||||
end, { desc = "Go to definition of the type", silent = true })
|
||||
vim.keymap.set("n", "gr", function()
|
||||
vim.lsp.buf.references()
|
||||
end, { desc = "List references in quickfix window", silent = true })
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end, { desc = "Show signature", silent = true })
|
||||
vim.keymap.set("n", "<Leader>lr", function()
|
||||
vim.lsp.buf.rename()
|
||||
end, { desc = "Rename all references", silent = true })
|
||||
vim.keymap.set("n", "<Leader>la", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end, { desc = "Code action", silent = true })
|
||||
vim.keymap.set("n", "<Leader>lj", function()
|
||||
vim.diagnostic.goto_next()
|
||||
end, { desc = "Go to next diagnostics", silent = true })
|
||||
vim.keymap.set("n", "<Leader>lk", function()
|
||||
vim.diagnostic.goto_prev()
|
||||
end, { desc = "Go to prev diagnostics", silent = true })
|
||||
|
||||
lsp.setup()
|
||||
|
||||
local null_linters = null_ls.builtins.diagnostics
|
||||
local null_formatters = null_ls.builtins.formatting
|
||||
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
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
|
||||
|
||||
null_ls.setup({
|
||||
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()
|
||||
-- TODO: use this when neovim 8.0 comes out
|
||||
lsp_formatting(bufnr)
|
||||
-- vim.lsp.buf.formatting_sync()
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
|
||||
sources = {
|
||||
-- Linters --
|
||||
null_linters.eslint_d,
|
||||
null_linters.gitlint,
|
||||
null_linters.luacheck,
|
||||
null_linters.markdownlint,
|
||||
null_linters.shellcheck,
|
||||
null_linters.yamllint,
|
||||
null_linters.todo_comments,
|
||||
|
||||
-- Formatters --
|
||||
null_formatters.blade_formatter,
|
||||
null_formatters.blue,
|
||||
null_formatters.fixjson,
|
||||
null_formatters.phpcsfixer,
|
||||
null_formatters.prettierd,
|
||||
null_formatters.shfmt,
|
||||
null_formatters.sql_formatter,
|
||||
null_formatters.stylua,
|
||||
null_formatters.yamlfmt,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
"VonHeikemen/lsp-zero.nvim",
|
||||
config = setup,
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{ "neovim/nvim-lspconfig" },
|
||||
{ "williamboman/mason.nvim" },
|
||||
{ "williamboman/mason-lspconfig.nvim" },
|
||||
|
||||
-- Autocompletion
|
||||
{ "hrsh7th/nvim-cmp" },
|
||||
{ "hrsh7th/cmp-buffer" },
|
||||
{ "hrsh7th/cmp-path" },
|
||||
{ "saadparwaiz1/cmp_luasnip" },
|
||||
{ "hrsh7th/cmp-nvim-lsp" },
|
||||
{ "hrsh7th/cmp-nvim-lua" },
|
||||
|
||||
-- Snippets
|
||||
{ "L3MON4D3/LuaSnip" },
|
||||
{ "rafamadriz/friendly-snippets" },
|
||||
|
||||
-- Linters and Formatters
|
||||
{ "jose-elias-alvarez/null-ls.nvim" },
|
||||
-- { "jayp0521/mason-null-ls.nvim" },
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
},
|
||||
}
|
||||
38
config/nvim.old/lua/plugins/nvim-comment-frame.lua
Normal file
38
config/nvim.old/lua/plugins/nvim-comment-frame.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local mapper = require("nvim-mapper")
|
||||
|
||||
require('nvim-comment-frame').setup({
|
||||
|
||||
-- if true, <leader>cf keymap will be disabled
|
||||
disable_default_keymap = true,
|
||||
|
||||
-- width of the comment frame
|
||||
frame_width = 70,
|
||||
|
||||
-- wrap the line after 'n' characters
|
||||
line_wrap_len = 50,
|
||||
|
||||
-- automatically indent the comment frame based on the line
|
||||
auto_indent = true,
|
||||
|
||||
-- add comment above the current line
|
||||
add_comment_above = true,
|
||||
|
||||
-- configurations for individual language goes here
|
||||
languages = {
|
||||
dosini = {
|
||||
start_str = ';;',
|
||||
end_str = ';;',
|
||||
fill_char = '*',
|
||||
auto_indent = false
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
mapper.map('n', '<Leader>ch',
|
||||
[[:lua require('nvim-comment-frame').add_comment()<CR>]],
|
||||
{silent = true, noremap = true}, "nvim-comment-frame", "one line",
|
||||
"Add one line header")
|
||||
mapper.map('n', '<Leader>cH',
|
||||
[[:lua require('nvim-comment-frame').add_multiline_comment()<CR>]],
|
||||
{silent = true, noremap = true}, "nvim-comment-frame", "multi line",
|
||||
"Add multi line header")
|
||||
47
config/nvim.old/lua/plugins/nvim-toggleterm.lua
Normal file
47
config/nvim.old/lua/plugins/nvim-toggleterm.lua
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
local mapper = require("nvim-mapper")
|
||||
-- don't close terminals on hidden
|
||||
vim.opt.hidden = true
|
||||
|
||||
require("toggleterm").setup {
|
||||
-- size can be a number or function which is passed the current terminal
|
||||
size = function(term)
|
||||
if term.direction == "horizontal" then
|
||||
return 15
|
||||
elseif term.direction == "vertical" then
|
||||
return vim.o.columns * 0.4
|
||||
end
|
||||
end,
|
||||
hide_numbers = true, -- hide the number column in toggleterm buffers
|
||||
shade_filetypes = {},
|
||||
shade_terminals = false,
|
||||
-- shading_factor = '<number>', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light
|
||||
start_in_insert = true,
|
||||
insert_mappings = true, -- whether or not the open mapping applies in insert mode
|
||||
persist_size = true,
|
||||
direction = 'float', -- 'vertical' | 'horizontal' | 'window' | 'float',
|
||||
close_on_exit = true, -- close the terminal window when the process exits
|
||||
shell = vim.o.shell, -- change the default shell
|
||||
-- This field is only relevant if direction is set to 'float'
|
||||
float_opts = {
|
||||
-- The border key is *almost* the same as 'nvim_win_open'
|
||||
-- see :h nvim_win_open for details on borders however
|
||||
-- the 'curved' border is a custom border type
|
||||
-- not natively supported but implemented in this plugin.
|
||||
border = 'single', -- 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
|
||||
width = math.ceil(vim.o.columns * 0.8),
|
||||
height = math.ceil(vim.o.lines * 0.6),
|
||||
winblend = 0,
|
||||
highlights = {border = "Normal", background = "Normal"}
|
||||
}
|
||||
}
|
||||
|
||||
-- Toggle Terminals
|
||||
mapper.map('n', '<Leader>mf', [[:1ToggleTerm<CR>]],
|
||||
{silent = true, noremap = true}, "Terminal", "toggle_term_1",
|
||||
"Toggle terminal 1")
|
||||
mapper.map('n', '<Leader>md', [[:2ToggleTerm<CR>]],
|
||||
{silent = true, noremap = true}, "Terminal", "toggle_term_2",
|
||||
"Toggle terminal 2")
|
||||
mapper.map('n', '<Leader>ms', [[:3ToggleTerm<CR>]],
|
||||
{silent = true, noremap = true}, "Terminal", "toggle_term_3",
|
||||
"Toggle terminal 3")
|
||||
53
config/nvim.old/lua/plugins/nvim-tree.lua
Normal file
53
config/nvim.old/lua/plugins/nvim-tree.lua
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
local function tree_config()
|
||||
local tree = require("nvim-tree")
|
||||
local tree_cb = require("nvim-tree.config").nvim_tree_callback
|
||||
|
||||
tree.setup({
|
||||
hijack_unnamed_buffer_when_opening = true,
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
hijack_cursor = true, -- cursor at the start of filename
|
||||
update_focused_file = {
|
||||
enable = true -- focus curren file
|
||||
},
|
||||
actions = { open_file = { quit_on_open = true } },
|
||||
renderer = {
|
||||
full_name = true, -- show remaining name in floating text
|
||||
group_empty = true, -- group empty folders
|
||||
add_trailing = true, -- Trailing slash to folders
|
||||
highlight_opened_files = "all",
|
||||
highlight_git = true
|
||||
},
|
||||
view = {
|
||||
centralize_selection = true, -- center current file on enter
|
||||
width = 30, -- N° of columns or %
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
-- list of mappings to set on the tree manually
|
||||
list = {
|
||||
{ key = { "l", "<CR>", "o", "<2-LeftMouse>" }, action = "edit" },
|
||||
-- {key = {"L", "<2-RightMouse>", "<C-]>"}, action = "cd"},
|
||||
{ key = "s", action = "vsplit" },
|
||||
{ key = "v", action = "split" },
|
||||
{ key = "t", action = "tabnew" },
|
||||
{ key = { "h", "<BS>" }, action = "close_node" },
|
||||
{ key = "i", action = "toggle_dotfiles" },
|
||||
{ key = "I", action = "toggle_ignored" },
|
||||
{ key = { "<C-l>", "<C-CR>" }, cb = tree_cb("system_open") }
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
-- bindings
|
||||
vim.keymap.set("n", "<leader>e", ":NvimTreeToggle<CR>", { desc = "Toggle file tree", silent = true })
|
||||
vim.keymap.set("n", "<C-e>", ":NvimTreeToggle<CR>", { desc = "Toggle file tree", silent = true })
|
||||
end
|
||||
|
||||
return {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
config = tree_config,
|
||||
requires = {
|
||||
'kyazdani42/nvim-web-devicons' -- optional, for file icons
|
||||
}
|
||||
}
|
||||
3
config/nvim.old/lua/plugins/prettyfolds.lua
Normal file
3
config/nvim.old/lua/plugins/prettyfolds.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
local function config() require('pretty-fold').setup({fill_char = " "}) end
|
||||
|
||||
return {'anuvyklack/pretty-fold.nvim', config = config}
|
||||
36
config/nvim.old/lua/plugins/projects.lua
Normal file
36
config/nvim.old/lua/plugins/projects.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
require("project_nvim").setup {
|
||||
-- Manual mode doesn't automatically change your root directory, so you have
|
||||
-- the option to manually do so using `:ProjectRoot` command.
|
||||
manual_mode = false,
|
||||
|
||||
-- Methods of detecting the root directory. **"lsp"** uses the native neovim
|
||||
-- lsp, while **"pattern"** uses vim-rooter like glob pattern matching. Here
|
||||
-- order matters: if one is not detected, the other is used as fallback. You
|
||||
-- can also delete or rearangne the detection methods.
|
||||
detection_methods = {"lsp", "pattern"},
|
||||
|
||||
-- All the patterns used to detect root dir, when **"pattern"** is in
|
||||
-- detection_methods
|
||||
patterns = {
|
||||
".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json"
|
||||
},
|
||||
|
||||
-- Table of lsp clients to ignore by name
|
||||
-- eg: { "efm", ... }
|
||||
ignore_lsp = {},
|
||||
|
||||
-- Don't calculate root dir on specific directories
|
||||
-- Ex: { "~/.cargo/*", ... }
|
||||
exclude_dirs = {},
|
||||
|
||||
-- Show hidden files in telescope
|
||||
show_hidden = false,
|
||||
|
||||
-- When set to false, you will get a message when project.nvim changes your
|
||||
-- directory.
|
||||
silent_chdir = false,
|
||||
|
||||
-- Path where project.nvim will store the project history for use in
|
||||
-- telescope
|
||||
datapath = vim.fn.stdpath("data")
|
||||
}
|
||||
80
config/nvim.old/lua/plugins/telescope.lua
Normal file
80
config/nvim.old/lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
local function config()
|
||||
-- Telescope.nvim
|
||||
local telescope = require("telescope")
|
||||
local pickers = require("telescope.builtin")
|
||||
require("project_nvim").setup()
|
||||
|
||||
-- Extensions
|
||||
telescope.load_extension("projects")
|
||||
|
||||
-- Open Files
|
||||
vim.keymap.set("n", "<Leader>f", function()
|
||||
pickers.find_files()
|
||||
end, { silent = true, desc = "Find file" })
|
||||
|
||||
vim.keymap.set("n", "<Leader>Fp", function()
|
||||
telescope.extensions.projects.projects()
|
||||
end, { silent = true, desc = "Find project" })
|
||||
|
||||
-- List vim stuff
|
||||
vim.keymap.set("n", "<Leader>bf", function()
|
||||
pickers.buffers()
|
||||
end, { silent = true, desc = "Find buffers" })
|
||||
|
||||
-- List LSP Stuff
|
||||
vim.keymap.set("n", "<Leader>ld", function()
|
||||
pickers.diagnostics({ bufnr = 0 })
|
||||
end, { silent = true, desc = "Find diagnostics" })
|
||||
|
||||
vim.keymap.set("n", "<Leader>lD", function()
|
||||
pickers.diagnostics()
|
||||
end, { silent = true, desc = "Find diagnostics in all buffers" })
|
||||
|
||||
-- Config
|
||||
local telescope_actions = require("telescope.actions")
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
entry_prefix = " ",
|
||||
selection_caret = "* ",
|
||||
file_ignore_patterns = { "%.env", "cache", ".xlsx" },
|
||||
mappings = {
|
||||
i = {
|
||||
["<C-j>"] = telescope_actions.move_selection_next,
|
||||
["<C-k>"] = telescope_actions.move_selection_previous,
|
||||
["<C-s>"] = telescope_actions.file_vsplit,
|
||||
["<C-v>"] = telescope_actions.file_split,
|
||||
["<ESC>"] = telescope_actions.close,
|
||||
},
|
||||
n = {
|
||||
["gg"] = telescope_actions.move_to_top,
|
||||
["G"] = telescope_actions.move_to_bottom,
|
||||
["s"] = telescope_actions.file_vsplit,
|
||||
["v"] = telescope_actions.file_split,
|
||||
},
|
||||
},
|
||||
path_display = {
|
||||
truncate = 1,
|
||||
},
|
||||
},
|
||||
-- Specific config
|
||||
pickers = {
|
||||
buffers = {
|
||||
sort_lastused = true,
|
||||
mappings = {
|
||||
i = { ["d"] = require("telescope.actions").delete_buffer },
|
||||
n = { ["<c-d>"] = require("telescope.actions").delete_buffer },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
branch = "0.1.x",
|
||||
requires = {
|
||||
"nvim-lua/plenary.nvim",
|
||||
"ahmedkhalf/project.nvim",
|
||||
},
|
||||
config = config,
|
||||
}
|
||||
37
config/nvim.old/lua/plugins/treesitter.lua
Normal file
37
config/nvim.old/lua/plugins/treesitter.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
local function config()
|
||||
|
||||
require('nvim-treesitter.configs').setup({
|
||||
ensure_installed = {
|
||||
"bash", "c", "comment", "cpp", "css", "dockerfile", "html",
|
||||
"javascript", "jsdoc", "json", "lua", "python", "query", "regex",
|
||||
"typescript", "yaml", "sql", "http", "php", "rust", "scss",
|
||||
"markdown", "dart"
|
||||
},
|
||||
highlight = {enable = true},
|
||||
indent = {enable = true},
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean
|
||||
max_file_lines = 1000 -- Do not enable for files with more than 1000 lines, int
|
||||
}
|
||||
})
|
||||
|
||||
-- Treesitter Folding
|
||||
vim.api.nvim_create_autocmd({
|
||||
'BufEnter', 'BufAdd', 'BufNew', 'BufNewFile', 'BufWinEnter'
|
||||
}, {
|
||||
group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}),
|
||||
callback = function()
|
||||
vim.opt.foldmethod = 'expr'
|
||||
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||
end
|
||||
})
|
||||
end
|
||||
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
require('nvim-treesitter.install').update({with_sync = true})
|
||||
end,
|
||||
config = config
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue