diff options
Diffstat (limited to '.config')
| -rw-r--r-- | .config/nvim/.editorconfig | 38 | ||||
| -rw-r--r-- | .config/nvim/README.md | 4 | ||||
| -rw-r--r-- | .config/nvim/autoload/utils.vim | 4 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 345 | ||||
| -rw-r--r-- | .config/nvim/lua/plugins/toggleterm.lua | 64 | ||||
| -rw-r--r-- | .config/nvim/lua/user/keys.lua | 129 |
6 files changed, 386 insertions, 198 deletions
diff --git a/.config/nvim/.editorconfig b/.config/nvim/.editorconfig new file mode 100644 index 0000000..86067d4 --- /dev/null +++ b/.config/nvim/.editorconfig @@ -0,0 +1,38 @@ +root = true + +[**] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 +charset = utf-8 + +# TypeScript/JavaScript config +[**.{ts,js}] +indent_size = 2 + +# Json config +[**.json] +indent_size = 2 + +# Lua config +[**.lua] +indent_size = 2 + +# Latex config +[**.tex] +trim_trailing_whitespace = false + +# Markdown config +[**.md] +trim_trailing_whitespace = false + +# Textfile config +[**.txt] +trim_trailing_whitespace = false +insert_final_newline = false + +# Snippets config +[**.snippets] +indent_style = tab diff --git a/.config/nvim/README.md b/.config/nvim/README.md index 78fee36..a841b13 100644 --- a/.config/nvim/README.md +++ b/.config/nvim/README.md @@ -1,4 +1,8 @@ ## Neovim +#### Dependencies +nvm +nvm install --lts + #### TODOS: - [ ] Markdown filetype plugin or autocommand to add two spaces each line diff --git a/.config/nvim/autoload/utils.vim b/.config/nvim/autoload/utils.vim index f1270bf..d244e90 100644 --- a/.config/nvim/autoload/utils.vim +++ b/.config/nvim/autoload/utils.vim @@ -117,8 +117,8 @@ endfunction "------------------------------------------------- -" Toggle Verbose -function! utils#ToggleVerbose() +" Verbose Toggle +function! utils#VerboseToggle() if !&verbose set verbosefile=~/.config/nvim/verbose.log set verbose=15 diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index ba577bc..b875182 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua @@ -1,7 +1,14 @@ -require('mason').setup() -local lspconfig = require('lspconfig') -local mason_lspconfig = require('mason-lspconfig') -local null_ls = require('null-ls') +--local mason = require('mason') +require("mason").setup() +require("mason-null-ls").setup({ + handlers = {}, + ensure_installed = nil, + automatic_installation = true, + automatic_setup = true, +}) +local lspconfig = require("lspconfig") +local mason_lspconfig = require("mason-lspconfig") +local null_ls = require("null-ls") --local lsp_lines = require('lsp_lines') local keymap = vim.keymap @@ -18,7 +25,6 @@ local border = { { "│", "FloatBorder" }, } - local signs = { Error = " ", Warn = "▲", Info = "", Hint = "⚑" } for type, icon in pairs(signs) do local hl = "DiagnosticSign" .. type @@ -45,13 +51,13 @@ vim.diagnostic.config({ virtual_lines = false, float = { show_header = true, - source = 'if_many', + source = "if_many", --border = 'rounded', border = border, focusable = true, }, - update_in_insert = false, -- default to false - severity_sort = false, -- default to false + update_in_insert = false, -- default to false + severity_sort = false, -- default to false }) vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { @@ -67,7 +73,7 @@ vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.s -- Use an on_attach function to only map the following keys after the language server attaches to the current buffer local on_attach = function(client, bufnr) -- Enable completion triggered by <c-x><c-o> - vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") local map = function(mode, l, r, opts) opts = opts or {} opts.silent = true @@ -91,8 +97,11 @@ local on_attach = function(client, bufnr) map("n", "ga", "<Cmd>lua vim.lsp.buf.code_action()<CR>") map("n", "gf", "<Cmd>lua vim.lsp.buf.formatting()<CR>") map("n", "go", "<Cmd>lua vim.diagnostic.open_float()<CR>") - map("n", "<leader>go", - ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>") + map( + "n", + "<leader>go", + ":call utils#ToggleDiagnosticsOpenFloat()<CR> | :echom ('Toggle Diagnostics Float open/close...')<CR> | :sl! | echo ('')<CR>" + ) map("n", "[d", "<Cmd>lua vim.diagnostic.goto_prev()<CR>") map("n", "]d", "<Cmd>lua vim.diagnostic.goto_next()<CR>") map("n", "gs", "<Cmd>lua vim.lsp.buf.document_symbol()<CR>") @@ -104,12 +113,12 @@ local on_attach = function(client, bufnr) end) -- TODO: Use the nicer new API for autocommands - cmd 'augroup lsp_aucmds' + cmd("augroup lsp_aucmds") if client.server_capabilities.documentHighlightProvider then - cmd 'au CursorHold <buffer> lua vim.lsp.buf.document_highlight()' - cmd 'au CursorMoved <buffer> lua vim.lsp.buf.clear_references()' + cmd("au CursorHold <buffer> lua vim.lsp.buf.document_highlight()") + cmd("au CursorMoved <buffer> lua vim.lsp.buf.clear_references()") end - cmd 'augroup END' + cmd("augroup END") end -- Toggle diagnostics visibility @@ -141,8 +150,8 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.offsetEncoding = { "utf-16" } local function prefer_null_ls_fmt(client) - client.server_capabilities.documentHighlightProvider = false - client.server_capabilities.documentFormattingProvider = false + client.server_capabilities.documentHighlightProvider = true + client.server_capabilities.documentFormattingProvider = true on_attach(client) end @@ -151,35 +160,42 @@ local servers = { bashls = {}, clangd = {}, cssls = { - filetypes = { 'css', 'scss', 'less', 'sass' }, - root_dir = lspconfig.util.root_pattern('package.json', '.git'), + filetypes = { "css", "scss", "less", "sass" }, + root_dir = lspconfig.util.root_pattern("package.json", ".git"), }, -- ghcide = {}, html = {}, - jsonls = { prefer_null_ls = true, cmd = { '--stdio' } }, + jsonls = { prefer_null_ls = true, cmd = { "--stdio" } }, intelephense = {}, julials = { on_new_config = function(new_config, _) - local julia = vim.fn.expand '~/.julia/environments/nvim-lspconfig/bin/julia' + local julia = vim.fn.expand("~/.julia/environments/nvim-lspconfig/bin/julia") if lspconfig.util.path.is_file(julia) then new_config.cmd[1] = julia end end, settings = { julia = { format = { indent = 2 } } }, }, - pyright = { settings = { python = { formatting = { provider = 'yapf' }, linting = { pytypeEnabled = true } } } }, + pyright = { + settings = { + python = { + formatting = { provider = "yapf" }, + linting = { pytypeEnabled = true }, + }, + }, + }, rust_analyzer = { settings = { - ['rust-analyzer'] = { + ["rust-analyzer"] = { cargo = { allFeatures = true }, checkOnSave = { - command = 'clippy', - extraArgs = { '--no-deps' }, + command = "clippy", + extraArgs = { "--no-deps" }, }, }, }, }, - dartls = ({ + dartls = { cmd = { "dart", "language-server", "--protocol=lsp" }, filetypes = { "dart" }, init_options = { @@ -196,10 +212,9 @@ local servers = { showTodos = true, }, }, - on_attach = function(client, bufnr) - end, - }), - lua_ls = ({ + on_attach = function(client, bufnr) end, + }, + lua_ls = { on_attach = on_attach, capabilities = capabilities, debounce_text_changes = 500, @@ -207,7 +222,7 @@ local servers = { Lua = { runtime = { version = "LuaJIT", - path = vim.split(package.path, ';'), + path = vim.split(package.path, ";"), }, diagnostics = { enable = true, @@ -220,7 +235,7 @@ local servers = { }, }, }, - }), + }, sqlls = {}, tsserver = { capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), @@ -229,12 +244,12 @@ local servers = { client.server_capabilities.document_range_formatting = false end, filetypes = { - 'javascript', - 'javascriptreact', - 'javascript.jsx', - 'typescript', - 'typescriptreact', - 'typescript.tsx' + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", }, }, vimls = {}, @@ -246,18 +261,30 @@ mason_lspconfig.setup({ automatic_installation = true, }) --- Linters/Formatters ensure installed -local registry = require("mason-registry") -for _, pkg_name in ipairs { "dart-debug-Adaptor", "stylua", "prettier", "prettierd" } do - local ok, pkg = pcall(registry.get_package, pkg_name) - if ok then - if not pkg:is_installed() then - pkg:install() - end - end -end +-- Your other configurations ... +--require("lspconfig").dartls.setup({ capabilities = capabilities }) +--local installed_lsp = mason_lspconfig.ensure_installed +--local mason_lspconfig = require("mason-lspconfig").ensure_installed -require("lspconfig").dartls.setup {capabilities = capabilities,} +--require("lspconfig").setup({ +-- function() +-- for _, lsp in ipairs(installed_lsp) do +-- if +-- lsp ~= "sqls" +-- --and lsp ~= "sumneko_lua" +-- --and lsp ~= "stylelint_lsp" +-- --and lsp ~= "rust_analyzer" +-- --and lsp ~= "sourcekit" +-- and lsp ~= "dartls" +-- then +-- lspconfig[lsp].setup({ +-- on_attach = on_attach, +-- capabilities = capabilities, +-- }) +-- end +-- end +-- end, +--}) for server, config in pairs(servers) do if config.prefer_null_ls then @@ -277,7 +304,6 @@ for server, config in pairs(servers) do lspconfig[server].setup(config) end - -- null_ls setup local builtins = null_ls.builtins local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) @@ -290,80 +316,126 @@ local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) -- prefer_local = true, --} -null_ls.setup { - sources = { - -- Diagnostics - builtins.diagnostics.chktex, - --null_ls.builtins.code_actions.eslint_d, - --null_ls.builtins.diagnostics.eslint_d, - --null_ls.builtins.formatting.eslint_d, - -- null_ls.builtins.diagnostics.cppcheck, - -- null_ls.builtins.diagnostics.proselint, - -- null_ls.builtins.diagnostics.pylint, - --builtins.diagnostics.selene, - builtins.diagnostics.dotenv_linter, - builtins.diagnostics.shellcheck.with({ - -- shell script diagnostics - diagnostic_config = { - -- see :help vim.diagnostic.config() - underline = true, - virtual_text = false, - signs = true, - update_in_insert = false, - severity_sort = true, - }, - diagnostics_format = "[#{c}] #{m} (#{s})", - -- this will run every time the source runs, - -- so you should prefer caching results if possible - }), - builtins.diagnostics.zsh, - builtins.diagnostics.todo_comments, - builtins.diagnostics.teal, - -- null_ls.builtins.diagnostics.vale, - builtins.diagnostics.vint, - builtins.diagnostics.tidy, - builtins.diagnostics.php, - builtins.diagnostics.phpcs, - -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, +--null_ls.setup({ +local sources = { + -- Diagnostics + builtins.diagnostics.chktex, + --null_ls.builtins.code_actions.eslint_d, + --null_ls.builtins.diagnostics.eslint_d, + --null_ls.builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.cppcheck, + -- null_ls.builtins.diagnostics.proselint, + -- null_ls.builtins.diagnostics.pylint, + --builtins.diagnostics.selene, + builtins.diagnostics.dotenv_linter, + builtins.diagnostics.shellcheck.with({ + -- shell script diagnostics + diagnostic_config = { + -- see :help vim.diagnostic.config() + underline = true, + virtual_text = false, + signs = true, + update_in_insert = false, + severity_sort = true, + }, + diagnostics_format = "[#{c}] #{m} (#{s})", + -- this will run every time the source runs, + -- so you should prefer caching results if possible + }), + builtins.diagnostics.zsh.with({ + filetypes = "zsh", + "sh", + }), + builtins.diagnostics.todo_comments, + builtins.diagnostics.teal, + -- null_ls.builtins.diagnostics.vale, + builtins.diagnostics.vint, + builtins.diagnostics.tidy, + builtins.diagnostics.php, + builtins.diagnostics.phpcs, + builtins.diagnostics.flake8, + builtins.diagnostics.eslint_d.with({ + condition = function(utils) + return utils.root_has_file(".eslintrc.json") + end, + }), + builtins.formatting.eslint_d, + -- null_ls.builtins.diagnostics.write_good.with { filetypes = { 'markdown', 'tex' } }, - -- Formatting - builtins.formatting.shfmt.with({ - filetypes = { "bash", "zsh", "sh" }, - extra_args = { "-i", "2", "-ci" }, - }), - builtins.formatting.shellharden, - builtins.formatting.trim_whitespace.with { filetypes = { "tmux", "teal", "zsh" } }, - builtins.formatting.clang_format, - builtins.formatting.rustfmt, - builtins.formatting.sql_formatter, - -- null_ls.builtins.formatting.cmake_format, - builtins.formatting.isort, - builtins.formatting.htmlbeautifier, - -- null_ls.builtins.formatting.prettier, - builtins.formatting.prettierd, - builtins.formatting.prettier.with({ - filetypes = { "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "yaml", "markdown", "html", - "css", "scss", "less", "graphql", "vue", "svelte" }, - extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, - }), - builtins.formatting.rustfmt, - builtins.formatting.stylua, - builtins.formatting.dart_format, - builtins.formatting.trim_whitespace, - builtins.formatting.yapf, - -- null_ls.builtins.formatting.black + -- Formatting + builtins.formatting.shfmt.with({ + filetypes = { "bash", "zsh", "sh" }, + extra_args = { "-i", "2", "-ci" }, + }), + builtins.formatting.shellharden, + builtins.formatting.trim_whitespace.with({ + filetypes = { "tmux", "teal", "zsh" }, + }), + --builtins.formatting.beautysh, + builtins.formatting.beautysh.with({ + filetypes = "zsh", + }), + builtins.formatting.clang_format, + builtins.formatting.rustfmt, + builtins.formatting.sql_formatter, + -- null_ls.builtins.formatting.cmake_format, + builtins.formatting.isort, + builtins.formatting.htmlbeautifier, + -- null_ls.builtins.formatting.prettier, + builtins.formatting.prettierd, + builtins.formatting.prettier.with({ + filetypes = { + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "json", + "yaml", + "markdown", + "html", + "css", + "scss", + "less", + "graphql", + "vue", + "svelte", + }, + extra_args = { "--single-quote", "--tab-width 4", "--print-width 200" }, + }), + builtins.formatting.rustfmt, + builtins.formatting.stylua, + --builtins.formatting.dart_format, + builtins.formatting.dart_format.with({ + filetypes = { "dart" }, + }), + builtins.formatting.trim_whitespace, + builtins.formatting.yapf, + -- null_ls.builtins.formatting.black - -- Code Actions - builtins.code_actions.shellcheck, -- shell script code actions - --builtins.code_actions.eslint_d.with(eslint_opts), - -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, - builtins.code_actions.gitsigns, - builtins.code_actions.gitrebase, + -- Code Actions + builtins.code_actions.shellcheck, -- shell script code actions + --builtins.code_actions.eslint_d.with(eslint_opts), + -- null_ls.builtins.code_actions.refactoring.with { filetypes = { 'javascript', 'typescript', 'lua', 'python', 'c', 'cpp' } }, + builtins.code_actions.gitsigns, + builtins.code_actions.gitrebase, - -- Hover - builtins.hover.dictionary, - builtins.hover.printenv, - }, + -- Hover + builtins.hover.dictionary, + builtins.hover.printenv, +} +--}) +-- Linters/Formatters ensure installed +--for _, pkg_name in ipairs({ +-- "dart-debug-Adaptor", +-- "stylua", +-- "prettier", +-- "prettierd", +--}) do + +-- Import the builtins table from the null-ls module and store it in the null_ls_sources variable +null_ls.setup({ + sources = sources, + update_in_insert = true, on_attach = function(client, bufnr) if client.supports_method("textDocument/formatting") then vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) @@ -372,8 +444,35 @@ null_ls.setup { buffer = bufnr, callback = function() vim.lsp.buf.format() - end + end, }) end end, -} +}) + +-- Install all the null-ls sources using Mason +local registry = require("mason-registry") +for _, source_name in ipairs(sources) do + local ok, pkg = pcall(registry.get_package, source_name) + if ok then + if not pkg:is_installed() then + pkg:install() + end + end +end +-- Loop through the null_ls_sources table and install the packages +-- Install all sources for null-ls +--local null_ls_sources = require("null-ls").builtins + +--for _, source_name in ipairs(null_ls_sources) do +-- local ok, pkg = pcall(mason.get_package, source_name) +-- if ok then +-- if not pkg:is_installed() then +-- pkg:install() +-- end +-- end +--end +vim.api.nvim_create_user_command("NullLsToggle", function() + -- you can also create commands to disable or enable sources + require("null-ls").toggle({}) +end, {}) diff --git a/.config/nvim/lua/plugins/toggleterm.lua b/.config/nvim/lua/plugins/toggleterm.lua index 2146dc3..2f978a4 100644 --- a/.config/nvim/lua/plugins/toggleterm.lua +++ b/.config/nvim/lua/plugins/toggleterm.lua @@ -3,22 +3,15 @@ if not status_ok then return end toggleterm.setup({ - --size = function(term) - -- if term.direction == "horizontal" then - -- return 12 - -- elseif term.direction == "vertical" then - -- return vim.o.columns * 0.3 - -- end - --end, - --size = 20, - open_mapping = [[<leader>tt]], - --autochdir = true, + --open_mapping = [[<leader>tt]], + autochdir = true, hide_numbers = true, shade_filetypes = {}, - shade_terminals = false, + shade_terminals = true, shading_factor = 1, start_in_insert = true, insert_mappings = true, + terminal_mappings = true, persist_size = true, direction = "float", --direction = "vertical", @@ -28,21 +21,24 @@ toggleterm.setup({ highlights = { -- highlights which map to a highlight group name and a table of it's values -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split - Normal = { - background = "#000000", - }, + --Normal = { + -- background = "#000000", + --}, + Normal = { guibg = 'Black', guifg = 'DarkGray' }, + FloatBorder = { guibg = 'Black', guifg = 'DarkGray' }, + NormalFloat = { guibg = 'Black' }, --float_opts = { -- border = as.style.current.border, -- winblend = 3, --}, - size = function(term) - if term.direction == 'horizontal' then - return 15 - elseif term.direction == 'vertical' then - return math.floor(vim.o.columns * 0.4) - end - end, }, + size = function(term) + if term.direction == 'horizontal' then + return 7 + elseif term.direction == 'vertical' then + return math.floor(vim.o.columns * 0.4) + end + end, float_opts = { width = 70, height = 15, @@ -66,6 +62,7 @@ end function _G.set_terminal_keymaps() local opts = { noremap = true } --local opts = {buffer = 0} + --vim.api.nvim_buf_set_keymap(0, "i", ";to", "[[<Esc>]]<cmd>Toggleterm", opts) vim.api.nvim_buf_set_keymap(0, "t", "<C-c>", [[<Esc>]], opts) vim.api.nvim_buf_set_keymap(0, "t", "<esc>", [[<C-\><C-n>]], opts) vim.api.nvim_buf_set_keymap(0, "t", "jk", [[<C-\><C-n>]], opts) @@ -78,6 +75,17 @@ end -- if you only want these mappings for toggle term use term://*toggleterm#* instead vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') local Terminal = require("toggleterm.terminal").Terminal + +local horizontal_term = Terminal:new({ hidden = true, direction = "horizontal" }) +local vertical_term = Terminal:new({ hidden = true, direction = "vertical" }) + +function Horizontal_term_toggle() + horizontal_term:toggle(8, "horizontal") +end +function Vertical_term_toggle() + horizontal_term:toggle(math.floor(vim.o.columns * 0.5), "vertical") +end + local lazygit = Terminal:new({ cmd = "lazygit", count = 5, @@ -152,3 +160,17 @@ local python = Terminal:new({ cmd = "python", hidden = true }) function _PYTHON_TOGGLE() python:toggle() end + +function Gh_dash() +Terminal:new({ + cmd = 'gh dash', + hidden = true, + direction = 'float', + on_open = float_handler, + float_opts = { + height = function() return math.floor(vim.o.lines * 0.8) end, + width = function() return math.floor(vim.o.columns * 0.95) end, + }, +}) + Gh_dash:toggle() +end diff --git a/.config/nvim/lua/user/keys.lua b/.config/nvim/lua/user/keys.lua index 2ba14dd..36f7fbd 100644 --- a/.config/nvim/lua/user/keys.lua +++ b/.config/nvim/lua/user/keys.lua @@ -13,32 +13,33 @@ local term_opts = { noremap = true, silent = false } -- Semi-colon as leader key vim.g.mapleader = ";" +-- "jk" and "kj" to exit insert-mode +map("i", "jk", "<esc>") +map("i", "kj", "<esc>") + -- Jump to next match on line using `.` instead of `;` NOTE: commented out in favour of "ggandor/flit.nvim" --map("n", ".", ";") -- Repeat last command using `<Space>` instead of `.` NOTE: commented out in favour of "ggandor/flit.nvim" --map("n", "<Space>", ".") --- "jk" to exit insert-mode -map("i", "jk", "<esc>") - -- Reload nvim config -map("n", "<leader><CR>", - "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>") - +map( + "n", + "<leader><CR>", + "<cmd>luafile ~/.config/nvim/init.lua<CR> | :echom ('Nvim config loading...') | :sl! | echo ('')<CR>" +) --------------- Extended Operations --------------- -- Conditional 'q' to quit on floating/quickfix/help windows otherwise still use it for macros -- TODO: Have a list of if available on system/packages, example "Zen Mode" to not work on it (quit Zen Mode) -map('n', 'q', function() +map("n", "q", function() local config = vim.api.nvim_win_get_config(0) if config.relative ~= "" then -- is_floating_window? return ":silent! close!<CR>" - elseif - vim.o.buftype == 'quickfix' then + elseif vim.o.buftype == "quickfix" then return ":quit<CR>" - elseif - vim.o.buftype == 'help' then + elseif vim.o.buftype == "help" then return ":close<CR>" else return "q" @@ -107,10 +108,10 @@ map("i", "<A-k>", "<up>") map("i", "<A-l>", "<right>") -- Map Alt+(h/j/k/l) in command mode to move directional -vim.api.nvim_set_keymap('c', '<A-h>', '<Left>', { noremap = true }) -vim.api.nvim_set_keymap('c', '<A-j>', '<Down>', { noremap = true }) -vim.api.nvim_set_keymap('c', '<A-k>', '<Up>', { noremap = true }) -vim.api.nvim_set_keymap('c', '<A-l>', '<Right>', { noremap = true }) +vim.api.nvim_set_keymap("c", "<A-h>", "<Left>", { noremap = true }) +vim.api.nvim_set_keymap("c", "<A-j>", "<Down>", { noremap = true }) +vim.api.nvim_set_keymap("c", "<A-k>", "<Up>", { noremap = true }) +vim.api.nvim_set_keymap("c", "<A-l>", "<Right>", { noremap = true }) -- Create tab, edit and move between them map("n", "<C-T>n", ":tabnew<CR>") @@ -158,7 +159,7 @@ map("v", "<leader>sr", 'y:%s/<C-r><C-r>"//g<Left><Left>c') map("n", "<leader>td", "<Cmd>call utils#ToggleDiff()<CR>") -- Toggle Verbose -map("n", "<leader>tv", "<Cmd>call utils#ToggleVerbose()<CR>") +map("n", "<leader>vt", "<Cmd>call utils#VerboseToggle()<CR>") -- Jump List map("n", "<leader>j", "<Cmd>call utils#GotoJump()<CR>") @@ -170,8 +171,11 @@ map("i", "<C-l>", "<Del>") map("n", "<leader><C-l>", "<Cmd>!clear<CR>") -- Change file to an executable -map("n", "<Leader>x", - ":lua require('user.mods').Toggle_executable()<CR> | :echom ('Toggle executable')<CR> | :sl! | echo ('')<CR>") +map( + "n", + "<Leader>x", + ":lua require('user.mods').Toggle_executable()<CR> | :echom ('Toggle executable')<CR> | :sl! | echo ('')<CR>" +) --map("n", "<leader>x", ":!chmod +x %<CR>") -- Paste without replace clipboard @@ -185,7 +189,7 @@ map("v", "p", '"_dP') map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>") -- Open the current file in the default program (on Mac this should just be just `open`) -map('n', '<leader>o', ':!xdg-open %<cr><cr>') +map("n", "<leader>o", ":!xdg-open %<cr><cr>") -- URL handling if vim.fn.has("mac") == 1 then @@ -195,7 +199,7 @@ elseif vim.fn.has("unix") == 1 then elseif vim.fn.has("wsl") == 1 then map("", "gx", '<Cmd>call jobstart(["wslview", expand("<cfile>")], {"detach": v:true})<CR>', {}) else - map[''].gx = { '<Cmd>lua print("Error: gx is not supported on this OS!")<CR>' } + map[""].gx = { '<Cmd>lua print("Error: gx is not supported on this OS!")<CR>' } end -- Substitute globally and locally in the selected region. @@ -206,8 +210,8 @@ map("v", "ss", ":s//g<Left><Left>") map("n", "<Leader>tc", ":lua require('user.mods').toggle_completion()<CR>") -- Disable default completion. -map('i', '<C-n>', '<Nop>') -map('i', '<C-p>', '<Nop>') +map("i", "<C-n>", "<Nop>") +map("i", "<C-p>", "<Nop>") -- Set line wrap map("n", "<M-z>", function() @@ -232,21 +236,21 @@ map("n", "<Space>", "za") --vim.cmd([[ -- map <leader>s :up \| saveas! %:p:r-<C-R>=strftime("%y.%m.%d-%H:%M")<CR>-bak.<C-R>=expand("%:e")<CR> \| 3sleep \| e #<CR> --]]) +map("n", "<leader>.b", ":!cp % %.backup<CR>") -- Toggle transparency -map('n', '<leader>tb', ':call utils#Toggle_transparent_background()<CR>') +map("n", "<leader>tb", ":call utils#Toggle_transparent_background()<CR>") -- Toggle zoom map("n", "<leader>z", ":call utils#ZoomToggle()<CR>") map("n", "<C-w>z", "<C-w>|<C-w>_") -- Toggle statusline -map('n', '<S-h>', ':call ToggleHiddenAll()<CR>') +map("n", "<S-h>", ":call ToggleHiddenAll()<CR>") -- Open last closed buffer map("n", "<C-t>", ":call OpenLastClosed()<CR>") - ---------------- Plugin Operations ---------------- -- Packer map("n", "<leader>Pc", "<cmd>PackerCompile<cr>") @@ -256,17 +260,31 @@ map("n", "<leader>PS", "<cmd>PackerStatus<cr>") map("n", "<leader>Pu", "<cmd>PackerUpdate<cr>") -- Tmux navigation (aserowy/tmux.nvim) -map('n', '<C-h>', '<CMD>NavigatorLeft<CR>') -map('n', '<C-l>', '<CMD>NavigatorRight<CR>') -map('n', '<C-k>', '<CMD>NavigatorUp<CR>') -map('n', '<C-j>', '<CMD>NavigatorDown<CR>') +map("n", "<C-h>", "<CMD>NavigatorLeft<CR>") +map("n", "<C-l>", "<CMD>NavigatorRight<CR>") +map("n", "<C-k>", "<CMD>NavigatorUp<CR>") +map("n", "<C-j>", "<CMD>NavigatorDown<CR>") -- ToggleTerm ---map("n", "<leader>tt", "<cmd>ToggleTerm<cr>") +map({ "n", "t" }, "<leader>tt", "<cmd>ToggleTerm<CR>") +map({ "n", "t" }, "<leader>th", "<cmd>lua Horizontal_term_toggle()<CR>") +map({ "n", "t" }, "<leader>tv", "<cmd>lua Vertical_term_toggle()<CR>") +-- map["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" } +-- map["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } +-- map["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } +-- map["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } +-- map["<leader>tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } +-- map["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } +-- map["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" } +-- map["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" } +-- map["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" } +--end -- LazyGit map({ "n", "t" }, "<leader>gg", "<cmd>lua Lazygit_toggle()<CR>") +map("n", "<leader>tg", "<cmd>lua Gh_dash()<CR>") + -- Fugitive git bindings map("n", "<leader>gs", vim.cmd.Git) map("n", "<leader>ga", ":Git add %:p<CR><CR>") @@ -286,19 +304,11 @@ map("n", "<leader>gm", ":Gmove<Space>") --map("n", "<leader>go", ":Git checkout<Space>") --map("n", "<leader>gps", ":Dispatch! git push<CR>") --map("n", "<leader>gpl", ":Dispatch! git pull<CR>") --- map["<C-\\>"] = { "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" } --- map["<leader>tn"] = { function() toggle_term_cmd "node" end, desc = "ToggleTerm node" } --- map["<leader>tu"] = { function() toggle_term_cmd "ncdu" end, desc = "ToggleTerm NCDU" } --- map["<leader>tt"] = { function() toggle_term_cmd "htop" end, desc = "ToggleTerm htop" } --- map["<leader>tp"] = { function() toggle_term_cmd "python" end, desc = "ToggleTerm python" } --- map["<leader>tl"] = { function() toggle_term_cmd "lazygit" end, desc = "ToggleTerm lazygit" } --- map["<leader>tf"] = { "<cmd>ToggleTerm direction=float<cr>", desc = "ToggleTerm float" } --- map["<leader>th"] = { "<cmd>ToggleTerm size=10 direction=horizontal<cr>", desc = "ToggleTerm horizontal split" } --- map["<leader>tv"] = { "<cmd>ToggleTerm size=80 direction=vertical<cr>", desc = "ToggleTerm vertical split" } ---end -- Telescope -map("n", "<leader>ff", function() require("telescope.builtin").find_files { hidden = true, no_ignore = false } end) -- find all files +map("n", "<leader>ff", function() + require("telescope.builtin").find_files({ hidden = true, no_ignore = false }) +end) -- find all files --map("n", "<leader>fF", "<cmd>lua require('telescope.builtin').find_files()<cr>") -- find files with hidden option map("n", "<leader>fg", "<cmd>lua require('telescope.builtin').live_grep()<cr>") map("n", "<leader>fb", "<cmd>lua require('telescope.builtin').buffers()<cr>") @@ -318,8 +328,12 @@ map("n", "<leader>fw", [[<Cmd>lua require'plugins.telescope'.find_projects()<CR> map("n", "<leader>fm", "<cmd>lua require('telescope').extensions.media_files.media_files({})<cr>") -- find media files map("n", "<leader>fi", "<cmd>lua require('telescope').extensions.notify.notify({})<cr>") -- find notifications --map("n", "<leader>f/", "<cmd>lua require('plugins.telescope').curbuf()<cr>") -- find files with hidden option -map("n", "<leader>fF", ":cd %:p:h<CR>:pwd<CR><cmd>lua require('user.mods').findFilesInCwd()<CR>", - { noremap = true, silent = true, desc = "Find files in cwd" }) +map( + "n", + "<leader>fF", + ":cd %:p:h<CR>:pwd<CR><cmd>lua require('user.mods').findFilesInCwd()<CR>", + { noremap = true, silent = true, desc = "Find files in cwd" } +) -- FZF map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>") @@ -328,7 +342,7 @@ map("n", "<leader>fz", "<cmd>lua require('fzf-lua').files()<CR>") map("n", "<leader>f", ":NvimTreeToggle<CR>", {}) -- Undotree -map('n', '<leader>u', vim.cmd.UndotreeToggle) +map("n", "<leader>u", vim.cmd.UndotreeToggle) -- Markdown-preview map("n", "<leader>md", "<Plug>MarkdownPreviewToggle") @@ -341,7 +355,12 @@ map("n", "<leader>ww", "<cmd>lua require('user.mods').Toggle_autopairs()<CR>") map("n", "<leader>zm", "<CMD>ZenMode<CR> | :echom ('Zen Mode')<CR> | :sl! | echo ('')<CR>") -- Vim-rooter -map("n", "<leader>ro", "<CMD>Rooter<CR> | :echom ('cd to root/project directory')<CR> | :sl! | echo ('')<CR>", term_opts) +map( + "n", + "<leader>ro", + "<CMD>Rooter<CR> | :echom ('cd to root/project directory')<CR> | :sl! | echo ('')<CR>", + term_opts +) -- Trouble (UI to show diagnostics) map("n", "<leader>t", "<CMD>TroubleToggle<CR>") @@ -351,15 +370,18 @@ map("n", "<leader>tq", "<CMD>TroubleToggle quickfix<CR>") map("n", "<leader>tl", "<CMD>TroubleToggle loclist<CR>") map("n", "gR", "<CMD>TroubleToggle lsp_references<CR>") +-- Null-ls +map("n", "<leader>ls", "<CMD>NullLsToggle<CR>") + -- Replacer -map('n', '<Leader>qr', ':lua require("replacer").run()<CR>') +map("n", "<Leader>qr", ':lua require("replacer").run()<CR>') -- Quickfix map("n", "<leader>q", function() if vim.fn.getqflist({ winid = 0 }).winid ~= 0 then - require('plugins.quickfix').close() + require("plugins.quickfix").close() else - require('plugins.quickfix').open() + require("plugins.quickfix").open() --require("quickfix").open() end end, { desc = "Toggle quickfix window" }) @@ -373,7 +395,7 @@ if not (dap_ok and dap_ui_ok) then return end -vim.fn.sign_define('DapBreakpoint', { text = '🐞' }) +vim.fn.sign_define("DapBreakpoint", { text = "🐞" }) -- Start debugging session map("n", "<leader>ds", function() @@ -387,7 +409,9 @@ map("n", "<leader>dC", dap.continue) --map("n", "<leader>dC", dap.close) --map("n", "<leader>dt", dap.terminate) map("n", "<leader>dt", ui.toggle) -map("n", "<leader>dd", function() dap.disconnect({ terminateDebuggee = true }) end) +map("n", "<leader>dd", function() + dap.disconnect({ terminateDebuggee = true }) +end) map("n", "<leader>dn", dap.step_over) map("n", "<leader>di", dap.step_into) map("n", "<leader>do", dap.step_out) @@ -397,8 +421,9 @@ map("n", "<leader>dB", function() require("notify")("Breakpoints cleared", "warn") end) map("n", "<leader>dl", require("dap.ui.widgets").hover) -map("n", "<leader>de", function() require("dapui").float_element() end, - { desc = "Open Element" }) +map("n", "<leader>de", function() + require("dapui").float_element() +end, { desc = "Open Element" }) map("n", "<leader>dq", function() require("dapui").close() require("dap").repl.close() |
