Modernizied structure of configure files
This commit is contained in:
parent
515972d957
commit
6f55a66333
12 changed files with 264 additions and 254 deletions
10
init.lua
10
init.lua
|
|
@ -1,5 +1,5 @@
|
||||||
require("plugins/lazy")
|
require("config.lazy")
|
||||||
require("base/search")
|
require("base.search")
|
||||||
require("base/tabs")
|
require("base.tabs")
|
||||||
require("base/other")
|
require("base.other")
|
||||||
require("keys/main")
|
require("keys.main")
|
||||||
|
|
|
||||||
32
lua/config/lazy.lua
Normal file
32
lua/config/lazy.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
-- Bootstrap lazy.nvim
|
||||||
|
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||||
|
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||||
|
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||||
|
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||||
|
if vim.v.shell_error ~= 0 then
|
||||||
|
vim.api.nvim_echo({
|
||||||
|
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||||
|
{ out, "WarningMsg" },
|
||||||
|
{ "\nPress any key to exit..." },
|
||||||
|
}, true, {})
|
||||||
|
vim.fn.getchar()
|
||||||
|
os.exit(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.opt.rtp:prepend(lazypath)
|
||||||
|
|
||||||
|
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||||
|
-- loading lazy.nvim so that mappings are correct.
|
||||||
|
-- This is also a good place to setup other settings (vim.opt)
|
||||||
|
vim.g.mapleader = " "
|
||||||
|
vim.g.maplocalleader = "\\"
|
||||||
|
|
||||||
|
-- Setup lazy.nvim
|
||||||
|
require("lazy").setup({
|
||||||
|
spec = {
|
||||||
|
-- import your plugins
|
||||||
|
{ import = "plugins" },
|
||||||
|
},
|
||||||
|
-- automatically check for plugin updates
|
||||||
|
checker = { enabled = false },
|
||||||
|
})
|
||||||
2
lua/plugins/README.md
Normal file
2
lua/plugins/README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
All plugins what looks like a pure library (as a plenary.nvim) should be use in "depenedencies" filed and with "lazy = true".
|
||||||
|
Main theme should be load during startup (lazy = false) and high priority.
|
||||||
9
lua/plugins/aerial.lua
Normal file
9
lua/plugins/aerial.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
return {
|
||||||
|
'stevearc/aerial.nvim',
|
||||||
|
opts = {},
|
||||||
|
-- Optional dependencies
|
||||||
|
dependencies = {
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
"nvim-tree/nvim-web-devicons"
|
||||||
|
},
|
||||||
|
}
|
||||||
11
lua/plugins/colorscheme.lua
Normal file
11
lua/plugins/colorscheme.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
return {
|
||||||
|
{
|
||||||
|
'ellisonleao/gruvbox.nvim',
|
||||||
|
lazy = false,
|
||||||
|
priority = 1000,
|
||||||
|
config = function()
|
||||||
|
vim.cmd([[colorscheme gruvbox]])
|
||||||
|
end,
|
||||||
|
opts = { style = 'dark' }
|
||||||
|
},
|
||||||
|
} -- Main theme should be load during startup.
|
||||||
16
lua/plugins/compile-mode.lua
Normal file
16
lua/plugins/compile-mode.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
return { 'ej-shafran/compile-mode.nvim',
|
||||||
|
version = '^5.13.0',
|
||||||
|
dependencies = {
|
||||||
|
'nvim-lua/plenary.nvim', lazy = true,
|
||||||
|
'm00qek/baleia.nvim',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
---@type CompileModeOpts
|
||||||
|
vim.g.compile_mode = {
|
||||||
|
default_command = 'cmake --build build',
|
||||||
|
input_word_completion = true,
|
||||||
|
baleia_setup = true,
|
||||||
|
bang_expansion = true,
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
|
@ -1,249 +0,0 @@
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
|
||||||
vim.fn.system({
|
|
||||||
"git",
|
|
||||||
"clone",
|
|
||||||
"--filter=blob:none",
|
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
|
||||||
"--branch=stable", -- latest stable release
|
|
||||||
lazypath,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
-- Install plugins using lazy
|
|
||||||
require('lazy').setup({
|
|
||||||
{ 'tpope/vim-commentary', },
|
|
||||||
{ 'tpope/vim-fugitive', },
|
|
||||||
{
|
|
||||||
'morhetz/gruvbox',
|
|
||||||
lazy = false,
|
|
||||||
priority = 1000,
|
|
||||||
config = function()
|
|
||||||
vim.opt.termguicolors = true -- If we want ANSI shit in the "compile mode" for the highlight, it must be stay "true".
|
|
||||||
-- But it may be a buggy thing because, on Windows (Alacritty?), it's producing visual artifacts.
|
|
||||||
vim.opt.background = 'dark'
|
|
||||||
vim.g.gruvbox_italic = true
|
|
||||||
vim.cmd([[colorscheme gruvbox]])
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
-- {
|
|
||||||
-- "folke/tokyonight.nvim",
|
|
||||||
-- lazy = true
|
|
||||||
-- },
|
|
||||||
{ 'ej-shafran/compile-mode.nvim',
|
|
||||||
version = '^5.13.0',
|
|
||||||
dependencies = {
|
|
||||||
'nvim-lua/plenary.nvim',
|
|
||||||
'm00qek/baleia.nvim',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
---@type CompileModeOpts
|
|
||||||
vim.g.compile_mode = {
|
|
||||||
default_command = 'cmake --build build',
|
|
||||||
input_word_completion = true,
|
|
||||||
baleia_setup = true,
|
|
||||||
bang_expansion = true,
|
|
||||||
}
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{ 'nvim-telescope/telescope-fzf-native.nvim',
|
|
||||||
build = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
|
||||||
config = function()
|
|
||||||
local telescope = require('telescope')
|
|
||||||
|
|
||||||
telescope.setup{
|
|
||||||
extensions = {
|
|
||||||
fzf = {
|
|
||||||
fuzzy = true, -- false will only do exact matching
|
|
||||||
override_generic_sorter = true, -- override the generic sorter
|
|
||||||
override_file_sorter = true, -- override the file sorter
|
|
||||||
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
|
||||||
-- the default case_mode is "smart_case"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
telescope.load_extension('fzf')
|
|
||||||
|
|
||||||
local builtin = require('telescope.builtin')
|
|
||||||
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
|
|
||||||
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
|
|
||||||
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
|
||||||
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
|
||||||
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{ "nvim-treesitter/nvim-treesitter",
|
|
||||||
build = ":TSUpdate",
|
|
||||||
config = function()
|
|
||||||
require("nvim-treesitter.configs").setup {
|
|
||||||
ensure_installed = { 'c', 'cpp', 'lua' },
|
|
||||||
highlight = { enable = true, }
|
|
||||||
}
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
config = function()
|
|
||||||
-- Setup language servers
|
|
||||||
-- Server-specific settings. See `:help lspconfig-all`
|
|
||||||
vim.lsp.config('*', {
|
|
||||||
capabilities = {
|
|
||||||
textDocument = {
|
|
||||||
semanticTokens = {
|
|
||||||
multilineTokenSupport = true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
root_markers = { '.git' },
|
|
||||||
})
|
|
||||||
vim.lsp.config('clangd', {
|
|
||||||
cmd = { 'clangd', '--background-index', '--clang-tidy', '--log=verbose', '--header-insertion=never' },
|
|
||||||
filetypes = { 'c', 'cpp' }
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.lsp.enable('clangd')
|
|
||||||
-- Global mappings.
|
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
|
||||||
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
|
||||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
|
||||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
|
||||||
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
|
||||||
|
|
||||||
-- Use LspAttach autocommand to only map the following keys
|
|
||||||
-- after the language server attaches to the current buffer
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
|
||||||
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
|
||||||
callback = function(ev)
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
|
||||||
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
|
||||||
|
|
||||||
-- Buffer local mappings.
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
||||||
local opts = { buffer = ev.buf }
|
|
||||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
||||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
|
||||||
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
|
||||||
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
|
||||||
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
|
||||||
vim.keymap.set('n', '<space>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, opts)
|
|
||||||
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
|
||||||
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
|
||||||
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
|
||||||
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
|
||||||
vim.keymap.set('n', '<space>f', function()
|
|
||||||
vim.lsp.buf.format { async = true }
|
|
||||||
end, opts)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'hrsh7th/nvim-cmp',
|
|
||||||
dependencies = {
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
|
||||||
'hrsh7th/cmp-buffer',
|
|
||||||
'hrsh7th/cmp-path',
|
|
||||||
'hrsh7th/cmp-cmdline',
|
|
||||||
'hrsh7th/cmp-vsnip',
|
|
||||||
'hrsh7th/vim-vsnip',
|
|
||||||
'hrsh7th/cmp-nvim-lsp-signature-help',
|
|
||||||
},
|
|
||||||
config = function()
|
|
||||||
local cmp = require'cmp'
|
|
||||||
cmp.setup({
|
|
||||||
snippet = {
|
|
||||||
-- REQUIRED - you must specify a snippet engine
|
|
||||||
expand = function(args)
|
|
||||||
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
|
||||||
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
|
||||||
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
|
||||||
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
window = {
|
|
||||||
-- completion = cmp.config.window.bordered(),
|
|
||||||
-- documentation = cmp.config.window.bordered(),
|
|
||||||
},
|
|
||||||
mapping = cmp.mapping.preset.insert({
|
|
||||||
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
||||||
['<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.
|
|
||||||
}),
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'vsnip' }, -- For vsnip users.
|
|
||||||
-- { name = 'luasnip' }, -- For luasnip users.
|
|
||||||
-- { name = 'ultisnips' }, -- For ultisnips users.
|
|
||||||
-- { name = 'snippy' }, -- For snippy users.
|
|
||||||
}, {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
{ name = 'nvim_lsp_signature_help' },
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
-- 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' },
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup.filetype('cmake', {
|
|
||||||
sources = cmp.config.sources({
|
|
||||||
{ name = 'cmake', "CMakeLists.txt" },
|
|
||||||
}, {
|
|
||||||
{ name = 'buffer' },
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
|
||||||
cmp.setup.cmdline({ '/', '?' }, {
|
|
||||||
mapping = cmp.mapping.preset.cmdline(),
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- 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 = 'cmdline' }
|
|
||||||
})
|
|
||||||
})
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'stevearc/aerial.nvim',
|
|
||||||
dependencies = { 'neovim/nvim-lspconfig', },
|
|
||||||
config = function()
|
|
||||||
require('aerial').setup({
|
|
||||||
-- optionally use on_attach to set keymaps when aerial has attached to a buffer
|
|
||||||
on_attach = function(bufnr)
|
|
||||||
-- Jump forwards/backwards with '{' and '}'
|
|
||||||
vim.keymap.set('n', '{', '<cmd>AerialPrev<CR>', {buffer = bufnr})
|
|
||||||
vim.keymap.set('n', '}', '<cmd>AerialNext<CR>', {buffer = bufnr})
|
|
||||||
end
|
|
||||||
})
|
|
||||||
-- You probably also want to set a keymap to toggle aerial
|
|
||||||
vim.keymap.set('n', '<F8>', '<cmd>AerialToggle!<CR>')
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
83
lua/plugins/nvim-cmp.lua
Normal file
83
lua/plugins/nvim-cmp.lua
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
return {
|
||||||
|
'hrsh7th/nvim-cmp',
|
||||||
|
dependencies = {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
'hrsh7th/cmp-buffer',
|
||||||
|
'hrsh7th/cmp-path',
|
||||||
|
'hrsh7th/cmp-cmdline',
|
||||||
|
'hrsh7th/cmp-vsnip',
|
||||||
|
'hrsh7th/vim-vsnip',
|
||||||
|
'hrsh7th/cmp-nvim-lsp-signature-help',
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local cmp = require'cmp'
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
-- REQUIRED - you must specify a snippet engine
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
|
||||||
|
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
|
||||||
|
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
|
||||||
|
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<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.
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'vsnip' }, -- For vsnip users.
|
||||||
|
-- { name = 'luasnip' }, -- For luasnip users.
|
||||||
|
-- { name = 'ultisnips' }, -- For ultisnips users.
|
||||||
|
-- { name = 'snippy' }, -- For snippy users.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
{ name = 'nvim_lsp_signature_help' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- 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' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.filetype('cmake', {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'cmake', "CMakeLists.txt" },
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- 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 = 'cmdline' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
}
|
||||||
60
lua/plugins/nvim-lspconfig.lua
Normal file
60
lua/plugins/nvim-lspconfig.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
return {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
config = function()
|
||||||
|
-- Setup language servers
|
||||||
|
-- Server-specific settings. See `:help lspconfig-all`
|
||||||
|
vim.lsp.config('*', {
|
||||||
|
capabilities = {
|
||||||
|
textDocument = {
|
||||||
|
semanticTokens = {
|
||||||
|
multilineTokenSupport = true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
root_markers = { '.git' },
|
||||||
|
})
|
||||||
|
vim.lsp.config('clangd', {
|
||||||
|
cmd = { 'clangd', '--background-index', '--clang-tidy', '--log=verbose', '--header-insertion=never' },
|
||||||
|
filetypes = { 'c', 'cpp' }
|
||||||
|
})
|
||||||
|
|
||||||
|
vim.lsp.enable('clangd')
|
||||||
|
-- Global mappings.
|
||||||
|
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||||
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
|
||||||
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
|
||||||
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
|
||||||
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
|
||||||
|
|
||||||
|
-- Use LspAttach autocommand to only map the following keys
|
||||||
|
-- after the language server attaches to the current buffer
|
||||||
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
|
||||||
|
callback = function(ev)
|
||||||
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
|
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
|
||||||
|
|
||||||
|
-- Buffer local mappings.
|
||||||
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
|
local opts = { buffer = ev.buf }
|
||||||
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||||
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
|
||||||
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
|
||||||
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
|
||||||
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
|
||||||
|
vim.keymap.set('n', '<space>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, opts)
|
||||||
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
|
||||||
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
|
||||||
|
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
|
||||||
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
|
||||||
|
vim.keymap.set('n', '<space>f', function()
|
||||||
|
vim.lsp.buf.format { async = true }
|
||||||
|
end, opts)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
}
|
||||||
9
lua/plugins/nvim-treesitter.lua
Normal file
9
lua/plugins/nvim-treesitter.lua
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
return { "nvim-treesitter/nvim-treesitter",
|
||||||
|
build = ":TSUpdate",
|
||||||
|
config = function()
|
||||||
|
require("nvim-treesitter.configs").setup {
|
||||||
|
ensure_installed = { 'c', 'cpp', 'lua' },
|
||||||
|
highlight = { enable = true, }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
36
lua/plugins/telescope.lua
Normal file
36
lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
return {
|
||||||
|
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||||
|
dependencies = { 'nvim-lua/plenary.nvim', lazy = true,
|
||||||
|
{
|
||||||
|
'nvim-telescope/telescope-fzf-native.nvim',
|
||||||
|
build = (build_cmd ~= 'cmake') and 'make'
|
||||||
|
or 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && ' ..
|
||||||
|
'cmake --build build --config Release && ' ..
|
||||||
|
'cmake --install build --prefix build',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
config = function()
|
||||||
|
local telescope = require('telescope')
|
||||||
|
|
||||||
|
telescope.setup{
|
||||||
|
extensions = {
|
||||||
|
fzf = {
|
||||||
|
fuzzy = true, -- false will only do exact matching
|
||||||
|
override_generic_sorter = true, -- override the generic sorter
|
||||||
|
override_file_sorter = true, -- override the file sorter
|
||||||
|
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
|
||||||
|
-- the default case_mode is "smart_case"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
telescope.load_extension('fzf')
|
||||||
|
|
||||||
|
-- TODO: use keys = { }
|
||||||
|
local builtin = require('telescope.builtin')
|
||||||
|
vim.keymap.set('n', '<C-p>', builtin.find_files, {})
|
||||||
|
vim.keymap.set('n', '<leader>ft', builtin.treesitter, {})
|
||||||
|
vim.keymap.set('n', '<leader>fg', builtin.live_grep, {})
|
||||||
|
vim.keymap.set('n', '<leader>fb', builtin.buffers, {})
|
||||||
|
vim.keymap.set('n', '<leader>fh', builtin.help_tags, {})
|
||||||
|
end
|
||||||
|
}
|
||||||
1
lua/plugins/vim-commentary.lua
Normal file
1
lua/plugins/vim-commentary.lua
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
return { 'tpope/vim-commentary' }
|
||||||
Loading…
Add table
Add a link
Reference in a new issue