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" }, "conform.nvim": { "branch": "master", "commit": "1a99fdc1d3aa9ccdf3021e67982a679a8c5c740c" },
"edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" }, "edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" },
"fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" }, "fidget.nvim": { "branch": "main", "commit": "d855eed8a06531a7e8fd0684889b2943f373c469" },
"friendly-snippets": { "branch": "main", "commit": "00ba9dd3df89509f95437b8d595553707c46d5ea" },
"git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" }, "git-worktree.nvim": { "branch": "master", "commit": "f247308e68dab9f1133759b05d944569ad054546" },
"gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" }, "gitsigns.nvim": { "branch": "main", "commit": "863903631e676b33e8be2acb17512fdc1b80b4fb" },
"harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" }, "harpoon": { "branch": "harpoon2", "commit": "0378a6c428a0bed6a2781d459d7943843f374bce" },

View File

@ -12,4 +12,13 @@ if not vim.loop.fs_stat(lazypath) then
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("barink.keys") 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,43 +5,70 @@ vim.keymap.set('n', '<leader><F8>', vim.cmd.UndotreeToggle)
vim.keymap.set('n', '<leader>p', [["_dP]]) vim.keymap.set('n', '<leader>p', [["_dP]])
vim.keymap.set('n', '<leader>fa', vim.lsp.buf.format) vim.keymap.set('n', '<leader>fa', vim.lsp.buf.format)
vim.keymap.set('n', '<leader>m', ":Mason<CR>") 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>e', ':Explore<CR>', { noremap = false, silent = true })
vim.keymap.set('n', '<leader>le',':Lexplore<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>l', ':Neotree<CR>', { noremap = false, silent = true })
-- Move lines while in visual mode -- 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-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-k>', ':m \'<-2<CR>gv=gv', { noremap = true })
-- Move lines while in normal mode -- Move lines while in normal mode
vim.keymap.set('n', '<A-S-j>', ':m .+1<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}) vim.keymap.set('n', '<A-S-k>', ':m .-2<CR>==', { noremap = true })
-- Move line in edit mode -- Move line in edit mode
vim.keymap.set('i', '<A-j>', ':m .+1<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}) 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 ! -- Diagnostics !
vim.keymap.set('n', '<C-T>', function() require('trouble').toggle('diagnostics') 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>d', function() vim.diagnostic.open_float() end)
vim.keymap.set('n', '<leader>dn', function () vim.diagnostic.goto_next() 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>dp', function() vim.diagnostic.goto_prev() end)
vim.keymap.set('n', '<leader>ca', function () vim.lsp.buf.code_action() end) vim.keymap.set('n', '<leader>ca', function() vim.lsp.buf.code_action() end)
-- Debugging -- Debugging
vim.keymap.set('n', '<leader>b', function () require('dap').toggle_breakpoint() 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', '<F5>', function()
vim.keymap.set('n', '<F6>', function () require('dap').step_over() end ) print("Start debug session")
vim.keymap.set('n', '<F7>', function () require('dap').step_into() end ) 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. -- Easily hit escape in terminal mode.
vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>") vim.keymap.set("t", "<esc><esc>", "<c-\\><c-n>")
-- Open a terminal at the bottom of the screen with a fixed height. -- Open a terminal at the bottom of the screen with a fixed height.
vim.keymap.set("n", ",st", function() vim.keymap.set("n", ",st", function()
vim.cmd.new() vim.cmd.new()
vim.cmd.wincmd "J" vim.cmd.wincmd "J"
vim.api.nvim_win_set_height(0, 12) vim.api.nvim_win_set_height(0, 12)
vim.wo.winfixheight = true vim.wo.winfixheight = true
vim.cmd.term() vim.cmd.term()
end) 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", "stevearc/oil.nvim",
opt = { opt = {
default_file_explorer = false default_file_explorer = true
}, },
dependencies = { dependencies = {
'nvim-tree/nvim-web-devicons' 'nvim-tree/nvim-web-devicons'
}, },
config = function () config = function()
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc= "Open parent directory"}) vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })
end end
} }
} }

View File

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

View File

