Skip to content

Commit 7790c13

Browse files
committed
added basic klipper, vue and go configuration
1 parent 7201dc4 commit 7790c13

File tree

1 file changed

+116
-116
lines changed

1 file changed

+116
-116
lines changed

init.lua

Lines changed: 116 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,22 @@ vim.opt.mouse = 'a'
111111
vim.opt.showmode = false
112112

113113
-- Sync clipboard between OS and Neovim.
114-
-- Schedule the setting after `UiEnter` because it can increase startup-time.
115114
-- Remove this option if you want your OS clipboard to remain independent.
116115
-- See `:help 'clipboard'`
117-
vim.schedule(function()
118-
vim.opt.clipboard = 'unnamedplus'
119-
end)
116+
-- vim.g.clipboard = {
117+
-- name = 'klipper',
118+
-- copy = {
119+
--
120+
-- ['+'] = 'qdbus org.kde.klipper /klipper setClipboardContents "$(</dev/stdin)\n$(cat)"',
121+
-- ['*'] = 'qdbus org.kde.klipper /klipper setClipboardContents',
122+
-- },
123+
-- paste = {
124+
-- ['+'] = 'qdbus org.kde.klipper /klipper getClipboardContents',
125+
-- ['*'] = 'qdbus org.kde.klipper /klipper getClipboardContents',
126+
-- },
127+
-- cache_enabled = 0,
128+
-- }
129+
vim.opt.clipboard = 'unnamedplus'
120130

121131
-- Enable break indent
122132
vim.opt.breakindent = true
@@ -159,12 +169,19 @@ vim.opt.scrolloff = 10
159169

160170
-- [[ Basic Keymaps ]]
161171
-- See `:help vim.keymap.set()`
172+
vim.keymap.set('n', '<leader>y', '"+y')
173+
vim.keymap.set('n', '<leader>p', '"+p')
174+
vim.keymap.set('v', '<leader>y', '"+y')
175+
vim.keymap.set('v', '<leader>p', '"+p')
162176

163-
-- Clear highlights on search when pressing <Esc> in normal mode
164-
-- See `:help hlsearch`
177+
-- Set highlight on search, but clear on pressing <Esc> in normal mode
178+
vim.opt.hlsearch = true
165179
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
166180

167181
-- Diagnostic keymaps
182+
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
183+
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
184+
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
168185
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
169186

