housekeeping merge
This commit is contained in:
parent
398616cfcd
commit
2cbdb13009
6 changed files with 319 additions and 144 deletions
15
lua/core/globals.lua
Normal file
15
lua/core/globals.lua
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
if vim.fn.exists 'g:os' == 0 then
|
||||
local is_windows = vim.fn.has 'win64' == 1 or vim.fn.has 'win32' == 1 or vim.fn.has 'win16' == 1
|
||||
if is_windows then
|
||||
vim.g.os = 'Windows'
|
||||
else
|
||||
local uname_output = vim.fn.system 'uname'
|
||||
vim.g.os = string.gsub(uname_output, '\n', '')
|
||||
end
|
||||
end
|
||||
|
||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||
vim.g.have_nerd_font = true
|
||||
172
lua/core/keymaps.lua
Normal file
172
lua/core/keymaps.lua
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
-- BASIC KEYBINDS
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
|
||||
-- or just use <C-\><C-n> to exit terminal mode
|
||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||
vim.keymap.set('n', '<C-h>', '<C-w><C-h>', { desc = 'Move focus to the left window' })
|
||||
vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right window' })
|
||||
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
|
||||
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
|
||||
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
-- OIL-KEYMAPS
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
require('oil').setup {
|
||||
keymaps = {
|
||||
['g?'] = { 'actions.show_help', mode = 'n' },
|
||||
['<CR>'] = 'actions.select',
|
||||
['<C-s>'] = { 'actions.select', opts = { vertical = true } },
|
||||
-- ['<C-h>'] = { 'actions.select', opts = { horizontal = true } },
|
||||
['<C-t>'] = { 'actions.select', opts = { tab = true } },
|
||||
['<C-p>'] = 'actions.preview',
|
||||
['<C-c>'] = { 'actions.close', mode = 'n' },
|
||||
-- ['<C-l>'] = 'actions.refresh',
|
||||
['-'] = { 'actions.parent', mode = 'n' },
|
||||
['_'] = { 'actions.open_cwd', mode = 'n' },
|
||||
['`'] = { 'actions.cd', mode = 'n' },
|
||||
['~'] = { 'actions.cd', opts = { scope = 'tab' }, mode = 'n' },
|
||||
['gs'] = { 'actions.change_sort', mode = 'n' },
|
||||
['gx'] = 'actions.open_external',
|
||||
['g.'] = { 'actions.toggle_hidden', mode = 'n' },
|
||||
['g\\'] = { 'actions.toggle_trash', mode = 'n' },
|
||||
},
|
||||
vim.keymap.set('n', '<leader>o', '<CMD>Oil<CR>', { desc = 'Open parent directory' }),
|
||||
-- Set to false to disable all of the above keymaps
|
||||
use_default_keymaps = true,
|
||||
}
|
||||
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
-- TELESCOPE-KEYMAPS
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
local builtin = require 'telescope.builtin'
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' })
|
||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' })
|
||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' })
|
||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' })
|
||||
-- Slightly advanced example of overriding default behavior and theme
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
-- It's also possible to pass additional configuration options.
|
||||
-- See `:help telescope.builtin.live_grep()` for information about particular keys
|
||||
vim.keymap.set('n', '<leader>s/', function()
|
||||
builtin.live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
|
||||
-- Shortcut for searching your Neovim configuration files
|
||||
vim.keymap.set('n', '<leader>sn', function()
|
||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||
end, { desc = '[S]earch [N]eovim files' })
|
||||
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
-- OBSIDIAN-KEYMAPS
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
vim.keymap.set('n', 'gf', function()
|
||||
if require('obsidian').util.cursor_on_markdown_link() then
|
||||
return '<cmd>ObsidianFollowLink<CR>'
|
||||
else
|
||||
return 'gf'
|
||||
end
|
||||
end, { noremap = false, expr = true })
|
||||
|
||||
vim.keymap.set('n', 'gd', function()
|
||||
require('obsidian').util.gf_passthrough()
|
||||
end, { noremap = false, expr = true, buffer = true })
|
||||
|
||||
vim.keymap.set('n', '<leader>ch', function()
|
||||
return require('obsidian').util.toggle_checkbox()
|
||||
end, { buffer = true })
|
||||
|
||||
vim.keymap.set('n', 'cr', function()
|
||||
return require('obsidian').util.smart_action()
|
||||
end, { buffer = true, expr = true })
|
||||
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
-- CMP-KEYMAPS
|
||||
-- ################ ################ ################ ################
|
||||
-- ################ ################ ################ ################
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require 'luasnip'
|
||||
luasnip.config.setup {}
|
||||
|
||||
cmp.setup {
|
||||
-- For an understanding of why these mappings were
|
||||
-- chosen, you will need to read `:help ins-completion`
|
||||
--
|
||||
-- No, but seriously. Please read `:help ins-completion`, it is really good!
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
-- Select the [n]ext item
|
||||
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
-- Select the [p]revious item
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
|
||||
-- Scroll the documentation window [b]ack / [f]orward
|
||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
|
||||
-- Accept ([y]es) the completion.
|
||||
-- This will auto-import if your LSP supports it.
|
||||
-- This will expand snippets if the LSP sent a snippet.
|
||||
['<C-y>'] = cmp.mapping.confirm { select = true },
|
||||
|
||||
-- If you prefer more traditional completion keymaps,
|
||||
-- you can uncomment the following lines
|
||||
--['<CR>'] = cmp.mapping.confirm { select = true },
|
||||
--['<Tab>'] = cmp.mapping.select_next_item(),
|
||||
--['<S-Tab>'] = cmp.mapping.select_prev_item(),
|
||||
|
||||
-- Manually trigger a completion from nvim-cmp.
|
||||
-- Generally you don't need this, because nvim-cmp will display
|
||||
-- completions whenever it has completion options available.
|
||||
['<C-Space>'] = cmp.mapping.complete {},
|
||||
|
||||
-- Think of <c-l> as moving to the right of your snippet expansion.
|
||||
-- So if you have a snippet that's like:
|
||||
-- function $name($args)
|
||||
-- $body
|
||||
-- end
|
||||
--
|
||||
-- <c-l> will move you to the right of each of the expansion locations.
|
||||
-- <c-h> is similar, except moving you backwards.
|
||||
['<C-l>'] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<C-h>'] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
}
|
||||
68
lua/core/options.lua
Normal file
68
lua/core/options.lua
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
-- [[ Setting options ]]
|
||||
-- See `:help vim.opt`
|
||||
-- NOTE: You can change these options as you wish!
|
||||
-- For more options, you can see `:help option-list`
|
||||
|
||||
-- Make line numbers default
|
||||
vim.opt.number = true
|
||||
vim.opt.relativenumber = true
|
||||
-- You can also add relative line numbers, to help with jumping.
|
||||
-- Experiment for yourself to see if you like it!
|
||||
-- vim.opt.relativenumber = true
|
||||
|
||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||
vim.opt.mouse = 'a'
|
||||
|
||||
-- Don't show the mode, since it's already in the status line
|
||||
vim.opt.showmode = false
|
||||
|
||||
-- Sync clipboard between OS and Neovim.
|
||||
-- Schedule the setting after `UiEnter` because it can increase startup-time.
|
||||
-- Remove this option if you want your OS clipboard to remain independent.
|
||||
-- See `:help 'clipboard'`
|
||||
vim.schedule(function()
|
||||
vim.opt.clipboard = 'unnamedplus'
|
||||
end)
|
||||
|
||||
-- Enable break indent
|
||||
vim.opt.breakindent = true
|
||||
|
||||
-- Save undo history
|
||||
vim.opt.undofile = true
|
||||
|
||||
-- Case-insensitive searching UNLESS \C or one or more capital letters in the search term
|
||||
vim.opt.ignorecase = true
|
||||
vim.opt.smartcase = true
|
||||
|
||||
-- Keep signcolumn on by default
|
||||
vim.opt.signcolumn = 'yes'
|
||||
|
||||
-- Decrease update time
|
||||
vim.opt.updatetime = 250
|
||||
|
||||
-- Decrease mapped sequence wait time
|
||||
-- Displays which-key popup sooner
|
||||
vim.opt.timeoutlen = 300
|
||||
|
||||
-- Configure how new splits should be opened
|
||||
vim.opt.splitright = true
|
||||
vim.opt.splitbelow = true
|
||||
|
||||
-- Sets how neovim will display certain whitespace characters in the editor.
|
||||
-- See `:help 'list'`
|
||||
-- and `:help 'listchars'`
|
||||
vim.opt.list = true
|
||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
||||
|
||||
vim.opt.tabstop = 4 -- A TAB character looks like 4 spaces
|
||||
vim.opt.expandtab = true -- Pressing the TAB key will insert spaces instead of a TAB character
|
||||
vim.opt.softtabstop = 4 -- Number of spaces inserted instead of a TAB character
|
||||
vim.opt.shiftwidth = 4 -- Number of spaces inserted when indenting
|
||||
-- Preview substitutions live, as you type!
|
||||
vim.opt.inccommand = 'split'
|
||||
|
||||
-- Show which line your cursor is on
|
||||
vim.opt.cursorline = true
|
||||
|
||||
-- Minimal number of screen lines to keep above and below the cursor.
|
||||
vim.opt.scrolloff = 10
|
||||
7
lua/core/plugins.lua
Normal file
7
lua/core/plugins.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
'stevearc/oil.nvim',
|
||||
-- Optional dependencies
|
||||
dependencies = { { 'echasnovski/mini.icons', opts = {} } },
|
||||
'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically
|
||||
{ 'lewis6991/gitsigns.nvim', opts = 'plugin-options.gitsigns' },
|
||||
} --
|
||||
9
lua/plugin-options/gitsigns.lua
Normal file
9
lua/plugin-options/gitsigns.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue