Working on lsp
This commit is contained in:
parent
764b890c58
commit
2566fbbec4
18 changed files with 293 additions and 110 deletions
|
@ -1 +1,26 @@
|
|||
function isEmpty()
|
||||
return vim.api.nvim_buf_get_name(0) == "" or vim.fn.filereadable(vim.api.nvim_buf_get_name(0)) == 0 or vim.fn.line('$') == 1 and vim.fn.col('$') == 1
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ "VimEnter" }, {
|
||||
callback = function()
|
||||
if isEmpty() then
|
||||
require('telescope.builtin').find_files()
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufRead', {
|
||||
pattern = ".env*",
|
||||
command = "set filetype=sh"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufRead', {
|
||||
pattern = ".*rc",
|
||||
command = "set filetype=sh"
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd('BufRead', {
|
||||
pattern = "Dockerfile.*",
|
||||
command = "set filetype=dockerfile"
|
||||
})
|
||||
|
|
|
@ -11,51 +11,61 @@ vim.g.mapleader = " "
|
|||
-- command_mode = "c",
|
||||
|
||||
require('util').keymaps({
|
||||
n = {
|
||||
n = {
|
||||
["n"] = { "nzzzv", desc = "Next search result centered" },
|
||||
["N"] = { "Nzzzv", desc = "Previous search result centered" },
|
||||
["<esc>"] = { ":noh<CR><esc>", desc = "Clear search on escape" },
|
||||
["<return>"] = {":noh<CR><return>", desc = "Clear search on return" },
|
||||
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
|
||||
["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
|
||||
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
|
||||
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
|
||||
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
|
||||
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
|
||||
["y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
|
||||
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
|
||||
["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
|
||||
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
|
||||
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
|
||||
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
|
||||
["<C-u>"] = { "<C-u>zz", desc = "Vertical half page up and center cursor" },
|
||||
["<leader>y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["<Leader>p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
|
||||
["J"] = { "mzJ`z", desc = "Move line below onto this line" },
|
||||
-- window navigation
|
||||
["<C-h>"] = { "<C-w>h", desc = "Move window left current" },
|
||||
["<C-j>"] = { "<C-w>j", desc = "Move window below current" },
|
||||
["<C-k>"] = { "<C-w>k", desc = "Move window above current" },
|
||||
["<C-l>"] = { "<C-w>l", desc = "Move window right current" },
|
||||
-- reformat outside of LSP attachment
|
||||
["<leader>lf"] = { "GVgg=", desc = "Reformat file" }
|
||||
|
||||
-- ["<leader>,j"] = { name = " Jest Tests" },
|
||||
-- ["<leader>,jr"] = { function() require("jester").run() end, desc = "Run test under cursor" },
|
||||
-- ["<leader>,jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" },
|
||||
-- ["<leader>,jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" },
|
||||
-- ["<leader>lz"] = { ":LspRestart<CR>", desc = "Restart LSP Server" },
|
||||
},
|
||||
v = {
|
||||
["y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
|
||||
-- ["<leader>,j"] = { name = " Jest Tests" },
|
||||
-- ["<leader>,jr"] = { function() require("jester").run() end, desc = "Run test under cursor" },
|
||||
-- ["<leader>,jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" },
|
||||
-- ["<leader>,jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" },
|
||||
-- ["<leader>lz"] = { ":LspRestart<CR>", desc = "Restart LSP Server" },
|
||||
},
|
||||
v = {
|
||||
["y"] = { '"*y', desc = "Copy to system clipboard" },
|
||||
["p"] = { '"*p', desc = "Paste from system clipboard" },
|
||||
["J"] = { ":m '>+1<CR>gv=gv", desc = "Visually move block down"},
|
||||
["K"] = { ":m '<-2<CR>gv=gv", desc = "Visually move block up"},
|
||||
},
|
||||
i = {
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
c = {
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
},
|
||||
i = {
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
c = {
|
||||
["<C-h>"] = { "<Left>", desc = "Left" },
|
||||
["<C-j>"] = { "<Down>", desc = "Down" },
|
||||
["<C-k>"] = { "<Up>", desc = "Up" },
|
||||
["<C-l>"] = { "<Right>", desc = "Right" },
|
||||
["<C-4>"] = { "<End>", desc = "End" },
|
||||
["<C-6>"] = { "<Home>", desc = "Home" },
|
||||
},
|
||||
x = {
|
||||
["<leader>p"] = { '"_dP', desc = "Paste w/o copying replaced content" },
|
||||
["<C-r"] = {'"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection"},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
21
lua/lsp.lua
21
lua/lsp.lua
|
@ -1,21 +0,0 @@
|
|||
local lsp = require('lsp-zero').preset({})
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
lsp.default_keymaps({buffer = bufnr})
|
||||
end)
|
||||
|
||||
lsp.ensure_installed({
|
||||
"tsserver",
|
||||
"eslint",
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"cssls",
|
||||
"cssmodules_ls",
|
||||
"pyright",
|
||||
})
|
||||
|
||||
-- (Optional) Configure lua language server for neovim
|
||||
require('lspconfig').lua_ls.setup(lsp.nvim_lua_ls())
|
||||
|
||||
lsp.setup()
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
-- allow use of system keyboard
|
||||
vim.opt.clipboard = "unnamedplus"
|
||||
-- vim.opt.clipboard = "unnamedplus"
|
||||
|
||||
-- allow use of mouse
|
||||
vim.opt.mouse = 'a'
|
||||
|
|
|
@ -12,4 +12,6 @@
|
|||
["<leader>,ck"] = { ":Kebab<CR>", desc = "To Kebab Case" },
|
||||
["<leader>,ce"] = { ":Screm<CR>", desc = "To Screm Case" },
|
||||
- https://github.com/tpope/vim-fugitive
|
||||
|
||||
- https://github.com/folke/noice.nvim
|
||||
- greg's: https://github.com/gblock0/dotfiles/blob/master/nvim/.config/nvim/lua/gb/plugins.lua
|
||||
- others: https://nvimluau.dev/
|
||||
|
|
|
@ -4,6 +4,6 @@ return {
|
|||
event = "BufEnter *.http",
|
||||
requires = { "nvim-lua/plenary.nvim" },
|
||||
keys = {
|
||||
{ "<leader>r", function() require("rest-nvim").run() end, desc = "Send http request" }
|
||||
{ "<leader>r", function() require("rest-nvim").run() end, desc = "Send selected http request" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,80 @@
|
|||
return {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v2.x',
|
||||
dependencies = {
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'}, -- Required
|
||||
{ -- Optional
|
||||
'williamboman/mason.nvim',
|
||||
build = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
end,
|
||||
},
|
||||
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v2.x',
|
||||
dependencies = {
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'},
|
||||
{
|
||||
'williamboman/mason.nvim',
|
||||
build = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
end,
|
||||
},
|
||||
{'williamboman/mason-lspconfig.nvim'},
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'},
|
||||
{'hrsh7th/cmp-nvim-lsp'},
|
||||
{'hrsh7th/cmp-buffer'},
|
||||
{'hrsh7th/cmp-path'},
|
||||
{'hrsh7th/cmp-cmdline'},
|
||||
-- Snips
|
||||
{'L3MON4D3/LuaSnip'},
|
||||
},
|
||||
config = function()
|
||||
local lsp = require('lsp-zero').preset({})
|
||||
local config = require 'lspconfig'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
-- Autocompletion
|
||||
{'hrsh7th/nvim-cmp'}, -- Required
|
||||
{'hrsh7th/cmp-nvim-lsp'}, -- Required
|
||||
{'L3MON4D3/LuaSnip'}, -- Required
|
||||
},
|
||||
lsp.on_attach(function(_, bufnr)
|
||||
lsp.default_keymaps({ buffer = bufnr })
|
||||
end)
|
||||
|
||||
lsp.ensure_installed({
|
||||
-- -- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
|
||||
"lua_ls",
|
||||
"rust_analyzer",
|
||||
"tsserver",
|
||||
"eslint",
|
||||
"cssls",
|
||||
"cssmodules_ls",
|
||||
"pyright",
|
||||
})
|
||||
|
||||
config.lua_ls.setup(lsp.nvim_lua_ls())
|
||||
|
||||
config.rust_analyzer.setup {}
|
||||
|
||||
config.tsserver.setup {}
|
||||
config.eslint.setup {}
|
||||
config.cssls.setup {}
|
||||
config.cssmodules_ls.setup {}
|
||||
|
||||
config.pyright.setup {}
|
||||
|
||||
local cmp = require 'cmp'
|
||||
local cmp_action = require('lsp-zero').cmp_action()
|
||||
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = "path" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "buffer", keyword_length = 3 },
|
||||
{ name = "luasnip", keyword_length= 2 },
|
||||
},
|
||||
mapping = {
|
||||
['<CR>'] = cmp.mapping.confirm({select = false}),
|
||||
['<Tab>'] = cmp_action.tab_complete(),
|
||||
['<S-Tab>'] = cmp_action.select_prev_or_fallback(),
|
||||
-- Ctrl+Space to trigger completion menu
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
|
||||
['<C-f>'] = cmp_action.luasnip_jump_forward(),
|
||||
['<C-b>'] = cmp_action.luasnip_jump_backward(),
|
||||
}
|
||||
})
|
||||
lsp.setup()
|
||||
end,
|
||||
-- keys = {
|
||||
-- { "<leader>l", "<Nop>", desc = "LSP" },
|
||||
-- },
|
||||
}
|
||||
|
|
|
@ -1,18 +1,32 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = '0.1.1',
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" },
|
||||
},
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader>f", "<Nop>", desc = "Find ..." },
|
||||
{ "<leader>ff", function() require('telescope.builtin').find_files() end, desc = "Find Files" },
|
||||
{ "<leader>fg", function() require('telescope.builtin').git_files() end, desc = "Find Git only Files" },
|
||||
{ "<leader>fw", function() require('telescope.builtin').live_grep() end, desc = "Find Words" },
|
||||
{ "<leader>fc", function() require('telescope.builtin').commands() end, desc = "Find Commands" },
|
||||
{ "<leader>fk", function() require('telescope.builtin').keymaps() end, desc = "Find Commands" },
|
||||
},
|
||||
opts = {},
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = '0.1.1',
|
||||
dependencies = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-telescope/telescope-fzf-native.nvim", enabled = vim.fn.executable "make" == 1, build = "make" },
|
||||
},
|
||||
cmd = "Telescope",
|
||||
keys = {
|
||||
{ "<leader>f", "<Nop>", desc = "Find ..." },
|
||||
{ "<leader>ff", function() require('telescope.builtin').find_files() end, desc = "Find Files" },
|
||||
{ "<leader>fg", function() require('telescope.builtin').git_files() end, desc = "Find Git only Files" },
|
||||
{ "<leader>fw", function() require('telescope.builtin').live_grep() end, desc = "Find Words" },
|
||||
{ "<leader>fc", function() require('telescope.builtin').commands() end, desc = "Find Commands" },
|
||||
{ "<leader>fk", function() require('telescope.builtin').keymaps() end, desc = "Find Commands" },
|
||||
{ "<leader>fb", function() require('telescope.builtin').buffers() end, desc = "Find Commands" },
|
||||
},
|
||||
opts = {
|
||||
defaults = {
|
||||
vimgrep_arguments = {
|
||||
"rg",
|
||||
"-L",
|
||||
"--color=never",
|
||||
"--no-heading",
|
||||
"--with-filename",
|
||||
"--line-number",
|
||||
"--column",
|
||||
"--smart-case",
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ return {
|
|||
opts = {
|
||||
-- "all",
|
||||
ensure_installed = {
|
||||
"lua",
|
||||
"http",
|
||||
"json",
|
||||
"bash",
|
||||
|
@ -43,16 +44,12 @@ return {
|
|||
"markdown",
|
||||
"markdown_inline",
|
||||
"nix",
|
||||
"passwd",
|
||||
"prisma",
|
||||
"proto",
|
||||
"python",
|
||||
"regex",
|
||||
"rst",
|
||||
"rust",
|
||||
"scss",
|
||||
"sql",
|
||||
"svelte",
|
||||
"terraform",
|
||||
"toml",
|
||||
"tsx",
|
||||
|
|
19
lua/plugins_disabled/cmp.lua
Normal file
19
lua/plugins_disabled/cmp.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
return {
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{
|
||||
"hrsh7th/cmp-cmdline",
|
||||
},
|
||||
{
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
{
|
||||
"hrsh7th/cmp-buffer",
|
||||
},
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
75
lua/plugins_disabled/lsp.lua
Normal file
75
lua/plugins_disabled/lsp.lua
Normal file
|
@ -0,0 +1,75 @@
|
|||
return {
|
||||
{
|
||||
-- Mason: install and manage LSP servers, DAP servers, linters, and formatters
|
||||
"williamboman/mason.nvim",
|
||||
build = ":MasonUpdate", -- :MasonUpdate updates registry contents
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
opts = {
|
||||
-- Available servers: https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
|
||||
ensure_installed = {
|
||||
'lua_ls',
|
||||
'rust_analyzer',
|
||||
'tsserver',
|
||||
"eslint",
|
||||
'cssls',
|
||||
'cssmodules_ls',
|
||||
'pyright',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
config = function(_, opts)
|
||||
local c = require 'lspconfig'
|
||||
local u = require "lspconfig/util"
|
||||
|
||||
c.lua_ls.setup {
|
||||
workspace = {
|
||||
library = {
|
||||
[vim.fn.expand "$VIMRUNTIME/lua"] = true,
|
||||
[vim.fn.expand "$VIMRUNTIME/lua/vim/lsp"] = true,
|
||||
[vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy"] = true,
|
||||
},
|
||||
},
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { "vim" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
c.rust_analyzer.setup {
|
||||
on_attach = function() end,
|
||||
capabilities = {},
|
||||
filetypes = { "rust" },
|
||||
root_dir = u.root_pattern("Cargo.toml"),
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
cargo = {
|
||||
allFeatures = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
c.tsserver.setup {
|
||||
|
||||
}
|
||||
|
||||
c.eslint.setup {
|
||||
|
||||
}
|
||||
|
||||
c.cssls.setup {}
|
||||
|
||||
c.cssmodules_ls.setup {}
|
||||
|
||||
c.pyright.setup {}
|
||||
end
|
||||
},
|
||||
}
|
||||
|
3
lua/plugins_disabled/null-ls.lua
Normal file
3
lua/plugins_disabled/null-ls.lua
Normal file
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
}
|
|
@ -24,7 +24,7 @@ require('util').keymaps({
|
|||
end,
|
||||
desc = "Find Scratches",
|
||||
},
|
||||
["<leader>s"] = { "<Nop>", desc = " Scratch File" },
|
||||
["<leader>s"] = { "<Nop>", desc = "Scratch File" },
|
||||
["<leader>ss"] = { function() scratch ".txt" end, desc = "New text scratch file" },
|
||||
["<leader>sn"] = { function() scratch ".json" end, desc = "New json scratch file" },
|
||||
["<leader>sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue