diff --git a/.gitignore b/.gitignore index 9c1632e..da98ded 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.json packer_compiled.lua +lua/config/ diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua deleted file mode 100644 index c2ad48d..0000000 --- a/after/ftplugin/markdown.lua +++ /dev/null @@ -1,20 +0,0 @@ -require("nvim-surround").buffer_setup({ - surrounds = { - ["e"] = { - add = function() - local env = require("nvim-surround.config").get_input ("Environment: ") - return { { "\\begin{" .. env .. "}" }, { "\\end{" .. env .. "}" } } - end, - }, - ["b"] = { - add = { "**", "**" }, - find = "**.-**", - delete = "^(**)().-(**)()$", - }, - ["i"] = { - add = { "*", "*" }, - find = "*.-*", - delete = "^(*)().-(*)()$", - }, - }, -}) diff --git a/after/ftplugin/tex.lua b/after/ftplugin/tex.lua deleted file mode 100644 index 77de062..0000000 --- a/after/ftplugin/tex.lua +++ /dev/null @@ -1,107 +0,0 @@ -local config = require("nvim-surround.config") - -require("nvim-surround").buffer_setup({ - surrounds = { - -- ["e"] = { - -- add = function() - -- local env = require("nvim-surround.config").get_input ("Environment: ") - -- return { { "\\begin{" .. env .. "}" }, { "\\end{" .. env .. "}" } } - -- end, - -- }, - ["Q"] = { - add = { "``", "''" }, - find = "%b``.-''", - delete = "^(``)().-('')()$", - }, - ["q"] = { - add = { "`", "'" }, - find = "`.-'", - delete = "^(`)().-(')()$", - }, - ["b"] = { - add = { "\\textbf{", "}" }, - -- add = function() - -- if vim.fn["vimtex#syntax#in_mathzone"]() == 1 then - -- return { { "\\mathbf{" }, { "}" } } - -- end - -- return { { "\\textbf{" }, { "}" } } - -- end, - find = "\\%a-bf%b{}", - delete = "^(\\%a-bf{)().-(})()$", - }, - ["i"] = { - add = { "\\textit{", "}" }, - -- add = function() - -- if vim.fn["vimtex#syntax#in_mathzone"]() == 1 then - -- return { { "\\mathit{" }, { "}" } } - -- end - -- return { { "\\textit{" }, { "}" } } - -- end, - find = "\\%a-it%b{}", - delete = "^(\\%a-it{)().-(})()$", - }, - ["s"] = { - add = { "\\textsc{", "}" }, - find = "\\textsc%b{}", - delete = "^(\\textsc{)().-(})()$", - }, - ["t"] = { - add = { "\\texttt{", "}" }, - -- add = function() - -- if vim.fn["vimtex#syntax#in_mathzone"]() == 1 then - -- return { { "\\mathtt{" }, { "}" } } - -- end - -- return { { "\\texttt{" }, { "}" } } - -- end, - find = "\\%a-tt%b{}", - delete = "^(\\%a-tt{)().-(})()$", - }, - ["$"] = { - add = { "$", "$" }, - -- find = "%b$.-$", - -- delete = "^($)().-($)()$", - }, - }, -}) - --- PdfAnnots -function PdfAnnots() - local ok, pdf = pcall(vim.api.nvim_eval, - "vimtex#context#get().handler.get_actions().entry.file") - if not ok then - vim.notify "No file found" - return - end - - local cwd = vim.fn.getcwd() - vim.fn.chdir(vim.b.vimtex.root) - - if vim.fn.isdirectory('Annotations') == 0 then - vim.fn.mkdir('Annotations') - end - - local md = vim.fn.printf("Annotations/%s.md", vim.fn.fnamemodify(pdf, ":t:r")) - vim.fn.system(vim.fn.printf('pdfannots -o "%s" "%s"', md, pdf)) - vim.cmd.split(vim.fn.fnameescape(md)) - - vim.fn.chdir(cwd) -end - --- -- LSP menu to preserve vimtex citation data --- require('cmp').setup.buffer { --- formatting = { --- format = function(entry, vim_item) --- vim_item.menu = ({ --- omni = (vim.inspect(vim_item.menu):gsub('%"', "")), --- buffer = "[Buffer]", --- -- formatting for other sources --- })[entry.source.name] --- return vim_item --- end, --- }, --- sources = { --- { name = 'omni' }, --- { name = 'buffer' }, --- -- other sources --- }, --- } diff --git a/init.lua b/init.lua old mode 100644 new mode 100755 index e8aa528..491b2aa --- a/init.lua +++ b/init.lua @@ -1,60 +1,14 @@ --- GENERAL -require "user.options" -require "user.keymaps" -require "user.plugins" -require "user.autocommands" -require "user.colorscheme" -require "user.lsp.init" - --- PLUGINS - -require "user.autopairs" -require "user.comment" -require "user.impatient" -require "user.surround" ---require "user.yanky" -require "user.undotree" - --- Mappings -require "user.whichkey" - --- Terminal -require "user.toggleterm" - --- File Management -require "user.nvim-tree" -require "user.sessions" - --- Appearance ---require "user.bufferline" -require "user.lualine" -require "user.indentline" -require "user.alpha" -require "user.illuminate" - --- Autocomplete -require "user.cmp" - --- LaTeX -require "user.vimtex" - --- Markdown -require "user.autolist" - --- Snippets -require "user.luasnip" - --- Telescope -require "user.telescope" -require "user.dressing" - --- Treesitter -require "user.treesitter" - --- Git -require "user.gitsigns" - - - - - +require("autopairs") +-- require("buffers") -- not wotking atm +require("colorscheme") +require("grammar") +require("keymaps") +require("lsp") +require("lua-line") +require("nvimtree") +require("options") +require("plugins") +require("telescope") +require("term") +require("treesitter") +require("whichkey") diff --git a/lua/autopairs.lua b/lua/autopairs.lua new file mode 100755 index 0000000..a76f41f --- /dev/null +++ b/lua/autopairs.lua @@ -0,0 +1,148 @@ +---- If you want insert `(` after select function or method item +--local cmp_autopairs = require('nvim-autopairs.completion.cmp') +--local cmp = require('cmp') +--cmp.event:on( +-- 'confirm_done', +-- cmp_autopairs.on_confirm_done() +--) +--local Rule = require('nvim-autopairs.rule') +--local npairs = require('nvim-autopairs') +-- +--npairs.add_rule(Rule("$$","$$","tex")) +-- +--local handlers = require('nvim-autopairs.completion.handlers') +-- +--cmp.event:on( +-- 'confirm_done', +-- cmp_autopairs.on_confirm_done({ +-- filetypes = { +-- -- "*" is a alias to all filetypes +-- ["*"] = { +-- ["("] = { +-- kind = { +-- cmp.lsp.CompletionItemKind.Function, +-- cmp.lsp.CompletionItemKind.Method, +-- }, +-- handler = handlers["*"] +-- } +-- }, +-- lua = { +-- ["("] = { +-- kind = { +-- cmp.lsp.CompletionItemKind.Function, +-- cmp.lsp.CompletionItemKind.Method +-- }, +-- ---@param char string +-- ---@param item table item completion +-- ---@param bufnr number buffer number +-- ---@param rules table +-- ---@param commit_character table +-- handler = function(char, item, bufnr, rules, commit_character) +-- -- Your handler function. Inpect with print(vim.inspect{char, item, bufnr, rules, commit_character}) +-- end +-- } +-- }, +-- -- Disable for tex +-- tex = false +-- } +-- }) +--) +-- +---- you can use some built-in conditions +-- +--local cond = require('nvim-autopairs.conds') +--print(vim.inspect(cond)) +-- +--npairs.add_rules({ +-- Rule("$", "$",{"tex", "latex"}) +-- -- don't add a pair if the next character is % +-- :with_pair(cond.not_after_regex("%%")) +-- -- don't add a pair if the previous character is xxx +-- :with_pair(cond.not_before_regex("xxx", 3)) +-- -- don't move right when repeat character +-- :with_move(cond.none()) +-- -- don't delete if the next character is xx +-- :with_del(cond.not_after_regex("xx")) +-- -- disable adding a newline when you press +-- :with_cr(cond.none()) +-- }, +-- -- disable for .vim files, but it work for another filetypes +-- Rule("a","a","-vim") +--) +-- +--npairs.add_rules({ +-- Rule("$$","$$","tex") +-- :with_pair(function(opts) +-- print(vim.inspect(opts)) +-- if opts.line=="aa $$" then +-- -- don't add pair on that line +-- return false +-- end +-- end) +-- } +--) +-- +---- you can use regex +---- press u1234 => u1234number +--npairs.add_rules({ +-- Rule("u%d%d%d%d$", "number", "lua") +-- :use_regex(true) +--}) +-- +-- +-- +---- press x1234 => x12341234 +--npairs.add_rules({ +-- Rule("x%d%d%d%d$", "number", "lua") +-- :use_regex(true) +-- :replace_endpair(function(opts) +-- -- print(vim.inspect(opts)) +-- return opts.prev_char:sub(#opts.prev_char - 3,#opts.prev_char) +-- end) +--}) +-- +-- +---- you can do anything with regex +special key +---- example press tab to uppercase text: +---- press b1234s => B1234S1234S +-- +--npairs.add_rules({ +-- Rule("b%d%d%d%d%w$", "", "vim") +-- :use_regex(true,"") +-- :replace_endpair(function(opts) +-- return +-- opts.prev_char:sub(#opts.prev_char - 4,#opts.prev_char) +-- .."viwU" +-- end) +--}) +-- +---- you can exclude filetypes +--npairs.add_rule( +-- Rule("$$","$$") +-- :with_pair(cond.not_filetypes({"lua"})) +--) +----- check ./lua/nvim-autopairs/rules/basic.lua +-- +--local npairs = require("nvim-autopairs") +--local Rule = require('nvim-autopairs.rule') +-- +--npairs.setup({ +-- check_ts = true, +-- ts_config = { +-- lua = {'string'},-- it will not add a pair on that treesitter node +-- javascript = {'template_string'}, +-- java = false,-- don't check treesitter on java +-- } +--}) +-- +--local ts_conds = require('nvim-autopairs.ts-conds') +-- +-- +---- press % => %% only while inside a comment or string +--npairs.add_rules({ +-- Rule("%", "%", "lua") +-- :with_pair(ts_conds.is_ts_node({'string','comment'})), +-- Rule("$", "$", "lua") +-- :with_pair(ts_conds.is_not_ts_node({'function'})) +--}) +-- diff --git a/lua/user/bufferline.lua b/lua/buffers.lua old mode 100644 new mode 100755 similarity index 98% rename from lua/user/bufferline.lua rename to lua/buffers.lua index b4ff5e7..9d1a640 --- a/lua/user/bufferline.lua +++ b/lua/buffers.lua @@ -6,8 +6,8 @@ end bufferline.setup { options = { numbers = "none", -- | "ordinal" | "buffer_id" | "both" | function({ ordinal, id, lower, raise }): string, - close_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" - right_mouse_command = "Bdelete! %d", -- can be a string | function, see "Mouse actions" + close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" + right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions" left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions" middle_mouse_command = nil, -- can be a string | function, see "Mouse actions" -- NOTE: this plugin is designed with this icon in mind, diff --git a/lua/colorscheme.lua b/lua/colorscheme.lua new file mode 100755 index 0000000..c2f965d --- /dev/null +++ b/lua/colorscheme.lua @@ -0,0 +1,21 @@ +-- define colorscheme here +--[[ +local colorscheme = "rose" + +local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme) +if not is_ok then + vim.notify("colorscheme " .. colorscheme .. " not found!") + return +end +]]-- + +function ColorSchemes(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) + + --vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + --vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +ColorSchemes() + diff --git a/lua/grammar.lua b/lua/grammar.lua new file mode 100755 index 0000000..93c2044 --- /dev/null +++ b/lua/grammar.lua @@ -0,0 +1,21 @@ +require("grammar-guard").init() + +require("lspconfig").grammar_guard.setup({ + cmd = { '/usr/bin/ltex-ls' }, -- add this if you install ltex-ls yourself + settings = { + ltex = { + enabled = { "latex", "tex", "bib", "markdown" }, + language = "en", + diagnosticSeverity = "information", + setenceCacheSize = 2000, + additionalRules = { + enablePickyRules = true, + motherTongue = "en", + }, + trace = { server = "verbose" }, + dictionary = {}, + disabledRules = {}, + hiddenFalsePositives = {}, + }, + }, +}) diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100755 index 0000000..9467674 --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,84 @@ +-- define common options +local opts = { + noremap = true, -- non-recursive + silent = true, -- do not show message +} + +----------------- +-- Normal mode -- +----------------- + +-- Hint: see `:h vim.map.set()` +-- Better window navigation +vim.keymap.set("n", "", "h", opts) +vim.keymap.set("n", "", "j", opts) +vim.keymap.set("n", "", "k", opts) +vim.keymap.set("n", "", "l", opts) + +-- Resize with arrows +-- delta: 2 lines +vim.keymap.set("n", "", ":resize -2", opts) +vim.keymap.set("n", "", ":resize +2", opts) +vim.keymap.set("n", "", ":vertical resize -2", opts) +vim.keymap.set("n", "", ":vertical resize +2", opts) + +-- Open explorer +--vim.keymap.set("n", "pv", vim.cmd.Ex, opts) + +-- Navigate buffers +vim.keymap.set("n", "", ":bnext", opts) +vim.keymap.set("n", "", ":bprevious", opts) + +-- Telescope +local builtin = require("telescope.builtin") +--vim.keymap.set("n", "pf", builtin.find_files, {}) +--vim.keymap.set("n", "", builtin.git_files, {}) +--vim.keymap.set("n", "ps", function () +-- builtin.grep_string( { search = vim.fn.input("Grep > ") } ); +--end) + +-- Harpoon +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function () ui.nav_file(1) end) +vim.keymap.set("n", "", function () ui.nav_file(2) end) +vim.keymap.set("n", "", function () ui.nav_file(3) end) +vim.keymap.set("n", "", function () ui.nav_file(4) end) + +-- Undotree +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + +-- Fugitive +vim.keymap.set("n", "gs", vim.cmd.Git) + +-- Put line bellow in-front of line +vim.keymap.set("n", "J", "mzJ`z") + +-- Keep cursor in the middle +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- Don't loose buffer +vim.keymap.set("x", "p", "\"_dP") + + +----------------- +-- Visual mode -- +----------------- + +-- Hint: start visual mode with the same area as the previous area and the same mode +vim.keymap.set("v", "<", "", ">gv", opts) + +-- Move text on visual mode +vim.keymap.set("v", "J", ":m '>+1gv=gv", opts) +vim.keymap.set("v", "K", ":m '<-2gv=gv", opts) + + + + diff --git a/lua/user/lsp/mason.lua b/lua/lsp.lua old mode 100644 new mode 100755 similarity index 95% rename from lua/user/lsp/mason.lua rename to lua/lsp.lua index efe3245..6a52ce7 --- a/lua/user/lsp/mason.lua +++ b/lua/lsp.lua @@ -12,7 +12,7 @@ require("mason-lspconfig").setup({ -- A list of servers to automatically install if they"re not already installed --ensure_installed = { "pylsp", "gopls", "lua_ls", "rust_analyzer" }, --ensure_installed = { "pylsp", "lua_ls", "julials", "zls", "ltex", "texlab" }, - ensure_installed = { "bashls", "pylsp", "lua_ls", "julials", "ltex", "texlab" }, + ensure_installed = { "pylsp", "lua_ls", "julials", "zls", "ltex", "texlab" }, }) -- Set different settings for different languages" LSP @@ -86,17 +86,18 @@ lspconfig.pylsp.setup({ on_attach = on_attach, }) ---lspconfig.julials.setup{} ---[[ -]]-- +--lspconfig.gopls.setup({ +-- on_attach = on_attach, +--}) + lspconfig.julials.setup({ --on_attach = on_attach, - --symbol_cache_download = true, + symbol_cache_download = true, --symbol_server = "https://symbol-server", on_new_config = function(new_config, _) local julia = vim.fn.expand("/usr/share/julia/bin/julia") if require'lspconfig'.util.path.is_file(julia) then - vim.notify("julials loaded?!") + vim.notify("Hello!") new_config.cmd[1] = julia end end @@ -106,14 +107,6 @@ lspconfig.texlab.setup({ on_attach = on_attach, }) -lspconfig.ltex.setup({ - settings = { - ltex = { - language = "en-GB", - }, - }, -}) - lspconfig.zls.setup({ on_attach = on_attach, }) @@ -122,6 +115,13 @@ lspconfig.bashls.setup({ on_attach = on_attach, }) +lspconfig.ltex.setup({ + settings = { + ltex = { + language = "en-GB", + }, + }, +}) -- source: https://rust-analyzer.github.io/manual.html#nvim-lsp --lspconfig.rust_analyzer.setup({ -- on_attach = on_attach, diff --git a/lua/lua-line.lua b/lua/lua-line.lua new file mode 100755 index 0000000..e6ae731 --- /dev/null +++ b/lua/lua-line.lua @@ -0,0 +1,43 @@ +require("lualine").setup({}) +--[[ +require("lualine").setup { + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = ""}, + section_separators = { left = "", right = ""}, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + } + }, + sections = { + lualine_a = {"mode"}, + lualine_b = {"branch", "diff", "diagnostics"}, + lualine_c = {"filename"}, + lualine_x = {"encoding", "fileformat", "filetype"}, + lualine_y = {"progress"}, + lualine_z = {"location"} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {"filename"}, + lualine_x = {"location"}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {} +} +]]-- diff --git a/lua/nvimtree.lua b/lua/nvimtree.lua new file mode 100755 index 0000000..df3b05c --- /dev/null +++ b/lua/nvimtree.lua @@ -0,0 +1 @@ +require("nvim-tree").setup() diff --git a/lua/options.lua b/lua/options.lua new file mode 100755 index 0000000..daea7a7 --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,107 @@ +-- Hint: use `:h