Skip to content
Snippets Groups Projects
Commit 96f30204 authored by codecraft's avatar codecraft :crocodile:
Browse files

Set null-ls to format with <C-y>

Add 80 characters line
add path completion source
parent acc70cc0
No related branches found
No related tags found
No related merge requests found
...@@ -3,18 +3,20 @@ local opt = vim.opt ...@@ -3,18 +3,20 @@ local opt = vim.opt
local o = vim.o local o = vim.o
local wo = vim.wo local wo = vim.wo
-- Colorcolumn
o.colorcolumn = "79"
-- Set highlight on search -- Set highlight on search
o.hlsearch = false o.hlsearch = false
-- Make line numbers default -- Make line numbers default
wo.number = true -- activate numbers wo.number = true -- activate numbers
opt.nu = true -- right line number opt.nu = true -- right line number
opt.relativenumber = true -- relative opt.relativenumber = true -- relative
-- keep cursor in the middle of the screen -- keep cursor in the middle of the screen
opt.scrolloff = 25 opt.scrolloff = 25
-- TABS -- TABS
o.expandtab = true o.expandtab = true
o.tabstop = 4 o.tabstop = 4
...@@ -27,12 +29,12 @@ opt.ignorecase = true ...@@ -27,12 +29,12 @@ opt.ignorecase = true
opt.smartcase = true opt.smartcase = true
opt.incsearch = true opt.incsearch = true
-- appearance
o.termguicolors = true o.termguicolors = true
o.termguicolors = true opt.background = "dark"
-- Enable mouse mode -- Enable mouse mode
-- Enable mouse mode o.mouse = "a"
-- Enable break indent -- Enable break indent
o.breakindent = true o.breakindent = true
...@@ -50,18 +52,18 @@ opt.undofile = true ...@@ -50,18 +52,18 @@ opt.undofile = true
-- Decrease update time -- Decrease update time
o.updatetime = 250 o.updatetime = 250
wo.signcolumn = 'yes' wo.signcolumn = "yes"
-- Set completeopt to have a better completion experience -- Set completeopt to have a better completion experience
o.completeopt = 'menuone,noselect' o.completeopt = "menuone,noselect"
-- [[ Highlight on yank ]] -- [[ Highlight on yank ]]
-- See `:help vim.highlight.on_yank()` -- See `:help vim.highlight.on_yank()`
local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd('TextYankPost', { vim.api.nvim_create_autocmd("TextYankPost", {
callback = function() callback = function()
vim.highlight.on_yank() vim.highlight.on_yank()
end, end,
group = highlight_group, group = highlight_group,
pattern = '*', pattern = "*",
}) })
...@@ -8,6 +8,8 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then ...@@ -8,6 +8,8 @@ if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
end end
require("packer").startup(function(use) require("packer").startup(function(use)
-- dressing
use({ "stevearc/dressing.nvim" })
-- VimBeGood -- VimBeGood
use("ThePrimeagen/vim-be-good") use("ThePrimeagen/vim-be-good")
-- telescope filebrowser -- telescope filebrowser
...@@ -87,7 +89,14 @@ require("packer").startup(function(use) ...@@ -87,7 +89,14 @@ require("packer").startup(function(use)
use({ -- Autocompletion use({ -- Autocompletion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
requires = { "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip" }, requires = {
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-cmdline",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
},
}) })
use({ -- Highlight, edit, and navigate code use({ -- Highlight, edit, and navigate code
......
...@@ -24,5 +24,6 @@ cmp.setup({ ...@@ -24,5 +24,6 @@ cmp.setup({
{ name = "luasnip" }, { name = "luasnip" },
{ name = "buffer" }, { name = "buffer" },
{ name = "crates" }, { name = "crates" },
{ name = "path" },
}, },
}) })
local null_ls = require("null-ls") local null_ls = require('null-ls')
local mason_null_ls = require("mason-null-ls") local mason_null_ls = require('mason-null-ls')
local formatting = null_ls.builtins.formatting local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics local diagnostics = null_ls.builtins.diagnostics
...@@ -7,38 +7,23 @@ local diagnostics = null_ls.builtins.diagnostics ...@@ -7,38 +7,23 @@ local diagnostics = null_ls.builtins.diagnostics
local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local formatters_linters = { local formatters_linters = {
prettier = {}, prettier = {},
rustfmt = {}, rustfmt = {},
black = {}, black = {},
stylua = {},
} }
mason_null_ls.setup({ mason_null_ls.setup({
ensure_installed = vim.tbl_keys(formatters_linters), ensure_installed = vim.tbl_keys(formatters_linters)
}) })
null_ls.setup({ null_ls.setup ({
sources = { sources = {
formatting.prettier, formatting.prettier,
formatting.rustfmt, formatting.rustfmt,
formatting.black, formatting.black,
formatting.stylua, },
}, on_attach = function(current_client, bufnr)
on_attach = function(current_client, bufnr) if current_client.supports_method("textDocument/formatting") then
if current_client.supports_method("textDocument/formatting") then vim.api.nvim_buf_set_keymap(bufnr,"n", "<C-y>", '<CMD>lua vim.lsp.buf.format({ async = true })<CR>', { })
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr }) end
vim.api.nvim_create_autocmd("BufWritePre", { end,
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
filter = function(client)
-- only use null-ls for formatting instead of lsp server
return client.name == "null-ls"
end,
bufnr = bufnr,
})
end,
})
end
end,
}) })
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment