From 3d3f187224981d4a3071645cc0771730d700b0cc Mon Sep 17 00:00:00 2001 From: "fabio.lenherr" Date: Tue, 30 Aug 2022 01:52:48 +0200 Subject: [PATCH] chore: move folder --- nvim/init.lua | 23 +++ nvim/lua/settings/autocommands.lua | 5 + nvim/lua/settings/bufferline.lua | 167 +++++++++++++++++++ nvim/lua/settings/cmp.lua | 131 +++++++++++++++ nvim/lua/settings/colorscheme.lua | 6 + nvim/lua/settings/comment.lua | 22 +++ nvim/lua/settings/dashboard.lua | 42 +++++ nvim/lua/settings/devicons.lua | 23 +++ nvim/lua/settings/feline.lua | 8 + nvim/lua/settings/gitsigns.lua | 1 + nvim/lua/settings/haskell.lua | 43 +++++ nvim/lua/settings/impatient.lua | 6 + nvim/lua/settings/indentline.lua | 70 ++++++++ nvim/lua/settings/keymaps.lua | 9 + nvim/lua/settings/lint.lua | 4 + nvim/lua/settings/lsp.lua | 74 ++++++++ nvim/lua/settings/lsp_config/eslint.lua | 165 ++++++++++++++++++ nvim/lua/settings/lsp_config/handlers.lua | 100 +++++++++++ nvim/lua/settings/lsp_config/html.lua | 43 +++++ nvim/lua/settings/lsp_config/jdtls.lua | 17 ++ nvim/lua/settings/lsp_config/pyright.lua | 55 ++++++ nvim/lua/settings/lsp_config/sumneko_lua.lua | 16 ++ nvim/lua/settings/lsp_config/texlab.lua | 16 ++ nvim/lua/settings/lua_codeactions.lua | 14 ++ nvim/lua/settings/null-ls.lua | 16 ++ nvim/lua/settings/nvim-tree.lua | 103 ++++++++++++ nvim/lua/settings/options.lua | 33 ++++ nvim/lua/settings/pairs.lua | 33 ++++ nvim/lua/settings/plugins.lua | 42 +++++ nvim/lua/settings/prettier.lua | 19 +++ nvim/lua/settings/project.lua | 48 ++++++ nvim/lua/settings/test.log | 57 +++++++ nvim/lua/settings/treesitter.lua | 21 +++ nvim/lua/settings/vimtex.lua | 8 + nvim/plugged/Comment.nvim | 1 + nvim/plugged/FixCursorHold.nvim | 1 + nvim/plugged/LuaSnip | 1 + nvim/plugged/alpha-nvim | 1 + nvim/plugged/bufferline.nvim | 1 + nvim/plugged/cmp-buffer | 1 + nvim/plugged/cmp-cmdline | 1 + nvim/plugged/cmp-nvim-lsp | 1 + nvim/plugged/cmp-path | 1 + nvim/plugged/cmp_luasnip | 1 + nvim/plugged/feline.nvim | 1 + nvim/plugged/fern.vim | 1 + nvim/plugged/gitsigns.nvim | 1 + nvim/plugged/impatient.nvim | 1 + nvim/plugged/indent-blankline.nvim | 1 + nvim/plugged/kommentary | 1 + nvim/plugged/nightfox.nvim | 1 + nvim/plugged/null-ls.nvim | 1 + nvim/plugged/nvim-autopairs | 1 + nvim/plugged/nvim-cmp | 1 + nvim/plugged/nvim-code-action-menu | 1 + nvim/plugged/nvim-lint | 1 + nvim/plugged/nvim-lsp-installer | 1 + nvim/plugged/nvim-lspconfig | 1 + nvim/plugged/nvim-tree.lua | 1 + nvim/plugged/nvim-treesitter | 1 + nvim/plugged/nvim-web-devicons | 1 + nvim/plugged/plenary.nvim | 1 + nvim/plugged/popup.nvim | 1 + nvim/plugged/prettier.nvim | 1 + nvim/plugged/project.nvim | 1 + nvim/plugged/spellsitter.nvim | 1 + nvim/plugged/telescope.nvim | 1 + nvim/plugged/twilight.nvim | 1 + nvim/plugged/vgit.nvim | 1 + nvim/plugged/vim-bbye | 1 + nvim/plugged/vimtex | 1 + 71 files changed, 1477 insertions(+) create mode 100644 nvim/init.lua create mode 100644 nvim/lua/settings/autocommands.lua create mode 100644 nvim/lua/settings/bufferline.lua create mode 100644 nvim/lua/settings/cmp.lua create mode 100644 nvim/lua/settings/colorscheme.lua create mode 100644 nvim/lua/settings/comment.lua create mode 100644 nvim/lua/settings/dashboard.lua create mode 100644 nvim/lua/settings/devicons.lua create mode 100644 nvim/lua/settings/feline.lua create mode 100644 nvim/lua/settings/gitsigns.lua create mode 100644 nvim/lua/settings/haskell.lua create mode 100644 nvim/lua/settings/impatient.lua create mode 100644 nvim/lua/settings/indentline.lua create mode 100644 nvim/lua/settings/keymaps.lua create mode 100644 nvim/lua/settings/lint.lua create mode 100644 nvim/lua/settings/lsp.lua create mode 100644 nvim/lua/settings/lsp_config/eslint.lua create mode 100644 nvim/lua/settings/lsp_config/handlers.lua create mode 100644 nvim/lua/settings/lsp_config/html.lua create mode 100644 nvim/lua/settings/lsp_config/jdtls.lua create mode 100644 nvim/lua/settings/lsp_config/pyright.lua create mode 100644 nvim/lua/settings/lsp_config/sumneko_lua.lua create mode 100644 nvim/lua/settings/lsp_config/texlab.lua create mode 100644 nvim/lua/settings/lua_codeactions.lua create mode 100644 nvim/lua/settings/null-ls.lua create mode 100644 nvim/lua/settings/nvim-tree.lua create mode 100644 nvim/lua/settings/options.lua create mode 100644 nvim/lua/settings/pairs.lua create mode 100644 nvim/lua/settings/plugins.lua create mode 100644 nvim/lua/settings/prettier.lua create mode 100644 nvim/lua/settings/project.lua create mode 100644 nvim/lua/settings/test.log create mode 100644 nvim/lua/settings/treesitter.lua create mode 100644 nvim/lua/settings/vimtex.lua create mode 160000 nvim/plugged/Comment.nvim create mode 160000 nvim/plugged/FixCursorHold.nvim create mode 160000 nvim/plugged/LuaSnip create mode 160000 nvim/plugged/alpha-nvim create mode 160000 nvim/plugged/bufferline.nvim create mode 160000 nvim/plugged/cmp-buffer create mode 160000 nvim/plugged/cmp-cmdline create mode 160000 nvim/plugged/cmp-nvim-lsp create mode 160000 nvim/plugged/cmp-path create mode 160000 nvim/plugged/cmp_luasnip create mode 160000 nvim/plugged/feline.nvim create mode 160000 nvim/plugged/fern.vim create mode 160000 nvim/plugged/gitsigns.nvim create mode 160000 nvim/plugged/impatient.nvim create mode 160000 nvim/plugged/indent-blankline.nvim create mode 160000 nvim/plugged/kommentary create mode 160000 nvim/plugged/nightfox.nvim create mode 160000 nvim/plugged/null-ls.nvim create mode 160000 nvim/plugged/nvim-autopairs create mode 160000 nvim/plugged/nvim-cmp create mode 160000 nvim/plugged/nvim-code-action-menu create mode 160000 nvim/plugged/nvim-lint create mode 160000 nvim/plugged/nvim-lsp-installer create mode 160000 nvim/plugged/nvim-lspconfig create mode 160000 nvim/plugged/nvim-tree.lua create mode 160000 nvim/plugged/nvim-treesitter create mode 160000 nvim/plugged/nvim-web-devicons create mode 160000 nvim/plugged/plenary.nvim create mode 160000 nvim/plugged/popup.nvim create mode 160000 nvim/plugged/prettier.nvim create mode 160000 nvim/plugged/project.nvim create mode 160000 nvim/plugged/spellsitter.nvim create mode 160000 nvim/plugged/telescope.nvim create mode 160000 nvim/plugged/twilight.nvim create mode 160000 nvim/plugged/vgit.nvim create mode 160000 nvim/plugged/vim-bbye create mode 160000 nvim/plugged/vimtex diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..f8e15ac --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,23 @@ +require "settings.options" +require "settings.plugins" +require "settings.lint" +require "settings.cmp" +require "settings.lsp" +require "settings.devicons" +require "settings.treesitter" +require "settings.feline" +require "settings.colorscheme" +require "settings.nvim-tree" +require "settings.pairs" +require "settings.bufferline" +require "settings.comment" +require "settings.indentline" +require "settings.impatient" +require "settings.project" +require "settings.dashboard" +require "settings.vimtex" +require "settings.autocommands" +require "settings.haskell" +require "settings.keymaps" +require "settings.null-ls" +require "settings.prettier" diff --git a/nvim/lua/settings/autocommands.lua b/nvim/lua/settings/autocommands.lua new file mode 100644 index 0000000..26be752 --- /dev/null +++ b/nvim/lua/settings/autocommands.lua @@ -0,0 +1,5 @@ +vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + require("lint").try_lint() + end, +}) diff --git a/nvim/lua/settings/bufferline.lua b/nvim/lua/settings/bufferline.lua new file mode 100644 index 0000000..7d98cf0 --- /dev/null +++ b/nvim/lua/settings/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 ~= "" then + -- return true + -- end + -- -- filter out by buffer name + -- if vim.fn.bufname(buf_number) ~= "" 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() == "" 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/nvim/lua/settings/cmp.lua b/nvim/lua/settings/cmp.lua new file mode 100644 index 0000000..df5c052 --- /dev/null +++ b/nvim/lua/settings/cmp.lua @@ -0,0 +1,131 @@ +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 { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) -- For `luasnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), + [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), + [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. + [""] = 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. + [""] = cmp.mapping.confirm { select = true }, + [""] = 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", + }), + [""] = 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, + }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "path" }, + }, + confirm_opts = { + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }, + window = { + documentation = { + border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, + }, + }, + experimental = { + ghost_text = false, + native_menu = false, + }, +} diff --git a/nvim/lua/settings/colorscheme.lua b/nvim/lua/settings/colorscheme.lua new file mode 100644 index 0000000..04f4019 --- /dev/null +++ b/nvim/lua/settings/colorscheme.lua @@ -0,0 +1,6 @@ +local status_ok, _ = pcall(require, "nightfox") +if not status_ok then + return +end + +vim.cmd("colorscheme nightfox") diff --git a/nvim/lua/settings/comment.lua b/nvim/lua/settings/comment.lua new file mode 100644 index 0000000..2fa4a56 --- /dev/null +++ b/nvim/lua/settings/comment.lua @@ -0,0 +1,22 @@ +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/nvim/lua/settings/dashboard.lua b/nvim/lua/settings/dashboard.lua new file mode 100644 index 0000000..918a723 --- /dev/null +++ b/nvim/lua/settings/dashboard.lua @@ -0,0 +1,42 @@ +local status_ok, alpha = pcall(require, "alpha") +if not status_ok then + return +end + +local dashboard = require("alpha.themes.dashboard") +dashboard.section.header.val = { + [[ __ ]], + [[ ___ ___ ___ __ __ /\_\ ___ ___ ]], + [[ / _ `\ / __`\ / __`\/\ \/\ \\/\ \ / __` __`\ ]], + [[/\ \/\ \/\ __//\ \_\ \ \ \_/ |\ \ \/\ \/\ \/\ \ ]], + [[\ \_\ \_\ \____\ \____/\ \___/ \ \_\ \_\ \_\ \_\]], + [[ \/_/\/_/\/____/\/___/ \/__/ \/_/\/_/\/_/\/_/]], +} +dashboard.section.buttons.val = { + dashboard.button("f", " Find file", ":Telescope find_files "), + dashboard.button("e", " New file", ":ene startinsert "), + dashboard.button("p", " Find project", ":Telescope projects "), + dashboard.button("r", " Recently used files", ":Telescope oldfiles "), + dashboard.button("t", " Find text", ":Telescope live_grep "), + dashboard.button("c", " Configuration", ":e ~/.config/nvim/init.lua "), + dashboard.button("q", " Quit Neovim", ":qa"), +} + +local function footer() +-- NOTE: requires the fortune-mod package to work + -- local handle = io.popen("fortune") + -- local fortune = handle:read("*a") + -- handle:close() + -- return fortune + return "dashie@shitgaem.online" +end + +dashboard.section.footer.val = footer() + +dashboard.section.footer.opts.hl = "Type" +dashboard.section.header.opts.hl = "Include" +dashboard.section.buttons.opts.hl = "Keyword" + +dashboard.opts.opts.noautocmd = true +-- vim.cmd([[autocmd User AlphaReady echo 'ready']]) +alpha.setup(dashboard.opts) diff --git a/nvim/lua/settings/devicons.lua b/nvim/lua/settings/devicons.lua new file mode 100644 index 0000000..57c1386 --- /dev/null +++ b/nvim/lua/settings/devicons.lua @@ -0,0 +1,23 @@ +local status_ok , _ = pcall (require, "nvim-web-devicons") +if not status_ok then + return +end + + +require'nvim-web-devicons'.setup { + -- your personnal icons can go here (to override) + -- you can specify color or cterm_color instead of specifying both of them + -- DevIcon will be appended to `name` + override = { + zsh = { + icon = "", + color = "#428850", + cterm_color = "65", + name = "Zsh" + } + }; + + default = true; +} + +require'nvim-web-devicons'.get_icons() diff --git a/nvim/lua/settings/feline.lua b/nvim/lua/settings/feline.lua new file mode 100644 index 0000000..afda8a9 --- /dev/null +++ b/nvim/lua/settings/feline.lua @@ -0,0 +1,8 @@ +local status_ok, _ = pcall(require, "feline") +if not status_ok then + return +end + + +require('feline').setup() +--require('feline').winbar.setup() diff --git a/nvim/lua/settings/gitsigns.lua b/nvim/lua/settings/gitsigns.lua new file mode 100644 index 0000000..91fa65b --- /dev/null +++ b/nvim/lua/settings/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup() diff --git a/nvim/lua/settings/haskell.lua b/nvim/lua/settings/haskell.lua new file mode 100644 index 0000000..d463870 --- /dev/null +++ b/nvim/lua/settings/haskell.lua @@ -0,0 +1,43 @@ + +local util = require 'lspconfig.util' + +return { + default_config = { + cmd = { 'haskell-language-server-wrapper', '--lsp' }, + filetypes = { 'haskell', 'lhaskell' }, + root_dir = util.root_pattern('*.cabal', 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml'), + single_file_support = true, + settings = { + haskell = { + formattingProvider = 'ormolu', + }, + }, + lspinfo = function(cfg) + local extra = {} + local function on_stdout(_, data, _) + local version = data[1] + table.insert(extra, 'version: ' .. version) + end + + local opts = { + cwd = cfg.cwd, + stdout_buffered = true, + on_stdout = on_stdout, + } + local chanid = vim.fn.jobstart({ cfg.cmd[1], '--version' }, opts) + vim.fn.jobwait { chanid } + return extra + end, + }, + + docs = { + description = [[ +https://github.com/haskell/haskell-language-server +Haskell Language Server + ]], + + default_config = { + root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]], + }, + }, +} diff --git a/nvim/lua/settings/impatient.lua b/nvim/lua/settings/impatient.lua new file mode 100644 index 0000000..84419e0 --- /dev/null +++ b/nvim/lua/settings/impatient.lua @@ -0,0 +1,6 @@ +local status_ok, impatient = pcall(require, "impatient") +if not status_ok then + return +end + +impatient.enable_profile() diff --git a/nvim/lua/settings/indentline.lua b/nvim/lua/settings/indentline.lua new file mode 100644 index 0000000..fdf5870 --- /dev/null +++ b/nvim/lua/settings/indentline.lua @@ -0,0 +1,70 @@ +local status_ok, indent_blankline = pcall(require, "indent_blankline") +if not status_ok then + return +end + +vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" } +vim.g.indent_blankline_filetype_exclude = { + "help", + "startify", + "dashboard", + "packer", + "neogitstatus", + "NvimTree", + "Trouble", +} +vim.g.indentLine_enabled = 1 +-- vim.g.indent_blankline_char = "│" +vim.g.indent_blankline_char = "▏" +-- vim.g.indent_blankline_char = "▎" +vim.g.indent_blankline_show_trailing_blankline_indent = false +vim.g.indent_blankline_show_first_indent_level = true +vim.g.indent_blankline_use_treesitter = true +vim.g.indent_blankline_show_current_context = true +vim.g.indent_blankline_context_patterns = { + "class", + "return", + "function", + "method", + "^if", + "^while", + "jsx_element", + "^for", + "^object", + "^table", + "block", + "arguments", + "if_statement", + "else_clause", + "jsx_element", + "jsx_self_closing_element", + "try_statement", + "catch_clause", + "import_statement", + "operation_type", +} +-- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 +vim.wo.colorcolumn = "99999" + +-- vim.cmd [[highlight IndentBlanklineIndent1 guifg=#E06C75 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent2 guifg=#E5C07B gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent3 guifg=#98C379 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent4 guifg=#56B6C2 gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent5 guifg=#61AFEF gui=nocombine]] +-- vim.cmd [[highlight IndentBlanklineIndent6 guifg=#C678DD gui=nocombine]] +-- vim.opt.list = true +-- vim.opt.listchars:append "space:⋅" +-- vim.opt.listchars:append "space:" +-- vim.opt.listchars:append "eol:↴" + +indent_blankline.setup({ + -- show_end_of_line = true, + -- space_char_blankline = " ", + show_current_context = true, + -- show_current_context_start = true, + -- char_highlight_list = { + -- "IndentBlanklineIndent1", + -- "IndentBlanklineIndent2", + -- "IndentBlanklineIndent3", + -- }, +}) diff --git a/nvim/lua/settings/keymaps.lua b/nvim/lua/settings/keymaps.lua new file mode 100644 index 0000000..c4eddec --- /dev/null +++ b/nvim/lua/settings/keymaps.lua @@ -0,0 +1,9 @@ +local opts = { noremap = true, silent = true } + +local term_opts = { silent = true } + +-- Shorten function name +local keymap = vim.api.nvim_set_keymap + + +keymap("n", "c" ,":CodeActionMenu" , opts) diff --git a/nvim/lua/settings/lint.lua b/nvim/lua/settings/lint.lua new file mode 100644 index 0000000..ad45d4c --- /dev/null +++ b/nvim/lua/settings/lint.lua @@ -0,0 +1,4 @@ +require('lint').linters_by_ft = { + javascript = {'eslint',}, + react = {'eslint',}, +} diff --git a/nvim/lua/settings/lsp.lua b/nvim/lua/settings/lsp.lua new file mode 100644 index 0000000..5f6c1e7 --- /dev/null +++ b/nvim/lua/settings/lsp.lua @@ -0,0 +1,74 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + + +require'lspconfig'.hls.setup {} +require'lspconfig'.pyright.setup {} +require'lspconfig'.clangd.setup {} +require'lspconfig'.html.setup {} +require'lspconfig'.eslint.setup {} +require'lspconfig'.texlab.setup {} +require'lspconfig'.jdtls.setup {} +require'lspconfig'.sumneko_lua.setup {} +require'lspconfig'.gopls.setup {} +require'lspconfig'.jsonls.setup {} + + +require("nvim-lsp-installer").setup({ + automatic_installation = true, -- automatically detect which servers to install (based on which servers are set up via lspconfig) + ui = { + icons = { + server_installed = "✓", + server_pending = "➜", + server_uninstalled = "✗" + } + } +}) + + +local status_ok2, lsp_installer = pcall(require, "nvim-lsp-installer") +if not status_ok2 then + return +end + +local lspconfig = require("lspconfig") +local servers = {"jdtls" , "sumneko_lua" , "texlab", "pyright" , "eslint" , "html" } + +lsp_installer.setup { + ensure_installed = servers +} + +for _, server in pairs(servers) do + local opts = { + on_attach = require("settings.lsp_config.handlers").on_attach, + capabilities = require("settings.lsp_config.handlers").capabilities, + } + local has_custom_opts, server_custom_opts = pcall(require, "settings.lsp_config." .. server) + if has_custom_opts then + opts = vim.tbl_deep_extend("force", server_custom_opts, opts) + end + lspconfig[server].setup(opts) +end + + +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/nvim/lua/settings/lsp_config/eslint.lua b/nvim/lua/settings/lsp_config/eslint.lua new file mode 100644 index 0000000..d456970 --- /dev/null +++ b/nvim/lua/settings/lsp_config/eslint.lua @@ -0,0 +1,165 @@ +local util = require 'lspconfig.util' +local lsp = vim.lsp + +local function fix_all(opts) + opts = opts or {} + + local eslint_lsp_client = util.get_active_client_by_name(opts.bufnr, 'eslint') + if eslint_lsp_client == nil then + return + end + + local request + if opts.sync then + request = function(bufnr, method, params) + eslint_lsp_client.request_sync(method, params, nil, bufnr) + end + else + request = function(bufnr, method, params) + eslint_lsp_client.request(method, params, nil, bufnr) + end + end + + local bufnr = util.validate_bufnr(opts.bufnr or 0) + request(0, 'workspace/executeCommand', { + command = 'eslint.applyAllFixes', + arguments = { + { + uri = vim.uri_from_bufnr(bufnr), + version = lsp.util.buf_versions[bufnr], + }, + }, + }) +end + +local bin_name = 'vscode-eslint-language-server' +local cmd = { bin_name, '--stdio' } + +if vim.fn.has 'win32' == 1 then + cmd = { 'cmd.exe', '/C', bin_name, '--stdio' } +end + +return { + default_config = { + cmd = cmd, + filetypes = { + 'javascript', + 'javascriptreact', + 'javascript.jsx', + 'typescript', + 'typescriptreact', + 'typescript.tsx', + 'vue', + }, + -- https://eslint.org/docs/user-guide/configuring/configuration-files#configuration-file-formats + root_dir = util.root_pattern( + '.eslintrc', + '.eslintrc.js', + '.eslintrc.cjs', + '.eslintrc.yaml', + '.eslintrc.yml', + '.eslintrc.json', + 'package.json' + ), + -- Refer to https://github.com/Microsoft/vscode-eslint#settings-options for documentation. + settings = { + validate = 'on', + packageManager = 'npm', + useESLintClass = false, + codeActionOnSave = { + enable = false, + mode = 'all', + }, + format = true, + quiet = false, + onIgnoredFiles = 'off', + rulesCustomizations = {}, + run = 'onType', + -- nodePath configures the directory in which the eslint server should start its node_modules resolution. + -- This path is relative to the workspace folder (root dir) of the server instance. + nodePath = '', + -- use the workspace folder location or the file location (if no workspace folder is open) as the working directory + workingDirectory = { mode = 'location' }, + codeAction = { + disableRuleComment = { + enable = true, + location = 'separateLine', + }, + showDocumentation = { + enable = true, + }, + }, + }, + on_new_config = function(config, new_root_dir) + -- The "workspaceFolder" is a VSCode concept. It limits how far the + -- server will traverse the file system when locating the ESLint config + -- file (e.g., .eslintrc). + config.settings.workspaceFolder = { + uri = new_root_dir, + name = vim.fn.fnamemodify(new_root_dir, ':t'), + } + + -- Support Yarn2 (PnP) projects + local pnp_cjs = util.path.join(new_root_dir, '.pnp.cjs') + local pnp_js = util.path.join(new_root_dir, '.pnp.js') + if util.path.exists(pnp_cjs) or util.path.exists(pnp_js) then + config.cmd = vim.list_extend({ 'yarn', 'exec' }, cmd) + end + end, + handlers = { + ['eslint/openDoc'] = function(_, result) + if not result then + return + end + local sysname = vim.loop.os_uname().sysname + if sysname:match 'Windows' then + os.execute(string.format('start %q', result.url)) + elseif sysname:match 'Linux' then + os.execute(string.format('xdg-open %q', result.url)) + else + os.execute(string.format('open %q', result.url)) + end + return {} + end, + ['eslint/confirmESLintExecution'] = function(_, result) + if not result then + return + end + return 4 -- approved + end, + ['eslint/probeFailed'] = function() + vim.notify('[lspconfig] ESLint probe failed.', vim.log.levels.WARN) + return {} + end, + ['eslint/noLibrary'] = function() + vim.notify('[lspconfig] Unable to find ESLint library.', vim.log.levels.WARN) + return {} + end, + }, + }, + commands = { + EslintFixAll = { + function() + fix_all { sync = true, bufnr = 0 } + end, + description = 'Fix all eslint problems for this buffer', + }, + }, + docs = { + description = [[ +https://github.com/hrsh7th/vscode-langservers-extracted +`vscode-eslint-language-server` is a linting engine for JavaScript / Typescript. +It can be installed via `npm`: +```sh +npm i -g vscode-langservers-extracted +``` +`vscode-eslint-language-server` provides an `EslintFixAll` command that can be used to format a document on save: +```vim +autocmd BufWritePre *.tsx,*.ts,*.jsx,*.js EslintFixAll +``` +See [vscode-eslint](https://github.com/microsoft/vscode-eslint/blob/55871979d7af184bf09af491b6ea35ebd56822cf/server/src/eslintServer.ts#L216-L229) for configuration options. +Messages handled in lspconfig: `eslint/openDoc`, `eslint/confirmESLintExecution`, `eslint/probeFailed`, `eslint/noLibrary` +Additional messages you can handle: `eslint/noConfig` +]], + }, +} diff --git a/nvim/lua/settings/lsp_config/handlers.lua b/nvim/lua/settings/lsp_config/handlers.lua new file mode 100644 index 0000000..3c401de --- /dev/null +++ b/nvim/lua/settings/lsp_config/handlers.lua @@ -0,0 +1,100 @@ +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 + local status_ok, illuminate = pcall(require, "illuminate") + if not status_ok then + return + end + illuminate.on_attach(client) + -- end +end + +local function lsp_keymaps(bufnr) + local opts = { noremap = true, silent = true } + vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "lua vim.lsp.buf.declaration()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "lua vim.lsp.buf.definition()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "lua vim.lsp.buf.hover()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gi", "lua vim.lsp.buf.implementation()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "", "lua vim.lsp.buf.signature_help()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "rn", "lua vim.lsp.buf.rename()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "lua vim.lsp.buf.references()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "ca", "lua vim.lsp.buf.code_action()", opts) + -- vim.api.nvim_buf_set_keymap(bufnr, "n", "f", "lua vim.diagnostic.open_float()", opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "[d", 'lua vim.diagnostic.goto_prev({ border = "rounded" })', opts) + vim.api.nvim_buf_set_keymap( + bufnr, + "n", + "gl", + 'lua vim.diagnostic.open_float({ border = "rounded" })', + opts + ) + vim.api.nvim_buf_set_keymap(bufnr, "n", "]d", 'lua vim.diagnostic.goto_next({ border = "rounded" })', opts) + vim.api.nvim_buf_set_keymap(bufnr, "n", "q", "lua vim.diagnostic.setloclist()", opts) + vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]] +end + +M.on_attach = function(client, bufnr) +-- vim.notify(client.name .. " starting...") +-- TODO: refactor this into a method that checks if string in list + 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/nvim/lua/settings/lsp_config/html.lua b/nvim/lua/settings/lsp_config/html.lua new file mode 100644 index 0000000..b1771d3 --- /dev/null +++ b/nvim/lua/settings/lsp_config/html.lua @@ -0,0 +1,43 @@ +local util = require 'lspconfig.util' + +local bin_name = 'vscode-html-language-server' +local cmd = { bin_name, '--stdio' } + +if vim.fn.has 'win32' == 1 then + cmd = { 'cmd.exe', '/C', bin_name, '--stdio' } +end + +return { + default_config = { + cmd = cmd, + filetypes = { 'html' }, + root_dir = util.root_pattern('package.json', '.git'), + single_file_support = true, + settings = {}, + init_options = { + provideFormatter = true, + embeddedLanguages = { css = true, javascript = true }, + configurationSection = { 'html', 'css', 'javascript' }, + }, + }, + docs = { + description = [[ +https://github.com/hrsh7th/vscode-langservers-extracted +`vscode-html-language-server` can be installed via `npm`: +```sh +npm i -g vscode-langservers-extracted +``` +Neovim does not currently include built-in snippets. `vscode-html-language-server` only provides completions when snippet support is enabled. +To enable completion, install a snippet plugin and add the following override to your language client capabilities during setup. +The code-formatting feature of the lsp can be controlled with the `provideFormatter` option. +```lua +--Enable (broadcasting) snippet capability for completion +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true +require'lspconfig'.html.setup { + capabilities = capabilities, +} +``` +]], + }, +} diff --git a/nvim/lua/settings/lsp_config/jdtls.lua b/nvim/lua/settings/lsp_config/jdtls.lua new file mode 100644 index 0000000..1254f9b --- /dev/null +++ b/nvim/lua/settings/lsp_config/jdtls.lua @@ -0,0 +1,17 @@ +return { + settings = { + + java = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} + diff --git a/nvim/lua/settings/lsp_config/pyright.lua b/nvim/lua/settings/lsp_config/pyright.lua new file mode 100644 index 0000000..16513cc --- /dev/null +++ b/nvim/lua/settings/lsp_config/pyright.lua @@ -0,0 +1,55 @@ +local util = require 'lspconfig.util' + +local bin_name = 'pyright-langserver' +local cmd = { bin_name, '--stdio' } + +if vim.fn.has 'win32' == 1 then + cmd = { 'cmd.exe', '/C', bin_name, '--stdio' } +end + +local root_files = { + 'pyproject.toml', + 'setup.py', + 'setup.cfg', + 'requirements.txt', + 'Pipfile', + 'pyrightconfig.json', +} + +local function organize_imports() + local params = { + command = 'pyright.organizeimports', + arguments = { vim.uri_from_bufnr(0) }, + } + vim.lsp.buf.execute_command(params) +end + +return { + default_config = { + cmd = cmd, + filetypes = { 'python' }, + root_dir = util.root_pattern(unpack(root_files)), + single_file_support = true, + settings = { + python = { + analysis = { + autoSearchPaths = true, + useLibraryCodeForTypes = true, + diagnosticMode = 'workspace', + }, + }, + }, + }, + commands = { + PyrightOrganizeImports = { + organize_imports, + description = 'Organize Imports', + }, + }, + docs = { + description = [[ +https://github.com/microsoft/pyright +`pyright`, a static type checker and language server for python +]], + }, +} diff --git a/nvim/lua/settings/lsp_config/sumneko_lua.lua b/nvim/lua/settings/lsp_config/sumneko_lua.lua new file mode 100644 index 0000000..0ac454a --- /dev/null +++ b/nvim/lua/settings/lsp_config/sumneko_lua.lua @@ -0,0 +1,16 @@ +return { + settings = { + + Lua = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/nvim/lua/settings/lsp_config/texlab.lua b/nvim/lua/settings/lsp_config/texlab.lua new file mode 100644 index 0000000..be0e199 --- /dev/null +++ b/nvim/lua/settings/lsp_config/texlab.lua @@ -0,0 +1,16 @@ +return { + settings = { + + latex = { + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = { + [vim.fn.expand("$VIMRUNTIME/lua")] = true, + [vim.fn.stdpath("config") .. "/lua"] = true, + }, + }, + }, + }, +} diff --git a/nvim/lua/settings/lua_codeactions.lua b/nvim/lua/settings/lua_codeactions.lua new file mode 100644 index 0000000..1d24ff5 --- /dev/null +++ b/nvim/lua/settings/lua_codeactions.lua @@ -0,0 +1,14 @@ +local M = {} + +local lsp_util = vim.lsp.util + +function M.code_action_listener() + local context = { diagnostics = vim.lsp.diagnostic.get_line_diagnostics() } + local params = lsp_util.make_range_params() + params.context = context + vim.lsp.buf_request(0, 'textDocument/codeAction', params, function(err, _, result) + -- do something with result - e.g. check if empty and show some indication such as a sign + end) +end + +return M diff --git a/nvim/lua/settings/null-ls.lua b/nvim/lua/settings/null-ls.lua new file mode 100644 index 0000000..a3cfbf3 --- /dev/null +++ b/nvim/lua/settings/null-ls.lua @@ -0,0 +1,16 @@ +local null_ls = require("null-ls") + +null_ls.setup({ + on_attach = function(client, bufnr) + if client.server_capabilities.documentFormattingProvider then + vim.cmd("nnoremap f :lua vim.lsp.buf.formatting()") + + -- format on save + vim.cmd("autocmd BufWritePost lua vim.lsp.buf.formatting()") + end + + if client.server_capabilities.documentRangeFormattingProvider then + vim.cmd("xnoremap f :lua vim.lsp.buf.range_formatting({})") + end + end, +}) diff --git a/nvim/lua/settings/nvim-tree.lua b/nvim/lua/settings/nvim-tree.lua new file mode 100644 index 0000000..5c37fde --- /dev/null +++ b/nvim/lua/settings/nvim-tree.lua @@ -0,0 +1,103 @@ +-- following options are the default +-- each of these are documented in `:help nvim-tree.OPTION_NAME` + +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 + +-- Replaces auto_close +local tree_cb = nvim_tree_config.nvim_tree_callback +vim.api.nvim_create_autocmd("BufEnter", { + nested = true, + callback = function() + if #vim.api.nvim_list_wins() == 1 and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil then + vim.cmd "quit" + end + end +}) + +nvim_tree.setup { + disable_netrw = true, + hijack_netrw = true, + open_on_setup = false, + ignore_ft_on_setup = { + "startify", + "dashboard", + "alpha", + }, + open_on_tab = false, + hijack_cursor = false, + update_cwd = 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", + mappings = { + custom_only = false, + list = { + { key = { "l", "", "o" }, cb = tree_cb "edit" }, + { key = "h", cb = tree_cb "close_node" }, + { key = "v", cb = tree_cb "vsplit" }, + }, + }, + number = false, + relativenumber = false, + }, + trash = { + cmd = "trash", + require_confirm = true, + }, + actions = { + open_file = { + quit_on_open = true, + window_picker = { + enable = false, + }, + }, + }, + +-- unknown options as of 22.05 +-- +-- update_to_buf_dir = { +-- enable = true, +-- auto_open = true, +-- }, +-- auto_resize = true, +-- git_hl = 1, +-- root_folder_modifier = ":t", + +} diff --git a/nvim/lua/settings/options.lua b/nvim/lua/settings/options.lua new file mode 100644 index 0000000..6255f0a --- /dev/null +++ b/nvim/lua/settings/options.lua @@ -0,0 +1,33 @@ +local options = { + clipboard = "unnamedplus", + mouse = "a", + fileencoding = "utf-8", + relativenumber = true, + smartindent = true, + smartcase = true, + showmode = true, + termguicolors = true, + winbar = "", + ignorecase = true, + showtabline = 2, + timeoutlen = 100, -- time to wait for a mapped sequence to complete (in milliseconds) + undofile = true, -- enable persistent undoi updatetime = 300, -- faster completion (4000ms default) + writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited + expandtab = true, -- convert tabs to spaces + shiftwidth = 2, -- the number of spaces inserted for each indentation + tabstop = 2, -- insert 2 spaces for a tab + cursorline = true, + scrolloff = 8, -- is one of my fav + sidescrolloff = 8, + spell = true, + spelllang = "en_us", + mousemodel = "popup_setpos", +} + +--vim.opt.shortmess:append "c" + +for k, v in pairs(options) do + vim.opt[k] = v +end + + diff --git a/nvim/lua/settings/pairs.lua b/nvim/lua/settings/pairs.lua new file mode 100644 index 0000000..577e571 --- /dev/null +++ b/nvim/lua/settings/pairs.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 = "", + 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/nvim/lua/settings/plugins.lua b/nvim/lua/settings/plugins.lua new file mode 100644 index 0000000..417ad99 --- /dev/null +++ b/nvim/lua/settings/plugins.lua @@ -0,0 +1,42 @@ +local Plug = vim.fn['plug#'] +vim.call('plug#begin' ,'~/.config/nvim/plugged') +Plug('folke/twilight.nvim') +Plug('nvim-lua/popup.nvim') -- An implementation of the Popup API from vim in Neovim +Plug('nvim-lua/plenary.nvim') -- Useful lua functions used ny lots of plugins +Plug('EdenEast/nightfox.nvim') +Plug('kyazdani42/nvim-web-devicons') +Plug('feline-nvim/feline.nvim') +Plug('lewis6991/gitsigns.nvim') +Plug('tanvirtin/vgit.nvim') +Plug('nvim-lua/plenary.nvim') +Plug('b3nj5m1n/kommentary') +Plug('antoinemadec/FixCursorHold.nvim') +Plug('lambdalisue/fern.vim') +Plug('neovim/nvim-lspconfig') +Plug('nvim-treesitter/nvim-treesitter', {['do']= vim.fn[':TSUpdate']}) +Plug('williamboman/nvim-lsp-installer') +Plug('hrsh7th/nvim-cmp') +Plug('hrsh7th/cmp-nvim-lsp') +Plug('hrsh7th/cmp-buffer') +Plug('hrsh7th/cmp-path') +Plug('hrsh7th/cmp-cmdline') +Plug('saadparwaiz1/cmp_luasnip') +Plug('L3MON4D3/LuaSnip') +Plug('kyazdani42/nvim-tree.lua') +Plug('windwp/nvim-autopairs') +Plug('akinsho/bufferline.nvim') +Plug('numToStr/Comment.nvim') +Plug('lukas-reineke/indent-blankline.nvim') +Plug('lewis6991/impatient.nvim') +Plug('lewis6991/spellsitter.nvim') +Plug('moll/vim-bbye') +Plug('nvim-telescope/telescope.nvim') +Plug('ahmedkhalf/project.nvim') +Plug('goolord/alpha-nvim') +Plug('lervag/vimtex') +Plug('weilbith/nvim-code-action-menu') +Plug('mfussenegger/nvim-lint') +Plug 'jose-elias-alvarez/null-ls.nvim' +Plug 'MunifTanjim/prettier.nvim' +vim.call('plug#end') + diff --git a/nvim/lua/settings/prettier.lua b/nvim/lua/settings/prettier.lua new file mode 100644 index 0000000..91e8bb5 --- /dev/null +++ b/nvim/lua/settings/prettier.lua @@ -0,0 +1,19 @@ +local prettier = require("prettier") + +prettier.setup({ + bin = 'prettier', -- or `prettierd` + filetypes = { + "css", + "graphql", + "html", + "javascript", + "javascriptreact", + "json", + "less", + "markdown", + "scss", + "typescript", + "typescriptreact", + "yaml", + }, +}) diff --git a/nvim/lua/settings/project.lua b/nvim/lua/settings/project.lua new file mode 100644 index 0000000..27a1329 --- /dev/null +++ b/nvim/lua/settings/project.lua @@ -0,0 +1,48 @@ +local status_ok, project = pcall(require, "project_nvim") +if not status_ok then + return +end +project.setup({ + ---@usage set to false to disable project.nvim. + --- This is on by default since it's currently the expected behavior. + active = true, + + on_config_done = nil, + + ---@usage set to true to disable setting the current-woriking directory + --- Manual mode doesn't automatically change your root directory, so you have + --- the option to manually do so using `:ProjectRoot` command. + manual_mode = false, + + ---@usage Methods of detecting the root directory + --- Allowed values: **"lsp"** uses the native neovim lsp + --- **"pattern"** uses vim-rooter like glob pattern matching. Here + --- order matters: if one is not detected, the other is used as fallback. You + --- can also delete or rearangne the detection methods. + -- detection_methods = { "lsp", "pattern" }, -- NOTE: lsp detection will get annoying with multiple langs in one project + detection_methods = { "pattern" }, + + ---@usage patterns used to detect root dir, when **"pattern"** is in detection_methods + patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, + + ---@ Show hidden files in telescope when searching for files in a project + show_hidden = false, + + ---@usage When set to false, you will get a message when project.nvim changes your directory. + -- When set to false, you will get a message when project.nvim changes your directory. + silent_chdir = true, + + ---@usage list of lsp client names to ignore when using **lsp** detection. eg: { "efm", ... } + ignore_lsp = {}, + + ---@type string + ---@usage path to store the project history for use in telescope + datapath = vim.fn.stdpath("data"), +}) + +local tele_status_ok, telescope = pcall(require, "telescope") +if not tele_status_ok then + return +end + +telescope.load_extension('projects') diff --git a/nvim/lua/settings/test.log b/nvim/lua/settings/test.log new file mode 100644 index 0000000..1a0e222 --- /dev/null +++ b/nvim/lua/settings/test.log @@ -0,0 +1,57 @@ +** +(test.tex +LaTeX2e <2020-10-01> patch level 4 +L3 programming layer <2021-02-18> (article.cls +Document Class: article 2020/04/10 v1.4m Standard LaTeX document class +(size10.clo +File: size10.clo 2020/04/10 v1.4m Standard LaTeX file (size option) +) +\c@part=\count175 +\c@section=\count176 +\c@subsection=\count177 +\c@subsubsection=\count178 +\c@paragraph=\count179 +\c@subparagraph=\count180 +\c@figure=\count181 +\c@table=\count182 +\abovecaptionskip=\skip47 +\belowcaptionskip=\skip48 +\bibindent=\dimen138 +) (l3backend-xetex.def +File: l3backend-xetex.def 2021-03-18 L3 backend support: XeTeX +\c__kernel_sys_dvipdfmx_version_int=\count183 +\l__color_backend_stack_int=\count184 +\g__color_backend_stack_int=\count185 +\g__graphics_track_int=\count186 +\l__pdf_internal_box=\box47 +\g__pdf_backend_object_int=\count187 +\g__pdf_backend_annotation_int=\count188 +\g__pdf_backend_link_int=\count189 +) (test.aux) +\openout1 = `test.aux'. + +LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 2. +LaTeX Font Info: Trying to load font information for TS1+cmr on input line 2 +. + (ts1cmr.fd +File: ts1cmr.fd 2019/12/16 v2.5j Standard LaTeX font definitions +) +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for TU/lmr/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. +LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 2. +LaTeX Font Info: ... okay on input line 2. + [1 + +] (test.aux) ) +Output written on test.xdv (1 page, 624 bytes). diff --git a/nvim/lua/settings/treesitter.lua b/nvim/lua/settings/treesitter.lua new file mode 100644 index 0000000..4df0e45 --- /dev/null +++ b/nvim/lua/settings/treesitter.lua @@ -0,0 +1,21 @@ +local status_ok, _ = pcall(require, "nvim-treesitter.configs") +if not status_ok then + return +end + +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" + ensure_installed = { "latex" , "c", "cpp" , "lua", "haskell" , "java" , "javascript" , "typescript" }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} + +local status_ok2, _ = pcall(require, "spellsitter") +if not status_ok2 then + return +end + +require("spellsitter").setup() + diff --git a/nvim/lua/settings/vimtex.lua b/nvim/lua/settings/vimtex.lua new file mode 100644 index 0000000..d27a126 --- /dev/null +++ b/nvim/lua/settings/vimtex.lua @@ -0,0 +1,8 @@ +--vim.cmd('let g:vimtex_view_method = "zathura"') + +vim.cmd('let g:vimtex_view_general_viewer = "okular"') +--let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex' + +vim.cmd('let g:vimtex_compiler_method = "latexmk"') + +--let maplocalleader = "," diff --git a/nvim/plugged/Comment.nvim b/nvim/plugged/Comment.nvim new file mode 160000 index 0000000..3c69bab --- /dev/null +++ b/nvim/plugged/Comment.nvim @@ -0,0 +1 @@ +Subproject commit 3c69bab36569d5d0321351ec956fc43a8d409fb0 diff --git a/nvim/plugged/FixCursorHold.nvim b/nvim/plugged/FixCursorHold.nvim new file mode 160000 index 0000000..1bfb32e --- /dev/null +++ b/nvim/plugged/FixCursorHold.nvim @@ -0,0 +1 @@ +Subproject commit 1bfb32e7ba1344925ad815cb0d7f901dbc0ff7c1 diff --git a/nvim/plugged/LuaSnip b/nvim/plugged/LuaSnip new file mode 160000 index 0000000..52f4aed --- /dev/null +++ b/nvim/plugged/LuaSnip @@ -0,0 +1 @@ +Subproject commit 52f4aed58db32a3a03211d31d2b12c0495c45580 diff --git a/nvim/plugged/alpha-nvim b/nvim/plugged/alpha-nvim new file mode 160000 index 0000000..4781fcf --- /dev/null +++ b/nvim/plugged/alpha-nvim @@ -0,0 +1 @@ +Subproject commit 4781fcfea5ddc1a92d41b32dc325132ed6fce7a8 diff --git a/nvim/plugged/bufferline.nvim b/nvim/plugged/bufferline.nvim new file mode 160000 index 0000000..c78b3ec --- /dev/null +++ b/nvim/plugged/bufferline.nvim @@ -0,0 +1 @@ +Subproject commit c78b3ecf9539a719828bca82fc7ddb9b3ba0c353 diff --git a/nvim/plugged/cmp-buffer b/nvim/plugged/cmp-buffer new file mode 160000 index 0000000..12463cf --- /dev/null +++ b/nvim/plugged/cmp-buffer @@ -0,0 +1 @@ +Subproject commit 12463cfcd9b14052f9effccbf1d84caa7a2d57f0 diff --git a/nvim/plugged/cmp-cmdline b/nvim/plugged/cmp-cmdline new file mode 160000 index 0000000..c36ca4b --- /dev/null +++ b/nvim/plugged/cmp-cmdline @@ -0,0 +1 @@ +Subproject commit c36ca4bc1dedb12b4ba6546b96c43896fd6e7252 diff --git a/nvim/plugged/cmp-nvim-lsp b/nvim/plugged/cmp-nvim-lsp new file mode 160000 index 0000000..affe808 --- /dev/null +++ b/nvim/plugged/cmp-nvim-lsp @@ -0,0 +1 @@ +Subproject commit affe808a5c56b71630f17aa7c38e15c59fd648a8 diff --git a/nvim/plugged/cmp-path b/nvim/plugged/cmp-path new file mode 160000 index 0000000..466b6b8 --- /dev/null +++ b/nvim/plugged/cmp-path @@ -0,0 +1 @@ +Subproject commit 466b6b8270f7ba89abd59f402c73f63c7331ff6e diff --git a/nvim/plugged/cmp_luasnip b/nvim/plugged/cmp_luasnip new file mode 160000 index 0000000..a9de941 --- /dev/null +++ b/nvim/plugged/cmp_luasnip @@ -0,0 +1 @@ +Subproject commit a9de941bcbda508d0a45d28ae366bb3f08db2e36 diff --git a/nvim/plugged/feline.nvim b/nvim/plugged/feline.nvim new file mode 160000 index 0000000..1ea4267 --- /dev/null +++ b/nvim/plugged/feline.nvim @@ -0,0 +1 @@ +Subproject commit 1ea42671c523a080a01c62c40c2c8e7fc0139a8f diff --git a/nvim/plugged/fern.vim b/nvim/plugged/fern.vim new file mode 160000 index 0000000..7ba49dd --- /dev/null +++ b/nvim/plugged/fern.vim @@ -0,0 +1 @@ +Subproject commit 7ba49dd915c32ede51a6f6db3c4367748707a156 diff --git a/nvim/plugged/gitsigns.nvim b/nvim/plugged/gitsigns.nvim new file mode 160000 index 0000000..27aeb2e --- /dev/null +++ b/nvim/plugged/gitsigns.nvim @@ -0,0 +1 @@ +Subproject commit 27aeb2e715c32cbb99aa0b326b31739464b61644 diff --git a/nvim/plugged/impatient.nvim b/nvim/plugged/impatient.nvim new file mode 160000 index 0000000..8596ca8 --- /dev/null +++ b/nvim/plugged/impatient.nvim @@ -0,0 +1 @@ +Subproject commit 8596ca809595d9dd694d7afc6153760b729f1239 diff --git a/nvim/plugged/indent-blankline.nvim b/nvim/plugged/indent-blankline.nvim new file mode 160000 index 0000000..6177a59 --- /dev/null +++ b/nvim/plugged/indent-blankline.nvim @@ -0,0 +1 @@ +Subproject commit 6177a59552e35dfb69e1493fd68194e673dc3ee2 diff --git a/nvim/plugged/kommentary b/nvim/plugged/kommentary new file mode 160000 index 0000000..533d768 --- /dev/null +++ b/nvim/plugged/kommentary @@ -0,0 +1 @@ +Subproject commit 533d768a140b248443da8346b88e88db704212ab diff --git a/nvim/plugged/nightfox.nvim b/nvim/plugged/nightfox.nvim new file mode 160000 index 0000000..e602aca --- /dev/null +++ b/nvim/plugged/nightfox.nvim @@ -0,0 +1 @@ +Subproject commit e602acaad91a546be2250e026f0bdc6be8c8a44c diff --git a/nvim/plugged/null-ls.nvim b/nvim/plugged/null-ls.nvim new file mode 160000 index 0000000..8c90ccf --- /dev/null +++ b/nvim/plugged/null-ls.nvim @@ -0,0 +1 @@ +Subproject commit 8c90ccf7ffbdeb49da415837ec45e6ac457d5c60 diff --git a/nvim/plugged/nvim-autopairs b/nvim/plugged/nvim-autopairs new file mode 160000 index 0000000..b9cc0a2 --- /dev/null +++ b/nvim/plugged/nvim-autopairs @@ -0,0 +1 @@ +Subproject commit b9cc0a26f3b5610ce772004e1efd452b10b36bc9 diff --git a/nvim/plugged/nvim-cmp b/nvim/plugged/nvim-cmp new file mode 160000 index 0000000..033a817 --- /dev/null +++ b/nvim/plugged/nvim-cmp @@ -0,0 +1 @@ +Subproject commit 033a817ced907c8bcdcbe3355d7ea67446264f4b diff --git a/nvim/plugged/nvim-code-action-menu b/nvim/plugged/nvim-code-action-menu new file mode 160000 index 0000000..ee59940 --- /dev/null +++ b/nvim/plugged/nvim-code-action-menu @@ -0,0 +1 @@ +Subproject commit ee599409ed6ab31f6d7115e9c5c4550336470c14 diff --git a/nvim/plugged/nvim-lint b/nvim/plugged/nvim-lint new file mode 160000 index 0000000..1d597b8 --- /dev/null +++ b/nvim/plugged/nvim-lint @@ -0,0 +1 @@ +Subproject commit 1d597b89bd679a8f6c930aa1ad9715b2c058aa4d diff --git a/nvim/plugged/nvim-lsp-installer b/nvim/plugged/nvim-lsp-installer new file mode 160000 index 0000000..d941383 --- /dev/null +++ b/nvim/plugged/nvim-lsp-installer @@ -0,0 +1 @@ +Subproject commit d941383301598590092f497822e5f376724c831c diff --git a/nvim/plugged/nvim-lspconfig b/nvim/plugged/nvim-lspconfig new file mode 160000 index 0000000..eb03999 --- /dev/null +++ b/nvim/plugged/nvim-lspconfig @@ -0,0 +1 @@ +Subproject commit eb039998b1bcdafbd5d3b8ff917c871f5010c1e4 diff --git a/nvim/plugged/nvim-tree.lua b/nvim/plugged/nvim-tree.lua new file mode 160000 index 0000000..1caca62 --- /dev/null +++ b/nvim/plugged/nvim-tree.lua @@ -0,0 +1 @@ +Subproject commit 1caca6285427ebd2b4f0eb10f4d1ae3956ff09c0 diff --git a/nvim/plugged/nvim-treesitter b/nvim/plugged/nvim-treesitter new file mode 160000 index 0000000..55bfb4f --- /dev/null +++ b/nvim/plugged/nvim-treesitter @@ -0,0 +1 @@ +Subproject commit 55bfb4fcc9332c75a62401bc0f88bb55f9159da9 diff --git a/nvim/plugged/nvim-web-devicons b/nvim/plugged/nvim-web-devicons new file mode 160000 index 0000000..8d2c533 --- /dev/null +++ b/nvim/plugged/nvim-web-devicons @@ -0,0 +1 @@ +Subproject commit 8d2c5337f0a2d0a17de8e751876eeb192b32310e diff --git a/nvim/plugged/plenary.nvim b/nvim/plugged/plenary.nvim new file mode 160000 index 0000000..54b2e3d --- /dev/null +++ b/nvim/plugged/plenary.nvim @@ -0,0 +1 @@ +Subproject commit 54b2e3d58f567983feabaeb9408eccf6b7f32206 diff --git a/nvim/plugged/popup.nvim b/nvim/plugged/popup.nvim new file mode 160000 index 0000000..b7404d3 --- /dev/null +++ b/nvim/plugged/popup.nvim @@ -0,0 +1 @@ +Subproject commit b7404d35d5d3548a82149238289fa71f7f6de4ac diff --git a/nvim/plugged/prettier.nvim b/nvim/plugged/prettier.nvim new file mode 160000 index 0000000..ee5e349 --- /dev/null +++ b/nvim/plugged/prettier.nvim @@ -0,0 +1 @@ +Subproject commit ee5e3496926e07d167695998552074bd0629fbfb diff --git a/nvim/plugged/project.nvim b/nvim/plugged/project.nvim new file mode 160000 index 0000000..541115e --- /dev/null +++ b/nvim/plugged/project.nvim @@ -0,0 +1 @@ +Subproject commit 541115e762764bc44d7d3bf501b6e367842d3d4f diff --git a/nvim/plugged/spellsitter.nvim b/nvim/plugged/spellsitter.nvim new file mode 160000 index 0000000..430a253 --- /dev/null +++ b/nvim/plugged/spellsitter.nvim @@ -0,0 +1 @@ +Subproject commit 430a25393abbf482bddf03c224cd5b8eeb27b5e1 diff --git a/nvim/plugged/telescope.nvim b/nvim/plugged/telescope.nvim new file mode 160000 index 0000000..e6b69b1 --- /dev/null +++ b/nvim/plugged/telescope.nvim @@ -0,0 +1 @@ +Subproject commit e6b69b1488c598ff7b461c4d9cecad57ef708f9b diff --git a/nvim/plugged/twilight.nvim b/nvim/plugged/twilight.nvim new file mode 160000 index 0000000..8ab43c0 --- /dev/null +++ b/nvim/plugged/twilight.nvim @@ -0,0 +1 @@ +Subproject commit 8ab43c0fdc246fdd82382d7ef4ec383f8f755ef9 diff --git a/nvim/plugged/vgit.nvim b/nvim/plugged/vgit.nvim new file mode 160000 index 0000000..ee9081c --- /dev/null +++ b/nvim/plugged/vgit.nvim @@ -0,0 +1 @@ +Subproject commit ee9081c304b44509b2f4267f1f7addc303f9fb9b diff --git a/nvim/plugged/vim-bbye b/nvim/plugged/vim-bbye new file mode 160000 index 0000000..25ef93a --- /dev/null +++ b/nvim/plugged/vim-bbye @@ -0,0 +1 @@ +Subproject commit 25ef93ac5a87526111f43e5110675032dbcacf56 diff --git a/nvim/plugged/vimtex b/nvim/plugged/vimtex new file mode 160000 index 0000000..754bf6c --- /dev/null +++ b/nvim/plugged/vimtex @@ -0,0 +1 @@ +Subproject commit 754bf6c97272e9bf479057b44cc968c4dad34753