@ -1,4 +1,29 @@
return { return {
'lewis6991/gitsigns.nvim', '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,201 +1,201 @@
return return
{ {
'neovim/nvim-lspconfig', 'neovim/nvim-lspconfig',
dependencies = { dependencies = {
{ {
"folke/neoconf.nvim", "folke/neoconf.nvim",
opts = {} opts = {}
},
"williamboman/mason-lspconfig",
"williamboman/mason.nvim",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"hrsh7th/nvim-cmp",
{
'L3MON4D3/LuaSnip',
dependencies = 'hrsh7th/nvim-cmp',
version = "v2.*",
},
{'mfussenegger/nvim-jdtls', dependencies = {'nvim-dap'}},
"onsails/lspkind.nvim",
}, },
config = function() "williamboman/mason-lspconfig",
vim.opt.completeopt = { "menu", "menuone", "noselect", "preview"} "williamboman/mason.nvim",
require("lspkind").init({}) "hrsh7th/cmp-nvim-lsp",
require("mason").setup() "hrsh7th/cmp-buffer",
require("mason-lspconfig").setup({ "hrsh7th/cmp-path",
ensure_installed = { "lua_ls", "bashls", "rust_analyzer" } "hrsh7th/cmp-cmdline",
}) "hrsh7th/nvim-cmp",
local ls = require("luasnip") {
ls.config.set_config({ 'L3MON4D3/LuaSnip',
history = true, dependencies = {
updateevents = "TextChanged, TextChangedI", 'hrsh7th/nvim-cmp',
enable_autosnippets = true, 'rafamadriz/friendly-snippets',
}) },
local cmp = require('cmp') version = "v2.*",
local lspkind = require("lspkind") },
cmp.setup({ { 'mfussenegger/nvim-jdtls', dependencies = { 'nvim-dap' } },
formatting = { "onsails/lspkind.nvim",
format = lspkind.cmp_format({ },
mode = 'symbol', config = function()
maxwidth = 60, vim.opt.completeopt = { "menu", "menuone", "noselect", "preview" }
ellipsis_char = '...', require("lspkind").init({})
show_labelDetails = true, require("mason").setup()
}), require("mason-lspconfig").setup({
}, ensure_installed = { "lua_ls", "bashls", "rust_analyzer" }
snippet = { })
expand = function(args) local ls = require("luasnip")
require('luasnip').lsp_expand(args.body) ls.config.set_config({
end, history = true,
}, updateevents = "TextChanged, TextChangedI",
mapping = cmp.mapping.preset.insert({ enable_autosnippets = true,
['<C-b>'] = cmp.mapping.scroll_docs(-4), })
['<C-f>'] = cmp.mapping.scroll_docs(4), local cmp = require('cmp')
['<C-Space>'] = cmp.mapping.complete(), local lspkind = require("lspkind")
['<C-e>'] = cmp.mapping.abort(), cmp.setup({
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. formatting = {
format = lspkind.cmp_format({
mode = 'symbol',
maxwidth = 60,
ellipsis_char = '...',
show_labelDetails = true,
}), }),
sources = cmp.config.sources({ },
{ name = 'nvim_lsp', keyword_length = 1 }, snippet = {
{ name = 'path' }, expand = function(args)
}, { require('luasnip').lsp_expand(args.body)
{ name = 'buffer', keyword_length = 2 }, end,
}), },
window = { mapping = cmp.mapping.preset.insert({
documentation = cmp.config.window.bordered() ['<C-b>'] = cmp.mapping.scroll_docs(-4),
}, ['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<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 = {
documentation = cmp.config.window.bordered()
},
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
}) })
})
-- Set configuration for specific filetype. cmp.setup.filetype({ "sql" }, {
cmp.setup.filetype('gitcommit', { sources = {
sources = cmp.config.sources({ { name = "vim-dadbod-completion" },
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). { name = "buffer" },
}, { }
{ name = 'buffer' }, })
}) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
}) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'buffer' }
}, {
{ name = 'cmdline' }
}),
matching = { disallow_symbol_nonprefix_matching = false }
})
cmp.setup.filetype({ "sql"}, {
sources = { vim.keymap.set({ "i", "s" }, "<C-K>", function() ls.expand() end, { silent = true })
{ name = "vim-dadbod-completion"}, vim.keymap.set({ "i", "s" }, "<C-n>", function() ls.jump(1) end, { silent = true })
{ name = "buffer"} , 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" })
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,
mojo = true,
zls = true,
emmet_language_server = true,
rust_analyzer = true,
--gdtoolkit = { flags = { debounce_text_changes = 150 }},
jdtls = true,
pylsp = true,
phpactor = {
init_options = {
["language_server_phpstan.enabled"] = false,
["language_server_psalm.enabled"] = false,
} }
}) },
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). clangd = {
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
{ name = 'buffer' }
}, {
{ name = 'cmdline' }
}),
matching = { disallow_symbol_nonprefix_matching = false }
})
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"})
-- Set up lspconfig.
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local lsp = require("lspconfig")
local language_server = {
asm_lsp= true,
mojo = true,
zls = true,
emmet_language_server = true,
rust_analyzer = true,
gdtoolkit = { flags = { debounce_text_changes = 150 }},
jdtls = true,
pylsp = true,
phpactor = {
init_options = {
["language_server_phpstan.enabled"] = false,
["language_server_psalm.enabled"] = false,
}
},
clangd = {
capabilities = capabilities, capabilities = capabilities,
root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"), root_dir = require('lspconfig').util.root_pattern("compile_commands.json", "compile_flags.txt", ".git"),
cmd = {"clangd"}, cmd = { "clangd" },
filetypes = { "c", "cpp", "objc", "objcpp"}, filetypes = { "c", "cpp", "objc", "objcpp" },
settings = { settings = {
clangd = { clangd = {
compilationDatabasePath = "compile-commands.json", compilationDatabasePath = "compile-commands.json",
}, },
} }
}, },
ts_ls = true, ts_ls = true,
gopls = true, gopls = true,
intelephense = true, intelephense = true,
lua_ls = { lua_ls = {
config = { config = {
settings = { settings = {
Lua = { Lua = {
runtime = { runtime = {
version = 'LuaJIT', version = 'LuaJIT',
}, },
workspace = { workspace = {
checkThirdParty= false, checkThirdParty = false,
library = { library = {
vim.env.VIMRUNTIME vim.env.VIMRUNTIME
} }
}, },
-- diagnostics = { diagnostics = {
-- globals = { 'vim'} globals = { 'vim' }
-- }
} }
} }
} }
}, }
} },
}
for name, config in pairs(language_server) do for name, config in pairs(language_server) do
if config == true then if config == true then
config = {} config = {}
end
config = vim.tbl_deep_extend("force", {}, { capabilities = capabilities }, config)
lsp[name].setup({})
end end
vim.api.nvim_create_autocmd("LspAttach", { config = vim.tbl_deep_extend("force", {}, { capabilities = capabilities }, config)
callback = function (args) lsp[name].setup({})
local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client") end
vim.api.nvim_create_autocmd("LspAttach", {
local settings = language_server[client.name] callback = function(args)
if type(settings) ~= "table" then local client = assert(vim.lsp.get_client_by_id(args.data.client_id), "must have valid client")
settings = {}
end
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})
local settings = language_server[client.name]
if type(settings) ~= "table" then
settings = {}
end end
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 })
end
}) })
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,29 +21,27 @@ vim.opt.termguicolors = true
vim.opt.scrolloff = 8 vim.opt.scrolloff = 8
vim.g.netrw_browse_split = 0 vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
vim.g.netrw_winsize = 25
vim.opt.completeopt = {'menu', 'menuone', 'noselect' }
vim.opt.inccommand = 'split' vim.opt.inccommand = 'split'
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
callback = function (args) callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
if client.server_capabilities.hoverProvider then 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
end, end,
}) })
vim.g.netrw_browse_split = 0
vim.g.netrw_winsize = 25
--[[ --[[
-- Run zig test on save -- Run zig test on save
-- TODO: fix vim.cmd call -- TODO: fix vim.cmd call
-- TODO: only do this when a zig test file is open -- TODO: only do this when a zig test file is open
vim.api.nvim_create_autocmd('BufWritePost' , { vim.api.nvim_create_autocmd('BufWritePost' , {
callback = function () callback = function ()
vim.cmd{cmd = '!zig' , args= {'test', vim.fn.expand('%')} } vim.cmd{cmd = '!zig' , args= {'test', vim.fn.expand('%')} }
end end
})]]-- })]] --