Keybindings and smaller ui related improvements
Options: - lualine shows path of files - added breadcrumbs to programming buffers as winbar Plugins: - added mrcjkb/rustaceanvim for improved rust support - added lewis6991/gitsigns.nvim to show changes in files - dropped lspkind, it had no visible effect and could not easily be fixed - added j-hui/fidget.nvim to make $/progress messages (e.g. from lsp) visible Keybindings: - dropped unused and commented out keybindings - <leader>fr to resume last fzf search - <C-W>0, 1, 2, 3 to mimic emacs <C-x>.... window keys - <esc><esc> to clear last search - added desc field to many keybindings in lsp
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
-- Setup fzf-lua keybindings and some other searches
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, { desc = "Find file" })
|
||||
vim.keymap.set('n', '<leader>fs', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
|
||||
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
|
||||
vim.keymap.set('n', '<leader>fG', fzf.grep_cword, { desc = "Grep word under cursor" })
|
||||
vim.keymap.set('n', '<leader>fc', fzf.commands, { desc = "Commands" })
|
||||
vim.keymap.set('n', '<leader>ff', fzf.files, { desc = "Find file" })
|
||||
vim.keymap.set('n', '<leader>fg', fzf.live_grep, { desc = "Grep" })
|
||||
vim.keymap.set('n', '<leader>fm', fzf.manpages, { desc = "Manpages" })
|
||||
vim.keymap.set('n', '<leader>b', fzf.buffers, { desc = "Buffers" })
|
||||
vim.keymap.set('n', '<leader>fr', fzf.resume, { desc = "Resume last search" })
|
||||
vim.keymap.set('n', '<leader>fs', fzf.blines, { desc = "Search buffer" })
|
||||
|
||||
vim.keymap.set('n', '<leader>ft', ":TodoFzfLua<CR>", { desc = "Todos" })
|
||||
|
||||
-- use fzf buffer lines as default search
|
||||
vim.keymap.set('n', '/', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', '<C-/>', fzf.blines, { desc = "Search buffer" })
|
||||
vim.keymap.set('n', 'z=', fzf.spell_suggest, { desc = "Spelling suggestions" })
|
||||
|
||||
-- open file manager and git
|
||||
@@ -63,6 +64,9 @@ vim.keymap.set('n', '<space>mc', mywords.uhl_all, { desc = "Clear all highlights
|
||||
-- Shortcuts which are known from Emacs
|
||||
--
|
||||
------------------------------------------
|
||||
vim.keymap.set('n', '<C-W>1', ":wincmd o<CR>", { desc = "Win: close others" })
|
||||
vim.keymap.set('n', '<C-W>0', ":only<CR>", { desc = "Win: close current" })
|
||||
vim.keymap.set('n', '<C-W>0', ":hide<CR>", { desc = "Win: close current" })
|
||||
vim.keymap.set('n', '<C-W>1', ":only<CR>", { desc = "Win: close others" })
|
||||
vim.keymap.set('n', '<C-W>2', ":split<CR>", { desc = "Win: split horizontally" })
|
||||
vim.keymap.set('n', '<C-W>2', ":vsplit<CR>", { desc = "Win: split vertically" })
|
||||
vim.keymap.set('n', '<space>q', "gwap", { desc = "Wrap paragraph" })
|
||||
vim.keymap.set('n', '<esc><esc>', ":silent! nohls<CR>", { desc = "Clear search" })
|
||||
|
||||
45
lua/lsp.lua
45
lua/lsp.lua
@@ -13,7 +13,7 @@ require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'pylsp',
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
-- 'rust_analyzer', -- handled by rust mrcjkb/rustaceanvim
|
||||
'yamlls',
|
||||
'ts_ls',
|
||||
'gopls',
|
||||
@@ -22,45 +22,33 @@ require('mason-lspconfig').setup({
|
||||
},
|
||||
})
|
||||
|
||||
-- Customized on_attach function
|
||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
local opts = { noremap = true, silent = true }
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Popup diagnostics" })
|
||||
-- 2024-09-23 - currently unused
|
||||
-- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, bufnr)
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
-- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
local bufopts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = "LSP show signature", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder,
|
||||
{ desc = "Workspace add folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder,
|
||||
{ desc = "Workspace remove folder", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>wl', function()
|
||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||
end, bufopts)
|
||||
-- vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
||||
-- vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
||||
end, { desc = "Workspace list folders", unpack(bufopts) })
|
||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, { desc = "LSP Rename", unpack(bufopts) })
|
||||
vim.keymap.set("n", "<space>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, bufopts)
|
||||
end, { desc = "LSP Format buffer", unpack(bufopts) })
|
||||
|
||||
-- 2024-09-09 - some ccflow commands
|
||||
|
||||
local fzf = require('fzf-lua')
|
||||
vim.keymap.set('n', '<space>d', fzf.diagnostics_document, { desc = "Document diagnostics" })
|
||||
vim.keymap.set('n', '<space>D', fzf.diagnostics_workspace, { desc = "Workspace diagnostics" })
|
||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, { desc = "Popup diagnostics" })
|
||||
vim.keymap.set('n', '<space>s', fzf.lsp_document_symbols, { desc = "Doc symbols" })
|
||||
vim.keymap.set('n', '<space>c', fzf.lsp_code_actions, { desc = "Code Actions" })
|
||||
-- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
||||
@@ -69,7 +57,7 @@ local on_attach = function(client, bufnr)
|
||||
end
|
||||
|
||||
-- Set different settings for different languages' LSP
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md
|
||||
-- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md
|
||||
-- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D
|
||||
-- - the settings table is sent to the LSP
|
||||
-- - on_attach: a lua callback function to run after LSP attaches to a given buffer
|
||||
@@ -108,3 +96,12 @@ require('mason-lspconfig').setup_handlers({
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
-- use on_attach to get lsp related shortcuts
|
||||
vim.g.rustaceanvim = {
|
||||
-- LSP configuration
|
||||
server = {
|
||||
on_attach = on_attach
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,17 +12,10 @@ end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
-- Vscode-like pictograms
|
||||
{
|
||||
"onsails/lspkind.nvim",
|
||||
event = { "VimEnter" },
|
||||
},
|
||||
|
||||
-- Auto-completion engine
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"lspkind.nvim",
|
||||
"hrsh7th/cmp-nvim-lsp", -- lsp auto-completion
|
||||
"hrsh7th/cmp-buffer", -- buffer auto-completion
|
||||
"hrsh7th/cmp-path", -- path auto-completion
|
||||
@@ -49,6 +42,16 @@ require("lazy").setup({
|
||||
"williamboman/mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
"neovim/nvim-lspconfig",
|
||||
|
||||
-- Nice plugin to show what LSPs are doing in the background (and others
|
||||
-- using $/progress and vim.notify())
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
opts = {
|
||||
-- options
|
||||
},
|
||||
},
|
||||
|
||||
-- show lsp signature while coding
|
||||
{
|
||||
"ray-x/lsp_signature.nvim",
|
||||
@@ -94,6 +97,9 @@ require("lazy").setup({
|
||||
end,
|
||||
},
|
||||
|
||||
-- comfortable table editing, esp. used in orgmode
|
||||
{ 'dhruvasagar/vim-table-mode' },
|
||||
|
||||
-- fzf-lua
|
||||
{
|
||||
"ibhagwan/fzf-lua",
|
||||
@@ -107,7 +113,7 @@ require("lazy").setup({
|
||||
end
|
||||
},
|
||||
|
||||
-- whichkey
|
||||
-- which-key
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
@@ -161,6 +167,34 @@ require("lazy").setup({
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
config = function()
|
||||
-- an alternative might be:
|
||||
-- https://github.com/nvim-treesitter/nvim-treesitter-context
|
||||
local function breadcrumb()
|
||||
local result = require 'nvim-treesitter'.statusline(
|
||||
{
|
||||
type_patterns = {
|
||||
"class",
|
||||
"impl",
|
||||
"function",
|
||||
"method",
|
||||
"import",
|
||||
"for",
|
||||
"if",
|
||||
"while",
|
||||
"variable",
|
||||
"comment",
|
||||
},
|
||||
separator = " ▶ "
|
||||
}
|
||||
)
|
||||
if result == "" then
|
||||
result = ' '
|
||||
elseif result == nil then
|
||||
result = ''
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = false,
|
||||
@@ -181,7 +215,7 @@ require("lazy").setup({
|
||||
}
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'filename' },
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = { 'branch', 'diff', 'diagnostics' },
|
||||
lualine_c = {},
|
||||
lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
@@ -189,16 +223,25 @@ require("lazy").setup({
|
||||
lualine_z = { 'progress', 'location' }
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_a = { { 'filename', path = 1, shorting_target = 50 } },
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
lualine_c = {},
|
||||
-- lualine_x = { 'encoding', 'fileformat', 'filetype' },
|
||||
lualine_x = {},
|
||||
lualine_y = { 'filesize' },
|
||||
lualine_z = { 'location' }
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
winbar = {
|
||||
lualine_a = {
|
||||
{ breadcrumb,
|
||||
color = { bg = '#101010', fg = '#568200' },
|
||||
},
|
||||
},
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_a = { breadcrumb },
|
||||
},
|
||||
extensions = {}
|
||||
}
|
||||
end
|
||||
@@ -247,9 +290,6 @@ require("lazy").setup({
|
||||
"PhilRunninger/cmp-rpncalc",
|
||||
},
|
||||
|
||||
-- comfortable table editing, esp. used in orgmode
|
||||
{ 'dhruvasagar/vim-table-mode' },
|
||||
|
||||
-- TODO, WARN, HACK, PERF, NOTE, TEST and others highlighting and searching
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
@@ -275,8 +315,8 @@ require("lazy").setup({
|
||||
{ "cpkio/nvim-treesitter-asciidoc" },
|
||||
|
||||
|
||||
-- Greeter to run on NeoVim startup
|
||||
{
|
||||
|
||||
'goolord/alpha-nvim',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
@@ -384,5 +424,18 @@ require("lazy").setup({
|
||||
end,
|
||||
},
|
||||
|
||||
-- improved Rust support
|
||||
{
|
||||
'mrcjkb/rustaceanvim',
|
||||
version = '^5', -- Recommended
|
||||
lazy = false, -- This plugin is already lazy
|
||||
},
|
||||
|
||||
-- show git changes on the left
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
config = function()
|
||||
require('gitsigns').setup()
|
||||
end,
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user