mirror of
https://github.com/halfdan/dotfiles.git
synced 2025-04-26 12:25:39 +00:00
Refactor nvim config, thanks ThePrimeagen
This commit is contained in:
parent
2f168f25fa
commit
ab6ddb63aa
0
.config/nvim/after/plugin/init.lua
Normal file
0
.config/nvim/after/plugin/init.lua
Normal file
80
.config/nvim/after/plugin/keymappings.lua
Normal file
80
.config/nvim/after/plugin/keymappings.lua
Normal file
@ -0,0 +1,80 @@
|
||||
local Remap = require("halfdan.keymap")
|
||||
local nnoremap = Remap.nnoremap
|
||||
local vnoremap = Remap.vnoremap
|
||||
local inoremap = Remap.inoremap
|
||||
local xnoremap = Remap.xnoremap
|
||||
local nmap = Remap.nmap
|
||||
|
||||
-- better window movement
|
||||
nnoremap('<C-h>', '<C-w>h')
|
||||
nnoremap('<C-j>', '<C-w>j')
|
||||
nnoremap('<C-k>', '<C-w>k')
|
||||
nnoremap('<C-l>', '<C-w>l')
|
||||
|
||||
-- resize with arrows
|
||||
nnoremap('<C-Up>', ':resize -2<CR>')
|
||||
nnoremap('<C-Down>', ':resize +2<CR>')
|
||||
nnoremap('<C-Left>', ':vertical resize -2<CR>')
|
||||
nnoremap('<C-Right>', ':vertical resize +2<CR>')
|
||||
|
||||
-- improved keyboard support for navigation (especially terminal)
|
||||
nnoremap('<leader>h', '<C-w>h')
|
||||
nnoremap('<leader>j', '<C-w>j')
|
||||
nnoremap('<leader>k', '<C-w>k')
|
||||
nnoremap('<leader>l', '<C-w>l')
|
||||
nnoremap('<A-h>', '<C-w>h')
|
||||
nnoremap('<A-j>', '<C-w>j')
|
||||
nnoremap('<A-k>', '<C-w>k')
|
||||
nnoremap('<A-l>', '<C-w>l')
|
||||
|
||||
-- Change 2 split windows from vert to horiz or horiz to vert
|
||||
nnoremap('<leader>th', '<C-w>t<C-w>H')
|
||||
nnoremap('<leader>tk', '<C-w>t<C-w>K')
|
||||
|
||||
-- Make adjusting split sizes a bit more friendly
|
||||
vim.cmd([[
|
||||
noremap <silent> <C-Left> :vertical resize +3<CR>
|
||||
noremap <silent> <C-Right> :vertical resize -3<CR>
|
||||
noremap <silent> <C-Up> :resize +3<CR>
|
||||
noremap <silent> <C-Down> :resize -3<CR>
|
||||
]])
|
||||
|
||||
-- better indenting
|
||||
vnoremap('<', '<gv')
|
||||
vnoremap('>', '>gv')
|
||||
|
||||
-- Tab switch buffer
|
||||
nnoremap('<TAB>', ':bnext<CR>')
|
||||
nnoremap('<S-TAB>', ':bprevious<CR>')
|
||||
|
||||
-- Move selected line / block of text in visual mode
|
||||
xnoremap('J', ':move \'>+1<CR>gv-gv')
|
||||
xnoremap('K', ':move \'<-2<CR>gv-gv')
|
||||
|
||||
nnoremap('Q', '<Nop>')
|
||||
|
||||
-- Tagbar
|
||||
nnoremap('<Leader>hl', ':nohl<CR>')
|
||||
|
||||
-- Vim Test
|
||||
nnoremap('<leader>t', ':TestNearest<CR>')
|
||||
nnoremap('<leader>T', ':TestFile<CR>')
|
||||
nnoremap('<leader>a', ':TestSuite<CR>')
|
||||
nnoremap('<leader>l', ':TestLast<CR>')
|
||||
nnoremap('<leader>g', ':TestVisit<CR>')
|
||||
|
||||
vim.cmd("nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>")
|
||||
vim.cmd("nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>")
|
||||
-- -- scroll down hover doc or scroll in definition preview
|
||||
vim.cmd("nnoremap <silent> <C-f> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>")
|
||||
-- -- scroll up hover doc
|
||||
vim.cmd("nnoremap <silent> <C-b> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>")
|
||||
vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()')
|
||||
|
||||
-- Yank until end of line
|
||||
nnoremap('Y', 'yg$')
|
||||
-- Next item, but center line
|
||||
nnoremap('n', 'nzzzv')
|
||||
nnoremap('N', 'Nzzzv')
|
||||
-- Join line but keep cursor intact
|
||||
nnoremap('J', 'mzJ`z')
|
@ -1,3 +1,7 @@
|
||||
local Remap = require("halfdan.keymap")
|
||||
local nnoremap = Remap.nnoremap
|
||||
local inoremap = Remap.inoremap
|
||||
|
||||
-- TODO figure out why this don't work
|
||||
vim.fn.sign_define(
|
||||
"LspDiagnosticsSignError",
|
||||
@ -97,48 +101,47 @@ vim.cmd([[
|
||||
|
||||
-- Diagnostic keymaps
|
||||
vim.api.nvim_set_keymap('n', '<leader>e', '<cmd>lua vim.diagnostic.open_float()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', { noremap = true, silent = true })
|
||||
|
||||
-- LSP settings
|
||||
local lspconfig = require 'lspconfig'
|
||||
local on_attach = function(_, bufnr)
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
|
||||
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
||||
local function config(_config)
|
||||
return vim.tbl_deep_extend("force", {
|
||||
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities()),
|
||||
on_attach = function()
|
||||
-- local opts = { noremap = true, silent = true }
|
||||
nnoremap("gd", function() vim.lsp.buf.definition() end)
|
||||
nnoremap("gD", function() vim.lsp.buf.declaration() end)
|
||||
nnoremap("K", function() vim.lsp.buf.hover() end)
|
||||
nnoremap("<leader>vws", function() vim.lsp.buf.workspace_symbol() end)
|
||||
nnoremap("<leader>vd", function() vim.diagnostic.open_float() end)
|
||||
nnoremap("[d", function() vim.diagnostic.goto_next() end)
|
||||
nnoremap("]d", function() vim.diagnostic.goto_prev() end)
|
||||
nnoremap("<leader>vca", function() vim.lsp.buf.code_action() end)
|
||||
nnoremap("<leader>vrr", function() vim.lsp.buf.references() end)
|
||||
nnoremap("<leader>vrn", function() vim.lsp.buf.rename() end)
|
||||
inoremap("<C-h>", function() vim.lsp.buf.signature_help() end)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
-- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>so', [[<cmd>lua require('telescope.builtin').lsp_document_symbols()<CR>]], opts)
|
||||
-- vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
||||
end,
|
||||
}, _config or {})
|
||||
end
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
|
||||
lspconfig['elixirls'].setup{
|
||||
cmd = { "/Users/fbecker18/opt/elixir-ls/language_server.sh"},
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
lspconfig['elixirls'].setup{config({
|
||||
cmd = { "/Users/fbecker18/opt/elixir-ls/language_server.sh"}
|
||||
})}
|
||||
|
||||
-- Enable the following language servers
|
||||
local servers = { 'gopls', 'julials', 'rust_analyzer', 'pyright' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
lspconfig[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
lspconfig[lsp].setup(config())
|
||||
end
|
||||
|
||||
require('rust-tools').setup({
|
32
.config/nvim/after/plugin/telescope.lua
Normal file
32
.config/nvim/after/plugin/telescope.lua
Normal file
@ -0,0 +1,32 @@
|
||||
local Remap = require("halfdan.keymap")
|
||||
local nnoremap = Remap.nnoremap
|
||||
|
||||
nnoremap("<leader>ps", function()
|
||||
require('telescope.builtin').grep_string({ search = vim.fn.input("Grep For > ")})
|
||||
end)
|
||||
nnoremap("<C-p>", function()
|
||||
require('telescope.builtin').git_files()
|
||||
end)
|
||||
nnoremap("<Leader>pf", function()
|
||||
require('telescope.builtin').find_files()
|
||||
end)
|
||||
|
||||
nnoremap("<leader>pw", function()
|
||||
require('telescope.builtin').grep_string { search = vim.fn.expand("<cword>") }
|
||||
end)
|
||||
nnoremap("<leader>pb", function()
|
||||
require('telescope.builtin').buffers()
|
||||
end)
|
||||
nnoremap("<leader>vh", function()
|
||||
require('telescope.builtin').help_tags()
|
||||
end)
|
||||
|
||||
-- Telescope
|
||||
-- nnoremap('<leader>fs', ':lua require(\'telescope.builtin\').grep_string({ search = vim.fn.input("Grep For > ")})<CR>')
|
||||
-- nnoremap('<Leader>ff', ':lua require(\'telescope.builtin\').find_files()<CR>')
|
||||
|
||||
-- nnoremap('<leader>fw', ':lua require(\'telescope.builtin\').grep_string { search = vim.fn.expand("<cword>") }<CR>')
|
||||
-- nnoremap('<leader>fb', ':lua require(\'telescope.builtin\').buffers()<CR>')
|
||||
-- nnoremap('<leader>vh', ':lua require(\'telescope.builtin\').help_tags()<CR>')
|
||||
-- nnoremap('<leader>gwl', ':lua require(\'telescope\').extensions.git_worktree.git_worktrees()<CR>')
|
||||
-- nnoremap('<leader>gwc', ':lua require(\'telescope\').extensions.git_worktree.create_git_worktree()<CR>')
|
@ -1,20 +1 @@
|
||||
require('globals')
|
||||
require('keymappings')
|
||||
require('settings')
|
||||
require('plugins')
|
||||
|
||||
require('colorscheme')
|
||||
|
||||
require('lsp')
|
||||
|
||||
require('plugins.telescope')
|
||||
require('plugins.telescope-project')
|
||||
require('plugins.treesitter')
|
||||
require('plugins.cmp')
|
||||
require('plugins.lualine')
|
||||
require('plugins.tagbar')
|
||||
require('plugins.sneak')
|
||||
|
||||
require('themes.nord')
|
||||
|
||||
require('autocmds')
|
||||
require('halfdan')
|
||||
|
@ -1,19 +0,0 @@
|
||||
-- functions
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.edit_dotfiles()
|
||||
require'telescope.builtin'.git_files {
|
||||
shorten_path = false,
|
||||
cwd = "~/.dotfiles",
|
||||
prompt = "~ dotfiles ~",
|
||||
height = 10,
|
||||
|
||||
layout_strategy = 'horizontal',
|
||||
layout_options = {
|
||||
preview_width = 0.75,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
76
.config/nvim/lua/halfdan/debugger/init.lua
Normal file
76
.config/nvim/lua/halfdan/debugger/init.lua
Normal file
@ -0,0 +1,76 @@
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
local daptext = require("nvim-dap-virtual-text")
|
||||
|
||||
local remap = require("halfdan.keymap")
|
||||
local nnoremap = remap.nnoremap
|
||||
|
||||
daptext.setup()
|
||||
dapui.setup({
|
||||
layouts = {
|
||||
{
|
||||
elements = {
|
||||
"console",
|
||||
},
|
||||
size = 7,
|
||||
position = "bottom",
|
||||
},
|
||||
{
|
||||
elements = {
|
||||
-- Elements can be strings or table with id and size keys.
|
||||
{ id = "scopes", size = 0.25 },
|
||||
"watches",
|
||||
},
|
||||
size = 40,
|
||||
position = "left",
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open(1)
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close()
|
||||
end
|
||||
|
||||
-- require("theprimeagen.debugger.node");
|
||||
|
||||
nnoremap("<Home>", function()
|
||||
dapui.toggle(1)
|
||||
end)
|
||||
nnoremap("<End>", function()
|
||||
dapui.toggle(2)
|
||||
end)
|
||||
|
||||
nnoremap("<leader><leader>", function()
|
||||
dap.close()
|
||||
end)
|
||||
|
||||
nnoremap("<F5>", function()
|
||||
dap.continue()
|
||||
end)
|
||||
nnoremap("<F10>", function()
|
||||
dap.step_over()
|
||||
end)
|
||||
nnoremap("<F11>", function()
|
||||
dap.step_into()
|
||||
end)
|
||||
nnoremap("<F12>", function()
|
||||
dap.step_out()
|
||||
end)
|
||||
nnoremap("<Leader>b", function()
|
||||
dap.toggle_breakpoint()
|
||||
end)
|
||||
nnoremap("<Leader>B", function()
|
||||
dap.set_breakpoint(vim.fn.input('Breakpoint condition: '))
|
||||
end)
|
||||
nnoremap("<leader>rc", function()
|
||||
dap.run_to_cursor()
|
||||
end)
|
||||
nnoremap("<leader>dr", function()
|
||||
dap.repl.open()
|
||||
end)
|
14
.config/nvim/lua/halfdan/init.lua
Normal file
14
.config/nvim/lua/halfdan/init.lua
Normal file
@ -0,0 +1,14 @@
|
||||
require("halfdan.settings")
|
||||
require("halfdan.packer")
|
||||
require("halfdan.neogit")
|
||||
|
||||
require('halfdan.globals')
|
||||
require('halfdan.keymap')
|
||||
|
||||
require('halfdan.colorscheme')
|
||||
|
||||
require('halfdan.themes.nord')
|
||||
|
||||
require('halfdan.autocmds')
|
||||
|
||||
require('halfdan.debugger')
|
20
.config/nvim/lua/halfdan/keymap.lua
Normal file
20
.config/nvim/lua/halfdan/keymap.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local M = {}
|
||||
|
||||
local function bind(op, outer_opts)
|
||||
outer_opts = outer_opts or {noremap = true}
|
||||
return function(lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("force",
|
||||
outer_opts,
|
||||
opts or {}
|
||||
)
|
||||
vim.keymap.set(op, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
M.nmap = bind("n", {noremap = false})
|
||||
M.nnoremap = bind("n")
|
||||
M.vnoremap = bind("v")
|
||||
M.xnoremap = bind("x")
|
||||
M.inoremap = bind("i")
|
||||
|
||||
return M
|
10
.config/nvim/lua/halfdan/neogit.lua
Normal file
10
.config/nvim/lua/halfdan/neogit.lua
Normal file
@ -0,0 +1,10 @@
|
||||
local neogit = require('neogit')
|
||||
local nnoremap = require('halfdan.keymap').nnoremap
|
||||
|
||||
neogit.setup {}
|
||||
|
||||
nnoremap("<leader>gs", function()
|
||||
neogit.open({ })
|
||||
end);
|
||||
|
||||
nnoremap("<leader>ga", "<cmd>!git fetch --all<CR>");
|
@ -1,12 +1,12 @@
|
||||
vim.cmd('set iskeyword+=-') -- treat dash separated words as a word text object"
|
||||
vim.cmd('set shortmess+=c') -- Don't pass messages to |ins-completion-menu|.
|
||||
vim.cmd('set inccommand=split') -- Make substitution work in realtime
|
||||
vim.o.hidden = O.hidden_files -- Required to keep multiple buffers open multiple buffers
|
||||
vim.o.hidden = true -- Required to keep multiple buffers open multiple buffers
|
||||
vim.o.title = true
|
||||
TERMINAL = vim.fn.expand('$TERMINAL')
|
||||
vim.cmd('let &titleold="'..TERMINAL..'"')
|
||||
vim.o.titlestring="%<%F%=%l/%L - nvim"
|
||||
vim.wo.wrap = O.wrap_lines -- Display long lines as just one line
|
||||
vim.wo.wrap = false -- Display long lines as just one line
|
||||
vim.cmd('set whichwrap+=<,>,[,],h,l') -- move to next line with theses keys
|
||||
vim.cmd('syntax on') -- syntax highlighting
|
||||
vim.o.pumheight = 10 -- Makes popup menu smaller
|
||||
@ -22,8 +22,8 @@ vim.cmd('set ts=4') -- Insert 4 spaces for a tab
|
||||
vim.cmd('set sw=4') -- Change the number of space characters inserted for indentation
|
||||
vim.cmd('set expandtab') -- Converts tabs to spaces
|
||||
vim.bo.smartindent = true -- Makes indenting smart
|
||||
vim.wo.number = O.number -- set numbered lines
|
||||
vim.wo.relativenumber = O.relative_number -- set relative number
|
||||
vim.wo.number = true -- set numbered lines
|
||||
vim.wo.relativenumber = true -- set relative number
|
||||
vim.wo.cursorline = true -- Enable highlighting of the current line
|
||||
vim.o.showtabline = 2 -- Always show tabs
|
||||
vim.o.showmode = false -- We don't need to see things like -- INSERT -- anymore
|
||||
@ -31,7 +31,7 @@ vim.o.backup = false -- This is recommended by coc
|
||||
vim.o.writebackup = false -- This is recommended by coc
|
||||
vim.wo.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||
vim.o.updatetime = 300 -- Faster completion
|
||||
vim.o.timeoutlen = O.timeoutlen -- By default timeoutlen is 1000 ms
|
||||
vim.o.timeoutlen = 500 -- By default timeoutlen is 1000 ms
|
||||
vim.o.clipboard = "unnamedplus" -- Copy paste between vim and everything else
|
||||
vim.o.laststatus = 3 -- Set global status bar
|
||||
vim.opt.showtabline = 0 -- Disable tabline
|
||||
@ -40,3 +40,5 @@ vim.opt.showtabline = 0 -- Disable tabline
|
||||
-- Enable telescope theme
|
||||
vim.g.gruvbox_baby_telescope_theme = 1
|
||||
vim.g.gruvbox_baby_background_color = "dark"
|
||||
|
||||
vim.g.mapleader = ' '
|
@ -1,96 +0,0 @@
|
||||
vim.g.mapleader = ' '
|
||||
|
||||
-- better window movement
|
||||
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', {silent = true})
|
||||
|
||||
-- resize with arrows
|
||||
vim.api.nvim_set_keymap('n', '<C-Up>', ':resize -2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Down>', ':resize +2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Left>', ':vertical resize -2<CR>', {silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<C-Right>', ':vertical resize +2<CR>', {silent = true})
|
||||
|
||||
-- improved keyboard support for navigation (especially terminal)
|
||||
vim.api.nvim_set_keymap('n', '<leader>h', '<C-w>h', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>j', '<C-w>j', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>k', '<C-w>k', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>l', '<C-w>l', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-h>', '<C-w>h', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-j>', '<C-w>j', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-k>', '<C-w>k', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<A-l>', '<C-w>l', {noremap = true})
|
||||
|
||||
-- Change 2 split windows from vert to horiz or horiz to vert
|
||||
vim.api.nvim_set_keymap('n', '<leader>th', '<C-w>t<C-w>H', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>tk', '<C-w>t<C-w>K', {noremap = true})
|
||||
|
||||
-- Make adjusting split sizes a bit more friendly
|
||||
vim.cmd([[
|
||||
noremap <silent> <C-Left> :vertical resize +3<CR>
|
||||
noremap <silent> <C-Right> :vertical resize -3<CR>
|
||||
noremap <silent> <C-Up> :resize +3<CR>
|
||||
noremap <silent> <C-Down> :resize -3<CR>
|
||||
]])
|
||||
|
||||
-- better indenting
|
||||
vim.api.nvim_set_keymap('v', '<', '<gv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('v', '>', '>gv', {noremap = true, silent = true})
|
||||
|
||||
-- Tab switch buffer
|
||||
vim.api.nvim_set_keymap('n', '<TAB>', ':bnext<CR>', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', '<S-TAB>', ':bprevious<CR>', {noremap = true, silent = true})
|
||||
|
||||
-- Move selected line / block of text in visual mode
|
||||
vim.api.nvim_set_keymap('x', 'J', ':move \'>+1<CR>gv-gv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('x', 'K', ':move \'<-2<CR>gv-gv', {noremap = true, silent = true})
|
||||
|
||||
vim.api.nvim_set_keymap('n', 'Q', '<Nop>', {noremap = true, silent = true})
|
||||
|
||||
-- Telescope
|
||||
vim.api.nvim_set_keymap('n', '<leader>fs', ':lua require(\'telescope.builtin\').grep_string({ search = vim.fn.input("Grep For > ")})<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<Leader>ff', ':lua require(\'telescope.builtin\').find_files()<CR>', {noremap = true})
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>fw', ':lua require(\'telescope.builtin\').grep_string { search = vim.fn.expand("<cword>") }<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>fb', ':lua require(\'telescope.builtin\').buffers()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>vh', ':lua require(\'telescope.builtin\').help_tags()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>gwl', ':lua require(\'telescope\').extensions.git_worktree.git_worktrees()<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>gwc', ':lua require(\'telescope\').extensions.git_worktree.create_git_worktree()<CR>', {noremap = true})
|
||||
|
||||
-- Tagbar
|
||||
vim.api.nvim_set_keymap('n', '<Leader>hl', ':nohl<CR>', {noremap = true})
|
||||
|
||||
-- Vim Test
|
||||
vim.api.nvim_set_keymap('n', '<leader>t', ':TestNearest<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>T', ':TestFile<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>a', ':TestSuite<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>l', ':TestLast<CR>', {noremap = true})
|
||||
vim.api.nvim_set_keymap('n', '<leader>g', ':TestVisit<CR>', {noremap = true})
|
||||
|
||||
-- LSP
|
||||
vim.cmd("nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>")
|
||||
vim.cmd("nnoremap <silent> gD <cmd>lua vim.lsp.buf.declaration()<CR>")
|
||||
vim.cmd("nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>")
|
||||
vim.cmd("nnoremap <silent> gi <cmd>lua vim.lsp.buf.implementation()<CR>")
|
||||
vim.cmd("nnoremap <silent> ca :Lspsaga code_action<CR>")
|
||||
vim.cmd("nnoremap <silent> K :Lspsaga hover_doc<CR>")
|
||||
vim.cmd("nnoremap <silent> rn <cmd>lua vim.lsp.buf.rename()<CR>")
|
||||
vim.cmd("nnoremap <silent> ff <cmd>lua vim.lsp.buf.formatting()<CR>")
|
||||
|
||||
vim.cmd('nnoremap <silent> <C-k> <cmd>lua vim.lsp.buf.signature_help()<CR>')
|
||||
vim.cmd("nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>")
|
||||
vim.cmd("nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>")
|
||||
-- -- scroll down hover doc or scroll in definition preview
|
||||
vim.cmd("nnoremap <silent> <C-f> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(1)<CR>")
|
||||
-- -- scroll up hover doc
|
||||
vim.cmd("nnoremap <silent> <C-b> <cmd>lua require('lspsaga.action').smart_scroll_with_saga(-1)<CR>")
|
||||
vim.cmd('command! -nargs=0 LspVirtualTextToggle lua require("lsp/virtual_text").toggle()')
|
||||
|
||||
-- Yank until end of line
|
||||
vim.api.nvim_set_keymap('n', 'Y', 'yg$', {noremap = true, silent = true})
|
||||
-- Next item, but center line
|
||||
vim.api.nvim_set_keymap('n', 'n', 'nzzzv', {noremap = true, silent = true})
|
||||
vim.api.nvim_set_keymap('n', 'N', 'Nzzzv', {noremap = true, silent = true})
|
||||
-- Join line but keep cursor intact
|
||||
vim.api.nvim_set_keymap('n', 'J', 'mzJ`z', {noremap = true, silent = true})
|
@ -1,231 +0,0 @@
|
||||
local vim = vim
|
||||
local gl = require('galaxyline')
|
||||
local utils = require('utils')
|
||||
|
||||
local gls = gl.section
|
||||
gl.short_line_list = { 'defx', 'packager', 'vista' }
|
||||
|
||||
-- Colors
|
||||
local colors = {
|
||||
bg = '#282a36',
|
||||
fg = '#f8f8f2',
|
||||
section_bg = '#38393f',
|
||||
yellow = '#f1fa8c',
|
||||
cyan = '#8be9fd',
|
||||
green = '#50fa7b',
|
||||
orange = '#ffb86c',
|
||||
magenta = '#ff79c6',
|
||||
blue = '#8be9fd',
|
||||
red = '#ff5555'
|
||||
}
|
||||
|
||||
-- Local helper functions
|
||||
local buffer_not_empty = function()
|
||||
return not utils.is_buffer_empty()
|
||||
end
|
||||
|
||||
local in_git_repo = function ()
|
||||
local vcs = require('galaxyline.provider_vcs')
|
||||
local branch_name = vcs.get_git_branch()
|
||||
|
||||
return branch_name ~= nil
|
||||
end
|
||||
|
||||
local checkwidth = function()
|
||||
return utils.has_width_gt(40) and in_git_repo()
|
||||
end
|
||||
|
||||
local mode_color = function()
|
||||
local mode_colors = {
|
||||
n = colors.cyan,
|
||||
i = colors.green,
|
||||
c = colors.orange,
|
||||
V = colors.magenta,
|
||||
[''] = colors.magenta,
|
||||
v = colors.magenta,
|
||||
R = colors.red,
|
||||
}
|
||||
|
||||
local color = mode_colors[vim.fn.mode()]
|
||||
|
||||
if color == nil then
|
||||
color = colors.red
|
||||
end
|
||||
|
||||
return color
|
||||
end
|
||||
|
||||
-- Left side
|
||||
gls.left[1] = {
|
||||
FirstElement = {
|
||||
provider = function() return '▋' end,
|
||||
highlight = { colors.cyan, colors.section_bg }
|
||||
},
|
||||
}
|
||||
gls.left[2] = {
|
||||
ViMode = {
|
||||
provider = function()
|
||||
local alias = {
|
||||
n = 'NORMAL',
|
||||
i = 'INSERT',
|
||||
c = 'COMMAND',
|
||||
V = 'VISUAL',
|
||||
[''] = 'VISUAL',
|
||||
v = 'VISUAL',
|
||||
R = 'REPLACE',
|
||||
}
|
||||
vim.api.nvim_command('hi GalaxyViMode guifg='..mode_color())
|
||||
local alias_mode = alias[vim.fn.mode()]
|
||||
if alias_mode == nil then
|
||||
alias_mode = vim.fn.mode()
|
||||
end
|
||||
return alias_mode..' '
|
||||
end,
|
||||
highlight = { colors.bg, colors.bg },
|
||||
separator = " ",
|
||||
separator_highlight = {colors.bg, colors.section_bg},
|
||||
},
|
||||
}
|
||||
gls.left[3] ={
|
||||
FileIcon = {
|
||||
provider = 'FileIcon',
|
||||
condition = buffer_not_empty,
|
||||
highlight = { require('galaxyline.provider_fileinfo').get_file_icon_color, colors.section_bg },
|
||||
},
|
||||
}
|
||||
gls.left[4] = {
|
||||
FileName = {
|
||||
provider = 'FileName',
|
||||
condition = buffer_not_empty,
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = " ",
|
||||
separator_highlight = {colors.section_bg, colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[5] = {
|
||||
GitIcon = {
|
||||
provider = function() return ' ' end,
|
||||
condition = in_git_repo,
|
||||
highlight = {colors.red,colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[6] = {
|
||||
GitBranch = {
|
||||
provider = function()
|
||||
local vcs = require('galaxyline.provider_vcs')
|
||||
local branch_name = vcs.get_git_branch()
|
||||
if (string.len(branch_name) > 28) then
|
||||
return string.sub(branch_name, 1, 25).."..."
|
||||
end
|
||||
return branch_name .. " "
|
||||
end,
|
||||
condition = in_git_repo,
|
||||
highlight = {colors.fg,colors.bg},
|
||||
}
|
||||
}
|
||||
gls.left[7] = {
|
||||
DiffAdd = {
|
||||
provider = 'DiffAdd',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.green, colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[8] = {
|
||||
DiffModified = {
|
||||
provider = 'DiffModified',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.orange, colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[9] = {
|
||||
DiffRemove = {
|
||||
provider = 'DiffRemove',
|
||||
condition = checkwidth,
|
||||
icon = ' ',
|
||||
highlight = { colors.red,colors.bg },
|
||||
}
|
||||
}
|
||||
gls.left[10] = {
|
||||
LeftEnd = {
|
||||
provider = function() return ' ' end,
|
||||
condition = buffer_not_empty,
|
||||
highlight = {colors.section_bg,colors.bg}
|
||||
}
|
||||
}
|
||||
gls.left[11] = {
|
||||
DiagnosticError = {
|
||||
provider = 'DiagnosticError',
|
||||
icon = ' ',
|
||||
highlight = {colors.red,colors.section_bg}
|
||||
}
|
||||
}
|
||||
gls.left[12] = {
|
||||
Space = {
|
||||
provider = function () return ' ' end,
|
||||
highlight = {colors.section_bg,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[13] = {
|
||||
DiagnosticWarn = {
|
||||
provider = 'DiagnosticWarn',
|
||||
icon = ' ',
|
||||
highlight = {colors.orange,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[14] = {
|
||||
Space = {
|
||||
provider = function () return ' ' end,
|
||||
highlight = {colors.section_bg,colors.section_bg},
|
||||
}
|
||||
}
|
||||
gls.left[15] = {
|
||||
DiagnosticInfo = {
|
||||
provider = 'DiagnosticInfo',
|
||||
icon = ' ',
|
||||
highlight = {colors.blue,colors.section_bg},
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
-- Right side
|
||||
gls.right[1]= {
|
||||
FileFormat = {
|
||||
provider = function() return vim.bo.filetype end,
|
||||
highlight = { colors.fg,colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg,colors.bg },
|
||||
}
|
||||
}
|
||||
gls.right[2] = {
|
||||
LineInfo = {
|
||||
provider = 'LineColumn',
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = ' | ',
|
||||
separator_highlight = { colors.bg, colors.section_bg },
|
||||
},
|
||||
}
|
||||
|
||||
-- Short status line
|
||||
gls.short_line_left[1] = {
|
||||
BufferType = {
|
||||
provider = 'FileTypeName',
|
||||
highlight = { colors.fg, colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
gls.short_line_right[1] = {
|
||||
BufferIcon = {
|
||||
provider= 'BufferIcon',
|
||||
highlight = { colors.yellow, colors.section_bg },
|
||||
separator = ' ',
|
||||
separator_highlight = { colors.section_bg, colors.bg },
|
||||
}
|
||||
}
|
||||
|
||||
-- Force manual load so that nvim boots with a status line
|
||||
gl.load_galaxyline()
|
@ -1,13 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
function M.is_buffer_empty()
|
||||
-- Check whether the current buffer is empty
|
||||
return vim.fn.empty(vim.fn.expand('%:t')) == 1
|
||||
end
|
||||
|
||||
function M.has_width_gt(cols)
|
||||
-- Check if the windows width is greater than a given number of columns
|
||||
return vim.fn.winwidth(0) / 2 > cols
|
||||
end
|
||||
|
||||
return M
|
Loading…
x
Reference in New Issue
Block a user