feat: improve nvim keymaps, add trouble
This commit is contained in:
parent
d42d294c95
commit
76534ab4cb
13 changed files with 315 additions and 20 deletions
|
|
@ -6,7 +6,7 @@ require("settings.devicons")
|
|||
require("settings.treesitter")
|
||||
require("settings.nvim-tree")
|
||||
require("settings.pairs")
|
||||
require("settings.comment")
|
||||
--require("settings.comment")
|
||||
require("settings.indentline")
|
||||
require("settings.project")
|
||||
require("settings.dashboard")
|
||||
|
|
@ -25,3 +25,4 @@ require("telescope").setup({})
|
|||
require("telescope").load_extension("fzy_native")
|
||||
require("impatient").enable_profile()
|
||||
require("nightfox")
|
||||
require('Comment').setup()
|
||||
|
|
|
|||
6
nvim/lua/settings/.prettierrc
Normal file
6
nvim/lua/settings/.prettierrc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"trailingComma": "all",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": false
|
||||
}
|
||||
|
|
@ -5,7 +5,6 @@ require("bufferline").setup({
|
|||
tabpages = true,
|
||||
closable = true,
|
||||
clickable = true,
|
||||
exclude_ft = { "javascript" },
|
||||
exclude_name = { "package.json" },
|
||||
icons = true,
|
||||
icon_custom_colors = false,
|
||||
|
|
|
|||
|
|
@ -8,9 +8,27 @@ if not snip_status_ok then
|
|||
return
|
||||
end
|
||||
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets" })
|
||||
|
||||
luasnip.config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
enable_autosnippets = true,
|
||||
ext_opts = {
|
||||
[require("luasnip.util.types").choiceNode] = {
|
||||
active = {
|
||||
virt_text = { {
|
||||
Snippet = "",
|
||||
"Snippet",
|
||||
} },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.cmd('let g:snipMate = {"snippet_version" : 1 }')
|
||||
require("luasnip/loaders/from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||
--require("luasnip.loaders.from_snipmate").lazy_load()
|
||||
|
||||
local check_backspace = function()
|
||||
local col = vim.fn.col(".") - 1
|
||||
|
|
@ -47,6 +65,11 @@ local kind_icons = {
|
|||
}
|
||||
-- find more here: https://www.nerdfonts.com/cheat-sheet
|
||||
|
||||
--local has_words_before = function()
|
||||
-- local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
-- return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
--end
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
|
@ -55,7 +78,7 @@ cmp.setup({
|
|||
},
|
||||
mapping = {
|
||||
["<C-k>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
--["<C-j>"] = cmp.mapping.select_next_item(),
|
||||
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
|
||||
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
|
||||
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
|
||||
|
|
@ -64,13 +87,25 @@ cmp.setup({
|
|||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
-- 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.
|
||||
-- }),
|
||||
-- Accept currently selected item. If none selected, `select` first item.
|
||||
-- Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expandable() then
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-j>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
|
|
@ -84,9 +119,7 @@ cmp.setup({
|
|||
"s",
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
if luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,11 @@ local term_opts = { silent = true }
|
|||
|
||||
-- Shorten function name
|
||||
local keymap = vim.api.nvim_set_keymap
|
||||
--vim.lsp.handlers["textDocument/codeAction"] = require'lspactions'.codeaction
|
||||
--vim.cmd [[ nnoremap <leader>af :lua require'lspactions'.code_action()<CR> ]]
|
||||
|
||||
keymap("n", "c", ":CodeActionMenu<CR>", opts)
|
||||
keymap("n", "<M-CR>", ":CodeActionMenu<CR>", opts)
|
||||
keymap("n", "<C-f>", "<cmd>TroubleToggle<CR>", term_opts)
|
||||
keymap("n", "<F5>", ':lua require("dap").toggle_breakpoint()<CR>', opts)
|
||||
keymap("n", "<F6>", ':lua require("dap").step_over()<CR>', opts)
|
||||
keymap("n", "<F7>", ':lua require("dap").step_into()<CR>', opts)
|
||||
|
|
@ -26,3 +29,10 @@ vim.keymap.set("n", "ff", builtin.find_files, {})
|
|||
vim.keymap.set("n", "fg", builtin.live_grep, {})
|
||||
vim.keymap.set("n", "fb", builtin.buffers, {})
|
||||
vim.keymap.set("n", "fh", builtin.help_tags, {})
|
||||
|
||||
require("trouble").setup {
|
||||
action_keys = {
|
||||
--remove the fucking stupid keymap amk
|
||||
open_tab = {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ require("mason-lspconfig").setup({
|
|||
"html", -- html
|
||||
"eslint", -- latex
|
||||
"clangd", -- cpp / c
|
||||
"tsserver", -- python
|
||||
--"tsserver", -- python
|
||||
"texlab", -- latex
|
||||
"sumneko_lua", -- lua
|
||||
"pyright", -- python
|
||||
|
|
@ -56,10 +56,10 @@ require("lspconfig")["clangd"].setup({
|
|||
--on_attach = on_attach,
|
||||
})
|
||||
|
||||
require("lspconfig")["tsserver"].setup({
|
||||
capabilities = capabilities,
|
||||
--require("lspconfig")["tsserver"].setup({
|
||||
-- capabilities = capabilities,
|
||||
--on_attach = on_attach,
|
||||
})
|
||||
--})
|
||||
|
||||
require("lspconfig")["texlab"].setup({
|
||||
capabilities = capabilities,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ local null_ls = require("null-ls")
|
|||
|
||||
require("mason-null-ls").setup({
|
||||
ensure_installed = {
|
||||
"prettier",
|
||||
"prettierd",
|
||||
"clang_format",
|
||||
"latexindent",
|
||||
"shellharden",
|
||||
|
|
@ -22,7 +22,11 @@ null_ls.setup({
|
|||
end
|
||||
end,
|
||||
sources = {
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
require("null-ls").builtins.formatting.prettierd.with({
|
||||
env = {
|
||||
PRETTIERD_DEFAULT_CONFIG = vim.fn.expand("~/.config/nvim/lua/settings/.prettierrc"),
|
||||
},}
|
||||
),
|
||||
require("null-ls").builtins.formatting.clang_format,
|
||||
require("null-ls").builtins.formatting.latexindent,
|
||||
require("null-ls").builtins.formatting.shellharden,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ nvim_tree.setup { -- BEGIN_DEFAULT_OPTS
|
|||
centralize_selection = false,
|
||||
width = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
side = "right",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ local options = {
|
|||
mouse = "a",
|
||||
fileencoding = "utf-8",
|
||||
relativenumber = true,
|
||||
number = true,
|
||||
smartindent = true,
|
||||
smartcase = true,
|
||||
showmode = true,
|
||||
|
|
@ -10,7 +11,7 @@ local options = {
|
|||
-- winbar = "",
|
||||
ignorecase = true,
|
||||
showtabline = 2,
|
||||
timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||
timeoutlen = 200, -- time to wait for a mapped sequence to complete (in milliseconds)
|
||||
undofile = true, -- enable persistent undoi updatetime = 300, -- faster completion (4000ms default)
|
||||
writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited
|
||||
expandtab = true, -- convert tabs to spaces
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Plug("feline-nvim/feline.nvim")
|
|||
Plug("lewis6991/gitsigns.nvim")
|
||||
Plug("tanvirtin/vgit.nvim")
|
||||
Plug("nvim-lua/plenary.nvim")
|
||||
Plug("b3nj5m1n/kommentary")
|
||||
Plug("antoinemadec/FixCursorHold.nvim")
|
||||
Plug("lambdalisue/fern.vim")
|
||||
Plug("williamboman/mason.nvim")
|
||||
|
|
@ -51,4 +50,6 @@ Plug("p00f/nvim-ts-rainbow")
|
|||
Plug("nvim-telescope/telescope-ui-select.nvim")
|
||||
Plug("nvim-telescope/telescope-file-browser.nvim")
|
||||
Plug("nvim-telescope/telescope-fzy-native.nvim")
|
||||
Plug 'folke/trouble.nvim'
|
||||
vim.call("plug#end")
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ end
|
|||
|
||||
require("nvim-treesitter.configs").setup({
|
||||
-- A list of parser names, or "all"
|
||||
ensure_installed = { "latex", "c", "cpp", "rust", "lua", "haskell", "java", "javascript", "typescript" },
|
||||
ensure_installed = { "latex", "c", "cpp", "rust", "lua", "haskell", "java", "javascript", "typescript", "python", "html", "css",
|
||||
"yaml", "bash", "json", "c_sharp"},
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
|
|
|
|||
55
nvim/snippets/.texsnippetsold
Normal file
55
nvim/snippets/.texsnippetsold
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
snippet mini \minipg{}{}[]
|
||||
\\minipg{
|
||||
$1
|
||||
}
|
||||
{${2}}[${3}]
|
||||
|
||||
snippet graphics \includegraphics[]{}
|
||||
\\includegraphics[scale=$1]{${2}}
|
||||
|
||||
snippet code "code"
|
||||
\\begin{lstlisting}
|
||||
$1
|
||||
\\end{lstlisting}
|
||||
|
||||
snippet list "list"
|
||||
\\begin{itemize}
|
||||
\\item \\textcolor{${1}}{${2}}
|
||||
\\item \\textcolor{${1}}{${3}}
|
||||
\\item \\textcolor{${1}}{${4}}
|
||||
\\item \\textcolor{${1}}{${5}}
|
||||
\\vspace{-3mm}
|
||||
\\end{itemize}
|
||||
|
||||
snippet enum "enumerate"
|
||||
\\begin{enumerate}
|
||||
\\item \textcolor{${1}}{${2}}
|
||||
\\item \textcolor{${1}}{${3}}
|
||||
\\item \textcolor{${1}}{${4}}
|
||||
\\item \textcolor{${1}}{${5}}
|
||||
\\vspace{-3mm}
|
||||
\\end{enumerate}
|
||||
|
||||
snippet table "table"
|
||||
\\begin{table}[ht!]
|
||||
\\section{${1}}
|
||||
\\begin{tabular}{|m{0.2\linewidth}|m{0.755\linewidth}|}
|
||||
\hline
|
||||
$2
|
||||
\hline
|
||||
\\end{tabular}
|
||||
\\end{table}
|
||||
|
||||
snippet tabular "tabular"
|
||||
\\begin{tabular}{|m{0.2\linewidth}|m{0.755\linewidth}|}
|
||||
\hline
|
||||
$1
|
||||
\hline
|
||||
\\end{tabular}
|
||||
|
||||
snippet tx "textcolor"
|
||||
\\textcolor{${1}}{${2}}
|
||||
|
||||
snippet bm "vectormatrix"
|
||||
\\begin{bmatrix} $1 \\ $2 \\ $3 \end{bmatrix}
|
||||
184
nvim/snippets/tex.lua
Normal file
184
nvim/snippets/tex.lua
Normal file
|
|
@ -0,0 +1,184 @@
|
|||
local ls = require("luasnip")
|
||||
-- some shorthands...
|
||||
local s = ls.s
|
||||
local i = ls.i
|
||||
local t = ls.t
|
||||
local d = ls.dynamic_node
|
||||
local c = ls.choice_node
|
||||
local f = ls.function_node
|
||||
local sn = ls.snippet_node
|
||||
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local rep = require("luasnip.extras").rep
|
||||
|
||||
local snippets, autosnippets = {}, {}
|
||||
local group = vim.api.nvim_create_augroup("Tex Snippets", { clear = true })
|
||||
local file_pattern = "*.tex"
|
||||
------------------------------------------------- boilerplate end
|
||||
-- snippers go here:
|
||||
|
||||
local listSnippet = s(
|
||||
"list-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{itemize}}
|
||||
\item \textcolor{{{1}}}{{{5}}}
|
||||
\item \textcolor{{{2}}}{{{6}}}
|
||||
\item \textcolor{{{3}}}{{{7}}}
|
||||
\item \textcolor{{{4}}}{{{8}}}
|
||||
\vspace{{2mm}}
|
||||
\end{{itemize}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
i(2, "item 2"),
|
||||
i(3, "item 1"),
|
||||
i(4, "item 3"),
|
||||
i(5, "item 4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, listSnippet)
|
||||
|
||||
local enumerateSnippet = s(
|
||||
"enum-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{enumerate}}
|
||||
\item \textcolor{{{1}}}{{{5}}}
|
||||
\item \textcolor{{{2}}}{{{6}}}
|
||||
\item \textcolor{{{3}}}{{{7}}}
|
||||
\item \textcolor{{{4}}}{{{8}}}
|
||||
\vspace{{2mm}}
|
||||
\end{{enumerate}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
rep(1),
|
||||
rep(1),
|
||||
rep(1),
|
||||
i(2, "item 2"),
|
||||
i(3, "item 1"),
|
||||
i(4, "item 3"),
|
||||
i(5, "item 4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, enumerateSnippet)
|
||||
|
||||
local tableSnippet = s(
|
||||
"table-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{table}}[ht!]
|
||||
\section{{{}}}
|
||||
\begin{{tabular}}{{|m{{0.2\linewidth}}|m{{0.755\linewidth}}|}}
|
||||
\hline
|
||||
{}
|
||||
\hline
|
||||
\end{{tabular}}
|
||||
\end{{table}}
|
||||
]],
|
||||
{
|
||||
i(1, "Section Name"),
|
||||
i(2, "data....."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, tableSnippet)
|
||||
|
||||
local tabularSnippet = s(
|
||||
"tabular-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{tabular}}{{|m{{0.2\linewidth}}|m{{0.755\linewidth}}|}}
|
||||
\hline
|
||||
{}
|
||||
\hline
|
||||
\end{{tabular}}
|
||||
]],
|
||||
{
|
||||
i(1, "data....."),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
local textcolorSnippet = s(
|
||||
"tx-",
|
||||
fmt(
|
||||
[[
|
||||
\textcolor{{{1}}}{{{2}}}
|
||||
]],
|
||||
{
|
||||
i(1, "color"),
|
||||
i(2, "text...")
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, textcolorSnippet)
|
||||
|
||||
local boldSnippet = s(
|
||||
"bold-",
|
||||
fmt(
|
||||
[[
|
||||
\textbf{{{1}}}
|
||||
]],
|
||||
{
|
||||
i(1, "text..."),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, boldSnippet)
|
||||
|
||||
local minipgSnippet = s(
|
||||
"mini-",
|
||||
fmt(
|
||||
[[
|
||||
\minipg{{
|
||||
{1}
|
||||
}}{{{2}}}[{3}]
|
||||
]],
|
||||
{
|
||||
i(1, "data..."),
|
||||
rep(1),
|
||||
i(2, "0.4,0.4"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, minipgSnippet)
|
||||
|
||||
local graphicSnippet = s(
|
||||
"graph-",
|
||||
fmt(
|
||||
[[
|
||||
\includegraphics[scale={1}]{{{2}}}
|
||||
]],
|
||||
{
|
||||
i(1, "0.4"),
|
||||
i(2, "something.png"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, graphicSnippet)
|
||||
|
||||
local lstSnippet = s(
|
||||
"lst-",
|
||||
fmt(
|
||||
[[
|
||||
\begin{{lstlisting}}
|
||||
{}
|
||||
\end{{lstlisting}}
|
||||
]],
|
||||
{
|
||||
i(1, "data"),
|
||||
}
|
||||
)
|
||||
)
|
||||
table.insert(snippets, lstSnippet)
|
||||
|
||||
|
||||
------------------------------------------------- snippets end
|
||||
return snippets, autosnippets
|
||||
Loading…
Add table
Add a link
Reference in a new issue