stuff
This commit is contained in:
+54
-27
@@ -1,8 +1,12 @@
|
||||
-- Learn the keybindings, see :help lsp-zero-keybindings
|
||||
-- Learn to configure LSP servers, see :help lsp-zero-api-showcase
|
||||
local lsp = require('lsp-zero')
|
||||
local lsp = require("lsp-zero")
|
||||
|
||||
lsp.preset('recommended')
|
||||
lsp.preset({
|
||||
manage_nvim_cmp = {
|
||||
set_sources = "lsp",
|
||||
},
|
||||
})
|
||||
|
||||
lsp.ensure_installed({
|
||||
"tsserver",
|
||||
@@ -22,7 +26,7 @@ local cmp_mappings = lsp.defaults.cmp_mappings({
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
sign_icons = { },
|
||||
sign_icons = {},
|
||||
})
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
@@ -32,32 +36,55 @@ lsp.setup_nvim_cmp({
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
local opts = { buffer = bufnr, remap = false }
|
||||
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "gr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function() vim.lsp.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "[d", function() vim.lsp.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "]d", function() vim.lsp.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
lsp.default_keymaps({ buffer = bufnr })
|
||||
lsp.buffer_autoformat()
|
||||
|
||||
vim.keymap.set("n", "gd", function()
|
||||
vim.lsp.buf.definition()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "gr", function()
|
||||
vim.lsp.buf.references()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "K", function()
|
||||
vim.lsp.buf.hover()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function()
|
||||
vim.lsp.buf.workspace_symbol()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vd", function()
|
||||
vim.lsp.diagnostic.open_float()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "[d", function()
|
||||
vim.lsp.diagnostic.goto_next()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "]d", function()
|
||||
vim.lsp.diagnostic.goto_prev()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function()
|
||||
vim.lsp.buf.code_action()
|
||||
end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function()
|
||||
vim.lsp.buf.rename()
|
||||
end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function()
|
||||
vim.lsp.buf.signature_help()
|
||||
end, opts)
|
||||
end)
|
||||
|
||||
lsp.setup()
|
||||
|
||||
vim.diagnostic.config({
|
||||
virtual_text = true,
|
||||
signs = false,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = 'minimal',
|
||||
border = 'rounded',
|
||||
source = 'always',
|
||||
header = '',
|
||||
prefix = '',
|
||||
},
|
||||
});
|
||||
virtual_text = true,
|
||||
signs = false,
|
||||
update_in_insert = false,
|
||||
underline = true,
|
||||
severity_sort = true,
|
||||
float = {
|
||||
focusable = false,
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
source = "always",
|
||||
header = "",
|
||||
prefix = "",
|
||||
},
|
||||
})
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
-- null-ls setup
|
||||
local null_ls = require("null-ls")
|
||||
|
||||
-- for conciseness
|
||||
local formatting = null_ls.builtins.formatting -- to setup formatters
|
||||
local diagnostics = null_ls.builtins.diagnostics -- to setup linters
|
||||
|
||||
-- to setup format on save
|
||||
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
|
||||
|
||||
-- configure null_ls
|
||||
null_ls.setup({
|
||||
debug = true,
|
||||
|
||||
-- setup formatters & linters
|
||||
sources = {
|
||||
-- to disable file types use
|
||||
-- "formatting.prettier.with({disabled_filetypes: {}})" (see null-ls docs)
|
||||
formatting.prettier, -- js/ts formatter
|
||||
formatting.rustfmt, -- rust formatter
|
||||
formatting.stylua, -- lua formatter
|
||||
formatting.gofumpt, -- go formatter
|
||||
formatting.goimports, -- go auto-imports
|
||||
diagnostics.eslint_d.with({
|
||||
-- js/ts linter
|
||||
-- only enable eslint if root has .eslintrc.js (not in youtube nvim video)
|
||||
condition = function(utils)
|
||||
return utils.root_has_file(".eslintrc.js") -- change file extension if you use something else
|
||||
end,
|
||||
}),
|
||||
},
|
||||
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
on_attach = function(current_client, bufnr)
|
||||
if current_client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = augroup,
|
||||
buffer = bufnr,
|
||||
callback = function()
|
||||
-- on 0.8, you should use vim.lsp.buf.format({ bufnr = bufnr }) instead
|
||||
-- on later neovim version, you should use vim.lsp.buf.format({ async = false }) instead
|
||||
vim.lsp.buf.format({
|
||||
bufnr = bufnr,
|
||||
async = false,
|
||||
filter = function(client)
|
||||
return client.name == "null-ls"
|
||||
end,
|
||||
})
|
||||
-- vim.lsp.buf.formatting_sync()
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
@@ -76,11 +76,11 @@ require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = true,
|
||||
modified = true,
|
||||
file = false,
|
||||
folder = false,
|
||||
folder_arrow = false,
|
||||
git = false,
|
||||
modified = false,
|
||||
},
|
||||
glyphs = {
|
||||
default = " ",
|
||||
@@ -108,7 +108,7 @@ require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md" },
|
||||
special_files = {},
|
||||
symlink_destination = true,
|
||||
},
|
||||
hijack_directories = {
|
||||
|
||||
@@ -1,23 +1,8 @@
|
||||
local builtin = require("telescope.builtin")
|
||||
|
||||
local M = {}
|
||||
|
||||
require("telescope").load_extension("fzf")
|
||||
|
||||
M.project_files = function()
|
||||
local opts = require("telescope.themes").get_ivy({})
|
||||
opts.find_command = { "rg", "--files", "--hidden", "--follow", "--glob", "!.git/*" }
|
||||
vim.fn.system("git rev-parse --is-inside-work-tree")
|
||||
if vim.v.shell_error == 0 then
|
||||
builtin.git_files(opts)
|
||||
else
|
||||
opts.hidden = true
|
||||
builtin.find_files(opts)
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<leader>pf", builtin.find_files, {})
|
||||
vim.keymap.set("n", "<C-p", M.project_files, {})
|
||||
vim.keymap.set("n", "<C-p>", builtin.git_files, {})
|
||||
vim.keymap.set("n", "<leader>pb", builtin.buffers, {})
|
||||
vim.keymap.set("n", "<leader>pd", builtin.diagnostics, {})
|
||||
vim.keymap.set("n", "<leader>ps", function()
|
||||
builtin.grep_string({ search = vim.fn.input("Grep > ") })
|
||||
end)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
require 'nvim-treesitter.configs'.setup {
|
||||
-- A list of parser names, or "all" (the four listed parsers should always be installed)
|
||||
ensure_installed = { "help", "javascript", "typescript", "c", "lua", "vim", "rust", "go" },
|
||||
ensure_installed = { "javascript", "typescript", "c", "lua", "vim", "rust", "go" },
|
||||
|
||||
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||
sync_install = false,
|
||||
|
||||
Reference in New Issue
Block a user