diff --git a/nivm/lua/settings/autocommands.lua b/nivm/lua/settings/autocommands.lua new file mode 100644 index 0000000..ec7f220 --- /dev/null +++ b/nivm/lua/settings/autocommands.lua @@ -0,0 +1,2 @@ +vim.cmd('let g:vimtex_view_general_viewer = "evince"') +vim.cmd('let g:vimtex_compiler_method = "latexmk"') diff --git a/nivm/lua/settings/bufferline.lua b/nivm/lua/settings/bufferline.lua new file mode 100644 index 0000000..cdf728b --- /dev/null +++ b/nivm/lua/settings/bufferline.lua @@ -0,0 +1,146 @@ +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 = { + style = 'icon', + }, + buffer_close_icon = "", + -- buffer_close_icon = '', + modified_icon = "●", + close_icon = "", + -- close_icon = '', + left_trunc_marker = "", + right_trunc_marker = "", + -- 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, + offsets = { { filetype = "NvimTree", text = "", padding = 1 } }, + show_buffer_icons = true, + show_buffer_close_icons = true, + show_close_icon = true, + show_tab_indicators = false, + 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 = "slant", -- | "thick" | "thin" | { 'any', 'any' }, + enforce_regular_tabs = true, + always_show_bufferline = true, + hover = { + enabled = true, + delay = 200, + reveal = {'close'} + }, + -- 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 = { + fg = { attribute = "fg", highlight = "#ff0000" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + background = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + -- buffer_selected = { + -- guifg = {attribute='fg',highlight='#ff0000'}, + -- guibg = {attribute='bg',highlight='#0000ff'}, + -- gui = 'none' + -- }, + buffer_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + close_button = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + close_button_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + -- close_button_selected = { + -- guifg = {attribute='fg',highlight='TabLineSel'}, + -- guibg ={attribute='bg',highlight='TabLineSel'} + -- }, + + tab_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + tab = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + tab_close = { + -- guifg = {attribute='fg',highlight='LspDiagnosticsDefaultError'}, + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + + duplicate_selected = { + fg = { attribute = "fg", highlight = "TabLineSel" }, + bg = { attribute = "bg", highlight = "TabLineSel" }, + italic = true, + }, + duplicate_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + duplicate = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + italic = true, + }, + + modified = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + modified_selected = { + fg = { attribute = "fg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + modified_visible = { + fg = { attribute = "fg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + + separator = { + fg = { attribute = "bg", highlight = "TabLine" }, + bg = { attribute = "bg", highlight = "TabLine" }, + }, + separator_selected = { + fg = { attribute = "bg", highlight = "Normal" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + separator_visible = { + fg = {attribute='bg',highlight='TabLine'}, + bg = {attribute='bg',highlight='TabLine'} + }, + indicator_selected = { + fg = { attribute = "fg", highlight = "LspDiagnosticsDefaultHint" }, + bg = { attribute = "bg", highlight = "Normal" }, + }, + }, +} diff --git a/nivm/lua/settings/cmp.lua b/nivm/lua/settings/cmp.lua new file mode 100644 index 0000000..ef9069a --- /dev/null +++ b/nivm/lua/settings/cmp.lua @@ -0,0 +1,133 @@ +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 + +vim.cmd('let g:snipMate = {"snippet_version" : 1 }') +require("luasnip/loaders/from_vscode").lazy_load() +require("luasnip.loaders.from_snipmate").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/nivm/lua/settings/colorscheme.lua b/nivm/lua/settings/colorscheme.lua new file mode 100644 index 0000000..04f4019 --- /dev/null +++ b/nivm/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/nivm/lua/settings/comment.lua b/nivm/lua/settings/comment.lua new file mode 100644 index 0000000..2fa4a56 --- /dev/null +++ b/nivm/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/nivm/lua/settings/cpp-dap.lua b/nivm/lua/settings/cpp-dap.lua new file mode 100644 index 0000000..5f86d08 --- /dev/null +++ b/nivm/lua/settings/cpp-dap.lua @@ -0,0 +1,45 @@ +local dap = require('dap') +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = '/home/dashie/.config/nvim/plugged/cpptools/extension/debugAdapters/bin/OpenDebugAD7', +} + +dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = "Launch file --gui", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + args = {'--gui'}, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp diff --git a/nivm/lua/settings/dap-ui.lua b/nivm/lua/settings/dap-ui.lua new file mode 100644 index 0000000..cbd3d24 --- /dev/null +++ b/nivm/lua/settings/dap-ui.lua @@ -0,0 +1,73 @@ +require("dapui").setup({ + icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + -- Expand lines larger than the window + -- Requires >= 0.7 + expand_lines = vim.fn.has("nvim-0.7") == 1, + -- Layouts define sections of the screen to place windows. + -- The position can be "left", "right", "top" or "bottom". + -- The size specifies the height/width depending on position. It can be an Int + -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while + -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) + -- Elements are the elements shown in the layout (in order). + -- Layouts are opened in order so that earlier layouts take priority in window sizing. + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "scopes", size = 0.25 }, + "breakpoints", + "stacks", + "watches", + }, + size = 40, -- 40 columns + position = "left", + }, + { + elements = { + "repl", + "console", + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, + controls = { + -- Requires Neovim nightly (or 0.8 when released) + enabled = true, + -- Display controls in this element + element = "repl", + icons = { + pause = "", + play = "", + step_into = "", + step_over = "", + step_out = "", + step_back = "", + run_last = "↻", + terminate = "□", + }, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "" }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + max_value_lines = 100, -- Can be integer or nil. + } +}) +require("dapui").setup() diff --git a/nivm/lua/settings/dap.lua b/nivm/lua/settings/dap.lua new file mode 100644 index 0000000..1a26926 --- /dev/null +++ b/nivm/lua/settings/dap.lua @@ -0,0 +1,126 @@ +local dap = require('dap') +dap.adapters.cppdbg = { + id = 'cppdbg', + type = 'executable', + command = '/home/dashie/.config/nvim/plugged/cpptools/extension/debugAdapters/bin/OpenDebugAD7', +} + +dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = "Launch file --gui", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + args = {'--gui'}, + cwd = '${workspaceFolder}', + stopAtEntry = true, + }, + { + name = 'Attach to gdbserver :1234', + type = 'cppdbg', + request = 'launch', + MIMode = 'gdb', + miDebuggerServerAddress = 'localhost:1234', + miDebuggerPath = '/usr/bin/gdb', + cwd = '${workspaceFolder}', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/build/', 'file') + end, + }, +} + +dap.configurations.c = dap.configurations.cpp +dap.configurations.rust = dap.configurations.cpp + +require("dapui").setup({ + icons = { expanded = "▾", collapsed = "▸", current_frame = "▸" }, + mappings = { + -- Use a table to apply multiple mappings + expand = { "", "<2-LeftMouse>" }, + open = "o", + remove = "d", + edit = "e", + repl = "r", + toggle = "t", + }, + -- Expand lines larger than the window + -- Requires >= 0.7 + expand_lines = vim.fn.has("nvim-0.7") == 1, + -- Layouts define sections of the screen to place windows. + -- The position can be "left", "right", "top" or "bottom". + -- The size specifies the height/width depending on position. It can be an Int + -- or a Float. Integer specifies height/width directly (i.e. 20 lines/columns) while + -- Float value specifies percentage (i.e. 0.3 - 30% of available lines/columns) + -- Elements are the elements shown in the layout (in order). + -- Layouts are opened in order so that earlier layouts take priority in window sizing. + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + { id = "scopes", size = 0.25 }, + "breakpoints", + "stacks", + "watches", + }, + size = 40, -- 40 columns + position = "left", + }, + { + elements = { + "repl", + "console", + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, + controls = { + -- Requires Neovim nightly (or 0.8 when released) + enabled = true, + -- Display controls in this element + element = "repl", + icons = { + pause = "", + play = "", + step_into = "", + step_over = "", + step_out = "", + step_back = "", + run_last = "↻", + terminate = "□", + }, + }, + floating = { + max_height = nil, -- These can be integers or a float between 0 and 1. + max_width = nil, -- Floats will be treated as percentage of your screen. + border = "single", -- Border style. Can be "single", "double" or "rounded" + mappings = { + close = { "q", "" }, + }, + }, + windows = { indent = 1 }, + render = { + max_type_length = nil, -- Can be integer or nil. + max_value_lines = 100, -- Can be integer or nil. + } +}) +require("mason-nvim-dap").setup({ + ensure_installed = { "cpptools", + "bash-debug-adapter", + "firefox-debug-adapter", + "js-debug-adapter", + "node-debug2-adapter" + } +}) diff --git a/nivm/lua/settings/dashboard.lua b/nivm/lua/settings/dashboard.lua new file mode 100644 index 0000000..6ab1ec9 --- /dev/null +++ b/nivm/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/nivm/lua/settings/devicons.lua b/nivm/lua/settings/devicons.lua new file mode 100644 index 0000000..57c1386 --- /dev/null +++ b/nivm/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/nivm/lua/settings/feline.lua b/nivm/lua/settings/feline.lua new file mode 100644 index 0000000..afda8a9 --- /dev/null +++ b/nivm/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/nivm/lua/settings/gitsigns.lua b/nivm/lua/settings/gitsigns.lua new file mode 100644 index 0000000..91fa65b --- /dev/null +++ b/nivm/lua/settings/gitsigns.lua @@ -0,0 +1 @@ +require('gitsigns').setup() diff --git a/nivm/lua/settings/haskell.lua b/nivm/lua/settings/haskell.lua new file mode 100644 index 0000000..d463870 --- /dev/null +++ b/nivm/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/nivm/lua/settings/impatient.lua b/nivm/lua/settings/impatient.lua new file mode 100644 index 0000000..84419e0 --- /dev/null +++ b/nivm/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/nivm/lua/settings/indentline.lua b/nivm/lua/settings/indentline.lua new file mode 100644 index 0000000..fdf5870 --- /dev/null +++ b/nivm/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/nivm/lua/settings/keymaps.lua b/nivm/lua/settings/keymaps.lua new file mode 100644 index 0000000..f1f6ae3 --- /dev/null +++ b/nivm/lua/settings/keymaps.lua @@ -0,0 +1,23 @@ +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) +keymap("n", "", ':lua require("dap").toggle_breakpoint()', opts) +keymap("n", "", ':lua require("dap").step_over()', opts) +keymap("n", "", ':lua require("dap").step_into()', opts) +keymap("n", "", ':lua require("dap").continue()', opts) +keymap("n", "", ':lua require("dap").close() :lua require("dapui").toggle()', opts) +keymap("n", "", ':lua require("dap").continue() :lua require("dapui").toggle()', opts) + +keymap("n", "t", ':lua require("nvim-tree").toggle()', opts) +keymap("n", "f", ':lua require("nvim-tree").focus()', opts) + +keymap("n", "", ':BufferLineMoveNext', opts) +keymap("n", "", ':BufferLineMovePrev', opts) + +keymap("n", "", ':lua vim.lsp.buf.format { async = true }', opts) diff --git a/nivm/lua/settings/lint.lua b/nivm/lua/settings/lint.lua new file mode 100644 index 0000000..ad45d4c --- /dev/null +++ b/nivm/lua/settings/lint.lua @@ -0,0 +1,4 @@ +require('lint').linters_by_ft = { + javascript = {'eslint',}, + react = {'eslint',}, +} diff --git a/nivm/lua/settings/lsp.lua b/nivm/lua/settings/lsp.lua new file mode 100644 index 0000000..beddafb --- /dev/null +++ b/nivm/lua/settings/lsp.lua @@ -0,0 +1,158 @@ +local status_ok, _ = pcall(require, "lspconfig") +if not status_ok then + return +end + +require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } +}) + +require("mason-lspconfig").setup({ + ensure_installed = { + "cssls", -- css + "html", -- html + "eslint", -- latex + "clangd", -- cpp / c + "tsserver", -- python + "texlab", -- latex + "sumneko_lua", -- lua + "pyright", -- python + "rust_analyzer", -- rust + "jdtls", -- jdtls + "cmake", -- cmake + "bashls", -- shell + "ansiblels", -- ansible + "csharp_ls", -- dotnot + "hls" -- haskel + }, + automatic_installation = true +}) + +require('lspconfig')['cssls'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['html'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['eslint'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['clangd'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['tsserver'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['texlab'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['sumneko_lua'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['pyright'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['rust_analyzer'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['jdtls'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['cmake'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['bashls'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['ansiblels'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['csharp_ls'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + +require('lspconfig')['hls'].setup{ + capabilities = capabilities, + on_attach = on_attach +} + + + + + +--local status_ok2, lsp_installer = pcall(require, "mason") +--if not status_ok2 then +-- return +--end +-- +--local servers = {"jdtls" , "sumneko_lua" , "texlab", "pyright" , "eslint_d" , "html" , "cssls" , "rust_analyzer" , "bashls" , "csharp_ls" , "sqls" , "clangd" } +-- +--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/nivm/lua/settings/lsp_config/bashls.lua b/nivm/lua/settings/lsp_config/bashls.lua new file mode 100644 index 0000000..e2392e4 --- /dev/null +++ b/nivm/lua/settings/lsp_config/bashls.lua @@ -0,0 +1,37 @@ +local util = require 'lspconfig.util' + +local bin_name = 'bash-language-server' +local cmd = { bin_name, 'start' } + +if vim.fn.has 'win32' == 1 then + cmd = { 'cmd.exe', '/C', bin_name, 'start' } +end + +return { + default_config = { + cmd = cmd, + cmd_env = { + -- Prevent recursive scanning which will cause issues when opening a file + -- directly in the home directory (e.g. ~/foo.sh). + -- + -- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)". + GLOB_PATTERN = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)', + }, + filetypes = { 'sh' }, + root_dir = util.find_git_ancestor, + single_file_support = true, + }, + docs = { + description = [[ +https://github.com/mads-hartmann/bash-language-server +`bash-language-server` can be installed via `npm`: +```sh +npm i -g bash-language-server +``` +Language server for bash, written using tree sitter in typescript. +]], + default_config = { + root_dir = [[util.find_git_ancestor]], + }, + }, +} diff --git a/nivm/lua/settings/lsp_config/clangd.lua b/nivm/lua/settings/lsp_config/clangd.lua new file mode 100644 index 0000000..65da8c0 --- /dev/null +++ b/nivm/lua/settings/lsp_config/clangd.lua @@ -0,0 +1,87 @@ +local util = require 'lspconfig.util' + +-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader +local function switch_source_header(bufnr) + bufnr = util.validate_bufnr(bufnr) + local clangd_client = util.get_active_client_by_name(bufnr, 'clangd') + local params = { uri = vim.uri_from_bufnr(bufnr) } + if clangd_client then + clangd_client.request('textDocument/switchSourceHeader', params, function(err, result) + if err then + error(tostring(err)) + end + if not result then + print 'Corresponding file cannot be determined' + return + end + vim.api.nvim_command('edit ' .. vim.uri_to_fname(result)) + end, bufnr) + else + print 'method textDocument/switchSourceHeader is not supported by any servers active on the current buffer' + end +end + +local root_files = { + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', -- AutoTools +} + +local default_capabilities = { + textDocument = { + completion = { + editsNearCursor = true, + }, + }, + offsetEncoding = { 'utf-8', 'utf-16' }, +} + +return { + default_config = { + cmd = { 'clangd' }, + filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda', 'proto' }, + root_dir = function(fname) + return util.root_pattern(unpack(root_files))(fname) or util.find_git_ancestor(fname) + end, + single_file_support = true, + capabilities = default_capabilities, + }, + commands = { + ClangdSwitchSourceHeader = { + function() + switch_source_header(0) + end, + description = 'Switch between source/header', + }, + }, + docs = { + description = [[ +https://clangd.llvm.org/installation.html +- **NOTE:** Clang >= 11 is recommended! See [#23](https://github.com/neovim/nvim-lsp/issues/23). +- If `compile_commands.json` lives in a build directory, you should + symlink it to the root of your source tree. + ``` + ln -s /path/to/myproject/build/compile_commands.json /path/to/myproject/ + ``` +- clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) + specified as compile_commands.json, see https://clangd.llvm.org/installation#compile_commandsjson +]], + default_config = { + root_dir = [[ + root_pattern( + '.clangd', + '.clang-tidy', + '.clang-format', + 'compile_commands.json', + 'compile_flags.txt', + 'configure.ac', + '.git' + ) + ]], + capabilities = [[default capabilities, with offsetEncoding utf-8]], + }, + }, +} diff --git a/nivm/lua/settings/lsp_config/csharp_ls.lua b/nivm/lua/settings/lsp_config/csharp_ls.lua new file mode 100644 index 0000000..a03a25b --- /dev/null +++ b/nivm/lua/settings/lsp_config/csharp_ls.lua @@ -0,0 +1,20 @@ +local util = require 'lspconfig.util' + +return { + default_config = { + cmd = { 'csharp-ls' }, + root_dir = util.root_pattern('*.sln', '*.csproj', '*.fsproj', '.git'), + filetypes = { 'cs' }, + init_options = { + AutomaticWorkspaceInit = true, + }, + }, + docs = { + description = [[ +https://github.com/razzmatazz/csharp-language-server +Language Server for C#. +csharp-ls requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed. +The preferred way to install csharp-ls is with `dotnet tool install --global csharp-ls`. + ]], + }, +} diff --git a/nivm/lua/settings/lsp_config/cssls.lua b/nivm/lua/settings/lsp_config/cssls.lua new file mode 100644 index 0000000..d1b7aa6 --- /dev/null +++ b/nivm/lua/settings/lsp_config/cssls.lua @@ -0,0 +1,43 @@ +local util = require 'lspconfig.util' + +local bin_name = 'vscode-css-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 = { 'css', 'scss', 'less' }, + root_dir = util.root_pattern('package.json', '.git'), + single_file_support = true, + settings = { + css = { validate = true }, + scss = { validate = true }, + less = { validate = true }, + }, + }, + docs = { + description = [[ +https://github.com/hrsh7th/vscode-langservers-extracted +`css-languageserver` can be installed via `npm`: +```sh +npm i -g vscode-langservers-extracted +``` +Neovim does not currently include built-in snippets. `vscode-css-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. +```lua +--Enable (broadcasting) snippet capability for completion +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.completion.completionItem.snippetSupport = true +require'lspconfig'.cssls.setup { + capabilities = capabilities, +} +``` +]], + default_config = { + root_dir = [[root_pattern("package.json", ".git") or bufdir]], + }, + }, +} diff --git a/nivm/lua/settings/lsp_config/eslint.lua b/nivm/lua/settings/lsp_config/eslint.lua new file mode 100644 index 0000000..d456970 --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/eslint_d.lua b/nivm/lua/settings/lsp_config/eslint_d.lua new file mode 100644 index 0000000..d456970 --- /dev/null +++ b/nivm/lua/settings/lsp_config/eslint_d.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/nivm/lua/settings/lsp_config/handlers.lua b/nivm/lua/settings/lsp_config/handlers.lua new file mode 100644 index 0000000..5695f84 --- /dev/null +++ b/nivm/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.format { async = true }' ]] +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/nivm/lua/settings/lsp_config/html.lua b/nivm/lua/settings/lsp_config/html.lua new file mode 100644 index 0000000..b1771d3 --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/jdtls.lua b/nivm/lua/settings/lsp_config/jdtls.lua new file mode 100644 index 0000000..1254f9b --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/pyright.lua b/nivm/lua/settings/lsp_config/pyright.lua new file mode 100644 index 0000000..16513cc --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/rust_analyzer.lua b/nivm/lua/settings/lsp_config/rust_analyzer.lua new file mode 100644 index 0000000..bc85596 --- /dev/null +++ b/nivm/lua/settings/lsp_config/rust_analyzer.lua @@ -0,0 +1,77 @@ +local util = require 'lspconfig.util' + +local function reload_workspace(bufnr) + bufnr = util.validate_bufnr(bufnr) + vim.lsp.buf_request(bufnr, 'rust-analyzer/reloadWorkspace', nil, function(err) + if err then + error(tostring(err)) + end + vim.notify 'Cargo workspace reloaded' + end) +end + +return { + default_config = { + cmd = { 'rust-analyzer' }, + filetypes = { 'rust' }, + root_dir = function(fname) + local cargo_crate_dir = util.root_pattern 'Cargo.toml'(fname) + local cmd = { 'cargo', 'metadata', '--no-deps', '--format-version', '1' } + if cargo_crate_dir ~= nil then + cmd[#cmd + 1] = '--manifest-path' + cmd[#cmd + 1] = util.path.join(cargo_crate_dir, 'Cargo.toml') + end + local cargo_metadata = '' + local cargo_metadata_err = '' + local cm = vim.fn.jobstart(cmd, { + on_stdout = function(_, d, _) + cargo_metadata = table.concat(d, '\n') + end, + on_stderr = function(_, d, _) + cargo_metadata_err = table.concat(d, '\n') + end, + stdout_buffered = true, + stderr_buffered = true, + }) + if cm > 0 then + cm = vim.fn.jobwait({ cm })[1] + else + cm = -1 + end + local cargo_workspace_dir = nil + if cm == 0 then + cargo_workspace_dir = vim.json.decode(cargo_metadata)['workspace_root'] + else + vim.notify( + string.format('[lspconfig] cmd (%q) failed:\n%s', table.concat(cmd, ' '), cargo_metadata_err), + vim.log.levels.WARN + ) + end + return util.path.sanitize(cargo_workspace_dir) + or cargo_crate_dir + or util.root_pattern 'rust-project.json'(fname) + or util.find_git_ancestor(fname) + end, + settings = { + ['rust-analyzer'] = {}, + }, + }, + commands = { + CargoReload = { + function() + reload_workspace(0) + end, + description = 'Reload current cargo workspace', + }, + }, + docs = { + description = [[ +https://github.com/rust-analyzer/rust-analyzer +rust-analyzer (aka rls 2.0), a language server for Rust +See [docs](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#settings) for extra settings. + ]], + default_config = { + root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]], + }, + }, +} diff --git a/nivm/lua/settings/lsp_config/sqls.lua b/nivm/lua/settings/lsp_config/sqls.lua new file mode 100644 index 0000000..bdbf27b --- /dev/null +++ b/nivm/lua/settings/lsp_config/sqls.lua @@ -0,0 +1,23 @@ +local util = require 'lspconfig.util' + +return { + default_config = { + cmd = { 'sqls' }, + filetypes = { 'sql', 'mysql' }, + root_dir = util.root_pattern 'config.yml', + single_file_support = true, + settings = {}, + }, + docs = { + description = [[ +https://github.com/lighttiger2505/sqls +```lua +require'lspconfig'.sqls.setup{ + cmd = {"path/to/command", "-config", "path/to/config.yml"}; + ... +} +``` +Sqls can be installed via `go get github.com/lighttiger2505/sqls`. Instructions for compiling Sqls from the source can be found at [lighttiger2505/sqls](https://github.com/lighttiger2505/sqls). + ]], + }, +} diff --git a/nivm/lua/settings/lsp_config/sumneko_lua.lua b/nivm/lua/settings/lsp_config/sumneko_lua.lua new file mode 100644 index 0000000..0ac454a --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/texlab.lua b/nivm/lua/settings/lsp_config/texlab.lua new file mode 100644 index 0000000..be0e199 --- /dev/null +++ b/nivm/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/nivm/lua/settings/lsp_config/tsserver.lua b/nivm/lua/settings/lsp_config/tsserver.lua new file mode 100644 index 0000000..0af4cb6 --- /dev/null +++ b/nivm/lua/settings/lsp_config/tsserver.lua @@ -0,0 +1,56 @@ +local util = require 'lspconfig.util' + +local bin_name = 'typescript-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 = { + init_options = { hostInfo = 'neovim' }, + cmd = cmd, + filetypes = { + 'javascript', + 'javascriptreact', + 'javascript.jsx', + 'typescript', + 'typescriptreact', + 'typescript.tsx', + }, + root_dir = function(fname) + return util.root_pattern 'tsconfig.json'(fname) + or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname) + end, + }, + docs = { + description = [[ +https://github.com/theia-ide/typescript-language-server +`typescript-language-server` depends on `typescript`. Both packages can be installed via `npm`: +```sh +npm install -g typescript typescript-language-server +``` +To configure typescript language server, add a +[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or +[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your +project. +Here's an example that disables type checking in JavaScript files. +```json +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "checkJs": false + }, + "exclude": [ + "node_modules" + ] +} +``` +]], + default_config = { + root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]], + }, + }, +} diff --git a/nivm/lua/settings/lua_codeactions.lua b/nivm/lua/settings/lua_codeactions.lua new file mode 100644 index 0000000..1d24ff5 --- /dev/null +++ b/nivm/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/nivm/lua/settings/null-ls.lua b/nivm/lua/settings/null-ls.lua new file mode 100644 index 0000000..5f33860 --- /dev/null +++ b/nivm/lua/settings/null-ls.lua @@ -0,0 +1,44 @@ +local null_ls = require("null-ls") + +require("mason-null-ls").setup({ + ensure_installed = { + "prettier", + "clang_format", + "latexindent", + "shellharden", + "sql_formatter", + "fixjson", + "autopep8", + "stylua", + "rustfmt", + "stylish-haskell", + }, +}) + +null_ls.setup({ + on_attach = function(client, bufnr) + if client.server_capabilities.documentFormattingProvider then + vim.cmd("nnoremap f :lua vim.lsp.buf.format { async = true }") + + -- format on save + vim.cmd("autocmd BufWritePost lua vim.lsp.buf.format { async = true }") + end + + if client.server_capabilities.documentRangeFormattingProvider then + vim.cmd("xnoremap f :lua vim.lsp.buf.range_formatting({})") + end + end, + sources = { + require("null-ls").builtins.completion.spell, + require("null-ls").builtins.formatting.prettier, + require("null-ls").builtins.formatting.clang_format, + require("null-ls").builtins.formatting.latexindent, + require("null-ls").builtins.formatting.shellharden, + require("null-ls").builtins.formatting.sql_formatter, + require("null-ls").builtins.formatting.fixjson, + require("null-ls").builtins.formatting.autopep8, + require("null-ls").builtins.formatting.stylua, + require("null-ls").builtins.formatting.rustfmt, + require("null-ls").builtins.formatting.stylish_haskell, + }, +}) diff --git a/nivm/lua/settings/nvim-tree.lua b/nivm/lua/settings/nvim-tree.lua new file mode 100644 index 0000000..c995d02 --- /dev/null +++ b/nivm/lua/settings/nvim-tree.lua @@ -0,0 +1,233 @@ +-- 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 { -- BEGIN_DEFAULT_OPTS + auto_reload_on_write = true, + create_in_closed_folder = false, + disable_netrw = false, + hijack_cursor = false, + hijack_netrw = true, + hijack_unnamed_buffer_when_opening = false, + ignore_buffer_on_setup = false, + open_on_setup = true, + open_on_setup_file = true, + open_on_tab = true, + ignore_buf_on_tab_change = {}, + sort_by = "name", + root_dirs = {}, + prefer_startup_root = false, + sync_root_with_cwd = false, + reload_on_bufenter = false, + respect_buf_cwd = false, + on_attach = "disable", -- function(bufnr). If nil, will use the deprecated mapping strategy + remove_keymaps = false, -- boolean (disable totally or not) or list of key (lhs) + view = { + adaptive_size = false, + centralize_selection = false, + width = 30, + hide_root_folder = false, + side = "left", + preserve_window_proportions = false, + number = false, + relativenumber = false, + signcolumn = "yes", + -- @deprecated + mappings = { + custom_only = false, + list = { + -- user mappings go here + }, + }, + float = { + enable = false, + open_win_config = { + relative = "editor", + border = "rounded", + width = 30, + height = 30, + row = 1, + col = 1, + }, + }, + }, + renderer = { + add_trailing = false, + group_empty = true, + highlight_git = false, + full_name = false, + highlight_opened_files = "none", + root_folder_modifier = ":~", + indent_width = 2, + indent_markers = { + enable = false, + inline_arrows = true, + icons = { + corner = "└", + edge = "│", + item = "│", + bottom = "─", + none = " ", + }, + }, + icons = { + webdev_colors = true, + git_placement = "before", + padding = " ", + symlink_arrow = " ➛ ", + show = { + file = true, + folder = true, + folder_arrow = true, + git = true, + }, + glyphs = { + default = "", + symlink = "", + bookmark = "", + folder = { + arrow_closed = "", + arrow_open = "", + default = "", + open = "", + empty = "", + empty_open = "", + symlink = "", + symlink_open = "", + }, + git = { + unstaged = "✗", + staged = "✓", + unmerged = "", + renamed = "➜", + untracked = "★", + deleted = "", + ignored = "◌", + }, + }, + }, + special_files = { "cargo.toml", "makefile", "readme.md", "readme.md" }, + symlink_destination = true, + }, + hijack_directories = { + enable = true, + auto_open = true, + }, + update_focused_file = { + enable = false, + update_root = false, + ignore_list = {}, + }, + ignore_ft_on_setup = {}, + system_open = { + cmd = "", + args = {}, + }, + diagnostics = { + enable = false, + show_on_dirs = false, + debounce_delay = 50, + icons = { + hint = "", + info = "", + warning = "", + error = "", + }, + }, + filters = { + dotfiles = false, + custom = {}, + exclude = {}, + }, + filesystem_watchers = { + enable = true, + debounce_delay = 50, + }, + git = { + enable = true, + ignore = true, + show_on_dirs = true, + timeout = 400, + }, + actions = { + use_system_clipboard = true, + change_dir = { + enable = true, + global = false, + restrict_above_cwd = false, + }, + expand_all = { + max_folder_discovery = 300, + exclude = {}, + }, + file_popup = { + open_win_config = { + col = 1, + row = 1, + relative = "cursor", + border = "shadow", + style = "minimal", + }, + }, + open_file = { + quit_on_open = false, + resize_window = true, + window_picker = { + enable = true, + chars = "abcdefghijklmnopqrstuvwxyz1234567890", + exclude = { + filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" }, + buftype = { "nofile", "terminal", "help" }, + }, + }, + }, + remove_file = { + close_window = true, + }, + }, + trash = { + cmd = "gio trash", + require_confirm = true, + }, + live_filter = { + prefix = "[FILTER]: ", + always_show_folders = true, + }, + log = { + enable = false, + truncate = false, + types = { + all = false, + config = false, + copy_paste = false, + dev = false, + diagnostics = false, + git = false, + profile = false, + watcher = false, + }, + }, + } + +vim.g.nvim_tree_group_empty = 1 diff --git a/nivm/lua/settings/options.lua b/nivm/lua/settings/options.lua new file mode 100644 index 0000000..047d1c5 --- /dev/null +++ b/nivm/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/nivm/lua/settings/pairs.lua b/nivm/lua/settings/pairs.lua new file mode 100644 index 0000000..577e571 --- /dev/null +++ b/nivm/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/nivm/lua/settings/plugins.lua b/nivm/lua/settings/plugins.lua new file mode 100644 index 0000000..0c1a96f --- /dev/null +++ b/nivm/lua/settings/plugins.lua @@ -0,0 +1,54 @@ +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 "williamboman/mason.nvim" +Plug "williamboman/mason-lspconfig.nvim" +Plug 'neovim/nvim-lspconfig' +Plug 'jose-elias-alvarez/null-ls.nvim' +Plug 'jayp0521/mason-null-ls.nvim' +Plug 'mfussenegger/nvim-dap' +Plug 'rcarriga/nvim-dap-ui' +Plug 'theHamsta/nvim-dap-virtual-text' +Plug 'jayp0521/mason-nvim-dap.nvim' +Plug('nvim-treesitter/nvim-treesitter', { ['do'] = vim.fn[':TSUpdate'] }) +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 'MarcWeber/vim-addon-mw-utils' +Plug 'tomtom/tlib_vim' +Plug 'garbas/vim-snipmate' +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 'MunifTanjim/prettier.nvim' +Plug 'rafamadriz/friendly-snippets' +Plug 'p00f/nvim-ts-rainbow' +Plug 'nvim-telescope/telescope-ui-select.nvim' +Plug 'nvim-telescope/telescope-file-browser.nvim' +Plug 'nvim-telescope/telescope-fzy-native.nvim' +vim.call('plug#end') diff --git a/nivm/lua/settings/prettier.lua b/nivm/lua/settings/prettier.lua new file mode 100644 index 0000000..91e8bb5 --- /dev/null +++ b/nivm/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/nivm/lua/settings/project.lua b/nivm/lua/settings/project.lua new file mode 100644 index 0000000..27a1329 --- /dev/null +++ b/nivm/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/nivm/lua/settings/rainbow.lua b/nivm/lua/settings/rainbow.lua new file mode 100644 index 0000000..a070e04 --- /dev/null +++ b/nivm/lua/settings/rainbow.lua @@ -0,0 +1,14 @@ +require("nvim-treesitter.configs").setup { + highlight = { + -- ... + }, + -- ... + rainbow = { + enable = true, + -- disable = { "jsx", "cpp" }, list of languages you want to disable the plugin for + extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean + max_file_lines = nil, -- Do not enable for files with more than n lines, int + -- colors = {}, -- table of hex strings + -- termcolors = {} -- table of colour name strings + } +} diff --git a/nivm/lua/settings/telescope.lua b/nivm/lua/settings/telescope.lua new file mode 100644 index 0000000..790836a --- /dev/null +++ b/nivm/lua/settings/telescope.lua @@ -0,0 +1,8 @@ +local builtin = require('telescope.builtin') +local async = require "plenary.async" +require('telescope').setup{} +require('telescope').load_extension('fzy_native') +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fh', builtin.help_tags, {}) diff --git a/nivm/lua/settings/test.log b/nivm/lua/settings/test.log new file mode 100644 index 0000000..1a0e222 --- /dev/null +++ b/nivm/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/nivm/lua/settings/treesitter.lua b/nivm/lua/settings/treesitter.lua new file mode 100644 index 0000000..7068904 --- /dev/null +++ b/nivm/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" , "rust" , "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/nivm/lua/settings/vimtex.lua b/nivm/lua/settings/vimtex.lua new file mode 100644 index 0000000..9677bf0 --- /dev/null +++ b/nivm/lua/settings/vimtex.lua @@ -0,0 +1,24 @@ +--vim.cmd('let g:vimtex_view_method = "zathura"') +vim.cmd('let g:vimtex_view_general_viewer = "evince"') +--let g:vimtex_view_general_options = '--unique file:@pdf\#src:@line@tex' + +--vim.cmd('let g:vimtex_compiler_latexmk = { "options" : [ "-shell-escape", "-interaction=nonstopmode" , "-synctex=1" ], }') + +vim.cmd('let g:vimtex_compiler_method = "latexmk"') + + +--vim.cmd('let b:tex_use_shell_escape = 1') + +--let maplocalleader = "," + + +--let g:vimtex_compiler_latexmk = { +-- \ 'options' : [ +-- \ '-pdf', +-- \ '-shell-escape', +-- \ '-verbose', +-- \ '-file-line-error', +-- \ '-synctex=1', +-- \ '-interaction=nonstopmode', +-- \ ], +-- \}