chore(repo): First contentful commit
This is the first commit that actually adds files to the repo. Yes it's a bad commit but now the major features are here
This commit is contained in:
parent
0e87bcc2f6
commit
d032e3e274
|
|
@ -5,6 +5,9 @@ My main goal is to remove any technical debt and almost start fresh.
|
|||
|
||||
This could get interesting..
|
||||
|
||||
This is a work-in-progress config and may break sometimes.
|
||||
any releases made are expected to be stable
|
||||
|
||||
## Modules
|
||||
|
||||
### `sherlock5512.utilities.lua`
|
||||
|
|
|
|||
175
after/plugin/LSP.lua
Normal file
175
after/plugin/LSP.lua
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
local utilities = require("sherlock5512.utilities")
|
||||
local log = require("tjdevries.log")
|
||||
local required = {'mason','mason-lspconfig','lspconfig','cmp_nvim_lsp','fidget','neodev','mason-null-ls','mason-nvim-dap','dap','dapui'}
|
||||
local modules = utilities.require_modules(required)
|
||||
|
||||
if not modules then
|
||||
log.error("some modules could not be loaded")
|
||||
return
|
||||
end
|
||||
|
||||
local capabilities = modules['cmp_nvim_lsp'].default_capabilities()
|
||||
|
||||
modules['neodev'].setup()
|
||||
modules["mason"].setup()
|
||||
modules["mason-lspconfig"].setup {
|
||||
ensure_installed = {"lua_ls"}
|
||||
}
|
||||
|
||||
modules["mason-lspconfig"].setup_handlers {
|
||||
|
||||
function (server_name)
|
||||
modules["lspconfig"][server_name].setup {
|
||||
capabilities = capabilities
|
||||
}
|
||||
end
|
||||
}
|
||||
|
||||
modules['mason-null-ls'].setup({
|
||||
ensure_installed = {},
|
||||
automatic_installation = false,
|
||||
automatic_setup = true,
|
||||
})
|
||||
|
||||
modules['mason-null-ls'].setup_handlers {
|
||||
function (source_name, methods)
|
||||
require('mason-null-ls.automatic_setup')(source_name,methods)
|
||||
end,
|
||||
-- Custom handlers can be added below if needed
|
||||
}
|
||||
|
||||
modules['fidget'].setup{
|
||||
text = {
|
||||
spinner = "dots"
|
||||
}
|
||||
}
|
||||
|
||||
-- Built in diagnostic settings are also configured here
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
update_in_insert = true,
|
||||
severity_sort = false,
|
||||
})
|
||||
|
||||
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})
|
||||
end
|
||||
|
||||
local auGroupDiagHover = vim.api.nvim_create_augroup("Diagnostic_hover",{clear = true})
|
||||
vim.api.nvim_create_autocmd("CursorHold",{
|
||||
pattern = {"*"},
|
||||
callback = function ()
|
||||
vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})
|
||||
end,
|
||||
group = auGroupDiagHover
|
||||
})
|
||||
|
||||
-- ## DAP ## warning: here be dragons
|
||||
modules['mason-nvim-dap'].setup({
|
||||
automatic_setup = true,
|
||||
})
|
||||
|
||||
modules['mason-nvim-dap'].setup_handlers {
|
||||
function (source_name)
|
||||
require('mason-nvim-dap.automatic_setup')(source_name)
|
||||
end
|
||||
}
|
||||
|
||||
modules['dapui'].setup({
|
||||
icons = {
|
||||
expanded = "",
|
||||
collapsed = "",
|
||||
current_frame = "",
|
||||
},
|
||||
expand_lines = vim.fn.has("nvim-0.7") == 1,
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
-- Elements can be strings or table with id and size keys.
|
||||
{ id = "scopes", size = 0.25 },
|
||||
"breakpoints",
|
||||
"stacks",
|
||||
"watches",
|
||||
},
|
||||
size = 40, -- 40 columns
|
||||
position = "left",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
"repl",
|
||||
"console",
|
||||
},
|
||||
size = 0.25, -- 25% of total lines
|
||||
position = "bottom",
|
||||
},
|
||||
},
|
||||
controls = {
|
||||
-- Requires Neovim nightly (or 0.8 when released)
|
||||
enabled = true,
|
||||
-- Display controls in this element
|
||||
element = "repl",
|
||||
icons = {
|
||||
pause = "",
|
||||
play = "",
|
||||
step_into = "",
|
||||
step_over = "",
|
||||
step_out = "",
|
||||
step_back = "",
|
||||
run_last = "",
|
||||
terminate = "",
|
||||
},
|
||||
},
|
||||
floating = {
|
||||
max_height = nil, -- These can be integers or a float between 0 and 1.
|
||||
max_width = nil, -- Floats will be treated as percentage of your screen.
|
||||
border = "single", -- Border style. Can be "single", "double" or "rounded"
|
||||
mappings = {
|
||||
close = { "q", "<Esc>" },
|
||||
},
|
||||
},
|
||||
windows = { indent = 1 },
|
||||
render = {
|
||||
max_type_length = nil, -- Can be integer or nil.
|
||||
max_value_lines = 100, -- Can be integer or nil.
|
||||
}
|
||||
})
|
||||
|
||||
modules['dap'].listeners.after.event_initialized["dapui_config"] = function()
|
||||
modules['dapui'].open()
|
||||
end
|
||||
modules['dap'].listeners.before.event_terminated["dapui_config"] = function()
|
||||
modules['dapui'].close()
|
||||
end
|
||||
modules['dap'].listeners.before.event_exited["dapui_config"] = function()
|
||||
modules['dapui'].close()
|
||||
end
|
||||
|
||||
-- Also configure lspsaga here.
|
||||
-- Separate require check since we don't NEED lspsaga
|
||||
local ok,lspsaga = pcall(require,"lspsaga")
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
-- Wrapping since some distros still don't ship nvim 0.8
|
||||
if vim.fn.exists('+winbar') ~= 0 then
|
||||
lspsaga.setup({
|
||||
symbol_in_winbar = {
|
||||
in_custom = false,
|
||||
enable = true,
|
||||
seperator = '>',
|
||||
show_file = true,
|
||||
click_support = false
|
||||
},
|
||||
diagnostic_header = { " ", " ", " ", "ﴞ " },
|
||||
})
|
||||
else
|
||||
lspsaga.setup({
|
||||
diagnostic_header = { " ", " ", " ", "ﴞ " },
|
||||
})
|
||||
end
|
||||
11
after/plugin/bufferline.lua
Normal file
11
after/plugin/bufferline.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
local ok, bufferline = pcall(require,'bufferline')
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
bufferline.setup {
|
||||
options = {
|
||||
diagnostics = "nvim_lsp"
|
||||
}
|
||||
}
|
||||
7
after/plugin/colour.lua
Normal file
7
after/plugin/colour.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
local ok = pcall(require, "gruvbox")
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
vim.o.background = "dark"
|
||||
vim.cmd.colorscheme('gruvbox')
|
||||
103
after/plugin/completion.lua
Normal file
103
after/plugin/completion.lua
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
local utilities = require('sherlock5512.utilities')
|
||||
local required = {"lspkind","luasnip","cmp"}
|
||||
local modules = utilities.require_modules(required)
|
||||
|
||||
if not modules then
|
||||
return
|
||||
end
|
||||
|
||||
-- lspkind MUST be initialised before use
|
||||
modules.lspkind.init()
|
||||
|
||||
-- I define a default set of configs that are shared across all filetypes,
|
||||
-- This way I can have fietype specific configs without using autocommands.
|
||||
local defaultSources = modules.cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "path" },
|
||||
})
|
||||
|
||||
local defaultSnippet = {
|
||||
expand = function (args)
|
||||
modules.luasnip.lsp_expand(args.body)
|
||||
end
|
||||
}
|
||||
|
||||
local defaultMapping = {
|
||||
["<Tab>"] = modules.cmp.mapping(function(fallback)
|
||||
if modules.cmp.visible() then
|
||||
modules.cmp.select_next_item()
|
||||
elseif modules.luasnip.expand_or_locally_jumpable() then
|
||||
modules.luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i","s"}),
|
||||
|
||||
["<S-Tab>"] = modules.cmp.mapping(function(fallback)
|
||||
if modules.cmp.visible() then
|
||||
modules.cmp.select_prev_item()
|
||||
elseif modules.luasnip.locally_jumpable(-1) then
|
||||
modules.luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i","s"}),
|
||||
|
||||
["<C-n>"] = modules.cmp.mapping.select_next_item {behaviour = modules.cmp.SelectBehavior.Insert},
|
||||
["<C-p>"] = modules.cmp.mapping.select_prev_item {behaviour = modules.cmp.SelectBehavior.Insert},
|
||||
["<C-b>"] = modules.cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = modules.cmp.mapping.scroll_docs(4),
|
||||
["<C-e>"] = modules.cmp.mapping.abort(),
|
||||
["<CR>"] = modules.cmp.mapping.confirm({ select = false })
|
||||
}
|
||||
|
||||
local defaultFormat = modules.lspkind.cmp_format ({
|
||||
mode = "symbol_text",
|
||||
menu = {
|
||||
buffer = "[BUF]",
|
||||
nvim_lsp = "[LSP]",
|
||||
path = "[PTH]",
|
||||
luasnip = "[SNP]",
|
||||
emoji = "[EMJ]",
|
||||
},
|
||||
maxwidth = 50,
|
||||
ellipsis_char = "…"
|
||||
})
|
||||
|
||||
modules.cmp.setup {
|
||||
snippet = defaultSnippet,
|
||||
sources = defaultSources,
|
||||
mapping = defaultMapping,
|
||||
formatting = {
|
||||
format = defaultFormat
|
||||
}
|
||||
}
|
||||
|
||||
-- I'm not sure if the mappings are referenced after configuring,
|
||||
-- Just in case I deepcopy them before changing things.
|
||||
local mdSources = vim.deepcopy(defaultSources)
|
||||
table.insert(mdSources,{ name = "emoji"} )
|
||||
|
||||
modules.cmp.setup.filetype('markdown',{
|
||||
snippet = defaultSnippet,
|
||||
sources = mdSources,
|
||||
mapping = defaultMapping,
|
||||
})
|
||||
|
||||
-- completion for searches
|
||||
modules.cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = modules.cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
modules.cmp.setup.cmdline(':', {
|
||||
mapping = modules.cmp.mapping.preset.cmdline(),
|
||||
sources = modules.cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
})
|
||||
})
|
||||
43
after/plugin/format.lua
Normal file
43
after/plugin/format.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local ok, formatter = pcall(require,'formatter')
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
local config_ft = {}
|
||||
if pcall(require, 'mason') then
|
||||
-- Configure based on mason status
|
||||
local packages = require('mason-registry').get_installed_packages()
|
||||
local formatters = {} -- installed formatters go here
|
||||
|
||||
for _, package in pairs(packages) do
|
||||
local cats = package.spec.categories
|
||||
if vim.tbl_contains(cats,package.Cat.Formatter) then
|
||||
table.insert(formatters,package)
|
||||
end
|
||||
end
|
||||
|
||||
-- Insert one ugly ass control flow here
|
||||
for _, formatprog in pairs(formatters) do
|
||||
local name = formatprog.name
|
||||
|
||||
if name == 'stylua' then
|
||||
config_ft['lua'] = {
|
||||
require('formatter.filetypes.lua').stylua
|
||||
}
|
||||
print()
|
||||
end
|
||||
|
||||
print()
|
||||
end
|
||||
else
|
||||
-- Configure statically
|
||||
end
|
||||
|
||||
formatter.setup {
|
||||
logging = true,
|
||||
log_level = vim.log.levels.WARN,
|
||||
filetype = config_ft
|
||||
}
|
||||
|
||||
-- Configure keybindings
|
||||
53
after/plugin/lualine.lua
Normal file
53
after/plugin/lualine.lua
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
local ok, lualine = pcall(require,"lualine")
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
lualine.setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'gruvbox',
|
||||
component_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
},
|
||||
section_separators = {
|
||||
left = '',
|
||||
right = ''
|
||||
},
|
||||
disabled_filetypes = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = true,
|
||||
},
|
||||
sections = {
|
||||
lualine_a = {
|
||||
'mode',
|
||||
'spell_status',
|
||||
},
|
||||
lualine_b = {
|
||||
'branch',
|
||||
'diff',
|
||||
'diagnostics'
|
||||
},
|
||||
lualine_c = {
|
||||
'filename',
|
||||
},
|
||||
lualine_x = {
|
||||
'encoding',
|
||||
'fileformat',
|
||||
'filetype',
|
||||
},
|
||||
lualine_y = {
|
||||
'progress',
|
||||
'searchcount'
|
||||
},
|
||||
lualine_z = {
|
||||
'location'
|
||||
}
|
||||
},
|
||||
tabline = {},
|
||||
extensions = {
|
||||
'neo-tree',
|
||||
'quickfix'
|
||||
}
|
||||
}
|
||||
13
after/plugin/luasnips.lua
Normal file
13
after/plugin/luasnips.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
local ok, luasnip = pcall(require,"luasnip")
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
luasnip.config.set_config {
|
||||
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
|
||||
enable_autosnippets = true,
|
||||
}
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
48
after/plugin/neotree.lua
Normal file
48
after/plugin/neotree.lua
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
local ok, neotree = pcall(require,"neo-tree")
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
neotree.setup(
|
||||
{
|
||||
enable_git_status = true,
|
||||
enable_diagnostics = true,
|
||||
sort_case_insensitive = true,
|
||||
|
||||
filesystem = {
|
||||
filtered_items = {
|
||||
visible = false,
|
||||
hide_dotfiles = true,
|
||||
hide_gitignored = true,
|
||||
hide_hidden = true,
|
||||
},
|
||||
follow_current_file = true,
|
||||
hijack_netrw_behaviour = "open_default",
|
||||
use_libuv_file_watcher = true,
|
||||
},
|
||||
|
||||
window = {
|
||||
position = "left"
|
||||
},
|
||||
|
||||
buffers = {
|
||||
follow_current_file = true,
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
-- keybindings
|
||||
vim.keymap.set( 'n' ,
|
||||
'<leader>n' ,
|
||||
function ()
|
||||
vim.cmd('Neotree toggle filesystem')
|
||||
end ,
|
||||
{ desc='Toggle neotree'})
|
||||
|
||||
vim.keymap.set( 'n' ,
|
||||
'<leader>b' ,
|
||||
function ()
|
||||
vim.cmd('Neotree toggle buffers float')
|
||||
end ,
|
||||
{ desc='Toggle bufferlist'})
|
||||
7
after/plugin/notify.lua
Normal file
7
after/plugin/notify.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
local ok, notify = pcall(require, 'notify')
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
vim.notify = notify
|
||||
37
after/plugin/treesitter.lua
Normal file
37
after/plugin/treesitter.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
if not pcall(require, 'nvim-treesitter') then
|
||||
return
|
||||
end
|
||||
|
||||
require('nvim-treesitter.configs').setup {
|
||||
|
||||
ensure_installed = {
|
||||
"c",
|
||||
"cpp",
|
||||
"c_sharp",
|
||||
"markdown",
|
||||
"latex",
|
||||
"go",
|
||||
"rust"
|
||||
},
|
||||
sync_install = false,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
},
|
||||
|
||||
rainbow = {
|
||||
enable = true,
|
||||
extended_mode = true,
|
||||
max_file_lines = nil
|
||||
},
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = '<CR>',
|
||||
scope_incremental = '<CR>',
|
||||
node_incremental = '<TAB>',
|
||||
node_decremental = '<S-TAB>'
|
||||
}
|
||||
}
|
||||
}
|
||||
53
after/plugin/whichkey.lua
Normal file
53
after/plugin/whichkey.lua
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
-- Which-key is configured here. But bindings are located with the plugin that they are for
|
||||
|
||||
local ok, whichKey = pcall(require,'which-key')
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
-- Because which-key uses the timeoutlen to decide when to show it it set to 0 here
|
||||
-- This makes it appear instantly
|
||||
|
||||
vim.o.timeout = true
|
||||
vim.o.timeoutlen = 0
|
||||
|
||||
whichKey.setup({
|
||||
plugins = {
|
||||
marks = true,
|
||||
registers = true,
|
||||
spelling = {
|
||||
enabled = true,
|
||||
suggestions = 10,
|
||||
},
|
||||
|
||||
presets = {
|
||||
operators = true,
|
||||
motions = true,
|
||||
text_objects = true,
|
||||
windows = true,
|
||||
nav = true,
|
||||
z = true,
|
||||
g = true,
|
||||
},
|
||||
},
|
||||
icons = {
|
||||
breadcrumb = "",
|
||||
separator = "",
|
||||
group = "",
|
||||
},
|
||||
|
||||
window = {
|
||||
border = "single",
|
||||
position = "bottom",
|
||||
},
|
||||
-- ignore_missing = true,
|
||||
disable = {
|
||||
filetypes = {"TelescopePrompt"}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
-- TODO: Set some keymap documentation if some old-style plugins are loaded.
|
||||
-- NERD commenter - Name the group
|
||||
-- Vimwiki - Name the group
|
||||
36
after/plugin/zenmode.lua
Normal file
36
after/plugin/zenmode.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
local ok, zen = pcall(require, 'zen-mode')
|
||||
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
zen.setup {
|
||||
window = {
|
||||
backdrop = 1,
|
||||
width = 0.85,
|
||||
height = 0.50,
|
||||
options = {
|
||||
signcolumn = "no",
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
cursorline = true,
|
||||
cursorcolumn = false,
|
||||
list = false,
|
||||
},
|
||||
},
|
||||
plugins = {
|
||||
options = {
|
||||
enabled = true,
|
||||
ruler = false,
|
||||
showcmd = false,
|
||||
},
|
||||
twilight = {enabled = true},
|
||||
gitsigns = {enabled = true}
|
||||
}
|
||||
}
|
||||
|
||||
vim.keymap.set( 'n',
|
||||
'<leader>z',
|
||||
function ()
|
||||
zen.toggle()
|
||||
end, {desc = 'Toggle ZenMode'})
|
||||
1
ftplugin/email.lua
Normal file
1
ftplugin/email.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
vim.o.spell=true
|
||||
1
ftplugin/vimwiki.lua
Normal file
1
ftplugin/vimwiki.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
vim.o.textwidth = 75
|
||||
8
init.lua
Normal file
8
init.lua
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
-- Init file.
|
||||
|
||||
-- Ideally this file will stay empty.
|
||||
-- Everything will be loaded somewhere else
|
||||
--
|
||||
require('sherlock5512.opts')
|
||||
require('sherlock5512.plugins')
|
||||
require('sherlock5512.globalBindings')
|
||||
75
lua/sherlock5512/globalBindings.lua
Normal file
75
lua/sherlock5512/globalBindings.lua
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
-- Global bindings
|
||||
-- NOTE: A binding MUST only use neovim features to be loaded here.
|
||||
-- Any plugin bindings MUST be declared WITH the plugin config.
|
||||
-- This is to ensure plugins are loaded before binding anything
|
||||
|
||||
-- IMPORTANT: ALL keymaps MUST set the desc attribute
|
||||
-- It is advisable that where possible the keybinds call lua functions
|
||||
-- this is to make things easier to expand later
|
||||
|
||||
local map = vim.keymap.set
|
||||
|
||||
map('n',
|
||||
'<leader>o',
|
||||
function ()
|
||||
vim.o.spell = not vim.o.spell
|
||||
end ,
|
||||
{desc = "Toggle Spelling"}
|
||||
)
|
||||
|
||||
local function ModHeight(inc)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local height = vim.api.nvim_win_get_height(win)
|
||||
if inc then
|
||||
height = height + 1
|
||||
else
|
||||
height = height - 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function ModWidth(inc)
|
||||
local win = vim.api.nvim_get_current_win()
|
||||
local width = vim.api.nvim_win_get_width(win)
|
||||
if inc then
|
||||
width = width + 1
|
||||
else
|
||||
width = width - 1
|
||||
end
|
||||
vim.api.nvim_win_set_width(win,width)
|
||||
end
|
||||
|
||||
|
||||
map('n',
|
||||
'H',
|
||||
function() ModWidth(false) end,
|
||||
{desc = "Decrease Width"})
|
||||
map('n',
|
||||
'J',
|
||||
function() ModHeight(false) end,
|
||||
{desc = "Decrease Height"})
|
||||
map('n',
|
||||
'K',
|
||||
function() ModHeight(true) end,
|
||||
{desc = "Increase Height"})
|
||||
map('n',
|
||||
'L',
|
||||
function() ModWidth(true) end,
|
||||
{desc = "Increase Width"})
|
||||
|
||||
map('n',
|
||||
'<M-h>',
|
||||
function() vim.cmd.wincmd("h") end,
|
||||
{desc = "Change window "})
|
||||
map('n',
|
||||
'<M-j>',
|
||||
function() vim.cmd.wincmd("j") end,
|
||||
{desc = "Change window "})
|
||||
map('n',
|
||||
'<M-k>',
|
||||
function() vim.cmd.wincmd("k") end,
|
||||
{desc = "Change Window "})
|
||||
map('n',
|
||||
'<M-l>',
|
||||
function() vim.cmd.wincmd("l") end,
|
||||
{desc = "Change Window "})
|
||||
115
lua/sherlock5512/opts.lua
Normal file
115
lua/sherlock5512/opts.lua
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
-- Global settings
|
||||
|
||||
local opt = vim.opt -- make things quicker to type
|
||||
|
||||
opt.relativenumber = true
|
||||
opt.number = true -- display the current line number instead of 0
|
||||
|
||||
-- Make searching a little better
|
||||
opt.ignorecase = true
|
||||
opt.smartcase = true
|
||||
opt.hlsearch = true
|
||||
opt.incsearch = true
|
||||
|
||||
opt.splitright = true
|
||||
opt.splitbelow = true
|
||||
|
||||
-- write to swap file after this much wait time,
|
||||
-- also defines CursorHold
|
||||
opt.updatetime = 50
|
||||
|
||||
-- Scrolloff and sidescroll to keep context on screen
|
||||
opt.scrolloff = 15
|
||||
opt.sidescroll = 6
|
||||
|
||||
-- Use 24 colours in terminal
|
||||
opt.termguicolors = true
|
||||
|
||||
-- Set terminal title
|
||||
opt.title = true
|
||||
|
||||
-- Spell in english
|
||||
opt.spelllang = 'en_gb'
|
||||
|
||||
-- Ignore compiled files.
|
||||
opt.wildignore = {
|
||||
"*pycache*",
|
||||
"*.o",
|
||||
"*~",
|
||||
"*.pyc"}
|
||||
|
||||
-- sign column (mid width 2 max width 5)
|
||||
opt.signcolumn = "auto:2-5"
|
||||
|
||||
-- Cursorline
|
||||
-- Configured to only show in the current buffer
|
||||
opt.cursorline = true -- start enabled
|
||||
local auGroupCursorLine = vim.api.nvim_create_augroup("CursorLine", {clear = true})
|
||||
local set_cursorline = function(event, value, pattern)
|
||||
vim.api.nvim_create_autocmd(event, {
|
||||
group = auGroupCursorLine,
|
||||
pattern = pattern,
|
||||
callback = function()
|
||||
vim.opt_local.cursorline = value
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
set_cursorline("WinLeave", false)
|
||||
set_cursorline("WinEnter", true)
|
||||
set_cursorline("Filetype", false, "TelescopePrompt") -- no cursorline for Telescope
|
||||
|
||||
-- UI
|
||||
opt.showmode = false
|
||||
opt.showcmd = true
|
||||
opt.cmdheight = 1
|
||||
|
||||
|
||||
-- Indentation
|
||||
opt.autoindent = true
|
||||
opt.cindent = true
|
||||
opt.wrap = true
|
||||
|
||||
opt.tabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
opt.softtabstop = 4
|
||||
opt.expandtab = false
|
||||
|
||||
opt.breakindent = true
|
||||
opt.showbreak = '>'
|
||||
opt.linebreak = true
|
||||
|
||||
|
||||
-- Misc
|
||||
opt.belloff = "all"
|
||||
opt.clipboard = "unnamedplus" -- sync to system clipboard
|
||||
opt.mouse = "a"
|
||||
|
||||
-- Odd format options
|
||||
-- fixes a few bugbears of mine.
|
||||
|
||||
local auGroupFormatOptions = vim.api.nvim_create_augroup("FormatOptions", {clear = true})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType",
|
||||
{
|
||||
group = auGroupFormatOptions,
|
||||
pattern = "*",
|
||||
callback = function ()
|
||||
vim.opt.formatoptions = vim.opt.formatoptions
|
||||
- "r" -- don't auto comment
|
||||
- "o" -- REALLY don't auto comment
|
||||
end
|
||||
})
|
||||
|
||||
opt.shortmess = ""
|
||||
.. "f" -- short filecount
|
||||
.. "l" -- shorten lines and bytes count
|
||||
.. "m" -- [modified] -> [+]
|
||||
.. "n" -- [NewFile] -> [New]
|
||||
.. "r" -- [readonly] -> [RO]
|
||||
.. "w" -- written -> [w]
|
||||
.. "x" -- Short format
|
||||
.. "o" -- read message replaces write message
|
||||
.. "O" -- read message overwrite previous message
|
||||
.. "s" -- Don't say when search wraps
|
||||
.. "I" -- Don't show intro message
|
||||
148
lua/sherlock5512/plugins.lua
Normal file
148
lua/sherlock5512/plugins.lua
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
-- Sherlock5512's plugin list
|
||||
-- This is my opinionated choice of plugins
|
||||
|
||||
-- where are we going to install packer
|
||||
local packer_install_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
local log = require('tjdevries/log')
|
||||
|
||||
-- Is packer installed?
|
||||
if not vim.loop.fs_stat(packer_install_path) then
|
||||
log.warn("Packer is not installed. Bootstrapping...")
|
||||
if (vim.fn.executable("git") == 1 ) then -- only run if we have git
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'--depth', '1',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
packer_install_path})
|
||||
vim.cmd 'packadd packer.nvim'
|
||||
Packer_bootstapping=true;
|
||||
log.warn("Packer is now installed.\nPlease ignore any packer errors while plugins are installed")
|
||||
else
|
||||
log.error("Cannot find git, Packer installation failed")
|
||||
end
|
||||
end
|
||||
|
||||
return require('packer').startup(function(use)
|
||||
use 'wbthomason/packer.nvim' -- Allow packer to update itself
|
||||
|
||||
-- Looks
|
||||
use { 'ellisonleao/gruvbox.nvim' } -- Apparently has better tresitter support.
|
||||
use { 'nvim-lualine/lualine.nvim', -- Awesome status line
|
||||
requires = {{'nvim-tree/nvim-web-devicons'},-- With icons
|
||||
{'sherlock5512/lualine-spell-status'}} -- And spell status
|
||||
}
|
||||
use {'akinsho/bufferline.nvim',
|
||||
tag = "v3.*",
|
||||
requires = 'nvim-tree/nvim-web-devicons'}
|
||||
|
||||
-- Features
|
||||
use { 'nvim-neo-tree/neo-tree.nvim', -- file tree
|
||||
branch = 'v2.x',
|
||||
requires = {'nvim-lua/plenary.nvim',
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
'munifTanjim/nui.nvim',
|
||||
}
|
||||
}
|
||||
use { 'vimwiki/vimwiki' } -- Personal Wiki
|
||||
use { 'folke/which-key.nvim' } -- Keybinds with documentation
|
||||
use { 'rcarriga/nvim-notify' } -- Neater notifications
|
||||
|
||||
-- Commenting
|
||||
use { 'scrooloose/nerdcommenter' } -- commenting done good
|
||||
|
||||
-- Completion
|
||||
use { 'hrsh7th/nvim-cmp' } -- Completion engine
|
||||
use { 'hrsh7th/cmp-buffer' } -- Completion source (Current buffer text)
|
||||
use { 'hrsh7th/cmp-path' } -- Completion source (Paths)
|
||||
use { 'hrsh7th/cmp-nvim-lsp' } -- Completion source (Language server)
|
||||
use { 'hrsh7th/cmp-emoji' } -- Completion source (Emojis)
|
||||
use { 'hrsh7th/cmp-cmdline' } -- Completion source (Commandline)
|
||||
use { 'saadparwaiz1/cmp_luasnip' } --Completion source (snippets)
|
||||
use { 'onsails/lspkind.nvim' } -- Completion formatter
|
||||
|
||||
-- Snippets
|
||||
use { 'L3MON4D3/LuaSnip', -- Snippet engine
|
||||
requires = 'rafamadriz/friendly-snippets' } -- Snippet library
|
||||
|
||||
-- Mason
|
||||
use { 'williamboman/mason.nvim' } -- Manage: LSPs,DAPs,Linters,formatters
|
||||
use { 'williamboman/mason-lspconfig.nvim',
|
||||
requires = {
|
||||
'neovim/nvim-lspconfig',
|
||||
'williamboman/mason.nvim'}
|
||||
}
|
||||
use { 'jay-babu/mason-null-ls.nvim',
|
||||
requires = {
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
'williamboman/mason.nvim'}
|
||||
}
|
||||
|
||||
-- LSP tools
|
||||
use {'glepnir/lspsaga.nvim', -- Interact with LSP a little easier
|
||||
branch='main'
|
||||
}
|
||||
use {'j-hui/fidget.nvim'} -- Show LSP status
|
||||
use {'folke/trouble.nvim', -- Show diagnostics in a window
|
||||
requires = {'nvim-tree/nvim-web-devicons'}}
|
||||
|
||||
-- DAP
|
||||
use {'jay-babu/mason-nvim-dap.nvim',
|
||||
requires = {
|
||||
'williamboman/mason.nvim',
|
||||
'mfussenegger/nvim-dap'
|
||||
}
|
||||
}
|
||||
use { "rcarriga/nvim-dap-ui",
|
||||
requires = {"mfussenegger/nvim-dap"}
|
||||
}
|
||||
|
||||
-- Tresitter
|
||||
use {'nvim-treesitter/nvim-treesitter',
|
||||
run = ':TSUpdate'
|
||||
}
|
||||
use {'p00f/nvim-ts-rainbow',
|
||||
requires = 'nvim-treesitter/nvim-treesitter'}
|
||||
use {'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
requires = 'nvim-treesitter/nvim-treesitter'}
|
||||
use {'nvim-treesitter/playground',
|
||||
requires = 'nvim-treesitter/nvim-treesitter'}
|
||||
|
||||
-- Focus Aids
|
||||
use {'folke/zen-mode.nvim'}
|
||||
use {'folke/twilight.nvim'}
|
||||
|
||||
-- Formatting
|
||||
use {'mcauley-penney/tidy.nvim', -- simple plugin to remove trailing whitespace etc..
|
||||
config = function()
|
||||
require("tidy").setup()
|
||||
end
|
||||
}
|
||||
use {'mhartington/formatter.nvim'}
|
||||
|
||||
-- Telescope
|
||||
use {'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
{'nvim-tree/nvim-web-devicons', opt = true},
|
||||
{'nvim-treesitter/nvim-treesitter', opt = true}
|
||||
}
|
||||
}
|
||||
use {'nvim-telescope/telescope-fzf-native.nvim', run = 'make'}
|
||||
|
||||
-- Git integreations
|
||||
use {'lewis6991/gitsigns.nvim',
|
||||
config = function ()
|
||||
require('gitsigns').setup()
|
||||
end
|
||||
}
|
||||
|
||||
-- Language / Project specific
|
||||
use 'folke/neodev.nvim'
|
||||
|
||||
if Packer_bootstapping then
|
||||
require('packer').sync() -- install plugins on first run
|
||||
require('packer').compile() -- Compile packer loader.
|
||||
log.warn("Plugins installed, Please restart neovim!")
|
||||
end
|
||||
end)
|
||||
26
lua/sherlock5512/utilities.lua
Normal file
26
lua/sherlock5512/utilities.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
--- Utilities module
|
||||
|
||||
-- (LDoc)
|
||||
-- @module utilities
|
||||
-- @author Robert Morrison <sherlock5512>
|
||||
-- @license MIT
|
||||
|
||||
local utilities = {}
|
||||
|
||||
--- Require a table of modules
|
||||
-- @tparam table modules a list of modules to load
|
||||
-- @treturn table|nil a table of loaded modules indexed by their names or nil if one or more modules failed to load
|
||||
function utilities.require_modules(modules)
|
||||
local results = {}
|
||||
for _, module in pairs(modules) do
|
||||
local ok, result = pcall(require, module)
|
||||
if ok then
|
||||
results[module] = result
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
return results
|
||||
end
|
||||
|
||||
return utilities
|
||||
154
lua/tjdevries/log.lua
Normal file
154
lua/tjdevries/log.lua
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
-- log.lua
|
||||
--
|
||||
-- Inspired by rxi/log.lua
|
||||
-- Modified by tjdevries and can be found at github.com/tjdevries/vlog.nvim
|
||||
--
|
||||
-- This library is free software; you can redistribute it and/or modify it
|
||||
-- under the terms of the MIT license. See LICENSE for details.
|
||||
|
||||
-- User configuration section
|
||||
local default_config = {
|
||||
-- Name of the plugin. Prepended to log messages
|
||||
plugin = 'vlog.nvim',
|
||||
|
||||
-- Should print the output to neovim while running
|
||||
use_console = true,
|
||||
|
||||
-- Should highlighting be used in console (using echohl)
|
||||
highlights = true,
|
||||
|
||||
-- Should write to a file
|
||||
use_file = true,
|
||||
|
||||
-- Any messages above this level will be logged.
|
||||
level = "trace",
|
||||
|
||||
-- Level configuration
|
||||
modes = {
|
||||
{ name = "trace", hl = "Comment", },
|
||||
{ name = "debug", hl = "Comment", },
|
||||
{ name = "info", hl = "None", },
|
||||
{ name = "warn", hl = "WarningMsg", },
|
||||
{ name = "error", hl = "ErrorMsg", },
|
||||
{ name = "fatal", hl = "ErrorMsg", },
|
||||
},
|
||||
|
||||
-- Can limit the number of decimals displayed for floats
|
||||
float_precision = 0.01,
|
||||
}
|
||||
|
||||
-- {{{ NO NEED TO CHANGE
|
||||
local log = {}
|
||||
|
||||
local unpack = unpack or table.unpack
|
||||
|
||||
log.new = function(config, standalone)
|
||||
config = vim.tbl_deep_extend("force", default_config, config)
|
||||
|
||||
local outfile = string.format('%s/%s.log', vim.api.nvim_call_function('stdpath', {'data'}), config.plugin)
|
||||
|
||||
local obj
|
||||
if standalone then
|
||||
obj = log
|
||||
else
|
||||
obj = {}
|
||||
end
|
||||
|
||||
local levels = {}
|
||||
for i, v in ipairs(config.modes) do
|
||||
levels[v.name] = i
|
||||
end
|
||||
|
||||
local round = function(x, increment)
|
||||
increment = increment or 1
|
||||
x = x / increment
|
||||
return (x > 0 and math.floor(x + .5) or math.ceil(x - .5)) * increment
|
||||
end
|
||||
|
||||
local make_string = function(...)
|
||||
local t = {}
|
||||
for i = 1, select('#', ...) do
|
||||
local x = select(i, ...)
|
||||
|
||||
if type(x) == "number" and config.float_precision then
|
||||
x = tostring(round(x, config.float_precision))
|
||||
elseif type(x) == "table" then
|
||||
x = vim.inspect(x)
|
||||
else
|
||||
x = tostring(x)
|
||||
end
|
||||
|
||||
t[#t + 1] = x
|
||||
end
|
||||
return table.concat(t, " ")
|
||||
end
|
||||
|
||||
|
||||
local log_at_level = function(level, level_config, message_maker, ...)
|
||||
-- Return early if we're below the config.level
|
||||
if level < levels[config.level] then
|
||||
return
|
||||
end
|
||||
local nameupper = level_config.name:upper()
|
||||
|
||||
local msg = message_maker(...)
|
||||
local info = debug.getinfo(2, "Sl")
|
||||
local lineinfo = info.short_src .. ":" .. info.currentline
|
||||
|
||||
-- Output to console
|
||||
if config.use_console then
|
||||
local console_string = string.format(
|
||||
"[%-6s%s] %s: %s",
|
||||
nameupper,
|
||||
os.date("%H:%M:%S"),
|
||||
lineinfo,
|
||||
msg
|
||||
)
|
||||
|
||||
if config.highlights and level_config.hl then
|
||||
vim.cmd(string.format("echohl %s", level_config.hl))
|
||||
end
|
||||
|
||||
local split_console = vim.split(console_string, "\n")
|
||||
for _, v in ipairs(split_console) do
|
||||
vim.cmd(string.format([[echom "[%s] %s"]], config.plugin, vim.fn.escape(v, '"')))
|
||||
end
|
||||
|
||||
if config.highlights and level_config.hl then
|
||||
vim.cmd("echohl NONE")
|
||||
end
|
||||
end
|
||||
|
||||
-- Output to log file
|
||||
if config.use_file then
|
||||
local fp = io.open(outfile, "a")
|
||||
local str = string.format("[%-6s%s] %s: %s\n",
|
||||
nameupper, os.date(), lineinfo, msg)
|
||||
fp:write(str)
|
||||
fp:close()
|
||||
end
|
||||
end
|
||||
|
||||
for i, x in ipairs(config.modes) do
|
||||
obj[x.name] = function(...)
|
||||
return log_at_level(i, x, make_string, ...)
|
||||
end
|
||||
|
||||
obj[("fmt_%s" ):format(x.name)] = function()
|
||||
return log_at_level(i, x, function(...)
|
||||
local passed = {...}
|
||||
local fmt = table.remove(passed, 1)
|
||||
local inspected = {}
|
||||
for _, v in ipairs(passed) do
|
||||
table.insert(inspected, vim.inspect(v))
|
||||
end
|
||||
return string.format(fmt, unpack(inspected))
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
log.new(default_config, true)
|
||||
-- }}}
|
||||
|
||||
return log
|
||||
21
plugin/vimwiki.lua
Normal file
21
plugin/vimwiki.lua
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
-- This file MUST load before vimwiki and as such is placed in the plugin directory
|
||||
|
||||
-- Get the XDG_DOCUMENTS_DIR if it exists
|
||||
-- Otherwise use `$HOME/Documents` as default
|
||||
local docdir = vim.env.HOME .. '/Documents'
|
||||
if vim.env.XDG_DOCUMENTS_DIR then
|
||||
docdir = vim.env.XDG_DOCUMENTS_DIR
|
||||
end
|
||||
|
||||
|
||||
local wikiroot = docdir .. '/vimwiki'
|
||||
local mainWiki = {
|
||||
path = wikiroot .. '/src',
|
||||
path_html = wikiroot .. '/html',
|
||||
template_path = wikiroot .. '/templates',
|
||||
template_default = 'default'
|
||||
}
|
||||
|
||||
vim.g.vimwiki_list = {mainWiki}
|
||||
vim.g.vimwiki_global_ext = 0
|
||||
vim.g.vimwiki_dir_link = 'index'
|
||||
Loading…
Reference in New Issue
Block a user