Minor nvim config changes
This commit is contained in:
parent
90ca95ad38
commit
3d86f44d31
10 changed files with 82 additions and 97 deletions
|
@ -3,6 +3,7 @@
|
||||||
"LuaSnip": { "branch": "master", "commit": "f03089854a8e15594a01562fa7192d0009a6fbe7" },
|
"LuaSnip": { "branch": "master", "commit": "f03089854a8e15594a01562fa7192d0009a6fbe7" },
|
||||||
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
"Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" },
|
||||||
"bufferline.nvim": { "branch": "main", "commit": "1a3397556d194bb1f2cc530b07124ccc512c5501" },
|
"bufferline.nvim": { "branch": "main", "commit": "1a3397556d194bb1f2cc530b07124ccc512c5501" },
|
||||||
|
"cmake-tools.nvim": { "branch": "master", "commit": "edbf419e00b21e83d45f4a17edffb2035d7a0ce6" },
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||||
"fidget.nvim": { "branch": "main", "commit": "785efc604f6ffe3c3fdd2ea86262804d48863ee1" },
|
"fidget.nvim": { "branch": "main", "commit": "785efc604f6ffe3c3fdd2ea86262804d48863ee1" },
|
||||||
|
@ -17,6 +18,7 @@
|
||||||
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
|
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
|
||||||
"nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
|
"nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "694aaec65733e2d54d393abf80e526f86726c988" },
|
"nvim-lspconfig": { "branch": "master", "commit": "694aaec65733e2d54d393abf80e526f86726c988" },
|
||||||
|
"nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" },
|
||||||
"nvim-tree.lua": { "branch": "master", "commit": "05f55c1fd6470b31627655c528245794e3cd4b2c" },
|
"nvim-tree.lua": { "branch": "master", "commit": "05f55c1fd6470b31627655c528245794e3cd4b2c" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "0791b5ebb590a2d44e20640c52679df1fc42e8ab" },
|
"nvim-treesitter": { "branch": "master", "commit": "0791b5ebb590a2d44e20640c52679df1fc42e8ab" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" },
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" },
|
||||||
|
|
3
.config/nvim/lua/config/lsp/clangd.lua
Normal file
3
.config/nvim/lua/config/lsp/clangd.lua
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
return {
|
||||||
|
autoformat = true,
|
||||||
|
}
|
|
@ -1,103 +1,28 @@
|
||||||
-- This function gets run when an LSP connects to a particular buffer.
|
require('mason').setup()
|
||||||
|
require('mason-lspconfig').setup()
|
||||||
|
|
||||||
|
local mason_lspconfig = require('mason-lspconfig')
|
||||||
|
|
||||||
local on_attach = function(_, bufnr)
|
local on_attach = function(_, bufnr)
|
||||||
-- NOTE: Remember that lua is a real programming language, and as such it is possible
|
require("config.lsp.keybinds").init_keymap(bufnr)
|
||||||
-- to define small helper and utility functions so you don't have to repeat yourself
|
|
||||||
-- many times.
|
|
||||||
--
|
|
||||||
-- In this case, we create a function that lets us more easily define mappings specific
|
|
||||||
-- for LSP related items. It sets the mode, buffer and description for us each time.
|
|
||||||
local nmap = function(keys, func, desc)
|
|
||||||
if desc then
|
|
||||||
desc = 'LSP: ' .. desc
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
|
||||||
end
|
|
||||||
|
|
||||||
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
|
||||||
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
|
||||||
|
|
||||||
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
|
||||||
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
|
||||||
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
|
||||||
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
|
||||||
|
|
||||||
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
|
||||||
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
|
||||||
|
|
||||||
-- See `:help K` for why this keymap
|
|
||||||
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
|
||||||
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
|
||||||
|
|
||||||
-- Lesser used LSP functionality
|
|
||||||
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
|
||||||
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
|
||||||
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
|
||||||
nmap('<leader>wl', function()
|
|
||||||
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
||||||
end, '[W]orkspace [L]ist Folders')
|
|
||||||
|
|
||||||
-- Create a command `:Format` local to the LSP buffer
|
|
||||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||||
vim.lsp.buf.format()
|
vim.lsp.buf.format()
|
||||||
end, { desc = 'Format current buffer with LSP' })
|
end, { desc = 'Format current buffer with LSP' })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- document existing key chains
|
|
||||||
-- require('which-key').register {
|
|
||||||
-- ['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>g'] = { name = '[G]it', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>h'] = { name = 'More git', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
|
||||||
-- ['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- mason-lspconfig requires that these setup functions are called in this order
|
|
||||||
-- before setting up the servers.
|
|
||||||
require('mason').setup()
|
|
||||||
require('mason-lspconfig').setup()
|
|
||||||
|
|
||||||
-- Enable the following language servers
|
|
||||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
|
||||||
--
|
|
||||||
-- Add any additional override configuration in the following tables. They will be passed to
|
|
||||||
-- the `settings` field of the server config. You must look up that documentation yourself.
|
|
||||||
--
|
|
||||||
-- If you want to override the default filetypes that your language server will attach to you can
|
|
||||||
-- define the property 'filetypes' to the map in question.
|
|
||||||
local servers = {
|
local servers = {
|
||||||
clangd = {},
|
clangd = require("config.lsp.clangd"),
|
||||||
-- gopls = {},
|
pyright = require("config.lsp.pyright"),
|
||||||
-- pyright = {},
|
lua_ls = require("config.lsp.lua_ls"),
|
||||||
-- rust_analyzer = {},
|
|
||||||
-- tsserver = {},
|
|
||||||
-- html = { filetypes = { 'html', 'twig', 'hbs'} },
|
|
||||||
|
|
||||||
lua_ls = {
|
|
||||||
Lua = {
|
|
||||||
workspace = { checkThirdParty = false },
|
|
||||||
telemetry = { enable = false },
|
|
||||||
-- NOTE: toggle below to ignore Lua_LS's noisy `missing-fields` warnings
|
|
||||||
-- diagnostics = { disable = { 'missing-fields' } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Setup neovim lua configuration
|
|
||||||
require('neodev').setup()
|
|
||||||
|
|
||||||
-- nvim-cmp supports additional completion capabilities, so broadcast that to servers
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||||
|
|
||||||
-- Ensure the servers above are installed
|
mason_lspconfig.setup({
|
||||||
local mason_lspconfig = require 'mason-lspconfig'
|
|
||||||
|
|
||||||
mason_lspconfig.setup {
|
|
||||||
ensure_installed = vim.tbl_keys(servers),
|
ensure_installed = vim.tbl_keys(servers),
|
||||||
}
|
})
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers {
|
mason_lspconfig.setup_handlers {
|
||||||
function(server_name)
|
function(server_name)
|
||||||
|
|
36
.config/nvim/lua/config/lsp/keybinds.lua
Normal file
36
.config/nvim/lua/config/lsp/keybinds.lua
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.init_keymap(bufnr)
|
||||||
|
local nmap = function(keys, func, desc)
|
||||||
|
if desc then
|
||||||
|
desc = 'LSP: ' .. desc
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||||
|
end
|
||||||
|
|
||||||
|
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
|
||||||
|
nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
|
||||||
|
|
||||||
|
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||||
|
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||||
|
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||||
|
nmap('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition')
|
||||||
|
|
||||||
|
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||||
|
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||||
|
|
||||||
|
-- See `:help K` for why this keymap
|
||||||
|
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||||
|
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
|
||||||
|
|
||||||
|
-- Lesser used LSP functionality
|
||||||
|
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||||
|
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||||
|
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||||
|
nmap('<leader>wl', function()
|
||||||
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
||||||
|
end, '[W]orkspace [L]ist Folders')
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
8
.config/nvim/lua/config/lsp/lua_ls.lua
Normal file
8
.config/nvim/lua/config/lsp/lua_ls.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
require('neodev').setup()
|
||||||
|
|
||||||
|
return {
|
||||||
|
Lua = {
|
||||||
|
workspace = { checkThirdParty = false },
|
||||||
|
telemetry = { enable = false },
|
||||||
|
},
|
||||||
|
}
|
1
.config/nvim/lua/config/lsp/pyright.lua
Normal file
1
.config/nvim/lua/config/lsp/pyright.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
return {}
|
|
@ -5,8 +5,8 @@ map('n', '<C-q>', '<NOP>')
|
||||||
map('v', 'K', '<NOP>')
|
map('v', 'K', '<NOP>')
|
||||||
|
|
||||||
-- Movement between buffers
|
-- Movement between buffers
|
||||||
map({'n', 'v', 'i'}, '<A-u>', ':bp<CR>')
|
map({ 'n', 'v', 'i' }, '<A-u>', ':bp<CR>')
|
||||||
map({'n', 'v', 'i'}, '<A-i>', ':bn<CR>')
|
map({ 'n', 'v', 'i' }, '<A-i>', ':bn<CR>')
|
||||||
|
|
||||||
-- Remap for dealing with word wrap
|
-- Remap for dealing with word wrap
|
||||||
map('n', 'k', 'v:count == 0 ? "gk" : "k"', { expr = true, silent = true })
|
map('n', 'k', 'v:count == 0 ? "gk" : "k"', { expr = true, silent = true })
|
||||||
|
@ -14,8 +14,9 @@ map('n', 'j', 'v:count == 0 ? "gj" : "j"', { expr = true, silent = true })
|
||||||
|
|
||||||
-- Exit buffers/nvim with <leader>
|
-- Exit buffers/nvim with <leader>
|
||||||
map('n', '<leader>q', function() require('utils.close_buffer').close_buffer() end)
|
map('n', '<leader>q', function() require('utils.close_buffer').close_buffer() end)
|
||||||
map('n', '<leader><C-q>', function() require('utils.close_buffer').close_buffer(true) end)
|
map('n', '<leader>1', function() require('utils.close_buffer').close_buffer(true) end)
|
||||||
map('n', '<leader>Q', ':%bd | quit<CR>')
|
map('n', '<leader>Q', ':%bd | quit<CR>')
|
||||||
|
map('n', '<leader>!', ':%bd! | quit!<CR>')
|
||||||
map('n', '<leader>w', ':write<CR>')
|
map('n', '<leader>w', ':write<CR>')
|
||||||
|
|
||||||
-- Copy and paste from clipboard
|
-- Copy and paste from clipboard
|
||||||
|
@ -23,3 +24,8 @@ map('n', '<leader>y', '"+yy<ESC>')
|
||||||
map('v', '<leader>y', '"+y<ESC>')
|
map('v', '<leader>y', '"+y<ESC>')
|
||||||
map({ 'n', 'v' }, '<leader>p', '"+p<ESC>')
|
map({ 'n', 'v' }, '<leader>p', '"+p<ESC>')
|
||||||
map({ 'n', 'v' }, '<leader>P', '"+P<ESC>')
|
map({ 'n', 'v' }, '<leader>P', '"+P<ESC>')
|
||||||
|
|
||||||
|
-- Remap <M-BS> to remove last word
|
||||||
|
map('i', '<M-BS>', '<C-w>')
|
||||||
|
|
||||||
|
map('n', '<leader>F', function() vim.lsp.buf.format() end)
|
||||||
|
|
|
@ -8,7 +8,7 @@ require("cmake-tools").setup {
|
||||||
-- ${kitGenerator}
|
-- ${kitGenerator}
|
||||||
-- ${variant:xx}
|
-- ${variant:xx}
|
||||||
cmake_build_directory = "cmake-build-${variant:buildType}", -- this is used to specify generate directory for cmake, allows macro expansion
|
cmake_build_directory = "cmake-build-${variant:buildType}", -- this is used to specify generate directory for cmake, allows macro expansion
|
||||||
cmake_soft_link_compile_commands = false, -- this will automatically make a soft link from compile commands file to project root dir
|
cmake_soft_link_compile_commands = true, -- this will automatically make a soft link from compile commands file to project root dir
|
||||||
cmake_compile_commands_from_lsp = false, -- this will automatically set compile commands file location using lsp, to use it, please set `cmake_soft_link_compile_commands` to false
|
cmake_compile_commands_from_lsp = false, -- this will automatically set compile commands file location using lsp, to use it, please set `cmake_soft_link_compile_commands` to false
|
||||||
cmake_kits_path = nil, -- this is used to specify global cmake kits path, see CMakeKits for detailed usage
|
cmake_kits_path = nil, -- this is used to specify global cmake kits path, see CMakeKits for detailed usage
|
||||||
cmake_variants_message = {
|
cmake_variants_message = {
|
||||||
|
@ -56,12 +56,20 @@ require("cmake-tools").setup {
|
||||||
start_insert_in_launch_task = false, -- If you want to enter terminal with :startinsert upon using :CMakeRun
|
start_insert_in_launch_task = false, -- If you want to enter terminal with :startinsert upon using :CMakeRun
|
||||||
start_insert_in_other_tasks = false, -- If you want to enter terminal with :startinsert upon launching all other cmake tasks in the terminal. Generally set as false
|
start_insert_in_other_tasks = false, -- If you want to enter terminal with :startinsert upon launching all other cmake tasks in the terminal. Generally set as false
|
||||||
focus_on_main_terminal = false, -- Focus on cmake terminal when cmake task is launched. Only used if executor is terminal.
|
focus_on_main_terminal = false, -- Focus on cmake terminal when cmake task is launched. Only used if executor is terminal.
|
||||||
focus_on_launch_terminal = false, -- Focus on cmake launch terminal when executable target in launched.
|
focus_on_launch_terminal = true, -- Focus on cmake launch terminal when executable target in launched.
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cmake_notifications = {
|
cmake_notifications = {
|
||||||
enabled = true, -- show cmake execution progress in nvim-notify
|
enabled = false, -- show cmake execution progress in nvim-notify
|
||||||
spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }, -- icons used for progress display
|
spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" }, -- icons used for progress display
|
||||||
refresh_rate_ms = 100, -- how often to iterate icons
|
refresh_rate_ms = 100, -- how often to iterate icons
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local map = vim.keymap.set
|
||||||
|
|
||||||
|
-- Mappings
|
||||||
|
map('n', '<leader>b', ':CMakeBuild<CR>')
|
||||||
|
map('n', '<leader>c', ':CMakeClose<CR>')
|
||||||
|
map('n', '<leader>r', ':CMakeRun<CR>')
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ return {
|
||||||
'nvim-tree/nvim-tree.lua',
|
'nvim-tree/nvim-tree.lua',
|
||||||
'nvim-tree/nvim-web-devicons',
|
'nvim-tree/nvim-web-devicons',
|
||||||
'Civitasv/cmake-tools.nvim',
|
'Civitasv/cmake-tools.nvim',
|
||||||
|
'rcarriga/nvim-notify',
|
||||||
{ 'numToStr/Comment.nvim', opts = {} },
|
{ 'numToStr/Comment.nvim', opts = {} },
|
||||||
{ 'akinsho/bufferline.nvim', config = {} },
|
{ 'akinsho/bufferline.nvim', config = {} },
|
||||||
{ 'ethanholz/nvim-lastplace', config = {} },
|
{ 'ethanholz/nvim-lastplace', config = {} },
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
return {
|
return {
|
||||||
-- LSP Configuration & Plugins
|
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
dependencies = {
|
dependencies = {
|
||||||
-- Automatically install LSPs to stdpath for neovim
|
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
-- Useful status updates for LSP
|
|
||||||
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
||||||
{ 'j-hui/fidget.nvim', opts = {} },
|
{ 'j-hui/fidget.nvim', opts = {} },
|
||||||
|
|
||||||
-- Additional lua configuration, makes nvim stuff amazing!
|
|
||||||
'folke/neodev.nvim',
|
'folke/neodev.nvim',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue