add function signatures and format short cuts
This commit is contained in:
parent
434ee099bb
commit
109e3f7a63
41
init.lua
41
init.lua
|
|
@ -91,7 +91,7 @@ vim.g.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.opt`
|
-- See `:help vim.opt`
|
||||||
|
|
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- Experiment for yourself to see if you like it!
|
||||||
-- vim.opt.relativenumber = true
|
vim.opt.relativenumber = true
|
||||||
|
|
||||||
-- Enable mouse mode, can be useful for resizing splits for example!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
@ -146,7 +146,7 @@ vim.opt.splitbelow = true
|
||||||
-- See `:help 'list'`
|
-- See `:help 'list'`
|
||||||
-- and `:help 'listchars'`
|
-- and `:help 'listchars'`
|
||||||
vim.opt.list = true
|
vim.opt.list = true
|
||||||
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣', eol = '¬' }
|
||||||
|
|
||||||
-- Preview substitutions live, as you type!
|
-- Preview substitutions live, as you type!
|
||||||
vim.opt.inccommand = 'split'
|
vim.opt.inccommand = 'split'
|
||||||
|
|
@ -161,7 +161,7 @@ vim.opt.scrolloff = 10
|
||||||
-- See `:help vim.keymap.set()`
|
-- See `:help vim.keymap.set()`
|
||||||
|
|
||||||
-- MY KEYMAPS BEGIN
|
-- MY KEYMAPS BEGIN
|
||||||
vim.api.nvim_exec(
|
vim.api.nvim_exec2(
|
||||||
[[
|
[[
|
||||||
function! s:ZoomToggle() abort
|
function! s:ZoomToggle() abort
|
||||||
if exists('t:zoomed') && t:zoomed
|
if exists('t:zoomed') && t:zoomed
|
||||||
|
|
@ -176,19 +176,14 @@ vim.api.nvim_exec(
|
||||||
endfunction
|
endfunction
|
||||||
command! ZoomToggle call s:ZoomToggle()
|
command! ZoomToggle call s:ZoomToggle()
|
||||||
]],
|
]],
|
||||||
false
|
{ output = false }
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.cmd [[
|
vim.keymap.set('n', ',h', [[ (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"]], { silent = true, expr = true, desc = 'toggles highlighting' })
|
||||||
set listchars=eol:¬
|
|
||||||
" hi NonText guibg=#eee
|
|
||||||
nnoremap <silent><expr> ,h (&hls && v:hlsearch ? ':nohls' : ':set hls')."\n"
|
|
||||||
]]
|
|
||||||
|
|
||||||
vim.keymap.set('n', ';', ':', { noremap = true, desc = 'Command mode' })
|
vim.keymap.set('n', ';', ':', { noremap = true, desc = 'Command mode' })
|
||||||
vim.keymap.set('n', "'", '`', { noremap = true, desc = 'Mark character' })
|
vim.keymap.set('n', "'", '`', { noremap = true, desc = 'Mark character' })
|
||||||
vim.keymap.set('n', '`', "'", { noremap = true, desc = 'Mark line' })
|
vim.keymap.set('n', '`', "'", { noremap = true, desc = 'Mark line' })
|
||||||
-- vim.keymap.set("n", "œ", "<cmd>bdelete<CR>", { silent = true, desc = "Buffer Delete" })
|
|
||||||
vim.keymap.set('n', '<C-z>', '<cmd>ZoomToggle<CR>', { noremap = true, desc = 'Zoom Toggle' })
|
vim.keymap.set('n', '<C-z>', '<cmd>ZoomToggle<CR>', { noremap = true, desc = 'Zoom Toggle' })
|
||||||
|
|
||||||
vim.keymap.set('i', 'df', '<ESC>', { noremap = true, desc = 'ESC' })
|
vim.keymap.set('i', 'df', '<ESC>', { noremap = true, desc = 'ESC' })
|
||||||
|
|
@ -202,6 +197,9 @@ vim.keymap.set('n', ',N', '<cmd>Neotree reveal left<CR>', { noremap = true, desc
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>w', '<cmd>:w<CR>', { noremap = true, desc = 'Save file' })
|
vim.keymap.set('n', '<leader>w', '<cmd>:w<CR>', { noremap = true, desc = 'Save file' })
|
||||||
|
|
||||||
|
vim.keymap.set('i', '<C-k>', vim.lsp.buf.signature_help, { noremap = true, desc = 'Signature Help' })
|
||||||
|
vim.keymap.set('n', '<leader>ff', vim.lsp.buf.format, { noremap = true, desc = 'LSP format' })
|
||||||
|
|
||||||
vim.g.diagnostics_active = false
|
vim.g.diagnostics_active = false
|
||||||
function _G.toggle_diagnostics()
|
function _G.toggle_diagnostics()
|
||||||
if vim.g.diagnostics_active then
|
if vim.g.diagnostics_active then
|
||||||
|
|
@ -342,6 +340,7 @@ require('lazy').setup({
|
||||||
{ '<leader>d', group = '[D]ocument' },
|
{ '<leader>d', group = '[D]ocument' },
|
||||||
{ '<leader>r', group = '[R]ename' },
|
{ '<leader>r', group = '[R]ename' },
|
||||||
{ '<leader>s', group = '[S]earch' },
|
{ '<leader>s', group = '[S]earch' },
|
||||||
|
{ '<leader>f', group = '[F]ormat' },
|
||||||
{ '<leader>w', group = '[W]orkspace' },
|
{ '<leader>w', group = '[W]orkspace' },
|
||||||
{ '<leader>t', group = '[T]oggle' },
|
{ '<leader>t', group = '[T]oggle' },
|
||||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
||||||
|
|
@ -521,6 +520,7 @@ require('lazy').setup({
|
||||||
|
|
||||||
-- Allows extra capabilities provided by nvim-cmp
|
-- Allows extra capabilities provided by nvim-cmp
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
|
'hrsh7th/cmp-nvim-lsp-signature-help',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
-- Brief aside: **What is LSP?**
|
-- Brief aside: **What is LSP?**
|
||||||
|
|
@ -630,16 +630,6 @@ require('lazy').setup({
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- custom auto format
|
|
||||||
if client then
|
|
||||||
client.server_capabilities.documentFormattingProvider = true
|
|
||||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
||||||
callback = function()
|
|
||||||
vim.lsp.buf.format()
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
-- The following code creates a keymap to toggle inlay hints in your
|
-- The following code creates a keymap to toggle inlay hints in your
|
||||||
-- code, if the language server you are using supports them
|
-- code, if the language server you are using supports them
|
||||||
--
|
--
|
||||||
|
|
@ -838,7 +828,13 @@ require('lazy').setup({
|
||||||
-- Accept ([y]es) the completion.
|
-- Accept ([y]es) the completion.
|
||||||
-- This will auto-import if your LSP supports it.
|
-- This will auto-import if your LSP supports it.
|
||||||
-- This will expand snippets if the LSP sent a snippet.
|
-- This will expand snippets if the LSP sent a snippet.
|
||||||
['<C-j>'] = cmp.mapping.confirm { select = true },
|
['<C-j>'] = cmp.mapping(function(fallback)
|
||||||
|
if cmp.visible() then
|
||||||
|
cmp.confirm { select = true }
|
||||||
|
else
|
||||||
|
cmp.complete()
|
||||||
|
end
|
||||||
|
end, { 'i', 's' }),
|
||||||
|
|
||||||
-- If you prefer more traditional completion keymaps,
|
-- If you prefer more traditional completion keymaps,
|
||||||
-- you can uncomment the following lines
|
-- you can uncomment the following lines
|
||||||
|
|
@ -880,6 +876,7 @@ require('lazy').setup({
|
||||||
group_index = 0,
|
group_index = 0,
|
||||||
},
|
},
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'nvim_lsp_signature_help' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
{ name = 'path' },
|
{ name = 'path' },
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
return {
|
return {
|
||||||
'windwp/nvim-autopairs',
|
'windwp/nvim-autopairs',
|
||||||
event = 'InsertEnter',
|
event = 'InsertEnter',
|
||||||
config = true,
|
-- config = true,
|
||||||
-- use opts = {} for passing setup options
|
-- use opts = {} for passing setup options
|
||||||
-- this is equalent to setup({}) function
|
-- this is equalent to setup({}) function
|
||||||
|
config = function()
|
||||||
|
require('nvim-autopairs').setup {}
|
||||||
|
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||||
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue