diff options
-rw-r--r-- | init.lua | 43 | ||||
-rw-r--r-- | lua/user/autopairs.lua | 33 | ||||
-rw-r--r-- | lua/user/bepo.lua | 96 | ||||
-rw-r--r-- | lua/user/bufferline.lua | 167 | ||||
-rw-r--r-- | lua/user/cmp.lua | 132 | ||||
-rw-r--r-- | lua/user/colorscheme.lua | 21 | ||||
-rw-r--r-- | lua/user/comment.lua | 23 | ||||
-rw-r--r-- | lua/user/debounce.lua | 19 | ||||
-rw-r--r-- | lua/user/gitsigns.lua | 48 | ||||
-rw-r--r-- | lua/user/keymaps.lua | 82 | ||||
-rw-r--r-- | lua/user/lsp/handlers.lua | 97 | ||||
-rw-r--r-- | lua/user/lsp/init.lua | 13 | ||||
-rw-r--r-- | lua/user/lsp/lsp-installer.lua | 28 | ||||
-rw-r--r-- | lua/user/lsp/null-ls.lua | 19 | ||||
-rw-r--r-- | lua/user/lsp/settings/jsonls.lua | 197 | ||||
-rw-r--r-- | lua/user/lsp/settings/sumneko_lua.lua | 16 | ||||
-rw-r--r-- | lua/user/nvim-tree.lua | 110 | ||||
-rw-r--r-- | lua/user/options.lua | 48 | ||||
-rw-r--r-- | lua/user/plugins.lua | 106 | ||||
-rw-r--r-- | lua/user/telescope.lua | 96 | ||||
-rw-r--r-- | lua/user/treesitter.lua | 29 |
21 files changed, 1423 insertions, 0 deletions
diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..75b2a16 --- /dev/null +++ b/init.lua @@ -0,0 +1,43 @@ +require 'user.options' +require 'user.bepo' +require 'user.keymaps' +require 'user.plugins' +require 'user.colorscheme' +require 'user.cmp' +require 'user.lsp' +require 'user.comment' +require 'user.telescope' +require 'user.treesitter' +require 'user.autopairs' +require 'user.gitsigns' +require 'user.nvim-tree' +require 'user.bufferline' + +require('feline').setup({preset = 'noicon'}) + +-- When editing a file, always jump to the last known cursor position. +-- Don't do it when the position is invalid or when inside an event handler +-- (happens when dropping a file on gvim). +vim.cmd[[ + autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | + \ endif +]] + +vim.cmd([[ + augroup CmpDebounceAuGroup + au! + au TextChangedI * lua require('user.debounce').debounce() + augroup end +]]) + +-- UTF8 à tester +-- command! -nargs=* UTF8 call EncodeUTF8(<f-args>) +-- fun! EncodeUTF8(...) +-- let utf8str = "" +-- for i in a:000 +-- let utf8str .= "\\x" . i +-- endfor +-- exe "norm i" . eval("\"".utf8str."\"") +-- endfun diff --git a/lua/user/autopairs.lua b/lua/user/autopairs.lua new file mode 100644 index 0000000..577e571 --- /dev/null +++ b/lua/user/autopairs.lua @@ -0,0 +1,33 @@ +-- Setup nvim-cmp. +local status_ok, npairs = pcall(require, "nvim-autopairs") +if not status_ok then + return +end + +npairs.setup { + check_ts = true, + ts_config = { + lua = { "string", "source" }, + javascript = { "string", "template_string" }, + java = false, + }, + disable_filetype = { "TelescopePrompt", "spectre_panel" }, + fast_wrap = { + map = "<M-e>", + chars = { "{", "[", "(", '"', "'" }, + pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], "%s+", ""), + offset = 0, -- Offset from pattern match + end_key = "$", + keys = "qwertyuiopzxcvbnmasdfghjkl", + check_comma = true, + highlight = "PmenuSel", + highlight_grey = "LineNr", + }, +} + +local cmp_autopairs = require "nvim-autopairs.completion.cmp" +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end +cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done { map_char = { tex = "" } }) diff --git a/lua/user/bepo.lua b/lua/user/bepo.lua new file mode 100644 index 0000000..c124da0 --- /dev/null +++ b/lua/user/bepo.lua @@ -0,0 +1,96 @@ +local opts = { noremap = true, silent = true } +local keymap = vim.api.nvim_set_keymap + +-- {W} -> [É] +-- On remappe W sur É : +keymap('', 'é', 'w', opts) +keymap('', 'É', 'W', opts) +-- Corollaire, pour effacer/remplacer un mot quand on n’est pas au début (daé / laé). +-- (attention, cela diminue la réactivité du {A}…) +keymap('', 'aé', 'aw', opts) +keymap('', 'aÉ', 'aW', opts) + +-- [HJKL] -> {CTSR} +-- {cr} = « gauche / droite » +keymap('', 'c', 'h', opts) +keymap('', 'r', 'l', opts) +-- {ts} = « haut / bas » +keymap('', 't', 'j', opts) +keymap('', 's', 'k', opts) +-- {CR} = « haut / bas de l'écran » +keymap('', 'C', 'H', opts) +keymap('', 'R', 'L', opts) +-- {TS} = « joindre / aide » +keymap('', 'T', 'J', opts) +keymap('', 'S', 'K', opts) +-- Corollaire : repli suivant / précédent +-- keymap('', 'zs', 'zj', opts) +-- keymap('', 'zt', 'zk', opts) + +-- {HJKL} <- [CTSR] +-- {J} = « Jusqu'à » (j = suivant, J = précédant) +keymap('', 'j', 't', opts) +keymap('', 'J', 'T', opts) +-- {L} = « Change » (l = attend un mvt, L = jusqu'à la fin de ligne) +keymap('', 'l', 'c', opts) +keymap('', 'L', 'C', opts) +-- {H} = « Remplace » (h = un caractère slt, H = reste en « Remplace ») +keymap('', 'h', 'r', opts) +keymap('', 'H', 'R', opts) +-- {K} = « Substitue » (k = caractère, K = ligne) +keymap('', 'k', 's', opts) +keymap('', 'K', 'S', opts) +-- Corollaire : correction orthographique +-- keymap('', ']k', ']s', opts) +-- keymap('', '[k', '[s', opts) + +-- Désambiguation de {g} +-- ligne écran précédente / suivante (à l'intérieur d'une phrase) +keymap('n', 'gs', 'gk', opts) +keymap('n', 'gt', 'gj', opts) +-- onglet précédant / suivant +keymap('n', 'gb', 'gT', opts) +keymap('n', 'gé', 'gt', opts) +-- optionnel : {gB} / {gÉ} pour aller au premier / dernier onglet +-- keymap('n', 'gB', ':exe 'silent! tabfirst'<CR>', opts) +-- keymap('n', 'gÉ', ':exe 'silent! tablast'<CR>', opts) +-- optionnel : {g'} pour aller au début de la ligne écran +-- keymap('n', 'g"', 'g0', opts) + +-- <> en direct +-- keymap('n', '«', '<', opts) +-- keymap('n', '»', '>', opts) + +-- Remaper la gestion des fenêtres +-- keymap('n', 'et', '<C-w>j', opts) +-- keymap('n', 'es', '<C-w>k', opts) +-- keymap('n', 'ec', '<C-w>h', opts) +-- keymap('n', 'er', '<C-w>l', opts) +-- keymap('n', 'ed', '<C-w>c', opts) +-- keymap('n', 'eo', '<C-w>s', opts) +-- keymap('n', 'ep', '<C-w>o', opts) +-- keymap('n', 'e<SPACE>', ':split<CR>', opts) +-- keymap('n', 'e<CR>', ':vsplit<CR>', opts) + +-- Chiffres en accès direct +-- ———————————————————————— +-- keymap('n', '' 1', opts) +-- keymap('n', '1', ''', opts) +-- keymap('n', '«', '2', opts) +-- keymap('n', '2', '<', opts) +-- keymap('n', '»', '3', opts) +-- keymap('n', '3', '>', opts) +-- keymap('n', '(', '4', opts) +-- keymap('n', '4', '(', opts) +-- keymap('n', ')', '5', opts) +-- keymap('n', '5', ')', opts) +-- keymap('n', '@', '6', opts) +-- keymap('n', '6', '@', opts) +-- keymap('n', '+', '7', opts) +-- keymap('n', '7', '+', opts) +-- keymap('n', '-', '8', opts) +-- keymap('n', '8', '-', opts) +-- keymap('n', '/', '9', opts) +-- keymap('n', '9', '/', opts) +-- keymap('n', '*', '0', opts) +-- keymap('n', '0', '*', opts) diff --git a/lua/user/bufferline.lua b/lua/user/bufferline.lua new file mode 100644 index 0000000..7d98cf0 --- /dev/null +++ b/lua/user/bufferline.lua @@ -0,0 +1,167 @@ +local status_ok, bufferline = pcall(require, "bufferline") +if not status_ok then + return +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" + 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, + -- and so changing this is NOT recommended, this is intended + -- as an escape hatch for people who cannot bear it for whatever reason + indicator_icon = "▎", + buffer_close_icon = "", + -- buffer_close_icon = '', + modified_icon = "●", + close_icon = "", + -- close_icon = '', + left_trunc_marker = "", + right_trunc_marker = "", + --- name_formatter can be used to change the buffer's label in the bufferline. + --- Please note some names can/will break the + --- bufferline so use this at your discretion knowing that it has + --- some limitations that will *NOT* be fixed. + -- name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr" + -- -- remove extension from markdown files for example + -- if buf.name:match('%.md') then + -- return vim.fn.fnamemodify(buf.name, ':t:r') + -- end + -- end, + max_name_length = 30, + max_prefix_length = 30, -- prefix used when a buffer is de-duplicated + tab_size = 21, + diagnostics = false, -- | "nvim_lsp" | "coc", + diagnostics_update_in_insert = false, + -- diagnostics_indicator = function(count, level, diagnostics_dict, context) + -- return "("..count..")" + -- end, + -- NOTE: this will be called a lot so don't do any heavy processing here + -- custom_filter = function(buf_number) + -- -- filter out filetypes you don't want to see + -- if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then + -- return true + -- end + -- -- filter out by buffer name + -- if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then + -- return true + -- end + -- -- filter out based on arbitrary rules + -- -- e.g. filter out vim wiki buffer from tabline in your work repo + -- if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then + -- return true + -- end + -- end, + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = true, + persist_buffer_sort = true, -- whether or not custom sorted buffers should persist + -- can also be a table containing 2 custom separators + -- [focused and unfocused]. eg: { '|', '|' } + separator_style = "thin", -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + -- sort_by = 'id' | 'extension' | 'relative_directory' | 'directory' | 'tabs' | function(buffer_a, buffer_b) + -- -- add custom logic + -- return buffer_a.modified > buffer_b.modified + -- end + }, + highlights = { + fill = { + guifg = { attribute = "fg", highlight = "#ff0000" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + background = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + + -- buffer_selected = { + -- guifg = {attribute='fg',highlight='#ff0000'}, + -- guibg = {attribute='bg',highlight='#0000ff'}, + -- gui = 'none' + -- }, + buffer_visible = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + -- close_button_selected = { + -- guifg = {attribute='fg',highlight='TabLineSel'}, + -- guibg ={attribute='bg',highlight='TabLineSel'} + -- }, + + tab_selected = { + guifg = { attribute = "fg", highlight = "Normal" }, + guibg = { attribute = "bg", highlight = "Normal" }, + }, + tab = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + tab_close = { + -- guifg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, + guifg = { attribute = "fg", highlight = "TabLineSel" }, + guibg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + guifg = { attribute = "fg", highlight = "TabLineSel" }, + guibg = { attribute = "bg", highlight = "TabLineSel" }, + gui = "italic", + }, + duplicate_visible = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + gui = "italic", + }, + duplicate = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + gui = "italic", + }, + + modified = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + modified_selected = { + guifg = { attribute = "fg", highlight = "Normal" }, + guibg = { attribute = "bg", highlight = "Normal" }, + }, + modified_visible = { + guifg = { attribute = "fg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + guifg = { attribute = "bg", highlight = "TabLine" }, + guibg = { attribute = "bg", highlight = "TabLine" }, + }, + separator_selected = { + guifg = { attribute = "bg", highlight = "Normal" }, + guibg = { attribute = "bg", highlight = "Normal" }, + }, + -- separator_visible = { + -- guifg = {attribute='bg',highlight='TabLine'}, + -- guibg = {attribute='bg',highlight='TabLine'} + -- }, + indicator_selected = { + guifg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + guibg = { attribute = "bg", highlight = "Normal" }, + }, + }, +} diff --git a/lua/user/cmp.lua b/lua/user/cmp.lua new file mode 100644 index 0000000..bf28333 --- /dev/null +++ b/lua/user/cmp.lua @@ -0,0 +1,132 @@ +local cmp_status_ok, cmp = pcall(require, "cmp") +if not cmp_status_ok then + return +end + +local snip_status_ok, luasnip = pcall(require, "luasnip") +if not snip_status_ok then + return +end +require("luasnip/loaders/from_vscode").lazy_load() + +local check_backspace = function() + local col = vim.fn.col "." - 1 + return col == 0 or vim.fn.getline("."):sub(col, col):match "%s" +end + +-- פּ ﯟ some other good icons +local kind_icons = { + Text = "", + Method = "m", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "", + Interface = "", + Module = "", + Property = "", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} +-- find more here: https://www.nerdfonts.com/cheat-sheet + +cmp.setup { + completion = { + autocomplete = false, -- see init.lua : debounce + }, + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + ["<A-s>"] = cmp.mapping.select_prev_item(), + ["<A-t>"] = cmp.mapping.select_next_item(), + ["<A-c>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + ["<A-r>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + ["<A-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + ["<A-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping. + ["<A-e>"] = cmp.mapping { + i = cmp.mapping.abort(), + c = cmp.mapping.close(), + }, + -- 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 + luasnip.expand() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif check_backspace() then + fallback() + else + fallback() + end + end, { + "i", + "s", + }), + ["<S-Tab>"] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { + "i", + "s", + }), + }, + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind + vim_item.menu = ({ + nvim_lsp = "[LSP]", + luasnip = "[Snippet]", + buffer = "[Buffer]", + path = "[Path]", + })[entry.source.name] + return vim_item + end, + }, + -- SEE : https://github.com/hrsh7th/nvim-cmp#where-can-i-find-more-completion-sources + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + experimental = { + ghost_text = true, -- grey autosuggestion + native_menu = false, + }, +} diff --git a/lua/user/colorscheme.lua b/lua/user/colorscheme.lua new file mode 100644 index 0000000..e2b2634 --- /dev/null +++ b/lua/user/colorscheme.lua @@ -0,0 +1,21 @@ + +vim.cmd[[ +" colorscheme solarized +" let g:solarized_termtrans=1 +colorscheme darkplus +hi CursorLineNr guibg=#8a4a59 +hi CursorLine guibg=#3a3a3a +hi ColorColumn guibg=#3a3a3a +hi Search guibg=peru guifg=wheat +hi NonText ctermfg=16 guifg=#4a4a59 +hi ExtraWhitespace ctermbg=red guibg=red ctermfg=black guifg=black +match ExtraWhitespace /\s\+$/ +set list listchars=tab:▸\ ,trail:·,precedes:←,extends:→,nbsp:␣ +hi Normal guibg=none " transparent bg +let g:airline_theme='wombat' +" let g:airline_powerline_fonts = 1 +" let g:airline#extensions#tabline#enabled = 1 +" let g:airline#extensions#tabline#fnamemod = ':t' +" let g:airline#extensions#tabline#buffer_idx_mode = 1 +]] + diff --git a/lua/user/comment.lua b/lua/user/comment.lua new file mode 100644 index 0000000..7f8870f --- /dev/null +++ b/lua/user/comment.lua @@ -0,0 +1,23 @@ +local status_ok, comment = pcall(require, "Comment") +if not status_ok then + return +end + +comment.setup { + pre_hook = function(ctx) + local U = require "Comment.utils" + + local location = nil + if ctx.ctype == U.ctype.block then + location = require("ts_context_commentstring.utils").get_cursor_location() + elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then + location = require("ts_context_commentstring.utils").get_visual_start_location() + end + + return require("ts_context_commentstring.internal").calculate_commentstring { + key = ctx.ctype == U.ctype.line and "__default" or "__multiline", + location = location, + } + end, +} + diff --git a/lua/user/debounce.lua b/lua/user/debounce.lua new file mode 100644 index 0000000..732c2e8 --- /dev/null +++ b/lua/user/debounce.lua @@ -0,0 +1,19 @@ +local M = {} + +local cmp = require("cmp") +local timer = vim.loop.new_timer() + +local DEBOUNCE_DELAY = 200 + +function M.debounce() + timer:stop() + timer:start( + DEBOUNCE_DELAY, + 0, + vim.schedule_wrap(function() + cmp.complete({ reason = cmp.ContextReason.Auto }) + end) + ) +end + +return M diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua new file mode 100644 index 0000000..923a2ea --- /dev/null +++ b/lua/user/gitsigns.lua @@ -0,0 +1,48 @@ +local status_ok, gitsigns = pcall(require, "gitsigns") +if not status_ok then + return +end + +gitsigns.setup { + signs = { + add = { hl = "GitSignsAdd", text = "▎", numhl = "GitSignsAddNr", linehl = "GitSignsAddLn" }, + change = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + delete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + topdelete = { hl = "GitSignsDelete", text = "契", numhl = "GitSignsDeleteNr", linehl = "GitSignsDeleteLn" }, + changedelete = { hl = "GitSignsChange", text = "▎", numhl = "GitSignsChangeNr", linehl = "GitSignsChangeLn" }, + }, + signcolumn = true, -- Toggle with `:Gitsigns toggle_signs` + numhl = false, -- Toggle with `:Gitsigns toggle_numhl` + linehl = false, -- Toggle with `:Gitsigns toggle_linehl` + word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff` + watch_gitdir = { + interval = 1000, + follow_files = true, + }, + attach_to_untracked = true, + current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame` + current_line_blame_opts = { + virt_text = true, + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' + delay = 1000, + ignore_whitespace = false, + }, + current_line_blame_formatter_opts = { + relative_time = false, + }, + sign_priority = 6, + update_debounce = 100, + status_formatter = nil, -- Use default + max_file_length = 40000, + preview_config = { + -- Options passed to nvim_open_win + border = "single", + style = "minimal", + relative = "cursor", + row = 0, + col = 1, + }, + yadm = { + enable = false, + }, +} diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua new file mode 100644 index 0000000..caf78a4 --- /dev/null +++ b/lua/user/keymaps.lua @@ -0,0 +1,82 @@ +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } + +-- Shorten function name +local keymap = vim.api.nvim_set_keymap + +--Remap space as leader key +keymap("", "<Space>", "<Nop>", opts) +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +-- Normal -- +-- Better window navigation +keymap('n', ',t', '<C-w>j', opts) +keymap('n', ',s', '<C-w>k', opts) +keymap('n', ',c', '<C-w>h', opts) +keymap('n', ',r', '<C-w>l', opts) +keymap('n', ',<SPACE>', ':split<CR>', opts) +keymap('n', ',<CR>', ':vsplit<CR>', opts) + +-- jump back from tag +keymap('n', ',,', ':pop<CR>', opts) + +-- lexpore navigation keys are not bepo : https://vonheikemen.github.io/devlog/tools/using-netrw-vim-builtin-file-explorer/ +-- keymap('n', '<Leader>e', ':Lex 20<CR>', opts) +-- switch to https://github.com/kyazdani42/nvim-tree.lua +keymap('n', '<Leader>e', ':NvimTreeToggle<CR>', opts) + +-- Resize with arrows +keymap("n", "<C-Up>", ":resize +2<CR>", opts) +keymap("n", "<C-Down>", ":resize -2<CR>", opts) +keymap("n", "<C-Left>", ":vertical resize +2<CR>", opts) +keymap("n", "<C-Right>", ":vertical resize -2<CR>", opts) + +-- Navigate buffers +keymap("n", "<S-Q>", ":bnext<CR>", opts) +keymap("n", "<S-H>", ":bprevious<CR>", opts) + +-- Move text up and down +-- keymap("n", "<A-j>", "<Esc>:m .+1<CR>==gi", opts) +-- keymap("n", "<A-k>", "<Esc>:m .-2<CR>==gi", opts) + +-- Insert -- +-- Press jk fast to enter +-- keymap("i", "jk", "<ESC>", opts) + +-- Visual -- +-- Stay in indent mode +keymap("v", "<", "<gv", opts) +keymap("v", ">", ">gv", opts) + +-- Move text up and down +-- keymap("v", "<A-j>", ":m .+1<CR>==", opts) +-- keymap("v", "<A-k>", ":m .-2<CR>==", opts) +keymap("v", "p", '"_dP', opts) -- no not overwrite the register content when past to replace + +-- Visual Block -- +-- Move text up and down +-- keymap("x", "J", ":move '>+1<CR>gv-gv", opts) +-- keymap("x", "K", ":move '<-2<CR>gv-gv", opts) +-- keymap("x", "<A-j>", ":move '>+1<CR>gv-gv", opts) +-- keymap("x", "<A-k>", ":move '<-2<CR>gv-gv", opts) + +-- Terminal -- +-- Better terminal navigation +-- keymap("t", "<C-h>", "<C-\\><C-N><C-w>h", term_opts) +-- keymap("t", "<C-j>", "<C-\\><C-N><C-w>j", term_opts) +-- keymap("t", "<C-k>", "<C-\\><C-N><C-w>k", term_opts) +-- keymap("t", "<C-l>", "<C-\\><C-N><C-w>l", term_opts) + +-- Telescope +keymap("n", "<Leader>b", "<cmd>lua require('telescope.builtin').buffers(require('telescope.themes').get_dropdown{previewer = false})<cr>", opts) +keymap("n", "<Leader>f", "<cmd>lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{previewer = false})<cr>", opts) diff --git a/lua/user/lsp/handlers.lua b/lua/user/lsp/handlers.lua new file mode 100644 index 0000000..b7b1a92 --- /dev/null +++ b/lua/user/lsp/handlers.lua @@ -0,0 +1,97 @@ +local M = {} + +-- TODO: backfill this to template +M.setup = function() + local signs = { + { name = "DiagnosticSignError", text = "" }, + { name = "DiagnosticSignWarn", text = "" }, + { name = "DiagnosticSignHint", text = "" }, + { name = "DiagnosticSignInfo", text = "" }, + } + + for _, sign in ipairs(signs) do + vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = "" }) + end + + local config = { + -- disable virtual text + virtual_text = false, + -- show signs + signs = { + active = signs, + }, + update_in_insert = true, + underline = true, + severity_sort = true, + float = { + focusable = false, + style = "minimal", + border = "rounded", + source = "always", + header = "", + prefix = "", + }, + } + + vim.diagnostic.config(config) + + vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { + border = "rounded", + }) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + border = "rounded", + }) +end + +local function lsp_highlight_document(client) + -- Set autocommands conditional on server_capabilities + if client.resolved_capabilities.document_highlight then + vim.api.nvim_exec( + [[ + augroup lsp_document_highlight + autocmd! * <buffer> + autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight() + autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references() + augroup END + ]], + false + ) + end +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + -- SEE : https://neovim.io/doc/user/lsp.html + vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "ga", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts) + + vim.api.nvim_buf_set_keymap(bufnr, "n", "gb", "<cmd>lua vim.lsp.buf.hover()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gé", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gk", '<cmd>lua vim.diagnostic.open_float({ border = "rounded" })<CR>', opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "g.", '<cmd>lua vim.diagnostic.goto_next({ border = "rounded" })<CR>', opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gx", '<cmd>lua vim.diagnostic.goto_prev({ border = "rounded" })<CR>', opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "<leader>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] -- FIXME what ? +end + +M.on_attach = function(client, bufnr) + if client.name == "tsserver" then + client.resolved_capabilities.document_formatting = false + end + lsp_keymaps(bufnr) + lsp_highlight_document(client) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +local status_ok, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") +if not status_ok then + return +end + +M.capabilities = cmp_nvim_lsp.update_capabilities(capabilities) + +return M diff --git a/lua/user/lsp/init.lua b/lua/user/lsp/init.lua new file mode 100644 index 0000000..add8bf8 --- /dev/null +++ b/lua/user/lsp/init.lua @@ -0,0 +1,13 @@ +local status_ok, lspconfig = pcall(require, "lspconfig") +if not status_ok then + return +end + +require "user.lsp.lsp-installer" +require("user.lsp.handlers").setup() +require "user.lsp.null-ls" + +lspconfig.gdscript.setup{ + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, +} diff --git a/lua/user/lsp/lsp-installer.lua b/lua/user/lsp/lsp-installer.lua new file mode 100644 index 0000000..7675878 --- /dev/null +++ b/lua/user/lsp/lsp-installer.lua @@ -0,0 +1,28 @@ +local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok then + return +end + +-- Register a handler that will be called for all installed servers. +-- Alternatively, you may also register handlers on specific server instances instead (see example below). +-- SEE : https://github.com/williamboman/nvim-lsp-installer#setup +lsp_installer.on_server_ready(function(server) + local opts = { + on_attach = require("user.lsp.handlers").on_attach, + capabilities = require("user.lsp.handlers").capabilities, + } + + if server.name == "jsonls" then + local jsonls_opts = require("user.lsp.settings.jsonls") + opts = vim.tbl_deep_extend("force", jsonls_opts, opts) + end + + if server.name == "sumneko_lua" then + local sumneko_opts = require("user.lsp.settings.sumneko_lua") + opts = vim.tbl_deep_extend("force", sumneko_opts, opts) + end + + -- This setup() function is exactly the same as lspconfig's setup function. + -- Refer to https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md + server:setup(opts) +end) diff --git a/lua/user/lsp/null-ls.lua b/lua/user/lsp/null-ls.lua new file mode 100644 index 0000000..15720d1 --- /dev/null +++ b/lua/user/lsp/null-ls.lua @@ -0,0 +1,19 @@ +local null_ls_status_ok, null_ls = pcall(require, "null-ls") +if not null_ls_status_ok then + return +end + +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/formatting +local formatting = null_ls.builtins.formatting +-- https://github.com/jose-elias-alvarez/null-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics +local diagnostics = null_ls.builtins.diagnostics + +null_ls.setup({ + debug = false, + sources = { + formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), + formatting.black.with({ extra_args = { "--fast" } }), + formatting.stylua, + -- diagnostics.flake8 + }, +}) diff --git a/lua/user/lsp/settings/jsonls.lua b/lua/user/lsp/settings/jsonls.lua new file mode 100644 index 0000000..1fffa68 --- /dev/null +++ b/lua/user/lsp/settings/jsonls.lua @@ -0,0 +1,197 @@ +local default_schemas = nil +local status_ok, jsonls_settings = pcall(require, "nlspsettings.jsonls") +if status_ok then + default_schemas = jsonls_settings.get_default_schemas() +end + +local schemas = { + { + description = "TypeScript compiler configuration file", + fileMatch = { + "tsconfig.json", + "tsconfig.*.json", + }, + url = "https://json.schemastore.org/tsconfig.json", + }, + { + description = "Lerna config", + fileMatch = { "lerna.json" }, + url = "https://json.schemastore.org/lerna.json", + }, + { + description = "Babel configuration", + fileMatch = { + ".babelrc.json", + ".babelrc", + "babel.config.json", + }, + url = "https://json.schemastore.org/babelrc.json", + }, + { + description = "ESLint config", + fileMatch = { + ".eslintrc.json", + ".eslintrc", + }, + url = "https://json.schemastore.org/eslintrc.json", + }, + { + description = "Bucklescript config", + fileMatch = { "bsconfig.json" }, + url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", + }, + { + description = "Prettier config", + fileMatch = { + ".prettierrc", + ".prettierrc.json", + "prettier.config.json", + }, + url = "https://json.schemastore.org/prettierrc", + }, + { + description = "Vercel Now config", + fileMatch = { "now.json" }, + url = "https://json.schemastore.org/now", + }, + { + description = "Stylelint config", + fileMatch = { + ".stylelintrc", + ".stylelintrc.json", + "stylelint.config.json", + }, + url = "https://json.schemastore.org/stylelintrc", + }, + { + description = "A JSON schema for the ASP.NET LaunchSettings.json files", + fileMatch = { "launchsettings.json" }, + url = "https://json.schemastore.org/launchsettings.json", + }, + { + description = "Schema for CMake Presets", + fileMatch = { + "CMakePresets.json", + "CMakeUserPresets.json", + }, + url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", + }, + { + description = "Configuration file as an alternative for configuring your repository in the settings page.", + fileMatch = { + ".codeclimate.json", + }, + url = "https://json.schemastore.org/codeclimate.json", + }, + { + description = "LLVM compilation database", + fileMatch = { + "compile_commands.json", + }, + url = "https://json.schemastore.org/compile-commands.json", + }, + { + description = "Config file for Command Task Runner", + fileMatch = { + "commands.json", + }, + url = "https://json.schemastore.org/commands.json", + }, + { + description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", + fileMatch = { + "*.cf.json", + "cloudformation.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", + }, + { + description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", + fileMatch = { + "serverless.template", + "*.sam.json", + "sam.json", + }, + url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", + }, + { + description = "Json schema for properties json file for a GitHub Workflow template", + fileMatch = { + ".github/workflow-templates/**.properties.json", + }, + url = "https://json.schemastore.org/github-workflow-template-properties.json", + }, + { + description = "golangci-lint configuration file", + fileMatch = { + ".golangci.toml", + ".golangci.json", + }, + url = "https://json.schemastore.org/golangci-lint.json", + }, + { + description = "JSON schema for the JSON Feed format", + fileMatch = { + "feed.json", + }, + url = "https://json.schemastore.org/feed.json", + versions = { + ["1"] = "https://json.schemastore.org/feed-1.json", + ["1.1"] = "https://json.schemastore.org/feed.json", + }, + }, + { + description = "Packer template JSON configuration", + fileMatch = { + "packer.json", + }, + url = "https://json.schemastore.org/packer.json", + }, + { + description = "NPM configuration file", + fileMatch = { + "package.json", + }, + url = "https://json.schemastore.org/package.json", + }, + { + description = "JSON schema for Visual Studio component configuration files", + fileMatch = { + "*.vsconfig", + }, + url = "https://json.schemastore.org/vsconfig.json", + }, + { + description = "Resume json", + fileMatch = { "resume.json" }, + url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", + }, +} + +local function extend(tab1, tab2) + for _, value in ipairs(tab2) do + table.insert(tab1, value) + end + return tab1 +end + +local extended_schemas = extend(schemas, default_schemas) + +local opts = { + settings = { + json = { + schemas = extended_schemas, + }, + }, + setup = { + commands = { + Format = { + function() + vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) + end, + }, + }, + }, +} + +return opts diff --git a/lua/user/lsp/settings/sumneko_lua.lua b/lua/user/lsp/settings/sumneko_lua.lua new file mode 100644 index 0000000..d7e82b4 --- /dev/null +++ b/lua/user/lsp/settings/sumneko_lua.lua @@ -0,0 +1,16 @@ +return { + settings = { + + Lua = { + diagnostics = { + globals = { "vim" }, -- teach about vim global variable + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/lua/user/nvim-tree.lua b/lua/user/nvim-tree.lua new file mode 100644 index 0000000..eb594b9 --- /dev/null +++ b/lua/user/nvim-tree.lua @@ -0,0 +1,110 @@ +-- following options are the default +-- each of these are documented in `:help nvim-tree.OPTION_NAME` +vim.g.nvim_tree_icons = { + default = "", + symlink = "", + git = { + unstaged = "", + staged = "S", + unmerged = "", + renamed = "➜", + deleted = "", + untracked = "U", + ignored = "◌", + }, + folder = { + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + }, +} + +local status_ok, nvim_tree = pcall(require, "nvim-tree") +if not status_ok then + return +end + +local config_status_ok, nvim_tree_config = pcall(require, "nvim-tree.config") +if not config_status_ok then + return +end + +local tree_cb = nvim_tree_config.nvim_tree_callback + +nvim_tree.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { }, + auto_close = true, + open_on_tab = false, + hijack_cursor = false, + update_cwd = true, + update_to_buf_dir = { + enable = true, + auto_open = true, + }, + diagnostics = { + enable = true, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + update_focused_file = { + enable = true, + update_cwd = true, + ignore_list = {}, + }, + system_open = { + cmd = nil, + args = {}, + }, + filters = { + dotfiles = false, + custom = {}, + }, + git = { + enable = true, + ignore = true, + timeout = 500, + }, + view = { + width = 30, + height = 30, + hide_root_folder = false, + side = "left", + auto_resize = true, + mappings = { + custom_only = false, + list = { -- see https://github.com/kyazdani42/nvim-tree.lua#keybindings + { key = { "l", "<CR>", "o" }, cb = tree_cb "edit" }, + { key = "t", action = "next_sibling"}, + { key = "s", action = "prev_sibling"}, + { key = ">", action = "next_git_item"}, + { key = "<", action = "prev_git_item"}, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + quit_on_open = 0, + git_hl = 1, + disable_window_picker = 0, + root_folder_modifier = ":t", + show_icons = { + git = 1, + folders = 1, + files = 1, + folder_arrows = 1, + tree_width = 30, + }, +} diff --git a/lua/user/options.lua b/lua/user/options.lua new file mode 100644 index 0000000..b94ca9c --- /dev/null +++ b/lua/user/options.lua @@ -0,0 +1,48 @@ +local options = { + backup = true, -- creates a backup file + clipboard = "unnamedplus", -- allows neovim to access the system clipboard + cmdheight = 2, -- more space in the neovim command line for displaying messages + completeopt = { "menuone", "noselect" }, -- mostly just for cmp + conceallevel = 0, -- so that `` is visible in markdown files + fileencoding = "utf-8", -- the encoding written to a file + hlsearch = true, -- highlight all matches on previous search pattern + ignorecase = false, -- ignore case in search patterns + --mouse = "a", -- enable the mouse to be used in neovim + pumheight = 10, -- pop up menu height + showmode = true, -- we don't need to see things like -- INSERT -- anymore + showtabline = 2, -- always show tabs + smartcase = true, -- smart case + smartindent = true, -- make indenting smarter again + splitbelow = true, -- force all horizontal splits to go below current window + splitright = true, -- force all vertical splits to go to the right of current window + swapfile = false, -- creates a swapfile + termguicolors = true, -- set term gui colors (most terminals support this) + timeoutlen = 400, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = false, -- enable persistent undo + --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 + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, -- highlight the current line + number = true, -- set numbered lines + relativenumber = false, -- set relative numbered lines + numberwidth = 4, -- set number column width to 2 {default 4} + signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time + wrap = false, -- display lines as one long line + scrolloff = 8, -- # lines above under the cursor + sidescrolloff = 8, + guifont = "monospace:h17", -- the font used in graphical neovim applications + colorcolumn = "80", -- vertical bar + ruler = true, + laststatus = 2, +} + +vim.opt.shortmess:append "c" + +for k, v in pairs(options) do + vim.opt[k] = v +end + +vim.cmd [[set iskeyword+=-]] -- word split definition +-- vim.cmd "set whichwrap+=<,>,[,],h,l" -- change line with left/right moves diff --git a/lua/user/plugins.lua b/lua/user/plugins.lua new file mode 100644 index 0000000..12d4e2a --- /dev/null +++ b/lua/user/plugins.lua @@ -0,0 +1,106 @@ +local fn = vim.fn + +-- Automatically install packer : ~/.local/share/nvim +local install_path = fn.stdpath "data" .. "/site/pack/packer/start/packer.nvim" +if fn.empty(fn.glob(install_path)) > 0 then + PACKER_BOOTSTRAP = fn.system { + "git", + "clone", + "--depth", + "1", + "https://github.com/wbthomason/packer.nvim", + install_path, + } + print "Installing packer close and reopen Neovim..." + vim.cmd [[packadd packer.nvim]] +end + +-- Autocommand that reloads neovim whenever you save the plugins.lua file +vim.cmd [[ + augroup packer_user_config + autocmd! + autocmd BufWritePost plugins.lua source <afile> | PackerSync + augroup end +]] + +-- Use a protected call so we don't error out on first use +local status_ok, packer = pcall(require, "packer") +if not status_ok then + return +end + +-- Have packer use a popup window +packer.init { + display = { + open_fn = function() + return require("packer.util").float { border = "rounded" } + end, + }, +} + +-- Install your plugins here +return packer.startup(function(use) + -- SEE : https://github.com/wbthomason/packer.nvim#quickstart + + -- My plugins here + use 'wbthomason/packer.nvim' -- Have packer manage itself + use 'nvim-lua/popup.nvim' -- An implementation of the Popup API from vim in Neovim + use 'nvim-lua/plenary.nvim' -- Useful lua functions used in lots of plugins + use 'numToStr/Comment.nvim' -- gc[N][motion] + -- use 'windwp/nvim-autopairs' -- Autopairs, integrates with both cmp and treesitter + use 'kyazdani42/nvim-web-devicons' -- nices icons + use 'kyazdani42/nvim-tree.lua' -- tree explorer + use 'akinsho/bufferline.nvim' -- buffer status line + -- use 'vim-airline/vim-airline' -- Status/Tab line + -- use 'vim-airline/vim-airline-themes' -- Status/Tab line Themes + use 'feline-nvim/feline.nvim' + use 'embear/vim-localvimrc' -- support .lvimrc + + -- Colorschemes + -- use 'lunarvim/colorschemes' -- A bunch of colorschemes you can try out + use 'lunarvim/darkplus.nvim' + -- use 'matsen/nvim-colors-solarized' + + -- languages + use 'habamax/vim-godot' + + -- cmp plugins + use 'hrsh7th/nvim-cmp' -- The completion plugin + use 'hrsh7th/cmp-buffer' -- buffer completions + use 'hrsh7th/cmp-path' -- path completions + use 'hrsh7th/cmp-cmdline' -- cmdline completions + use 'saadparwaiz1/cmp_luasnip' -- snippet completions + use 'hrsh7th/cmp-nvim-lsp' -- lsp completion + + -- snippets + use 'L3MON4D3/LuaSnip' -- snippet engine + use 'rafamadriz/friendly-snippets' -- a bunch of snippets to use + + -- LSP + use 'neovim/nvim-lspconfig' -- enable LSP + use 'williamboman/nvim-lsp-installer' -- simple to use language server installer + use 'tamago324/nlsp-settings.nvim' -- language server settings defined in json for + use 'jose-elias-alvarez/null-ls.nvim' -- for formatters and linters + use 'dense-analysis/ale' -- asynchronous lint engine + + -- Telescope + use 'nvim-telescope/telescope.nvim' -- highly extendable fuzzy finder + + -- Treesitter + use { -- language syntax tree for highlight + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + } + use 'JoosepAlviste/nvim-ts-context-commentstring' -- to help Comment + use 'p00f/nvim-ts-rainbow' + -- use 'nvim-treesitter/playground' -- TSHighlightCapturesUnderCursor, TSPlaygroundToggle, ... + + -- Git + use "lewis6991/gitsigns.nvim" + + -- Automatically set up your configuration after cloning packer.nvim + -- Put this at the end after all plugins + if PACKER_BOOTSTRAP then + require('packer').sync() + end +end) diff --git a/lua/user/telescope.lua b/lua/user/telescope.lua new file mode 100644 index 0000000..29d2885 --- /dev/null +++ b/lua/user/telescope.lua @@ -0,0 +1,96 @@ +local status_ok, telescope = pcall(require, "telescope") +if not status_ok then + return +end + +local actions = require "telescope.actions" + +telescope.setup { + defaults = { + + prompt_prefix = " ", + selection_caret = " ", + path_display = { "smart" }, + + mappings = { + i = { + ["<C-n>"] = actions.cycle_history_next, + ["<C-p>"] = actions.cycle_history_prev, + + ["<C-t>"] = actions.move_selection_next, + ["<C-s>"] = actions.move_selection_previous, + + ["<C-c>"] = actions.close, + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-v>"] = actions.select_vertical, + ["<C-k>"] = actions.select_tab, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + ["<C-l>"] = actions.complete_tag, + ["<C-_>"] = actions.which_key, -- keys from pressing <C-/> + }, + + n = { + ["<esc>"] = actions.close, + ["<CR>"] = actions.select_default, + ["<C-x>"] = actions.select_horizontal, + ["<C-v>"] = actions.select_vertical, + ["<C-k>"] = actions.select_tab, + + ["<Tab>"] = actions.toggle_selection + actions.move_selection_worse, + ["<S-Tab>"] = actions.toggle_selection + actions.move_selection_better, + ["<C-q>"] = actions.send_to_qflist + actions.open_qflist, + ["<M-q>"] = actions.send_selected_to_qflist + actions.open_qflist, + + ["j"] = actions.move_selection_next, + ["k"] = actions.move_selection_previous, + ["H"] = actions.move_to_top, + ["M"] = actions.move_to_middle, + ["L"] = actions.move_to_bottom, + + ["<Down>"] = actions.move_selection_next, + ["<Up>"] = actions.move_selection_previous, + ["gg"] = actions.move_to_top, + ["G"] = actions.move_to_bottom, + + ["<C-u>"] = actions.preview_scrolling_up, + ["<C-d>"] = actions.preview_scrolling_down, + + ["<PageUp>"] = actions.results_scrolling_up, + ["<PageDown>"] = actions.results_scrolling_down, + + ["?"] = actions.which_key, + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + -- Your extension configuration goes here: + -- extension_name = { + -- extension_config_key = value, + -- } + -- please take a look at the readme of the extension you want to configure + }, +} diff --git a/lua/user/treesitter.lua b/lua/user/treesitter.lua new file mode 100644 index 0000000..889373f --- /dev/null +++ b/lua/user/treesitter.lua @@ -0,0 +1,29 @@ +local status_ok, configs = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +configs.setup { + ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages + sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) + ignore_install = { "" }, -- List of parsers to ignore installing + autopairs = { + enable = true, + }, + highlight = { + enable = true, -- false will disable the whole extension + disable = { "" }, -- list of language that will be disabled + additional_vim_regex_highlighting = true, + }, + indent = { enable = true, disable = { "yaml" } }, + context_commentstring = { -- for nvim-ts-context-commentstring + enable = true, + enable_autocmd = false, + }, + playground = { + enable = true, + }, + rainbow = { + enable = true, + } +} |