new file: init.lua
new file: lua/ale.lua new file: lua/config.lua new file: lua/keybinds.lua new file: lua/nvim_lsp.lua new file: lua/packer_check.lua new file: lua/plugins.lua new file: lua/save_buffer_position.lua new file: plugin/packer_compiled.lua
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
require "ale"
|
||||
require "packer_check"
|
||||
require "plugins"
|
||||
require "config"
|
||||
require "keybinds"
|
||||
require "save_buffer_position"
|
||||
|
||||
--local theme = vim.env.LIGHTMODE == "1" and "onehalflight" or "onedark"
|
||||
--vim.cmd("colorscheme " .. theme)
|
||||
|
||||
vim.g.onedark_terminal_italics = true
|
||||
--vim.opt.background = "light"
|
||||
vim.opt.background = "dark"
|
||||
vim.cmd("colorscheme onedark")
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
local g = vim.g
|
||||
|
||||
-- neds to be before plugin startup
|
||||
g.ale_completion_enabled = false
|
||||
g.ale_linters_explicit = true
|
||||
|
||||
g.ale_fix_on_save = true
|
||||
g.ale_fixers = {
|
||||
c = {"clang-format"},
|
||||
cpp = {"clang-format"},
|
||||
sh = {"shfmt"},
|
||||
python = {"black"},
|
||||
lua = {"luafmt"},
|
||||
css = {"prettier"},
|
||||
scss = {"prettier"},
|
||||
html = {"prettier"},
|
||||
javascript = {"prettier"},
|
||||
typescript = {"prettier"},
|
||||
javascriptreact = {"prettier"},
|
||||
typescriptreact = {"prettier"}
|
||||
}
|
||||
|
||||
g.ale_linters = {
|
||||
sh = {"bashate"}
|
||||
--python = {"flake8"},
|
||||
--cpp = {"g++"},
|
||||
--html = {"tidy"},
|
||||
--css = {"stylelint"}
|
||||
}
|
||||
|
||||
g.ale_lint_on_text_changed = "normal"
|
||||
--g.ale_lint_on_text_changed = "never"
|
||||
g.ale_lint_on_enter = true
|
||||
g.ale_lint_on_insert_leave = true
|
||||
g.ale_lint_on_filetype_changed = false
|
||||
g.ale_lint_on_save = false
|
||||
|
||||
--local flake8_ignore_args = "--ignore=E501,E265,E402,E262,E261,E241,E266"
|
||||
--g.ale_python_flake8_options = flake8_ignore_args
|
||||
--g.ale_python_autopep8_options = flake8_ignore_args
|
||||
--g.ale_lua_luafmt_options = ""
|
||||
--g.ale_javascript_prettier_options = "--print-width 120 --tab-width 4"
|
||||
g.ale_c_clangformat_options = '-style="{IndentWidth: 4,TabWidth: 4}"'
|
||||
g.ale_sh_bashate_options = "-i E006,E042,E003"
|
||||
--g.ale_sh_shfmt_options = "-kp -s"
|
||||
+330
@@ -0,0 +1,330 @@
|
||||
-- env file highlighting
|
||||
vim.cmd [[au BufRead,BufNewFile .env.* set filetype=sh]]
|
||||
|
||||
local opt = vim.opt -- to set options
|
||||
local fn = vim.fn
|
||||
|
||||
opt.autoindent = true
|
||||
opt.autoread = true
|
||||
--opt.autowrite = true
|
||||
opt.expandtab = true
|
||||
opt.foldenable = false
|
||||
opt.hlsearch = true
|
||||
opt.ignorecase = true
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
opt.ruler = true
|
||||
opt.showcmd = true
|
||||
opt.smartcase = true
|
||||
opt.smartindent = true
|
||||
opt.splitbelow = true
|
||||
opt.splitright = true
|
||||
opt.title = true
|
||||
opt.wildmenu = true
|
||||
opt.termguicolors = true
|
||||
opt.linebreak = true
|
||||
|
||||
opt.inccommand = "split" -- Get a preview of replacements
|
||||
opt.incsearch = true -- Shows the match while typing
|
||||
|
||||
--opt.undofile = true
|
||||
--opt.undodir = "~/.local/share/nvim/undodir"
|
||||
|
||||
opt.encoding = "utf-8"
|
||||
opt.fileformat = "unix"
|
||||
opt.scrolloff = 4 -- Lines of context
|
||||
opt.shiftwidth = 4
|
||||
opt.synmaxcol = 4000
|
||||
opt.tabstop = 4
|
||||
opt.textwidth = 0
|
||||
--opt.titlestring = "NVIM: %f"
|
||||
opt.titlestring = [[NVIM: [%{fnamemodify(getcwd(), ':t')}] %t]]
|
||||
|
||||
opt.cursorline = true
|
||||
opt.cursorcolumn = true
|
||||
|
||||
-- "rbgrouleff/bclose.vim"
|
||||
vim.g.bclose_no_plugin_maps = true
|
||||
|
||||
-----------------------
|
||||
-- TREESITTER CONFIG --
|
||||
-----------------------
|
||||
require("nvim-treesitter.configs").setup {
|
||||
ensure_installed = "maintained",
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {"typescript", "tsx", "html"}
|
||||
}
|
||||
}
|
||||
|
||||
--------------
|
||||
-- NVIM-CMP --
|
||||
--------------
|
||||
|
||||
-- Set completeopt to have a better completion experience
|
||||
opt.completeopt = "menuone,noselect"
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm {
|
||||
--behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true
|
||||
},
|
||||
["<Tab>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
{"i", "s"}
|
||||
),
|
||||
["<S-Tab>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
{"i", "s"}
|
||||
)
|
||||
},
|
||||
sources = {
|
||||
{name = "nvim_lsp"},
|
||||
{name = "luasnip"}
|
||||
}
|
||||
}
|
||||
|
||||
--------------------
|
||||
-- NVIM-AUTOPAIRS --
|
||||
--------------------
|
||||
|
||||
--require("nvim-autopairs").setup {}
|
||||
--
|
||||
---- you need setup cmp first put this after cmp.setup()
|
||||
--require("nvim-autopairs.completion.cmp").setup(
|
||||
-- {
|
||||
-- map_cr = true, -- map <CR> on insert mode
|
||||
-- map_complete = true, -- it will auto insert `(` (map_char) after select function or method item
|
||||
-- auto_select = true, -- automatically select the first item
|
||||
-- insert = false, -- use insert confirm behavior instead of replace
|
||||
-- map_char = {
|
||||
-- -- modifies the function or method delimiter by filetypes
|
||||
-- all = "(",
|
||||
-- tex = "{"
|
||||
-- }
|
||||
-- }
|
||||
--)
|
||||
|
||||
------------------------
|
||||
-- NVIM-LSP-INSTALLER --
|
||||
------------------------
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local common_on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
local opts = {noremap = true, silent = true}
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
--buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "<c-k>", "<cmd>lua vim.lsp.diagnostic.goto_prev({wrap = false})<CR>", opts)
|
||||
buf_set_keymap("n", "<c-j>", "<cmd>lua vim.lsp.diagnostic.goto_next({wrap = false})<CR>", opts)
|
||||
buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||
end
|
||||
|
||||
-- enable null-ls integration (optional)
|
||||
require("null-ls").config {}
|
||||
require("lspconfig")["null-ls"].setup {}
|
||||
|
||||
require("nvim-lsp-installer").on_server_ready(
|
||||
function(server)
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local opts = {
|
||||
on_attach = common_on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150
|
||||
},
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
format = {enable = false}
|
||||
}
|
||||
}
|
||||
|
||||
local vscode_servers = {html = "html", jsonls = "json", cssls = "css"}
|
||||
local lang = vscode_servers[server.name]
|
||||
|
||||
if lang ~= nil then
|
||||
opts.cmd = {("vscode-" .. lang .. "-language-server"), "--stdio"}
|
||||
end
|
||||
|
||||
if server.name == "tsserver" then
|
||||
opts.on_attach = function(client, bufnr)
|
||||
local ts_utils = require("nvim-lsp-ts-utils")
|
||||
|
||||
ts_utils.setup {enable_import_on_completion = true}
|
||||
|
||||
-- required to fix code action ranges and filter diagnostics
|
||||
ts_utils.setup_client(client)
|
||||
|
||||
-- no default maps, so you may want to define some here
|
||||
local o = {silent = true}
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", o)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "rN", ":TSLspRenameFile<CR>", o)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gI", ":TSLspImportAll<CR>", o)
|
||||
|
||||
common_on_attach(client, bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
server:setup(opts)
|
||||
vim.cmd [[do User LspAttachBuffers]]
|
||||
end
|
||||
)
|
||||
|
||||
local lsp_installer_servers = require("nvim-lsp-installer.servers")
|
||||
local auto_servers = {
|
||||
"pylsp",
|
||||
"sumneko_lua",
|
||||
"tsserver",
|
||||
"bashls",
|
||||
"vimls",
|
||||
"rust_analyzer",
|
||||
"html",
|
||||
"cssls",
|
||||
"jsonls"
|
||||
--"eslintls"
|
||||
}
|
||||
|
||||
for _, s in ipairs(auto_servers) do
|
||||
local ok, server = lsp_installer_servers.get_server(s)
|
||||
if ok and not server:is_installed() then
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
|
||||
-------------
|
||||
-- LUALINE --
|
||||
-------------
|
||||
|
||||
require("lualine").setup {
|
||||
options = {theme = "onedark", icons_enabled = true},
|
||||
sections = {
|
||||
lualine_a = {"mode"},
|
||||
lualine_b = {
|
||||
"branch"
|
||||
},
|
||||
lualine_c = {"filename"},
|
||||
lualine_x = {
|
||||
"encoding",
|
||||
"fileformat",
|
||||
"filetype",
|
||||
[[string.format("%d Lines", vim.fn.line('$'))]],
|
||||
{
|
||||
"diagnostics",
|
||||
sources = {"nvim_lsp", "ale"}
|
||||
}
|
||||
},
|
||||
lualine_y = {
|
||||
"progress"
|
||||
},
|
||||
lualine_z = {"location"}
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = {"filename"},
|
||||
lualine_x = {"location"},
|
||||
lualine_y = {},
|
||||
lualine_z = {}
|
||||
},
|
||||
tabline = {
|
||||
lualine_a = {
|
||||
{
|
||||
"buffers",
|
||||
show_filename_only = false, -- shows shortened relative path when false
|
||||
show_modified_status = true, -- shows indicator then bufder is modified
|
||||
max_length = vim.o.columns * 1, -- maximum width of buffers component
|
||||
filetype_names = {
|
||||
TelescopePrompt = "Telescope",
|
||||
dashboard = "Dashboard",
|
||||
packer = "Packer",
|
||||
fzf = "FZF",
|
||||
alpha = "Alpha",
|
||||
["lsp-installer"] = "LSP Installer"
|
||||
}, -- shows specific buffer name for that filetype ( { `filetype` = `buffer_name`, ... } )
|
||||
buffers_color = {
|
||||
active = nil, -- color for active buffer
|
||||
inactive = nil -- color for inactive buffer
|
||||
}
|
||||
}
|
||||
},
|
||||
lualine_b = {},
|
||||
lualine_c = {},
|
||||
lualine_x = {},
|
||||
lualine_y = {},
|
||||
lualine_z = {
|
||||
{
|
||||
[[string.format("Tab %d/%d", vim.fn.tabpagenr(), vim.fn.tabpagenr('$'))]],
|
||||
cond = function()
|
||||
return fn.tabpagenr("$") > 1
|
||||
end
|
||||
}
|
||||
}
|
||||
},
|
||||
extensions = {}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
--local fn = vim.fn -- to call Vim functions e.g. fn.bufnr()
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
local options = {noremap = true}
|
||||
if opts then
|
||||
options = vim.tbl_extend("force", options, opts)
|
||||
end
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
||||
end
|
||||
|
||||
vim.g.mapleader = ","
|
||||
|
||||
map("v", "<C-C>", '"+y')
|
||||
map("n", "<Tab>", ":bnext<CR>")
|
||||
map("n", "<S-Tab>", ":bprevious<CR>")
|
||||
map("n", "<esc>", ":noh<cr><esc>", {silent = true}) --After searching, pressing escape stops the highlight
|
||||
|
||||
map("n", "<Leader>w", [[:%s/\s\+$//e <CR>]])
|
||||
map("n", "<Leader>x", ":Bclose <CR>")
|
||||
map("n", "<Leader>t", ":tabnew <CR>")
|
||||
|
||||
-- Split navigations
|
||||
map("n", "<C-Right>", "<C-W><C-L>")
|
||||
map("n", "<C-Left>", "<C-W><C-H>")
|
||||
map("n", "<C-Up>", "<C-W><C-K>")
|
||||
map("n", "<C-Down>", "<C-W><C-J>")
|
||||
|
||||
-- Resize split
|
||||
map("n", "<M-j>", "<C-W>-")
|
||||
map("n", "<M-k>", "<C-W>+")
|
||||
map("n", "<M-h>", "<C-W><")
|
||||
map("n", "<M-l>", "<C-W>>")
|
||||
|
||||
-- Scroll viewport
|
||||
map("n", "<S-Up>", "<C-Y>")
|
||||
map("n", "<S-Down>", "<C-E>")
|
||||
map("v", "<S-Up>", "<C-Y>")
|
||||
map("v", "<S-Down>", "<C-E>")
|
||||
map("i", "<S-Up>", "<C-X><C-Y>")
|
||||
map("i", "<S-Down>", "<C-X><C-E>")
|
||||
|
||||
-- Make visual yanks place the cursor back where started
|
||||
map("v", "y", "ygv<Esc>")
|
||||
|
||||
-- map Enter to switch tabs
|
||||
--map("n", "<Enter>", ":tabnext<CR>")
|
||||
--map("n", "<Backspace>", ":tabprevious<CR>")
|
||||
|
||||
---------
|
||||
-- HOP --
|
||||
---------
|
||||
local hopword = [[<cmd>lua require'hop'.hint_words()<cr>]]
|
||||
local hopline = [[<cmd>lua require'hop'.hint_lines_skip_whitespace()<cr>]]
|
||||
--map("n", "<m-l>", hopline, {silent = true})
|
||||
--map("v", "<m-l>", hopline, {silent = true})
|
||||
--map("n", "<m-w>", hopword, {silent = true})
|
||||
--map("v", "<m-w>", hopword, {silent = true})
|
||||
map("n", "W", hopline, {silent = true})
|
||||
map("v", "W", hopline, {silent = true})
|
||||
map("n", "w", hopword, {silent = true})
|
||||
map("v", "w", hopword, {silent = true})
|
||||
|
||||
---------
|
||||
-- FZF --
|
||||
---------
|
||||
map("n", "<Leader>o", ":Files <CR>")
|
||||
map("n", "<Leader>b", ":Buffers <CR>")
|
||||
map("n", "<Leader>h", ":Helptags <CR>")
|
||||
map("n", "<Leader>;", ":History: <CR>")
|
||||
map("n", "<Leader>c", ":Commands <CR>")
|
||||
map("n", "<Leader>/", ":Rg <CR>")
|
||||
map("n", "<Leader>[", ":Windows <CR>")
|
||||
|
||||
---------
|
||||
-- ALE --
|
||||
---------
|
||||
--map("n", "<c-k>", ":ALEPreviousWrap <CR>", {silent = true})
|
||||
--map("n", "<c-j>", ":ALENextWrap <CR>", {silent = true})
|
||||
@@ -0,0 +1,203 @@
|
||||
local opt = vim.opt -- to set options
|
||||
|
||||
--------------
|
||||
-- NVIM-CMP --
|
||||
--------------
|
||||
|
||||
-- Set completeopt to have a better completion experience
|
||||
opt.completeopt = "menuone,noselect"
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end
|
||||
},
|
||||
mapping = {
|
||||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-n>"] = cmp.mapping.select_next_item(),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm {
|
||||
--behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true
|
||||
},
|
||||
["<Tab>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
{"i", "s"}
|
||||
),
|
||||
["<S-Tab>"] = cmp.mapping(
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
{"i", "s"}
|
||||
)
|
||||
},
|
||||
sources = {
|
||||
{name = "nvim_lsp"},
|
||||
{name = "luasnip"}
|
||||
}
|
||||
}
|
||||
|
||||
--------------------
|
||||
-- NVIM-AUTOPAIRS --
|
||||
--------------------
|
||||
|
||||
--require("nvim-autopairs").setup {}
|
||||
--
|
||||
---- you need setup cmp first put this after cmp.setup()
|
||||
--require("nvim-autopairs.completion.cmp").setup(
|
||||
-- {
|
||||
-- map_cr = true, -- map <CR> on insert mode
|
||||
-- map_complete = true, -- it will auto insert `(` (map_char) after select function or method item
|
||||
-- auto_select = true, -- automatically select the first item
|
||||
-- insert = false, -- use insert confirm behavior instead of replace
|
||||
-- map_char = {
|
||||
-- -- modifies the function or method delimiter by filetypes
|
||||
-- all = "(",
|
||||
-- tex = "{"
|
||||
-- }
|
||||
-- }
|
||||
--)
|
||||
|
||||
------------------------
|
||||
-- NVIM-LSP-INSTALLER --
|
||||
------------------------
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local common_on_attach = function(client, bufnr)
|
||||
local function buf_set_keymap(...)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, ...)
|
||||
end
|
||||
local function buf_set_option(...)
|
||||
vim.api.nvim_buf_set_option(bufnr, ...)
|
||||
end
|
||||
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
|
||||
-- Mappings.
|
||||
local opts = {noremap = true, silent = true}
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
--buf_set_keymap("n", "<C-k>", "<cmd>lua vim.lsp.buf.signature_help()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>D", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>ca", "<cmd>lua vim.lsp.buf.code_action()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>q", "<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
||||
buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
||||
buf_set_keymap("n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
|
||||
buf_set_keymap("n", "<c-k>", "<cmd>lua vim.lsp.diagnostic.goto_prev({wrap = false})<CR>", opts)
|
||||
buf_set_keymap("n", "<c-j>", "<cmd>lua vim.lsp.diagnostic.goto_next({wrap = false})<CR>", opts)
|
||||
buf_set_keymap("n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
|
||||
buf_set_keymap("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
|
||||
buf_set_keymap("n", "gi", "<cmd>lua vim.lsp.buf.implementation()<CR>", opts)
|
||||
buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
||||
end
|
||||
|
||||
-- enable null-ls integration (optional)
|
||||
require("null-ls").config {}
|
||||
require("lspconfig")["null-ls"].setup {}
|
||||
|
||||
local tsserver_on_attach = function(client, bufnr)
|
||||
local ts_utils = require("nvim-lsp-ts-utils")
|
||||
|
||||
ts_utils.setup {enable_import_on_completion = true}
|
||||
|
||||
-- required to fix code action ranges and filter diagnostics
|
||||
ts_utils.setup_client(client)
|
||||
|
||||
-- no default maps, so you may want to define some here
|
||||
local o = {silent = true}
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gs", ":TSLspOrganize<CR>", o)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "rN", ":TSLspRenameFile<CR>", o)
|
||||
vim.api.nvim_buf_set_keymap(bufnr, "n", "gI", ":TSLspImportAll<CR>", o)
|
||||
|
||||
common_on_attach(client, bufnr)
|
||||
end
|
||||
|
||||
require("nvim-lsp-installer").on_server_ready(
|
||||
function(server)
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local opts = {
|
||||
on_attach = common_on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150
|
||||
},
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
format = {enable = false}
|
||||
}
|
||||
}
|
||||
|
||||
local vscode_servers = {html = "html", jsonls = "json", cssls = "css"}
|
||||
local lang = vscode_servers[server.name]
|
||||
|
||||
if lang ~= nil then
|
||||
opts.cmd = {("vscode-" .. lang .. "-language-server"), "--stdio"}
|
||||
end
|
||||
|
||||
if server.name == "tsserver" then
|
||||
opts.on_attach = tsserver_on_attach
|
||||
end
|
||||
|
||||
server:setup(opts)
|
||||
vim.cmd [[do User LspAttachBuffers]]
|
||||
end
|
||||
)
|
||||
|
||||
local lsp_installer_servers = require("nvim-lsp-installer.servers")
|
||||
local auto_servers = {
|
||||
"pylsp",
|
||||
"sumneko_lua",
|
||||
"tsserver",
|
||||
"bashls",
|
||||
"vimls",
|
||||
"rust_analyzer",
|
||||
"html",
|
||||
"cssls",
|
||||
"jsonls"
|
||||
--"eslintls"
|
||||
}
|
||||
|
||||
for _, s in ipairs(auto_servers) do
|
||||
local ok, server = lsp_installer_servers.get_server(s)
|
||||
if ok and not server:is_installed() then
|
||||
server:install()
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
local fn = vim.fn
|
||||
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
|
||||
|
||||
if fn.empty(fn.glob(install_path)) > 0 then
|
||||
fn.system({"git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path})
|
||||
vim.cmd "packadd packer.nvim"
|
||||
vim.cmd ":PackerSync"
|
||||
end
|
||||
@@ -0,0 +1,70 @@
|
||||
local use = require("packer").use
|
||||
|
||||
require("packer").startup(
|
||||
function()
|
||||
use "wbthomason/packer.nvim"
|
||||
|
||||
-- NAVIGATION
|
||||
use {
|
||||
"phaazon/hop.nvim",
|
||||
as = "hop",
|
||||
config = function()
|
||||
-- you can configure Hop the way you like here; see :h hop-config
|
||||
require "hop".setup {}
|
||||
--require "hop".setup {keys = "etovxqpdygfblzhckisuran"}
|
||||
end
|
||||
}
|
||||
|
||||
-- TABLE
|
||||
use "dhruvasagar/vim-table-mode"
|
||||
|
||||
-- VIM THEMING
|
||||
use "rafi/awesome-vim-colorschemes" -- vim themes
|
||||
|
||||
-- FILE MANAGEMENT
|
||||
use "junegunn/fzf"
|
||||
use "junegunn/fzf.vim"
|
||||
use "rbgrouleff/bclose.vim"
|
||||
use "francoiscabrol/ranger.vim"
|
||||
|
||||
-- AIRLINE
|
||||
use {
|
||||
"nvim-lualine/lualine.nvim",
|
||||
requires = {"kyazdani42/nvim-web-devicons", opt = true}
|
||||
}
|
||||
|
||||
-- EDITOR
|
||||
--use "windwp/nvim-autopairs"
|
||||
use "jiangmiao/auto-pairs"
|
||||
use "dense-analysis/ale"
|
||||
--use "nathanmsmith/nvim-ale-diagnostic"
|
||||
|
||||
-- LSP
|
||||
use {"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}
|
||||
use "neovim/nvim-lspconfig" -- Collection of configurations for built-in LSP client
|
||||
use "williamboman/nvim-lsp-installer"
|
||||
use "hrsh7th/cmp-nvim-lsp" -- LSP source for nvim-cmp
|
||||
|
||||
use "nvim-lua/plenary.nvim"
|
||||
use "jose-elias-alvarez/nvim-lsp-ts-utils"
|
||||
use "jose-elias-alvarez/null-ls.nvim"
|
||||
|
||||
use "L3MON4D3/LuaSnip" -- Snippets plugin
|
||||
use "hrsh7th/nvim-cmp" -- Autocompletion plugin
|
||||
use "saadparwaiz1/cmp_luasnip" -- Snippets source for nvim-cmp
|
||||
|
||||
-- JS
|
||||
use "HerringtonDarkholme/yats.vim"
|
||||
use "chemzqm/vim-jsx-improve"
|
||||
use "yuezk/vim-js" -- js
|
||||
use "maxmellon/vim-jsx-pretty" -- react/tsx syntax highlight & indent
|
||||
--use "leafOfTree/vim-vue-plugin" -- vue syntax highlight & indent
|
||||
|
||||
-- PYTHON
|
||||
use {"numirias/semshi", run = ":UpdateRemotePlugins"} -- python
|
||||
use "Vimjas/vim-python-pep8-indent"
|
||||
|
||||
-- HTML/CSS
|
||||
use "mattn/emmet-vim"
|
||||
end
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
vim.cmd [[
|
||||
|
||||
" https://vim.fandom.com/wiki/Avoid_scrolling_when_switch_buffers
|
||||
" Save current view settings on a per-window, per-buffer basis.
|
||||
|
||||
function! AutoSaveWinView()
|
||||
if !exists("w:SavedBufView")
|
||||
let w:SavedBufView = {}
|
||||
endif
|
||||
let w:SavedBufView[bufnr("%")] = winsaveview()
|
||||
endfunction
|
||||
|
||||
" Restore current view settings.
|
||||
|
||||
function! AutoRestoreWinView()
|
||||
let buf = bufnr("%")
|
||||
if exists("w:SavedBufView") && has_key(w:SavedBufView, buf)
|
||||
let v = winsaveview()
|
||||
let atStartOfFile = v.lnum == 1 && v.col == 0
|
||||
if atStartOfFile && !&diff
|
||||
call winrestview(w:SavedBufView[buf])
|
||||
endif
|
||||
unlet w:SavedBufView[buf]
|
||||
endif
|
||||
endfunction
|
||||
|
||||
autocmd BufLeave * call AutoSaveWinView()
|
||||
autocmd BufEnter * call AutoRestoreWinView()
|
||||
|
||||
]]
|
||||
@@ -0,0 +1,202 @@
|
||||
-- Automatically generated packer.nvim plugin loader code
|
||||
|
||||
if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
|
||||
vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
|
||||
return
|
||||
end
|
||||
|
||||
vim.api.nvim_command('packadd packer.nvim')
|
||||
|
||||
local no_errors, error_msg = pcall(function()
|
||||
|
||||
local time
|
||||
local profile_info
|
||||
local should_profile = false
|
||||
if should_profile then
|
||||
local hrtime = vim.loop.hrtime
|
||||
profile_info = {}
|
||||
time = function(chunk, start)
|
||||
if start then
|
||||
profile_info[chunk] = hrtime()
|
||||
else
|
||||
profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
|
||||
end
|
||||
end
|
||||
else
|
||||
time = function(chunk, start) end
|
||||
end
|
||||
|
||||
local function save_profiles(threshold)
|
||||
local sorted_times = {}
|
||||
for chunk_name, time_taken in pairs(profile_info) do
|
||||
sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
|
||||
end
|
||||
table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
|
||||
local results = {}
|
||||
for i, elem in ipairs(sorted_times) do
|
||||
if not threshold or threshold and elem[2] > threshold then
|
||||
results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
|
||||
end
|
||||
end
|
||||
|
||||
_G._packer = _G._packer or {}
|
||||
_G._packer.profile_output = results
|
||||
end
|
||||
|
||||
time([[Luarocks path setup]], true)
|
||||
local package_path_str = "/home/guy/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?.lua;/home/guy/.cache/nvim/packer_hererocks/2.0.5/share/lua/5.1/?/init.lua;/home/guy/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?.lua;/home/guy/.cache/nvim/packer_hererocks/2.0.5/lib/luarocks/rocks-5.1/?/init.lua"
|
||||
local install_cpath_pattern = "/home/guy/.cache/nvim/packer_hererocks/2.0.5/lib/lua/5.1/?.so"
|
||||
if not string.find(package.path, package_path_str, 1, true) then
|
||||
package.path = package.path .. ';' .. package_path_str
|
||||
end
|
||||
|
||||
if not string.find(package.cpath, install_cpath_pattern, 1, true) then
|
||||
package.cpath = package.cpath .. ';' .. install_cpath_pattern
|
||||
end
|
||||
|
||||
time([[Luarocks path setup]], false)
|
||||
time([[try_loadstring definition]], true)
|
||||
local function try_loadstring(s, component, name)
|
||||
local success, result = pcall(loadstring(s))
|
||||
if not success then
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
|
||||
end)
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
time([[try_loadstring definition]], false)
|
||||
time([[Defining packer_plugins]], true)
|
||||
_G.packer_plugins = {
|
||||
LuaSnip = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/LuaSnip"
|
||||
},
|
||||
ale = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/ale"
|
||||
},
|
||||
["auto-pairs"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/auto-pairs"
|
||||
},
|
||||
["awesome-vim-colorschemes"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/awesome-vim-colorschemes"
|
||||
},
|
||||
["bclose.vim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/bclose.vim"
|
||||
},
|
||||
["cmp-nvim-lsp"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/cmp-nvim-lsp"
|
||||
},
|
||||
cmp_luasnip = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/cmp_luasnip"
|
||||
},
|
||||
["emmet-vim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/emmet-vim"
|
||||
},
|
||||
fzf = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/fzf"
|
||||
},
|
||||
["fzf.vim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/fzf.vim"
|
||||
},
|
||||
hop = {
|
||||
config = { "\27LJ\1\0025\0\0\2\0\3\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0002\1\0\0>\0\2\1G\0\1\0\nsetup\bhop\frequire\0" },
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/hop"
|
||||
},
|
||||
["lualine.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/lualine.nvim"
|
||||
},
|
||||
["null-ls.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/null-ls.nvim"
|
||||
},
|
||||
["nvim-cmp"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-cmp"
|
||||
},
|
||||
["nvim-lsp-installer"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-lsp-installer"
|
||||
},
|
||||
["nvim-lsp-ts-utils"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-lsp-ts-utils"
|
||||
},
|
||||
["nvim-lspconfig"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-lspconfig"
|
||||
},
|
||||
["nvim-treesitter"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-treesitter"
|
||||
},
|
||||
["nvim-web-devicons"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/nvim-web-devicons"
|
||||
},
|
||||
["packer.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/packer.nvim"
|
||||
},
|
||||
["plenary.nvim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/plenary.nvim"
|
||||
},
|
||||
["ranger.vim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/ranger.vim"
|
||||
},
|
||||
semshi = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/semshi"
|
||||
},
|
||||
["vim-js"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/vim-js"
|
||||
},
|
||||
["vim-jsx-improve"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/vim-jsx-improve"
|
||||
},
|
||||
["vim-jsx-pretty"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/vim-jsx-pretty"
|
||||
},
|
||||
["vim-python-pep8-indent"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/vim-python-pep8-indent"
|
||||
},
|
||||
["vim-table-mode"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/vim-table-mode"
|
||||
},
|
||||
["yats.vim"] = {
|
||||
loaded = true,
|
||||
path = "/home/guy/.local/share/nvim/site/pack/packer/start/yats.vim"
|
||||
}
|
||||
}
|
||||
|
||||
time([[Defining packer_plugins]], false)
|
||||
-- Config for: hop
|
||||
time([[Config for hop]], true)
|
||||
try_loadstring("\27LJ\1\0025\0\0\2\0\3\0\a4\0\0\0%\1\1\0>\0\2\0027\0\2\0002\1\0\0>\0\2\1G\0\1\0\nsetup\bhop\frequire\0", "config", "hop")
|
||||
time([[Config for hop]], false)
|
||||
if should_profile then save_profiles() end
|
||||
|
||||
end)
|
||||
|
||||
if not no_errors then
|
||||
vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
|
||||
end
|
||||
Reference in New Issue
Block a user