Install neoformat and run it on config
This commit is contained in:
@@ -1,58 +1,68 @@
|
|||||||
require("packer").startup(function(use)
|
require("packer").startup(function(use)
|
||||||
use({ "wbthomason/packer.nvim" })
|
use({"wbthomason/packer.nvim"})
|
||||||
|
|
||||||
-- Colorscheme
|
-- Colorscheme
|
||||||
use({ "EdenEast/nightfox.nvim" })
|
use({"EdenEast/nightfox.nvim"})
|
||||||
|
|
||||||
-- Treesitter
|
-- Treesitter
|
||||||
use({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", {
|
use({
|
||||||
{ "p00f/nvim-ts-rainbow" },
|
"nvim-treesitter/nvim-treesitter",
|
||||||
{ "JoosepAlviste/nvim-ts-context-commentstring" },
|
run = ":TSUpdate",
|
||||||
{ "nvim-treesitter/playground" }
|
{
|
||||||
}})
|
{"p00f/nvim-ts-rainbow"},
|
||||||
|
{"JoosepAlviste/nvim-ts-context-commentstring"},
|
||||||
|
{"nvim-treesitter/playground"}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
-- Make commenting code great
|
-- Make commenting code great
|
||||||
use({ "tpope/vim-commentary" })
|
use({"tpope/vim-commentary"})
|
||||||
|
|
||||||
-- File tree
|
-- File tree
|
||||||
use({ "kyazdani42/nvim-tree.lua", requires = { "kyazdani42/nvim-web-devicons" } })
|
use({
|
||||||
|
"kyazdani42/nvim-tree.lua",
|
||||||
|
requires = {"kyazdani42/nvim-web-devicons"}
|
||||||
|
})
|
||||||
|
|
||||||
-- Automatically close brackets and quotes
|
-- Automatically close brackets and quotes
|
||||||
use({ "windwp/nvim-autopairs" })
|
use({"windwp/nvim-autopairs"})
|
||||||
|
|
||||||
-- Telescope
|
-- Telescope
|
||||||
use({ "nvim-telescope/telescope.nvim", requires = { "nvim-lua/plenary.nvim" } })
|
use({"nvim-telescope/telescope.nvim", requires = {"nvim-lua/plenary.nvim"}})
|
||||||
use({ "nvim-telescope/telescope-symbols.nvim" })
|
use({"nvim-telescope/telescope-symbols.nvim"})
|
||||||
|
|
||||||
-- Statusline
|
-- Statusline
|
||||||
use({ "nvim-lualine/lualine.nvim", requires = { "kyazdani42/nvim-web-devicons" } })
|
use({
|
||||||
|
"nvim-lualine/lualine.nvim",
|
||||||
|
requires = {"kyazdani42/nvim-web-devicons"}
|
||||||
|
})
|
||||||
|
|
||||||
use({ "iamcco/markdown-preview.nvim", run = "cd app && yarn install" })
|
use({"iamcco/markdown-preview.nvim", run = "cd app && yarn install"})
|
||||||
|
|
||||||
-- Highlight colors in editor
|
-- Highlight colors in editor
|
||||||
use({ "norcalli/nvim-colorizer.lua" })
|
use({"norcalli/nvim-colorizer.lua"})
|
||||||
|
|
||||||
-- LSP
|
-- LSP
|
||||||
use({ "neovim/nvim-lspconfig" })
|
use({"neovim/nvim-lspconfig", "williamboman/nvim-lsp-installer"})
|
||||||
use({ "hrsh7th/nvim-cmp" })
|
use({"hrsh7th/nvim-cmp"})
|
||||||
use({ "L3MON4D3/LuaSnip" })
|
use({"L3MON4D3/LuaSnip"})
|
||||||
use({
|
use({
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path",
|
||||||
"hrsh7th/cmp-buffer",
|
"hrsh7th/cmp-cmdline", "hrsh7th/cmp-nvim-lua",
|
||||||
"hrsh7th/cmp-path",
|
|
||||||
"hrsh7th/cmp-cmdline",
|
|
||||||
"hrsh7th/cmp-nvim-lua",
|
|
||||||
"saadparwaiz1/cmp_luasnip"
|
"saadparwaiz1/cmp_luasnip"
|
||||||
})
|
})
|
||||||
use({ "ray-x/lsp_signature.nvim" })
|
use({"ray-x/lsp_signature.nvim"})
|
||||||
use({ "dense-analysis/ale" })
|
use({"dense-analysis/ale"})
|
||||||
|
|
||||||
-- Tabs
|
-- Tabs
|
||||||
use({ "romgrk/barbar.nvim" })
|
use({"romgrk/barbar.nvim"})
|
||||||
|
|
||||||
-- Git
|
-- Git
|
||||||
use({ "lewis6991/gitsigns.nvim", requires = { "nvim-lua/plenary.nvim" } })
|
use({"lewis6991/gitsigns.nvim", requires = {"nvim-lua/plenary.nvim"}})
|
||||||
use({ "tpope/vim-fugitive" })
|
use({"tpope/vim-fugitive"})
|
||||||
|
|
||||||
|
-- Formatter
|
||||||
|
use({"sbdchd/neoformat"})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
require("nightfox").load()
|
require("nightfox").load()
|
||||||
@@ -64,7 +74,7 @@ vim.o.autoindent = true
|
|||||||
vim.o.number = true
|
vim.o.number = true
|
||||||
vim.o.relativenumber = true
|
vim.o.relativenumber = true
|
||||||
vim.o.wrap = true
|
vim.o.wrap = true
|
||||||
vim.o.swapfile = true
|
vim.o.swapfile = false
|
||||||
vim.o.encoding = "utf-8"
|
vim.o.encoding = "utf-8"
|
||||||
vim.o.hidden = true
|
vim.o.hidden = true
|
||||||
vim.o.writebackup = false
|
vim.o.writebackup = false
|
||||||
@@ -81,16 +91,17 @@ vim.o.signcolumn = "yes"
|
|||||||
|
|
||||||
vim.g.mapleader = " "
|
vim.g.mapleader = " "
|
||||||
|
|
||||||
|
vim.cmd([[autocmd BufWritePre * undojoin | Neoformat]])
|
||||||
|
|
||||||
require("lsp")
|
require("lsp")
|
||||||
|
|
||||||
vim.cmd("let g:ale_fixers = {'javascript': ['prettier', 'eslint'], 'typescript': ['prettier', 'eslint'], 'python': ['autopep8', 'remove_trailing_lines', 'reorder-python-imports', 'trim_whitespace']}")
|
vim.cmd(
|
||||||
|
"let g:ale_fixers = {'javascript': ['prettier', 'eslint'], 'typescript': ['prettier', 'eslint'], 'python': ['autopep8', 'remove_trailing_lines', 'reorder-python-imports', 'trim_whitespace']}")
|
||||||
vim.cmd("let g:ale_fix_on_save = 1")
|
vim.cmd("let g:ale_fix_on_save = 1")
|
||||||
|
|
||||||
require("nvim-treesitter.configs").setup({
|
require("nvim-treesitter.configs").setup({
|
||||||
ensure_installed = "maintained",
|
ensure_installed = "maintained",
|
||||||
highlight = {
|
highlight = {enable = true},
|
||||||
enable = true
|
|
||||||
},
|
|
||||||
incremental_selection = {
|
incremental_selection = {
|
||||||
enable = true,
|
enable = true,
|
||||||
keymaps = {
|
keymaps = {
|
||||||
@@ -100,14 +111,8 @@ require("nvim-treesitter.configs").setup({
|
|||||||
node_decremental = "<S-TAB>"
|
node_decremental = "<S-TAB>"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rainbow = {
|
rainbow = {enable = true, extended_mode = true, disable = {"html"}},
|
||||||
enable = true,
|
context_commentstring = {enable = true}
|
||||||
extended_mode = true,
|
|
||||||
disable = { "html" }
|
|
||||||
},
|
|
||||||
context_commentstring = {
|
|
||||||
enable = true
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
require("nvim-tree").setup({
|
require("nvim-tree").setup({
|
||||||
@@ -116,18 +121,23 @@ require("nvim-tree").setup({
|
|||||||
auto_close = true,
|
auto_close = true,
|
||||||
open_on_tab = true,
|
open_on_tab = true,
|
||||||
update_cwd = true,
|
update_cwd = true,
|
||||||
update_focused_file = { enable = true },
|
update_focused_file = {enable = true},
|
||||||
view = { width = 30, side = "left", auto_resize = true },
|
view = {width = 30, side = "left", auto_resize = true},
|
||||||
filters = { custom = { ".git" } }
|
filters = {custom = {".git"}}
|
||||||
})
|
})
|
||||||
vim.g.nvim_tree_add_trailing = 1
|
vim.g.nvim_tree_add_trailing = 1
|
||||||
vim.g.nvim_tree_indent_markers = 1
|
vim.g.nvim_tree_indent_markers = 1
|
||||||
vim.g.nvim_tree_show_icons = { git = 0, folders = 0, files = 0, folder_arrows = 0 }
|
vim.g.nvim_tree_show_icons = {
|
||||||
|
git = 0,
|
||||||
|
folders = 0,
|
||||||
|
files = 0,
|
||||||
|
folder_arrows = 0
|
||||||
|
}
|
||||||
|
|
||||||
require("telescope").setup({
|
require("telescope").setup({
|
||||||
defaults = {
|
defaults = {
|
||||||
sorting_strategy = "ascending",
|
sorting_strategy = "ascending",
|
||||||
file_ignore_patterns = { ".git", "node_modules" }
|
file_ignore_patterns = {".git", "node_modules"}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -137,7 +147,7 @@ require("gitsigns").setup({
|
|||||||
noremap = true,
|
noremap = true,
|
||||||
["n <leader>gs"] = [[:lua require("gitsigns").stage_hunk()<CR>]],
|
["n <leader>gs"] = [[:lua require("gitsigns").stage_hunk()<CR>]],
|
||||||
["n <leader>gu"] = [[:lua require("gitsigns").undo_stage_hunk()<CR>]],
|
["n <leader>gu"] = [[:lua require("gitsigns").undo_stage_hunk()<CR>]],
|
||||||
["n <leader>gr"] = [[:lua require("gitsigns").reset_hunk()<CR>]],
|
["n <leader>gr"] = [[:lua require("gitsigns").reset_hunk()<CR>]]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
local nvim_lsp = require("lspconfig")
|
local lsp_installer = require("nvim-lsp-installer")
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
|
|
||||||
local kind_icons = {
|
local kind_icons = {
|
||||||
@@ -8,7 +8,8 @@ local kind_icons = {
|
|||||||
Constructor = "",
|
Constructor = "",
|
||||||
Field = "",
|
Field = "",
|
||||||
Variable = "",
|
Variable = "",
|
||||||
Class = "ﴯ", Interface = "",
|
Class = "ﴯ",
|
||||||
|
Interface = "",
|
||||||
Module = "",
|
Module = "",
|
||||||
Property = "ﰠ",
|
Property = "ﰠ",
|
||||||
Unit = "",
|
Unit = "",
|
||||||
@@ -30,121 +31,85 @@ local kind_icons = {
|
|||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args) require("luasnip").lsp_expand(args.body) end
|
||||||
require("luasnip").lsp_expand(args.body)
|
|
||||||
end
|
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
["<C-j>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }),
|
["<C-j>"] = cmp.mapping.select_next_item({
|
||||||
["<C-k>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }),
|
behavior = cmp.SelectBehavior.Select
|
||||||
|
}),
|
||||||
|
["<C-k>"] = cmp.mapping.select_prev_item({
|
||||||
|
behavior = cmp.SelectBehavior.Select
|
||||||
|
}),
|
||||||
["<C-space>"] = cmp.mapping.complete(),
|
["<C-space>"] = cmp.mapping.complete(),
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true, behavior = cmp.SelectBehavior.Insert }),
|
["<CR>"] = cmp.mapping.confirm({
|
||||||
["<TAB>"] = cmp.mapping.confirm({ select = true, behavior = cmp.SelectBehavior.Insert })
|
select = true,
|
||||||
|
behavior = cmp.SelectBehavior.Insert
|
||||||
|
}),
|
||||||
|
["<TAB>"] = cmp.mapping.confirm({
|
||||||
|
select = true,
|
||||||
|
behavior = cmp.SelectBehavior.Insert
|
||||||
|
})
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "nvim_lsp" },
|
{name = "nvim_lsp"}, {name = "luasnip"}, {name = "nvim_lua"}
|
||||||
{ name = "luasnip" },
|
}, {{name = "path"}, {name = "buffer"}}),
|
||||||
{ name = "nvim_lua" }
|
completion = {completeopt = "menu,menuone,noselect,noinsert,preview"},
|
||||||
}, {
|
experimental = {ghost_text = true},
|
||||||
{ name = "path" },
|
|
||||||
{ name = "buffer" }
|
|
||||||
}),
|
|
||||||
completion = {
|
|
||||||
completeopt = "menu,menuone,noselect,noinsert"
|
|
||||||
},
|
|
||||||
experimental = {
|
|
||||||
ghost_text = true
|
|
||||||
},
|
|
||||||
sorting = {
|
sorting = {
|
||||||
comparators = {
|
comparators = {
|
||||||
cmp.config.compare.exact,
|
cmp.config.compare.exact, cmp.config.compare.score,
|
||||||
cmp.config.compare.score,
|
cmp.config.compare.recently_used, cmp.config.compare.kind,
|
||||||
cmp.config.compare.recently_used,
|
|
||||||
cmp.config.compare.kind,
|
|
||||||
cmp.config.compare.offset
|
cmp.config.compare.offset
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
documentation = {
|
documentation = {
|
||||||
border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" },
|
border = {"╭", "─", "╮", "│", "╯", "─", "╰", "│"},
|
||||||
zindex = 999
|
zindex = 999
|
||||||
},
|
},
|
||||||
formatting = {
|
formatting = {
|
||||||
format = function(entry, vim_item)
|
format = function(entry, vim_item)
|
||||||
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind)
|
vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind],
|
||||||
vim_item.menu = ({ buffer = "[Buffer]", nvim_lsp = "[LSP]", luasnip = "[Snippet]", nvim_lua = "[Lua]", path = "[File]" })[entry.source.name]
|
vim_item.kind)
|
||||||
|
vim_item.menu = ({
|
||||||
|
buffer = "[Buffer]",
|
||||||
|
nvim_lsp = "[LSP]",
|
||||||
|
luasnip = "[Snippet]",
|
||||||
|
nvim_lua = "[Lua]",
|
||||||
|
path = "[File]"
|
||||||
|
})[entry.source.name]
|
||||||
return vim_item
|
return vim_item
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
cmp.setup.cmdline("/", {
|
cmp.setup.cmdline("/", {sources = {{name = "buffer"}}})
|
||||||
sources = {
|
|
||||||
{ name = "buffer" }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup.cmdline(":", {
|
cmp.setup.cmdline(":", {sources = {{name = "path"}, {name = "cmdline"}}})
|
||||||
sources = {
|
|
||||||
{ name = "path" },
|
|
||||||
{ name = "cmdline" }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp
|
||||||
|
.protocol
|
||||||
|
.make_client_capabilities())
|
||||||
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
local on_attach = function(_, bufnr)
|
lsp_installer.on_server_ready(function(server)
|
||||||
require("lsp_signature").on_attach({}, bufnr)
|
local opts = {}
|
||||||
end
|
|
||||||
|
|
||||||
local servers = { "tsserver", "pyright" }
|
if server.name == "sumneko_lua" then
|
||||||
|
local runtime_path = vim.split(package.path, ';')
|
||||||
|
table.insert(runtime_path, "lua/?.lua")
|
||||||
|
table.insert(runtime_path, "lua/?/init.lua")
|
||||||
|
|
||||||
for _, server in ipairs(servers) do
|
opts.settings = {
|
||||||
nvim_lsp[server].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 150
|
|
||||||
}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
nvim_lsp.gopls.setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
gopls = {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
local runtime_path = vim.split(package.path, ';')
|
|
||||||
table.insert(runtime_path, "lua/?.lua")
|
|
||||||
table.insert(runtime_path, "lua/?/init.lua")
|
|
||||||
nvim_lsp.sumneko_lua.setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = on_attach,
|
|
||||||
cmd = { "/sbin/lua-language-server", "-E", "/usr/lib/lua-language-server/main.lua" },
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {version = "LuaJIT", path = runtime_path},
|
||||||
version = "LuaJIT",
|
diagnostics = {globals = {"vim"}},
|
||||||
path = runtime_path
|
workspace = {library = vim.api.nvim_get_runtime_file("", true)},
|
||||||
},
|
telemetry = {enable = false}
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" }
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
library = vim.api.nvim_get_runtime_file("", true)
|
|
||||||
},
|
|
||||||
telemetry = {
|
|
||||||
enable = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
end
|
||||||
})
|
|
||||||
|
server:setup(opts)
|
||||||
|
end)
|
||||||
|
|
||||||
require("luasnip/loaders/from_vscode").lazy_load()
|
require("luasnip/loaders/from_vscode").lazy_load()
|
||||||
|
|
||||||
-- Auto formatting
|
|
||||||
vim.cmd([[autocmd BufWritePre * lua vim.lsp.buf.formatting_sync(nil, 1000)]])
|
|
||||||
vim.cmd([[autocmd BufWritePre *.ts,*.js,*.jsx,*.tsx,*.py ALEFix]])
|
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
local function map(mode, shortcut, command)
|
local function map(mode, shortcut, command)
|
||||||
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
|
vim.api.nvim_set_keymap(mode, shortcut, command,
|
||||||
|
{noremap = true, silent = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function nmap(shortcut, command)
|
local function nmap(shortcut, command) map("n", shortcut, command) end
|
||||||
map("n", shortcut, command)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function vmap(shortcut, command)
|
local function vmap(shortcut, command) map("v", shortcut, command) end
|
||||||
map("v", shortcut, command)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Quickly save/quit vim
|
-- Quickly save/quit vim
|
||||||
nmap("<leader>w", ":w<CR>")
|
nmap("<leader>w", ":w<CR>")
|
||||||
|
|||||||
Reference in New Issue
Block a user