Repository navigation
Expand file tree
/
Copy pathmappings.lua
More file actions
73 lines (58 loc) · 2.04 KB
/
Copy pathmappings.lua
File metadata and controls
73 lines (58 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
require "nvchad.mappings"
local map = vim.keymap.set
local function mark_and_move(motion)
return function()
local count = vim.v.count > 0 and vim.v.count or ""
if count ~= "" then
vim.cmd("normal! m'")
vim.cmd("normal! " .. count .. motion)
else
vim.cmd("normal! " .. motion)
end
end
end
for _, m in ipairs({ 'j', 'k' }) do
map('n', m, mark_and_move(m), { noremap = true, silent = true })
end
map('i', '<Tab>', '<Tab>', { noremap = true, silent = true })
map("n", "<Space>k", function()
local prettier_fts = {
html = true, css = true, scss = true, less = true,
javascript = true, javascriptreact = true,
typescript = true, typescriptreact = true,
json = true, yaml = true, markdown = true, graphql = true,
}
local ft = vim.bo.filetype
if prettier_fts[ft] then
vim.notify("Formatting with Prettier (Conform)", vim.log.levels.INFO)
require("conform").format({ lsp_fallback = false })
else
vim.notify("Formatting with LSP (" .. ft .. ")", vim.log.levels.INFO)
vim.lsp.buf.format({ async = false })
end
end, { noremap = true, silent = true, desc = "Format (Prettier or LSP)" })
-- map('n', '<Space>k', ':lua vim.lsp.buf.format()<CR>', {
-- noremap = true, silent = true
-- })
map('n', '<Space>ca', ':lua vim.lsp.buf.code_action()<CR>', {
noremap = true, silent = true
})
map('n', '<Space><Tab>', function() vim.cmd('LspClangdSwitchSourceHeader') end, {
noremap = true, silent = true
})
map('n', '<C-k>', '<C-i>', { noremap = true, silent = true })
map('n', '<leader>gr', function()
require('telescope.builtin').lsp_references()
end)
map('n', '<leader>ds', function()
require('telescope.builtin').diagnostics()
end)
map('n', '<leader>sy', function()
require('telescope.builtin').lsp_document_symbols()
end)
map('n', '<leader>asy', function()
require('telescope.builtin').lsp_workspace_symbols()
end)
map('n', '<leader>td', function()
require('telescope.builtin').lsp_type_definitions()
end)