1
0

Removing Which-key, adding a bunch of small improvments

Highlight on yank
gitsigns
oil as default explorer
This commit is contained in:
Nigel Barink 2024-10-06 17:04:11 +02:00
parent bd1e208133
commit a6c0657d70
Signed by: Nigel
GPG Key ID: 6893A31C2D84A9D2
9 changed files with 289 additions and 244 deletions

View File

@ -9,6 +9,7 @@
"conform.nvim": { "branch": "master", "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" },
"edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" },
"git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" },
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },

View File

@ -12,4 +12,13 @@ if not vim.loop.fs_stat(lazypath) then
end
vim.opt.rtp:prepend(lazypath)
require("barink.keys")
require("lazy").setup("barink.plugins")
require("lazy").setup("barink.plugins" , {
root = vim.fn.stdpath("data") .. "/lazy", -- directory where plugins will be installed
-- leave nil when passing the spec as the first argument to setup()
change_detection = {
-- automatically check for config file changes and reload the ui
enabled = false,
notify = true, -- get a notification when changes are found
},
})

View File

@ -5,34 +5,42 @@ vim.keymap.set('n', '<leader><F8>', vim.cmd.UndotreeToggle)
vim.keymap.set('n', '<leader>p', [["_dP]])
vim.keymap.set('n', '<leader>fa', vim.lsp.buf.format)
vim.keymap.set('n', '<leader>m', ":Mason<CR>")
vim.keymap.set('n', '<leader>e',':Explore<CR>', {noremap = false, silent=true})
vim.keymap.set('n', '<leader>le',':Lexplore<CR>', {noremap = false, silent=true})
vim.keymap.set('n', '<leader>l', ':Neotree<CR>', {noremap = false, silent= true})
vim.keymap.set('n', '<leader>e', ':Explore<CR>', { noremap = false, silent = true })
vim.keymap.set('n', '<leader>le', ':Lexplore<CR>', { noremap = false, silent = true })
vim.keymap.set('n', '<leader>l', ':Neotree<CR>', { noremap = false, silent = true })
-- Move lines while in visual mode
vim.keymap.set('v', '<A-S-j>', ':m \'>+1<CR>gv=gv', {noremap = true})
vim.keymap.set('v', '<A-S-k>', ':m \'<-2<CR>gv=gv', {noremap = true})
vim.keymap.set('v', '<A-S-j>', ':m \'>+1<CR>gv=gv', { noremap = true })
vim.keymap.set('v', '<A-S-k>', ':m \'<-2<CR>gv=gv', { noremap = true })
-- Move lines while in normal mode
vim.keymap.set('n', '<A-S-j>', ':m .+1<CR>==', {noremap = true})
vim.keymap.set('n', '<A-S-k>', ':m .-2<CR>==', {noremap = true})
vim.keymap.set('n', '<A-S-j>', ':m .+1<CR>==', { noremap = true })
vim.keymap.set('n', '<A-S-k>', ':m .-2<CR>==', { noremap = true })
-- Move line in edit mode
vim.keymap.set('i', '<A-j>', ':m .+1<CR>==gi', {noremap = true})
vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', {noremap = true})
vim.keymap.set('i', '<A-j>', ':m .+1<CR>==gi', { noremap = true })
vim.keymap.set('i', '<A-k>', ':m .-2<CR>==gi', { noremap = true })
-- Simplified split navigation
vim.keymap.set('n', '<C-h>', '<C-w><C-h>')
vim.keymap.set('n', '<C-j>', '<C-w><C-j>')
vim.keymap.set('n', '<C-k>', '<C-w><C-k>')
vim.keymap.set('n', '<C-l>', '<C-w><C-l>')
-- Diagnostics !
vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') end )
vim.keymap.set('n', '<leader>d', function () vim.diagnostic.open_float() end )
vim.keymap.set('n', '<leader>dn', function () vim.diagnostic.goto_next() end )
vim.keymap.set('n', '<leader>dp', function () vim.diagnostic.goto_prev() end )
vim.keymap.set('n', '<leader>ca', function () vim.lsp.buf.code_action() end)
vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') end)
vim.keymap.set('n', '<leader>d', function() vim.diagnostic.open_float() end)
vim.keymap.set('n', '<leader>dn', function() vim.diagnostic.goto_next() end)
vim.keymap.set('n', '<leader>dp', function() vim.diagnostic.goto_prev() end)
vim.keymap.set('n', '<leader>ca', function() vim.lsp.buf.code_action() end)
-- Debugging
vim.keymap.set('n', '<leader>b', function () require('dap').toggle_breakpoint() end )
vim.keymap.set('n', '<F5>', function () print("Start debug session" ) require('dap').continue() end )
vim.keymap.set('n', '<F6>', function () require('dap').step_over() end )
vim.keymap.set('n', '<F7>', function () require('dap').step_into() end )
vim.keymap.set('n', '<leader>b', function() require('dap').toggle_breakpoint() end)
vim.keymap.set('n', '<F5>', function()
print("Start debug session")
require('dap').continue()
end)
vim.keymap.set('n', '<F6>', function() require('dap').step_over() end)
vim.keymap.set('n', '<F7>', function() require('dap').step_into() end)
vim.keymap.set('n', '<leader>=',":Gen Generate<CR>")
vim.keymap.set('n', '<leader>=', ":Gen Generate<CR>")
-- Easily hit escape in terminal mode.
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
@ -45,3 +53,22 @@ vim.keymap.set("n", ",st", function()
vim.wo.winfixheight = true
vim.cmd.term()
end)
-- Open quickfix list
vim.keymap.set("n", "<M-k>", "<cmd>cnext<CR>zz")
vim.keymap.set("n", "<M-j>", "<cmd>cprev<CR>zz")
-- Go to next in location list
vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
-- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
desc = "Highlight when yanking text ",
group = vim.api.nvim_create_augroup('barink', { clear = true }),
callback = function()
vim.highlight.on_yank()
end
})

View File

@ -2,13 +2,13 @@ return {
{
"stevearc/oil.nvim",
opt = {
default_file_explorer = false
default_file_explorer = true
},
dependencies = {
'nvim-tree/nvim-web-devicons'
},
config = function ()
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc= "Open parent directory"})
config = function()
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
end
}
}

View File

@ -1,8 +1,8 @@
return {
{
"j-hui/fidget.nvim",
opt = {
}
config = function()
local opts = {
}
require("fidget").setup(opts)
end
}

View File

@ -1,4 +1,29 @@
return {
'lewis6991/gitsigns.nvim',
opt = {}
config = function()
local opts = {
signs = {
add = { text = '+' },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "-" },
changedelete = { text = "~" }
},
signs_staged = {
add = { text = '+' },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "-" },
changedelete = { text = "~" },
untracked = { text = "*" },
},
signs_staged_enable = true,
signcolumn = true,
watch_gitdir = {
follow_files = true
},
auto_attach = true
}
require("gitsigns").setup(opts)
end,
}

View File

@ -1,5 +1,5 @@
return
{
{
'neovim/nvim-lspconfig',
dependencies = {
{
@ -15,14 +15,17 @@ return
"hrsh7th/nvim-cmp",
{
'L3MON4D3/LuaSnip',
dependencies = 'hrsh7th/nvim-cmp',
dependencies = {
'hrsh7th/nvim-cmp',
'rafamadriz/friendly-snippets',
},
version = "v2.*",
},
{'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}},
{ 'mfussenegger/nvim-jdtls', dependencies = { 'nvim-dap' } },
"onsails/lspkind.nvim",
},
config = function()
vim.opt.completeopt = { "menu", "menuone", "noselect", "preview"}
vim.opt.completeopt = { "menu", "menuone", "noselect", "preview" }
require("lspkind").init({})
require("mason").setup()
require("mason-lspconfig").setup({
@ -55,12 +58,12 @@ return
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
['<C-y>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp', keyword_length = 1 },
{ name = 'luasnip' },
{ name = 'path' },
}, {
{ name = 'buffer', keyword_length = 2 },
}),
window = {
@ -78,10 +81,10 @@ return
})
})
cmp.setup.filetype({ "sql"}, {
cmp.setup.filetype({ "sql" }, {
sources = {
{ name = "vim-dadbod-completion"},
{ name = "buffer"} ,
{ name = "vim-dadbod-completion" },
{ name = "buffer" },
}
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
@ -98,29 +101,28 @@ return
})
vim.keymap.set({"i", "s"}, "<C-K>", function() ls.expand() end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-n>", function() ls.jump(1) end, {silent = true })
vim.keymap.set({"i", "s"}, "<C-p>", function() ls.jump(-1) end, {silent = true})
vim.keymap.set({"i", "s"}, "<C-E>", function()
vim.keymap.set({ "i", "s" }, "<C-K>", function() ls.expand() end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-n>", function() ls.jump(1) end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-p>", function() ls.jump(-1) end, { silent = true })
vim.keymap.set({ "i", "s" }, "<C-E>", function()
if ls.choice_active() then
ls.change_choice(1)
end
end, {silent = true})
require("luasnip.loaders.from_lua").load({paths= "~/.config/nvim/lua/barink/snippets"})
end, { silent = true })
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/barink/snippets" })
require("luasnip.loaders.from_vscode").lazy_load()
-- Set up lspconfig.
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp = require("lspconfig")
local language_server = {
asm_lsp= true,
asm_lsp = true,
mojo = true,
zls = true,
emmet_language_server = true,
rust_analyzer = true,
gdtoolkit = { flags = { debounce_text_changes = 150 }},
--gdtoolkit = { flags = { debounce_text_changes = 150 }},
jdtls = true,
pylsp = true,
phpactor = {
@ -132,8 +134,8 @@ return
clangd = {
capabilities = capabilities,
root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"),
cmd = {"clangd"},
filetypes = { "c", "cpp", "objc", "objcpp"},
cmd = { "clangd" },
filetypes = { "c", "cpp", "objc", "objcpp" },
settings = {
clangd = {
compilationDatabasePath = "compile-commands.json",
@ -151,14 +153,14 @@ return
version = 'LuaJIT',
},
workspace = {
checkThirdParty= false,
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
}
},
-- diagnostics = {
-- globals = { 'vim'}
-- }
diagnostics = {
globals = { 'vim' }
}
}
}
}
@ -173,7 +175,7 @@ return
lsp[name].setup({})
end
vim.api.nvim_create_autocmd("LspAttach", {
callback = function (args)
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client")
local settings = language_server[client.name]
@ -184,17 +186,15 @@ return
local builtin = require "telescope.builtin"
vim.opt_local.omnifunc = "v:lua.vim.lsp.omnifunc"
vim.keymap.set("n", "gd", builtin.lsp_definitions, {buffer = -1})
vim.keymap.set("n", "gr", builtin.lsp_references, {buffer = -1})
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, {buffer = -1})
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, {buffer = -1})
vim.keymap.set("n", "K", vim.lsp.buf.hover, {buffer = -1})
vim.keymap.set("n", "<LEADER>cr", vim.lsp.buf.rename, {buffer =-1})
vim.keymap.set("n", "<LEADER>ca", vim.lsp.buf.code_action, {buffer = -1})
vim.keymap.set("n", "<LEADER>wd", builtin.lsp_document_symbols, {buffer = -1})
vim.keymap.set("n", "gd", builtin.lsp_definitions, { buffer = -1 })
vim.keymap.set("n", "gr", builtin.lsp_references, { buffer = -1 })
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { buffer = -1 })
vim.keymap.set("n", "gT", vim.lsp.buf.type_definition, { buffer = -1 })
vim.keymap.set("n", "K", vim.lsp.buf.hover, { buffer = -1 })
vim.keymap.set("n", "<LEADER>cr", vim.lsp.buf.rename, { buffer = -1 })
vim.keymap.set("n", "<LEADER>ca", vim.lsp.buf.code_action, { buffer = -1 })
vim.keymap.set("n", "<LEADER>wd", builtin.lsp_document_symbols, { buffer = -1 })
end
})
end,

View File

@ -1,15 +0,0 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
opts = {
},
keys = {
{
"<leader>?",
function()
require("which-key").show({global = false})
end,
desc = "Buffer Local Keymaps (which-key)",
}
}
}

View File

@ -21,20 +21,21 @@ vim.opt.termguicolors = true
vim.opt.scrolloff = 8
vim.g.netrw_browse_split = 0
vim.g.netrw_winsize = 25
vim.opt.completeopt = {'menu', 'menuone', 'noselect' }
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.opt.inccommand = 'split'
vim.api.nvim_create_autocmd('LspAttach', {
callback = function (args)
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.hoverProvider then
vim.keymap.set('n', 'K', vim.lsp.buf.hover, {buffer = args.buf})
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { buffer = args.buf })
end
end,
})
vim.g.netrw_browse_split = 0
vim.g.netrw_winsize = 25
--[[
-- Run zig test on save
-- TODO: fix vim.cmd call
@ -43,7 +44,4 @@ vim.api.nvim_create_autocmd('BufWritePost' , {
callback = function ()
vim.cmd{cmd = '!zig' , args= {'test', vim.fn.expand('%')} }
end
})]]--
})]] --