170187
-- Exit terminal mode in the builtin terminal with a shortcut that is a bit easier
@@ -207,12 +224,9 @@ vim.api.nvim_create_autocmd('TextYankPost', {
207224
-- [[ Install `lazy.nvim` plugin manager ]]
208225
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
209226
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
210-
if not (vim.uv or vim.loop).fs_stat(lazypath) then
227+
if not vim.loop.fs_stat(lazypath) then
211228
local lazyrepo = 'https://github.com/folke/lazy.nvim.git'
212-
local out = vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
213-
if vim.v.shell_error ~= 0 then
214-
error('Error cloning lazy.nvim:\n' .. out)
215-
end
229+
vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath }
216230
end ---@diagnostic disable-next-line: undefined-field
217231
vim.opt.rtp:prepend(lazypath)
218232

@@ -237,6 +251,11 @@ require('lazy').setup({
237251
--
238252
-- Use `opts = {}` to force a plugin to be loaded.
239253
--
254+
-- This is equivalent to:
255+
-- require('Comment').setup({})
256+
257+
-- "gc" to comment visual regions/lines
258+
{ 'numToStr/Comment.nvim', opts = {} },
240259

241260
-- Here is a more advanced example where we pass configuration
242261
-- options to `gitsigns.nvim`. This is equivalent to the following Lua:
@@ -274,55 +293,24 @@ require('lazy').setup({
274293
{ -- Useful plugin to show you pending keybinds.
275294
'folke/which-key.nvim',
276295
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
277-
opts = {
278-
icons = {
279-
-- set icon mappings to true if you have a Nerd Font
280-
mappings = vim.g.have_nerd_font,
281-
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
282-
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
283-
keys = vim.g.have_nerd_font and {} or {
284-
Up = '<Up> ',
285-
Down = '<Down> ',
286-
Left = '<Left> ',
287-
Right = '<Right> ',
288-
C = '<C-…> ',
289-
M = '<M-…> ',
290-
D = '<D-…> ',
291-
S = '<S-…> ',
292-
CR = '<CR> ',
293-
Esc = '<Esc> ',
294-
ScrollWheelDown = '<ScrollWheelDown> ',
295-
ScrollWheelUp = '<ScrollWheelUp> ',
296-
NL = '<NL> ',
297-
BS = '<BS> ',
298-
Space = '<Space> ',
299-
Tab = '<Tab> ',
300-
F1 = '<F1>',
301-
F2 = '<F2>',
302-
F3 = '<F3>',
303-
F4 = '<F4>',
304-
F5 = '<F5>',
305-
F6 = '<F6>',
306-
F7 = '<F7>',
307-
F8 = '<F8>',
308-
F9 = '<F9>',
309-
F10 = '<F10>',
310-
F11 = '<F11>',
311-
F12 = '<F12>',
312-
},
313-
},
296+
config = function() -- This is the function that runs, AFTER loading
297+
require('which-key').setup()
314298

315299
-- Document existing key chains
316-
spec = {
317-
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
318-
{ '<leader>d', group = '[D]ocument' },
319-
{ '<leader>r', group = '[R]ename' },
320-
{ '<leader>s', group = '[S]earch' },
321-
{ '<leader>w', group = '[W]orkspace' },
322-
{ '<leader>t', group = '[T]oggle' },
323-
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
324-
},
325-
},
300+
require('which-key').register {
301+
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
302+
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
303+
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
304+
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
305+
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
306+
['<leader>t'] = { name = '[T]oggle', _ = 'which_key_ignore' },
307+
['<leader>h'] = { name = 'Git [H]unk', _ = 'which_key_ignore' },
308+
}
309+
-- visual mode
310+
require('which-key').register({
311+
['<leader>h'] = { 'Git [H]unk' },
312+
}, { mode = 'v' })
313+
end,
326314
},
327315

328316
-- NOTE: Plugins can specify dependencies.
@@ -437,22 +425,7 @@ require('lazy').setup({
437425
end,
438426
},
439427

440-
-- LSP Plugins
441-
{
442-
-- `lazydev` configures Lua LSP for your Neovim config, runtime and plugins
443-
-- used for completion, annotations and signatures of Neovim apis
444-
'folke/lazydev.nvim',
445-
ft = 'lua',
446-
opts = {
447-
library = {
448-
-- Load luvit types when the `vim.uv` word is found
449-
{ path = 'luvit-meta/library', words = { 'vim%.uv' } },
450-
},
451-
},
452-
},
453-
{ 'Bilal2453/luvit-meta', lazy = true },
454-
{
455-
-- Main LSP Configuration
428+
{ -- LSP Configuration & Plugins
456429
'neovim/nvim-lspconfig',
457430
dependencies = {
458431
-- Automatically install LSPs and related tools to stdpath for Neovim
@@ -464,8 +437,9 @@ require('lazy').setup({
464437
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
465438
{ 'j-hui/fidget.nvim', opts = {} },
466439

467-
-- Allows extra capabilities provided by nvim-cmp
468-
'hrsh7th/cmp-nvim-lsp',
440+
-- `neodev` configures Lua LSP for your Neovim config, runtime and plugins
441+
-- used for completion, annotations and signatures of Neovim apis
442+
{ 'folke/neodev.nvim', opts = {} },
469443
},
470444
config = function()
471445
-- Brief aside: **What is LSP?**
@@ -505,9 +479,8 @@ require('lazy').setup({
505479
--
506480
-- In this case, we create a function that lets us more easily define mappings specific
507481
-- for LSP related items. It sets the mode, buffer and description for us each time.
508-
local map = function(keys, func, desc, mode)
509-
mode = mode or 'n'
510-
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
482+
local map = function(keys, func, desc)
483+
vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
511484
end
512485

513486
-- Jump to the definition of the word under your cursor.
@@ -541,7 +514,11 @@ require('lazy').setup({
541514

542515
-- Execute a code action, usually your cursor needs to be on top of an error
543516
-- or a suggestion from your LSP for this to activate.
544-
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction', { 'n', 'x' })
517+
map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction')
518+
519+
-- Opens a popup that displays documentation about the word under your cursor
520+
-- See `:help K` for why this keymap.
521+
map('K', vim.lsp.buf.hover, 'Hover Documentation')
545522

546523
-- WARN: This is not Goto Definition, this is Goto Declaration.
547524
-- For example, in C this would take you to the header.
@@ -553,7 +530,7 @@ require('lazy').setup({
553530
--
554531
-- When you move your cursor, the highlights will be cleared (the second autocommand).
555532
local client = vim.lsp.get_client_by_id(event.data.client_id)
556-
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
533+
if client and client.server_capabilities.documentHighlightProvider then
557534
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
558535
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
559536
buffer = event.buf,
@@ -576,13 +553,13 @@ require('lazy').setup({
576553
})
577554
end
578555

579-
-- The following code creates a keymap to toggle inlay hints in your
556+
-- The following autocommand is used to enable inlay hints in your
580557
-- code, if the language server you are using supports them
581558
--
582559
-- This may be unwanted, since they displace some of your code
583-
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then
560+
if client and client.server_capabilities.inlayHintProvider and vim.lsp.inlay_hint then
584561
map('<leader>th', function()
585-
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf })
562+
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
586563
end, '[T]oggle Inlay [H]ints')
587564
end
588565
end,
@@ -606,17 +583,44 @@ require('lazy').setup({
606583
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
607584
local servers = {
608585
-- clangd = {},
609-
-- gopls = {},
586+
gopls = {},
610587
-- pyright = {},
611588
-- rust_analyzer = {},
612589
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
613590
--
614591
-- Some languages (like typescript) have entire language plugins that can be useful:
615592
-- https://github.com/pmizio/typescript-tools.nvim
616593
--
617-
-- But for many setups, the LSP (`ts_ls`) will work just fine
618-
-- ts_ls = {},
619-
--
594+
-- But for many setups, the LSP (`tsserver`) will work just fine
595+
volar = {
596+
filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' },
597+
init_options = {
598+
vue = {
599+
hybridMode = false,
600+
},
601+
typescript = {
602+
-- Global install of typescript
603+
tsdk = '~/.nvm/versions/node/v18.20.3/lib/node_modules/typescript',
604+
},
605+
},
606+
},
607+
608+
tsserver = {
609+
init_options = {
610+
plugins = {
611+
{
612+
name = '@vue/typescript-plugin',
613+
location = '/home/vjn/.nvm/versions/node/v22.2.0/lib/node_modules/@vue/typescript-plugin/',
614+
languages = { 'javascript', 'typescript', 'vue' },
615+
},
616+
},
617+
},
618+
filetypes = {
619+
'javascript',
620+
'typescript',
621+
'vue',
622+
},
623+
},
620624

621625
lua_ls = {
622626
-- cmd = {...},
@@ -656,7 +660,7 @@ require('lazy').setup({
656660
local server = servers[server_name] or {}
657661
-- This handles overriding only values explicitly passed
658662
-- by the server configuration above. Useful when disabling
659-
-- certain features of an LSP (for example, turning off formatting for ts_ls)
663+
-- certain features of an LSP (for example, turning off formatting for tsserver)
660664
server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {})
661665
require('lspconfig')[server_name].setup(server)
662666
end,
@@ -667,13 +671,12 @@ require('lazy').setup({
667671

668672
{ -- Autoformat
669673
'stevearc/conform.nvim',
670-
event = { 'BufWritePre' },
671-
cmd = { 'ConformInfo' },
674+
lazy = false,
672675
keys = {
673676
{
674677
'<leader>f',
675678
function()
676-
require('conform').format { async = true, lsp_format = 'fallback' }
679+
require('conform').format { async = true, lsp_fallback = true }
677680
end,
678681
mode = '',
679682
desc = '[F]ormat buffer',
@@ -686,24 +689,19 @@ require('lazy').setup({
686689
-- have a well standardized coding style. You can add additional
687690
-- languages here or re-enable it for the disabled ones.
688691
local disable_filetypes = { c = true, cpp = true }
689-
local lsp_format_opt
690-
if disable_filetypes[vim.bo[bufnr].filetype] then
691-
lsp_format_opt = 'never'
692-
else
693-
lsp_format_opt = 'fallback'
694-
end
695692
return {
696693
timeout_ms = 500,
697-
lsp_format = lsp_format_opt,
694+
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
698695
}
699696
end,
700697
formatters_by_ft = {
701698
lua = { 'stylua' },
702699
-- Conform can also run multiple formatters sequentially
703700
-- python = { "isort", "black" },
704701
--
705-
-- You can use 'stop_after_first' to run the first available formatter from the list
706-
-- javascript = { "prettierd", "prettier", stop_after_first = true },
702+
-- You can use a sub-list to tell conform to run *until* a formatter
703+
-- is found.
704+
-- javascript = { { "prettierd", "prettier" } },
707705
},
708706
},
709707
},
@@ -811,11 +809,6 @@ require('lazy').setup({
811809
-- https://github.com/L3MON4D3/LuaSnip?tab=readme-ov-file#keymaps
812810
},
813811
sources = {
814-
{
815-
name = 'lazydev',
816-
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
817-
group_index = 0,
818-
},
819812
{ name = 'nvim_lsp' },
820813
{ name = 'luasnip' },
821814
{ name = 'path' },
@@ -852,7 +845,7 @@ require('lazy').setup({
852845
--
853846
-- Examples:
854847
-- - va) - [V]isually select [A]round [)]paren
855-
-- - yinq - [Y]ank [I]nside [N]ext [Q]uote
848+
-- - yinq - [Y]ank [I]nside [N]ext [']quote
856849
-- - ci' - [C]hange [I]nside [']quote
857850
require('mini.ai').setup { n_lines = 500 }
858851

@@ -885,10 +878,8 @@ require('lazy').setup({
885878
{ -- Highlight, edit, and navigate code
886879
'nvim-treesitter/nvim-treesitter',
887880
build = ':TSUpdate',
888-
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
889-
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
890881
opts = {
891-
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' },
882+
ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'vim', 'vimdoc' },
892883
-- Autoinstall languages that are not installed
893884
auto_install = true,
894885
highlight = {
@@ -900,12 +891,21 @@ require('lazy').setup({
900891
},
901892
indent = { enable = true, disable = { 'ruby' } },
902893
},
903-
-- There are additional nvim-treesitter modules that you can use to interact
904-
-- with nvim-treesitter. You should go explore a few and see what interests you:
905-
--
906-
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
907-
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
908-
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
894+
config = function(_, opts)
895+
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
896+
897+
-- Prefer git instead of curl in order to improve connectivity in some environments
898+
require('nvim-treesitter.install').prefer_git = true
899+
---@diagnostic disable-next-line: missing-fields
900+
require('nvim-treesitter.configs').setup(opts)
901+
902+
-- There are additional nvim-treesitter modules that you can use to interact
903+
-- with nvim-treesitter. You should go explore a few and see what interests you:
904+
--
905+
-- - Incremental selection: Included, see `:help nvim-treesitter-incremental-selection-mod`
906+
-- - Show your current context: https://github.com/nvim-treesitter/nvim-treesitter-context
907+
-- - Treesitter + textobjects: https://github.com/nvim-treesitter/nvim-treesitter-textobjects
908+
end,
909909
},
910910

911911
-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the

0 commit comments

Comments
 (0)